diff options
author | Paul B Mahol <onemda@gmail.com> | 2018-05-01 17:46:08 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2018-05-03 14:15:07 +0200 |
commit | 5abcf45d752df0a3f654833272eb0d7aae34d431 (patch) | |
tree | d0bcadb189cc3b58515f52f774520722db4fd147 /libavformat | |
parent | 943f7902e6f7fc08eb015e0e1aacae77c252b1f2 (diff) | |
download | ffmpeg-5abcf45d752df0a3f654833272eb0d7aae34d431.tar.gz |
avformat/yuv4mpegdec: simplify math
This one actually works with hd1080 y4m files when seeking backwards.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/yuv4mpegdec.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c index 8662a42a4c..eff7fc518e 100644 --- a/libavformat/yuv4mpegdec.c +++ b/libavformat/yuv4mpegdec.c @@ -314,14 +314,11 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) static int yuv4_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags) { - 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 = FFMAX(0, pts - 1); + pos = pts * s->packet_size; if (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0) return -1; |