Skip to content
Permalink
Browse files

AvFormatDecoder: Discard any initial audio packets prior to initial v…

…ideo timecode.

Refs #9120

Signed-off-by: Mark Kendall <mkendall@mythtv.org>
  • Loading branch information
Mark Spieth Mark Kendall
Mark Spieth authored and Mark Kendall committed Mar 20, 2011
1 parent 7ebf5a6 commit caf431c7c643040fd646345bbb8c41bb3e77ea13
Showing with 26 additions and 3 deletions.
  1. +23 −2 mythtv/libs/libmythtv/avformatdecoder.cpp
  2. +3 −1 mythtv/libs/libmythtv/avformatdecoder.h
@@ -257,6 +257,7 @@ AvFormatDecoder::AvFormatDecoder(MythPlayer *parent,
start_code_state(0xffffffff),
lastvpts(0), lastapts(0),
lastccptsu(0),
firstvpts(0), firstvptsinuse(false),
faulty_pts(0), faulty_dts(0),
last_pts_for_fault_detection(0),
last_dts_for_fault_detection(0),
@@ -729,6 +730,12 @@ void AvFormatDecoder::SeekReset(long long newKey, uint skipFrames,
if (decoded_video_frame)
m_parent->DiscardVideoFrame(decoded_video_frame);
}

if (doflush)
{
firstvpts = 0;
firstvptsinuse = true;
}
}

void AvFormatDecoder::SetEof(bool eof)
@@ -2628,7 +2635,8 @@ void AvFormatDecoder::MpegPreProcessPkt(AVStream *stream, AVPacket *pkt)

gopset = false;
prevgoppos = 0;
lastapts = lastvpts = lastccptsu = 0;
firstvpts = lastapts = lastvpts = lastccptsu = 0;
firstvptsinuse = true;
faulty_pts = faulty_dts = 0;
last_pts_for_fault_detection = 0;
last_dts_for_fault_detection = 0;
@@ -2735,7 +2743,8 @@ bool AvFormatDecoder::H264PreProcessPkt(AVStream *stream, AVPacket *pkt)

gopset = false;
prevgoppos = 0;
lastapts = lastvpts = lastccptsu = 0;
firstvpts = lastapts = lastvpts = lastccptsu = 0;
firstvptsinuse = true;
faulty_pts = faulty_dts = 0;
last_pts_for_fault_detection = 0;
last_dts_for_fault_detection = 0;
@@ -3006,6 +3015,8 @@ bool AvFormatDecoder::ProcessVideoFrame(AVStream *stream, AVFrame *mpa_pic)
framesPlayed++;

lastvpts = temppts;
if (!firstvpts && firstvptsinuse)
firstvpts = temppts;

return true;
}
@@ -3810,6 +3821,16 @@ bool AvFormatDecoder::ProcessAudioPacket(AVStream *curstream, AVPacket *pkt,
skipaudio = false;
}

// skip any audio frames preceding first video frame
if (firstvptsinuse && firstvpts && (lastapts < firstvpts))
{
VERBOSE(VB_PLAYBACK+VB_TIMESTAMP,
LOC + QString("discarding early audio timecode %1 %2 %3")
.arg(pkt->pts).arg(pkt->dts).arg(lastapts));
break;
}
firstvptsinuse = false;

avcodeclock->lock();
data_size = 0;

@@ -286,8 +286,10 @@ class AvFormatDecoder : public DecoderBase
uint32_t start_code_state;

long long lastvpts;
long long lastapts;
long long lastapts;
long long lastccptsu;
long long firstvpts;
bool firstvptsinuse;

int64_t faulty_pts;
int64_t faulty_dts;

0 comments on commit caf431c

Please sign in to comment.
You can’t perform that action at this time.