All pastes #327000 Raw Edit

Unnamed

public text v1 · immutable
#327000 ·published 2007-01-24 17:28 UTC
rendered paste body
--- a/mythtv/libs/libmythtv/dtvrecorder.cpp
+++ b/mythtv/libs/libmythtv/dtvrecorder.cpp
@@ -37,7 +37,7 @@ DTVRecorder::DTVRecorder(TVRec *rec) :
     _stream_fd(-1),
     _recording_type("all"),
     // used for scanning pes headers for keyframes
-    _header_pos(0),                 _first_keyframe(-1),
+    _header_pos(2),                 _first_keyframe(-1),
     _last_gop_seen(0),              _last_seq_seen(0),
     _last_keyframe_seen(0),
     // H.264 support
@@ -136,7 +136,7 @@ void DTVRecorder::Reset(void)
 {
     QMutexLocker locker(&_position_map_lock);
 
-    _header_pos                 = 0;
+    _header_pos                 = 2;
     _first_keyframe             =-1;
     _last_keyframe_seen         = 0;
     _last_gop_seen              = 0;
@@ -218,7 +218,7 @@ bool DTVRecorder::FindMPEG2Keyframes(const TSPacket* tspacket)
     // looking for first byte of MPEG start code (3 bytes 0 0 1)
     // otherwise, pick up search where we left off.
     const bool payloadStart = tspacket->PayloadStart();
-    _header_pos = (payloadStart) ? 0 : _header_pos;
+    _header_pos = (payloadStart) ? 2 : _header_pos;
 
     // Just make these local for efficiency reasons (gcc not so smart..)
     const uint maxKFD = kMaxKeyFrameDistance;
@@ -235,15 +235,9 @@ bool DTVRecorder::FindMPEG2Keyframes(const TSPacket* tspacket)
     for (; i < TSPacket::SIZE; i++)
     {
         const unsigned char k = tspacket->data()[i];
-        if (0 == _header_pos)
-            _header_pos = (k == 0x00) ? 1 : 0;
-        else if (1 == _header_pos)
-            _header_pos = (k == 0x00) ? 2 : 0;
-        else if (2 == _header_pos)
-            _header_pos = (k == 0x00) ? 2 : ((k == 0x01) ? 3 : 0);
-        else if (3 == _header_pos)
+        _header_pos = (_header_pos << 8) | k;
+        if (_header_pos >> 8 == 0x000001)
         {
-            _header_pos = 0;
             // At this point we have seen the start code 0 0 1
             // the next byte will be the PES packet stream id.
             const int stream_id = k;
@@ -386,7 +380,7 @@ bool DTVRecorder::FindH264Keyframes(const TSPacket* tspacket)
     {
         // reset PES sync state
         _pes_synced = false;
-        _header_pos = 0;
+        _header_pos = 2;
     }
 
     bool hasFrame = false;
--- a/mythtv/libs/libmythtv/dtvrecorder.h
+++ b/mythtv/libs/libmythtv/dtvrecorder.h
@@ -66,7 +66,7 @@ class DTVRecorder: public RecorderBase
     QString _recording_type;
 
     // used for scanning pes headers for keyframes
-    uint      _header_pos;
+    uint32_t  _header_pos;
     int       _first_keyframe;
     unsigned long long _last_gop_seen;
     unsigned long long _last_seq_seen;