Ticket #9256: 0001-Tweaking-in-recording-seektable-building.patch

File 0001-Tweaking-in-recording-seektable-building.patch, 4.2 KB (added by beirdo, 8 years ago)
  • mythtv/libs/libmythtv/dtvrecorder.cpp

    From 828ab23f65866d59d5ef87146fd2ebf3314fb4ad Mon Sep 17 00:00:00 2001
    From: Gavin Hurlbut <gjhurlbu@gmail.com>
    Date: Fri, 12 Nov 2010 02:47:46 -0800
    Subject: [PATCH] Tweaking in-recording seektable building
    
    
    diff --git a/mythtv/libs/libmythtv/dtvrecorder.cpp b/mythtv/libs/libmythtv/dtvrecorder.cpp
    index cd29039..f043b64 100644
    a b  
    1111#include "mpegstreamdata.h"
    1212#include "dtvrecorder.h"
    1313#include "tv_rec.h"
     14#include "mythverbose.h"
    1415
    1516extern "C" {
    1617extern const uint8_t *ff_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state);
    bool DTVRecorder::FindMPEG2Keyframes(const TSPacket* tspacket) 
    329330    if (hasKeyFrame)
    330331    {
    331332        _last_keyframe_seen = _frames_seen_count;
    332         HandleKeyframe();
     333        HandleKeyframe(_frames_written_count, TSPacket::SIZE);
    333334    }
    334335
    335336    if (hasFrame)
    bool DTVRecorder::FindAudioKeyframes(const TSPacket*) 
    388389        if (1 == (_frames_seen_count & 0x7))
    389390        {
    390391            _last_keyframe_seen = _frames_seen_count;
    391             HandleKeyframe();
     392            HandleKeyframe(_frames_written_count);
    392393            hasKeyFrame = true;
    393394        }
    394395
    bool DTVRecorder::FindOtherKeyframes(const TSPacket *tspacket) 
    416417    _frames_written_count++;
    417418    _last_keyframe_seen = _frames_seen_count;
    418419
    419     HandleKeyframe();
     420    HandleKeyframe(_frames_written_count);
    420421
    421422    _has_written_other_keyframe = true;
    422423
    void DTVRecorder::SetNextRecording(const ProgramInfo *progInf, RingBuffer *rb) 
    451452 *  \brief This save the current frame to the position maps
    452453 *         and handles ringbuffer switching.
    453454 */
    454 void DTVRecorder::HandleKeyframe(uint64_t extra)
     455void DTVRecorder::HandleKeyframe(uint64_t frameNum, int64_t extra)
    455456{
    456457    if (!ringBuffer)
    457458        return;
    458459
     460#if 0
    459461    unsigned long long frameNum = _frames_written_count;
     462#endif
    460463
    461464    _first_keyframe = (_first_keyframe < 0) ? frameNum : _first_keyframe;
    462465
    void DTVRecorder::HandleKeyframe(uint64_t extra) 
    466469    {
    467470        long long startpos = ringBuffer->GetWritePosition();
    468471        // FIXME: handle keyframes with start code spanning over two ts packets
    469         startpos += _payload_buffer.size() + extra;
     472        startpos += _payload_buffer.size() - extra;
    470473
    471474        // Don't put negative offsets into the database, they get munged into
    472475        // MAX_INT64 - offset, which is an exceedingly large number, and
    void DTVRecorder::FindPSKeyFrames(const uint8_t *buffer, uint len) 
    773776            hasKeyFrame &= (_last_seq_seen + maxKFD) < _frames_seen_count;
    774777        }
    775778
    776         if (hasKeyFrame)
    777         {
    778             _last_keyframe_seen = _frames_seen_count;
    779             HandleKeyframe(bufptr - bufstart);
    780         }
    781 
    782779        if (hasFrame)
    783780        {
    784781            _frames_seen_count++;
    785             if (!_wait_for_keyframe_option || _first_keyframe>=0)
     782            if (!_wait_for_keyframe_option || _first_keyframe >= 0)
    786783                _frames_written_count++;
    787784        }
    788785
     786        if (hasKeyFrame)
     787        {
     788            _last_keyframe_seen = _frames_seen_count;
     789            HandleKeyframe(_frames_written_count, bufptr - bufstart);
     790        }
     791
    789792        if ((aspectRatio > 0) && (aspectRatio != m_videoAspect))
    790793        {
    791794            m_videoAspect = aspectRatio;
    void DTVRecorder::FindPSKeyFrames(const uint8_t *buffer, uint len) 
    846849    uint64_t rem = (bufend - bufstart);
    847850    _payload_buffer.resize(idx + rem);
    848851    memcpy(&_payload_buffer[idx], bufstart, rem);
     852#if 0
     853VERBOSE(VB_GENERAL, QString("idx: %1, rem: %2").arg(idx).arg(rem) );
     854#endif
    849855}
    850856
    851857/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • mythtv/libs/libmythtv/dtvrecorder.h

    diff --git a/mythtv/libs/libmythtv/dtvrecorder.h b/mythtv/libs/libmythtv/dtvrecorder.h
    index aa3b173..55da6ec 100644
    a b class DTVRecorder: public RecorderBase 
    5151    void FinishRecording(void);
    5252    void ResetForNewFile(void);
    5353
    54     void HandleKeyframe(uint64_t extra = 0);
     54    void HandleKeyframe(uint64_t frameNum, int64_t extra = 0);
    5555
    5656    void BufferedWrite(const TSPacket &tspacket);
    5757