rendered paste bodyIndex: libs/libmythtv/avformatdecoder.cpp
===================================================================
--- libs/libmythtv/avformatdecoder.cpp (revision 22174)
+++ libs/libmythtv/avformatdecoder.cpp (working copy)
@@ -2140,6 +2140,8 @@
pic->age = 256 * 256 * 256 * 64;
+ pic->reordered_opaque= c->reordered_opaque;
+
return 1;
}
@@ -2286,6 +2288,8 @@
render->state |= FF_VDPAU_STATE_USED_FOR_REFERENCE;
#endif
+ pic->reordered_opaque= c->reordered_opaque;
+
return 0;
}
@@ -3854,8 +3858,7 @@
}
AVCodecContext *context = curstream->codec;
- AVFrame mpa_pic;
- bzero(&mpa_pic, sizeof(AVFrame));
+ AVFrame *mpa_pic= avcodec_alloc_frame();
int gotpicture = 0;
@@ -3868,24 +3871,25 @@
// HACK
while (!gotpicture && count < 5)
{
- ret = d->DecodeMPEG2Video(context, &mpa_pic,
+ ret = d->DecodeMPEG2Video(context, mpa_pic,
&gotpicture, ptr, len);
count++;
}
}
else
{
- ret = d->DecodeMPEG2Video(context, &mpa_pic,
+ ret = d->DecodeMPEG2Video(context, mpa_pic,
&gotpicture, ptr, len);
}
}
else
{
- ret = avcodec_decode_video(context, &mpa_pic,
+ curstream->codec->reordered_opaque= pkt->pts;
+ ret = avcodec_decode_video(context, mpa_pic,
&gotpicture, ptr, len);
// Reparse it to not drop the DVD still frame
if (decodeStillFrame)
- ret = avcodec_decode_video(context, &mpa_pic,
+ ret = avcodec_decode_video(context, mpa_pic,
&gotpicture, ptr, len);
}
avcodeclock.unlock();
@@ -3906,21 +3910,21 @@
}
// Decode ATSC captions
- for (uint i = 0; i < (uint)mpa_pic.atsc_cc_len;
- i += ((mpa_pic.atsc_cc_buf[i] & 0x1f) * 3) + 2)
+ for (uint i = 0; i < (uint)mpa_pic->atsc_cc_len;
+ i += ((mpa_pic->atsc_cc_buf[i] & 0x1f) * 3) + 2)
{
- DecodeDTVCC(mpa_pic.atsc_cc_buf + i);
+ DecodeDTVCC(mpa_pic->atsc_cc_buf + i);
}
// Decode DVB captions from MPEG user data
- if (mpa_pic.dvb_cc_len > 0)
+ if (mpa_pic->dvb_cc_len > 0)
{
unsigned long long utc = lastccptsu;
- for (uint i = 0; i < (uint)mpa_pic.dvb_cc_len; i += 2)
+ for (uint i = 0; i < (uint)mpa_pic->dvb_cc_len; i += 2)
{
- uint8_t cc_lo = mpa_pic.dvb_cc_buf[i];
- uint8_t cc_hi = mpa_pic.dvb_cc_buf[i+1];
+ uint8_t cc_lo = mpa_pic->dvb_cc_buf[i];
+ uint8_t cc_hi = mpa_pic->dvb_cc_buf[i+1];
uint16_t cc_dt = (cc_hi << 8) | cc_lo;
@@ -3933,7 +3937,7 @@
lastccptsu = utc;
}
- VideoFrame *picframe = (VideoFrame *)(mpa_pic.opaque);
+ VideoFrame *picframe = (VideoFrame *)(mpa_pic->opaque);
if (!directrendering)
{
@@ -3952,7 +3956,7 @@
myth_sws_img_convert(
&tmppicture, PIX_FMT_YUV420P,
- (AVPicture *)&mpa_pic,
+ (AVPicture *)mpa_pic,
context->pix_fmt,
context->width,
context->height);
@@ -3961,18 +3965,32 @@
{
// Set the frame flags, but then discard it
// since we are not using it for display.
- xf->interlaced_frame = mpa_pic.interlaced_frame;
- xf->top_field_first = mpa_pic.top_field_first;
+ xf->interlaced_frame = mpa_pic->interlaced_frame;
+ xf->top_field_first = mpa_pic->top_field_first;
xf->frameNumber = framesPlayed;
GetNVP()->DiscardVideoFrame(xf);
}
}
+ int decoder_reorder_pts = 1;
+ if( (decoder_reorder_pts || pkt->dts == AV_NOPTS_VALUE)
+ && mpa_pic->reordered_opaque != AV_NOPTS_VALUE) {
+ pts= (long long)mpa_pic->reordered_opaque;
+ }
+ else if(pkt->dts != (int64_t)AV_NOPTS_VALUE) {
+ pts= (long long)pkt->dts;
+ }
+ else {
+ pts= 0;
+ }
+ pts = (long long)(av_q2d(curstream->time_base) * pts * 1000);
+
long long temppts = pts;
// Validate the video pts against the last pts. If it's
// a little bit smaller or equal, compute it from the last.
// Otherwise assume a wraparound.
+#if 0
if (!ringBuffer->isDVD() &&
temppts <= lastvpts &&
(temppts + 10000 > lastvpts || temppts < 0))
@@ -3980,9 +3998,10 @@
temppts = lastvpts;
temppts += (long long)(1000 * av_q2d(context->time_base));
// MPEG2 frames can be repeated, update pts accordingly
- temppts += (long long)(mpa_pic.repeat_pict * 500
+ temppts += (long long)(mpa_pic->repeat_pict * 500
* av_q2d(curstream->codec->time_base));
}
+#endif
VERBOSE(VB_PLAYBACK+VB_TIMESTAMP, LOC +
QString("video timecode %1 %2 %3 %4")
@@ -3990,34 +4009,34 @@
.arg(lastvpts));
/* XXX: Broken.
- if (mpa_pic.qscale_table != NULL && mpa_pic.qstride > 0 &&
+ if (mpa_pic->qscale_table != NULL && mpa_pic->qstride > 0 &&
context->height == picframe->height)
{
- int tblsize = mpa_pic.qstride *
+ int tblsize = mpa_pic->qstride *
((picframe->height + 15) / 16);
- if (picframe->qstride != mpa_pic.qstride ||
+ if (picframe->qstride != mpa_pic->qstride ||
picframe->qscale_table == NULL)
{
- picframe->qstride = mpa_pic.qstride;
+ picframe->qstride = mpa_pic->qstride;
if (picframe->qscale_table)
delete [] picframe->qscale_table;
picframe->qscale_table = new unsigned char[tblsize];
}
- memcpy(picframe->qscale_table, mpa_pic.qscale_table,
+ memcpy(picframe->qscale_table, mpa_pic->qscale_table,
tblsize);
}
*/
- picframe->interlaced_frame = mpa_pic.interlaced_frame;
- picframe->top_field_first = mpa_pic.top_field_first;
- picframe->repeat_pict = mpa_pic.repeat_pict;
+ picframe->interlaced_frame = mpa_pic->interlaced_frame;
+ picframe->top_field_first = mpa_pic->top_field_first;
+ picframe->repeat_pict = mpa_pic->repeat_pict;
picframe->frameNumber = framesPlayed;
GetNVP()->ReleaseNextVideoFrame(picframe, temppts);
- if (d->HasMPEG2Dec() && mpa_pic.data[3])
- context->release_buffer(context, &mpa_pic);
+ if (d->HasMPEG2Dec() && mpa_pic->data[3])
+ context->release_buffer(context, mpa_pic);
decoded_video_frame = picframe;
gotvideo = 1;