[FFmpeg-devel] [PATCH] avfilter/vf_interlace: more accurate pts calculation

Aleksey Vasenev margtu-fivt at ya.ru
Sun Nov 30 13:39:17 CET 2014


We keep only half source frames.
Source: time_base 1/10 and ptss 0 1 2 3 4 5 6 7 8 9
Before change: time_base 1/5 and ptss 0 1 2 3 4
After change: time_base 1/10 and ptss 0 2 4 6 8
You can see that before and after equal. No problem with timings.
We still need reduce frame_rate because it now half of origin.
On 30.11.2014 15:05, Vittorio Giovara wrote:
>
> On 12/11/2014 23:38, Aleksey Vasenev wrote:
>> Signed-off-by: Aleksey Vasenev <margtu-fivt at ya.ru>
>> ---
>>   libavfilter/vf_interlace.c | 2 --
>>   1 file changed, 2 deletions(-)
>>
>> diff --git a/libavfilter/vf_interlace.c b/libavfilter/vf_interlace.c
>> index e07963f..42e2c9a 100644
>> --- a/libavfilter/vf_interlace.c
>> +++ b/libavfilter/vf_interlace.c
>> @@ -111,7 +111,6 @@ static int config_out_props(AVFilterLink *outlink)
>>       outlink->time_base = inlink->time_base;
>>       outlink->frame_rate = inlink->frame_rate;
>>       // half framerate
>> -    outlink->time_base.num *= 2;
>>       outlink->frame_rate.den *= 2;
>>       outlink->flags |= FF_LINK_FLAG_REQUEST_LOOP;
>>   @@ -204,7 +203,6 @@ static int filter_frame(AVFilterLink *inlink, 
>> AVFrame *buf)
>>       av_frame_copy_props(out, s->cur);
>>       out->interlaced_frame = 1;
>>       out->top_field_first  = tff;
>> -    out->pts             /= 2;  // adjust pts to new framerate
>>         /* copy upper/lower field from cur */
>>       copy_picture_field(s->cur, out, inlink, tff ? FIELD_UPPER : 
>> FIELD_LOWER, s->lowpass);
> This does not look correct to me.
> The pts are relative to the time base/frame rate so if you are going 
> to change one you have to take care of the other. In the end the 
> interlaced stream will have wrong timing and you might experience 
> frame drops.
>
> I advise reverting.
> Vittorio
>
>
>



More information about the ffmpeg-devel mailing list