avformat/yuv4mpegdec: fix seeking backwards

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol
2018-04-25 18:30:46 +02:00
parent a12899ad9b
commit b2570afde3
2 changed files with 34 additions and 22 deletions
+10 -1
View File
@@ -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;
}