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

Alexander Strange astrange
Tue Feb 1 05:48:13 CET 2011


On Jan 31, 2011, at 1:28 PM, M?ns Rullg?rd wrote:

> Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
> 
>> On Mon, Jan 31, 2011 at 12:37:20PM +0000, M?ns Rullg?rd wrote:
>>> Jean-Daniel Dupas <devlists at shadowlab.org> writes:
>>> 
>>>> Le 30 janv. 2011 ? 20:39, M?ns Rullg?rd a ?crit :
>>>> 
>>>>> Nicolas George <nicolas.george at normalesup.org> writes:
>>>>> 
>>>>>> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
>>>>>> ---
>>>>>> cmdutils.c           |   27 ---------------------------
>>>>>> cmdutils.h           |   24 ------------------------
>>>>>> ffmpeg.c             |   14 ++++++--------
>>>>>> ffplay.c             |   10 +++-------
>>>>>> libavcodec/avcodec.h |   20 ++++++++++++++++++++
>>>>>> libavcodec/utils.c   |   43 ++++++++++++++++++++++++++++++++++++++++++-
>>>>>> 6 files changed, 71 insertions(+), 67 deletions(-)
>>>>>> 
>>>>>> This patch moves the guess_correct_pts function from cmdutils to libavcodec.
>>>>>> The feature is available through a new field in AVFrame, guessed_pts.
>>>>>> 
>>>>>> make test and ffplay still work, but I would like to have some more time to
>>>>>> read it carefully, but I have things to do in the next few days, and this
>>>>>> feature was discussed in another thread, so here the current version. It
>>>>>> will conflict with some patches that will certainly soon be applied, so I
>>>>>> will update and submit it again anyway.
>>>>> 
>>>>> What is all this guessing supposed to achieve anyway?  It makes me
>>>>> feel uneasy
>>>> 
>>>> Try to play H.264 with reordered frame in avi container without this
>>>> guess, and you will see why it is necessary.
>>> 
>>> AVI does not have timestamps (only an implied DTS), so the PTS would
>>> be calculated by counting decoded frames and multiplying by the frame
>>> rate.
>> 
>> AVI has 0-size frames that are used to (very inefficiently) handle
>> variable frame rate, your method certain will mess up timing completely
>> for that case.
> 
> That doesn't work with reordered frames anyway.

It works if you don't use reordered timestamps. That is, you wait until after the frames have been reordered by decoding, then apply timestamps sequentially from the file.
Which is what this does, by choosing dts as the timestamp.

Anyway lavf really doesn't have that many hacks here. The problems mostly come from storing reordered formats in AVI (not to mention packed B-frames), and formats where both PTS/DTS are stored and one is nonsense. After that you have to decide between PTS and DTS anyway, because only PTS is stored in mkv, only DTS is stored in avi.



More information about the ffmpeg-devel mailing list