From 4b73e7f3606fe0a33c258c802998b4e24ae24fb0 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Tue, 21 Feb 2017 15:14:51 -0700 Subject: [PATCH] matroskadec: remove broken subtitle seek code It looks up an index on one stream, and then uses that index on a different stream. If nb_index_entries is different on the streams, kaboom! --- libavformat/matroskadec.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 4e121b6..d88088a 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2693,7 +2693,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, MatroskaDemuxContext *matroska = s->priv_data; MatroskaTrack *tracks = NULL; AVStream *st = s->streams[stream_index]; - int i, index, index_sub, index_min; + int i, index; /* Parse the CUES now since we need the index data to seek. */ if (matroska->cues_parsing_deferred) { @@ -2720,27 +2720,15 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, if (index < 0) return 0; - index_min = index; tracks = matroska->tracks.elem; for (i = 0; i < matroska->tracks.nb_elem; i++) { tracks[i].audio.pkt_cnt = 0; tracks[i].audio.sub_packet_cnt = 0; tracks[i].audio.buf_timecode = AV_NOPTS_VALUE; tracks[i].end_timecode = 0; - if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE && - tracks[i].stream->discard != AVDISCARD_ALL) { - index_sub = av_index_search_timestamp( - tracks[i].stream, st->index_entries[index].timestamp, - AVSEEK_FLAG_BACKWARD); - if (index_sub >= 0 && - st->index_entries[index_sub].pos < st->index_entries[index_min].pos && - st->index_entries[index].timestamp - - st->index_entries[index_sub].timestamp < 30000000000 / matroska->time_scale) - index_min = index_sub; - } } - avio_seek(s->pb, st->index_entries[index_min].pos, SEEK_SET); + avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET); matroska->current_id = 0; matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY); matroska->skip_to_timecode = st->index_entries[index].timestamp; -- 2.9.3