[FFmpeg-devel] [PATCH] Implement guessed_pts in avcodec_decode_video2.

Nicolas George nicolas.george
Sun Feb 6 20:44:55 CET 2011

Le tridi 13 pluvi?se, an CCXIX, Michael Niedermayer a ?crit?:
> the "pkt_pts" = AV_NOPTS_VALUE; should stay, aka the pts should be reset after
> use.

The version you reviewed killed the pkt_pts variable altogether. Not

But this pkt_pts variable seems strange: if I understand the code correctly,
if a video packet has no PTS, pkt_pts will stay from a previous audio
packet. This seems wrong, as audio frames have not the same duration as
video size, thus the PTS will not be a multiple of the framerate.
Furthermore, some streams have the audio with a lot of advance with regard
to the video.

Well, this is now a distinct issue from current version of the patch.

> double ;;


> also this has scaling issues, as ist->*pts are effectively scaled back and
> forth between 2 timebases all the time

I did not like it either, but did not found a better solution. This is
longer an issue.

> also, even though independant of this patch i think a av_rescale_q that
> preserved AV_NOPTS_VALUE could simplify quite a bit of code over our codebase.

No longer an issue either, but I had the same thought when writing that

> and i dont think next_pts could have become AV_NOPTS_VALUE before, so a check
> that could make it that now looks suspicious, just look:


> Ill look into this and apply it to videolan if its ok

I would hate for it to be the start of a API difference between
git.videolan.org and git.ffmpeg.org, though.

Anyway, here is a new version, rebased on 1fe2d4d "Adopt pkt_dts/pkt_pts in
lavc clients" that I cherry-picked, as it looks to me to do the right thing.

As you can see, 1fe2d4d avoids the rescaling issues by injecting the
rescaled timestamps in the packet before decoding. The patch has now only to
move the guess_correct_pts into libavcodec.

(I still dislike the fact that ffmpeg rescales timestamps to 1/1000000
between ist->time_base and ost->time_base, but that is completely


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Implement-guessed_pts-in-avcodec_decode_video2.patch
Type: text/x-diff
Size: 10258 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110206/47297dfc/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110206/47297dfc/attachment.pgp>

More information about the ffmpeg-devel mailing list