]> git.sesse.net Git - ffmpeg/commitdiff
lavf/webm_dash: fix hardcode in cues_end computation
authorVignesh Venkatasubramanian <vigneshv@google.com>
Wed, 1 Oct 2014 17:13:30 +0000 (10:13 -0700)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 1 Oct 2014 18:47:11 +0000 (20:47 +0200)
Fix an incorrect hard code in cues_end computation. Updating the fate
test reference files related to the fix as well. The earlier computation
was clearly wrong as the cues_end field was greater than the file size
itself in some cases.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/matroskadec.c
tests/ref/fate/webm-dash-manifest
tests/ref/fate/webm-dash-manifest-unaligned-audio-streams
tests/ref/fate/webm-dash-manifest-unaligned-video-streams

index b8ddf67b79c33e09d61ee6a65f8c8df6f846c2a6..d856fccfc0079db8d200871c1257c557b4faf595 100644 (file)
@@ -3261,10 +3261,13 @@ static int webm_dash_manifest_cues(AVFormatContext *s)
     before_pos = avio_tell(matroska->ctx->pb);
     cues_start = seekhead[i].pos + matroska->segment_start;
     if (avio_seek(matroska->ctx->pb, cues_start, SEEK_SET) == cues_start) {
-        uint64_t cues_length = 0, cues_id = 0;
-        ebml_read_num(matroska, matroska->ctx->pb, 4, &cues_id);
-        ebml_read_length(matroska, matroska->ctx->pb, &cues_length);
-        cues_end = cues_start + cues_length + 11; // 11 is the offset of Cues ID.
+        // cues_end is computed as cues_start + cues_length + length of the
+        // Cues element ID + EBML length of the Cues element. cues_end is
+        // inclusive and the above sum is reduced by 1.
+        uint64_t cues_length = 0, cues_id = 0, bytes_read = 0;
+        bytes_read += ebml_read_num(matroska, matroska->ctx->pb, 4, &cues_id);
+        bytes_read += ebml_read_length(matroska, matroska->ctx->pb, &cues_length);
+        cues_end = cues_start + cues_length + bytes_read - 1;
     }
     avio_seek(matroska->ctx->pb, before_pos, SEEK_SET);
     if (cues_start == -1 || cues_end == -1) return -1;
index 1c1a6793e1a9839fcd9195c18f2aee576faafa3d..4b88040ff5f2f42a4283a553d89a4500eef2e82e 100644 (file)
@@ -20,7 +20,7 @@
 <Representation id="1" bandwidth="302355">
 <BaseURL>dash_video2.webm</BaseURL>
 <SegmentBase
-  indexRange="1115782-1115886">
+  indexRange="1115782-1115879">
 <Initialization
   range="0-249" />
 </SegmentBase>
@@ -38,7 +38,7 @@
 <Representation id="1" bandwidth="82814">
 <BaseURL>dash_audio2.webm</BaseURL>
 <SegmentBase
-  indexRange="335312-335432">
+  indexRange="335312-335425">
 <Initialization
   range="0-3927" />
 </SegmentBase>
index 5e1743e7bfc0ca5989d8593188a1a8dc2996fed3..6e9de211fb3d5884f851acc7aa4931761d3c792d 100644 (file)
@@ -20,7 +20,7 @@
 <Representation id="1" bandwidth="83502">
 <BaseURL>dash_audio3.webm</BaseURL>
 <SegmentBase
-  indexRange="335312-335432">
+  indexRange="335312-335425">
 <Initialization
   range="0-3927" />
 </SegmentBase>
index 3576b605cbb3b2b17f0cf30824c6ed262791ae18..ce205638b6ffa9a8e516bd7504a19dcd53946973 100644 (file)
@@ -20,7 +20,7 @@
 <Representation id="1" bandwidth="321574">
 <BaseURL>dash_video3.webm</BaseURL>
 <SegmentBase
-  indexRange="1116070-1116461">
+  indexRange="1116070-1116455">
 <Initialization
   range="0-249" />
 </SegmentBase>