[FFmpeg-devel] [PATCH 5/5] ffmpeg: Use guess_correct_pts() for decoded timestamps

Baptiste Coudurier baptiste.coudurier
Mon Oct 4 00:18:16 CEST 2010


On 10/3/10 3:15 PM, Michael Niedermayer wrote:
> On Sun, Oct 03, 2010 at 05:39:40PM -0400, Alexander Strange wrote:
>> On Sun, Oct 3, 2010 at 7:36 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
>>> On Sun, Oct 03, 2010 at 04:17:21AM -0400, Alexander Strange wrote:
>>>>
>>>> On Sep 28, 2010, at 10:57 AM, Michael Niedermayer wrote:
>>>>
>>>>> On Mon, Jul 26, 2010 at 01:16:10PM -0700, Alexander Strange wrote:
>>>>>> ---
>>>>>> ffmpeg.c |    7 +++++++
>>>>>> 1 files changed, 7 insertions(+), 0 deletions(-)
>>>>>>
>>>>>> diff --git a/ffmpeg.c b/ffmpeg.c
>>>>>> index 6625c58..16e69dd 100644
>>>>>> --- a/ffmpeg.c
>>>>>> +++ b/ffmpeg.c
>>>>>> @@ -304,6 +304,7 @@ typedef struct AVInputStream {
>>>>>>     int64_t       next_pts;  /* synthetic pts for cases where pkt.pts
>>>>>>                                 is not defined */
>>>>>>     int64_t       pts;       /* current pts */
>>>>>> +    PtsCorrectionContext pts_ctx;
>>>>>>     int is_start;            /* is 1 at the start and after a discontinuity */
>>>>>>     int showed_multi_packet_warning;
>>>>>>     int is_past_recording_time;
>>>>>> @@ -1509,6 +1510,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
>>>>>>     void *buffer_to_free;
>>>>>>     static unsigned int samples_size= 0;
>>>>>>     AVSubtitle subtitle, *subtitle_to_free;
>>>>>> +    int64_t pkt_pts = AV_NOPTS_VALUE;
>>>>>> #if CONFIG_AVFILTER
>>>>>>     int frame_available;
>>>>>> #endif
>>>>>> @@ -1531,6 +1533,8 @@ static int output_packet(AVInputStream *ist, int ist_index,
>>>>>>
>>>>>>     if(pkt->dts != AV_NOPTS_VALUE)
>>>>>>         ist->next_pts = ist->pts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
>>>>>> +    if(pkt->pts != AV_NOPTS_VALUE)
>>>>>> +        pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
>>>>>>
>>>>>>     //while we have more to decode or while the decoder did output something on EOF
>>>>>>     while (avpkt.size > 0 || (!pkt && ist->next_pts != ist->pts)) {
>>>>>> @@ -1583,6 +1587,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
>>>>>>                     decoded_data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
>>>>>>                     /* XXX: allocate picture correctly */
>>>>>>                     avcodec_get_frame_defaults(&picture);
>>>>>> +                    ist->st->codec->reordered_opaque = pkt_pts;
>>>>>
>>>>> you should set pkt_pts here to AV_NOPTS_VALUE to prevent a second use
>>>>
>>>> Done.
>>>>
>>>
>>>>  ffmpeg.c |    8 ++++++++
>>>>  1 file changed, 8 insertions(+)
>>>> 5766825474b6d5a4cb1fb4f46d1d1b5257487e11  0001-ffmpeg-Use-guess_correct_pts-for-decoded-timestamps.patch
>>>> From a369f55a7e2f0452e6a40383c52d5fe9abde6cf8 Mon Sep 17 00:00:00 2001
>>>> From: Alexander Strange <astrange at ithinksw.com>
>>>> Date: Sun, 27 Jun 2010 22:30:59 -0700
>>>> Subject: [PATCH] ffmpeg: Use guess_correct_pts() for decoded timestamps
>>>
>>> looks good if it passes fate
>>
>> rv30 regression fails, but the timestamps look broken already (20
>> faulty pts). Looking at the packets, I think the file timestamps are
>> actually dts and not pts (they're monotonic but the file has
>> B-frames), so the current output is wrong.
>>
>> I'll file a bug and commit/update the rv30 reference soon if there's
>> no objections.
> 
> no objections from me based on your mail without looking at the timestamps
> maybe you want to wait for some rv devel but thats not a must if they take
> to long to reply

I confirm that the timestamps in RM are dts, not pts.

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list