Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2018-04-25 19:30:46 +0300
committerPaul B Mahol <onemda@gmail.com>2018-04-25 19:30:46 +0300
commitb2570afde3623ef2806b82f1d4e7428283b32491 (patch)
treebb12ff9365f45b2348addbc7577e2f8cdbcc227e /libavformat/yuv4mpegdec.c
parenta12899ad9b4d7de3cc255e8944094c8ce8d2aa31 (diff)
avformat/yuv4mpegdec: fix seeking backwards
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavformat/yuv4mpegdec.c')
-rw-r--r--libavformat/yuv4mpegdec.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
index ff0125e4cf..8662a42a4c 100644
--- a/libavformat/yuv4mpegdec.c
+++ b/libavformat/yuv4mpegdec.c
@@ -314,7 +314,16 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
static int yuv4_read_seek(AVFormatContext *s, int stream_index,
int64_t pts, int flags)
{
- if (avio_seek(s->pb, pts * s->packet_size + s->internal->data_offset, SEEK_SET) < 0)
+ 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 (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0)
return -1;
return 0;
}