On Tue,  1 May 2018 17:48:32 +0200
Paul B Mahol <one...@gmail.com> wrote:

> This one actually works with hd1080 y4m files when seeking backwards.
> 
> Signed-off-by: Paul B Mahol <one...@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;

That seems questionable too. Though I'm not sure if the previous code
is correct.

In theory, you're supposed to do this:
1. Determine seek target as accurately as possible
2. If the seek target is not exact then:
2a. if AVSEEK_FLAG_FORWARD is set, then round to the next frame
2b. otherwise, round to the previous frame

But if pts is in the stream timebase, then 2. can never happen. (And
also, I have no idea what the code removed by this patch does.)

Regarding mpv, can you just send me a reproducible test case?
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to