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

Paul B Mahol onemda at gmail.com
Tue May 1 18:48:32 EEST 2018


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;
-- 
2.11.0



More information about the ffmpeg-devel mailing list