Skip to content

Commit

Permalink
dtvrecorder: update MPEG-2 parser to properly generate repeat_pict va…
Browse files Browse the repository at this point in the history
…lues

This is going to be used for generating correct video duration.

Refs #10104
  • Loading branch information
tralph committed Jan 20, 2012
1 parent 97047fc commit be8919f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
21 changes: 13 additions & 8 deletions mythtv/libs/libmythtv/dtvrecorder.cpp
Expand Up @@ -55,6 +55,9 @@ DTVRecorder::DTVRecorder(TVRec *rec) :
_last_keyframe_seen(0),
_audio_bytes_remaining(0), _video_bytes_remaining(0),
_other_bytes_remaining(0),
// MPEG2 parser information
_progressive_sequence(0),
_repeat_pict(0),
// H.264 support
_pes_synced(false),
_seen_sps(false),
Expand Down Expand Up @@ -186,6 +189,9 @@ void DTVRecorder::ResetForNewFile(void)
memset(_pid_status, 0, sizeof(_pid_status));
memset(_continuity_counter, 0xff, sizeof(_continuity_counter));

_progressive_sequence = 0;
_repeat_pict = 0;

_pes_synced = false;
//_seen_sps
positionMap.clear();
Expand Down Expand Up @@ -400,10 +406,9 @@ bool DTVRecorder::FindMPEG2Keyframes(const TSPacket* tspacket)
// (there are others that we don't care about)
const uint8_t *bufptr = tspacket->data() + tspacket->AFCOffset();
const uint8_t *bufend = tspacket->data() + TSPacket::kSize;
int progressive_sequence = 0;
int ext_type, bytes_left;
int picture_structure, top_field_first, repeat_first_field, progressive_frame;
int repeat_pict = 0;
_repeat_pict = 0;

while (bufptr < bufend)
{
Expand Down Expand Up @@ -445,7 +450,7 @@ bool DTVRecorder::FindMPEG2Keyframes(const TSPacket* tspacket)
case 0x1: /* sequence extension */
if (bytes_left >= 6)
{
progressive_sequence = bufptr[1] & (1 << 3);
_progressive_sequence = bufptr[1] & (1 << 3);
}
break;
case 0x8: /* picture coding extension */
Expand All @@ -457,19 +462,19 @@ bool DTVRecorder::FindMPEG2Keyframes(const TSPacket* tspacket)
progressive_frame = bufptr[4] & (1 << 7);

/* check if we must repeat the frame */
repeat_pict = 1;
_repeat_pict = 1;
if (repeat_first_field)
{
if (progressive_sequence)
if (_progressive_sequence)
{
if (top_field_first)
repeat_pict = 5;
_repeat_pict = 5;
else
repeat_pict = 3;
_repeat_pict = 3;
}
else if (progressive_frame)
{
repeat_pict = 2;
_repeat_pict = 2;
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions mythtv/libs/libmythtv/dtvrecorder.h
Expand Up @@ -136,6 +136,10 @@ class DTVRecorder :
unsigned int _video_bytes_remaining;
unsigned int _other_bytes_remaining;

// MPEG2 parser information
int _progressive_sequence;
int _repeat_pict;

// H.264 support
bool _pes_synced;
bool _seen_sps;
Expand Down

0 comments on commit be8919f

Please sign in to comment.