summaryrefslogtreecommitdiffstats
path: root/contrib/ffmpeg/old/A13-mkv-fix-seek-crash.patch
blob: 3563855b1859d71eedc615f72e2ee30db49289ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From 4b73e7f3606fe0a33c258c802998b4e24ae24fb0 Mon Sep 17 00:00:00 2001
From: John Stebbins <stebbins@jetheaddev.com>
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