[FFmpeg-devel] [PATCH] avformat/yuv4mpegdec: simplify math

Paul B Mahol onemda at gmail.com
Wed May 2 00:15:26 EEST 2018


On 5/1/18, Michael Niedermayer <michael at niedermayer.cc> wrote:
> On Tue, May 01, 2018 at 05:48:32PM +0200, Paul B Mahol wrote:
>> This one actually works with hd1080 y4m files when seeking backwards.
>>
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>>  libavformat/yuv4mpegdec.c | 8 +++-----
>>  1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
>> index 8662a42a4c..de3d5637fe 100644
>> --- a/libavformat/yuv4mpegdec.c
>> +++ b/libavformat/yuv4mpegdec.c
>> @@ -317,11 +317,9 @@ static int yuv4_read_seek(AVFormatContext *s, int
>> stream_index,
>>      AVStream *st = s->streams[0];
>>      int64_t pos;
>>
>> -    pos = av_rescale_rnd(pts * s->packet_size,
>> -                         st->time_base.num,
>> -                         st->time_base.den * s->packet_size,
>> -                         (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN :
>> AV_ROUND_UP);
>> -    pos *= s->packet_size;
>> +    if (flags & AVSEEK_FLAG_BACKWARD)
>> +        pts -= 1;
>> +    pos = pts * s->packet_size;
>>
>>      if (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0)
>>          return -1;
>
> breaks fate-seek-lavf-yuv4mpeg
>

If you have no other remarks, I will update reference and push patch.


More information about the ffmpeg-devel mailing list