diff options
author | Vignesh Venkatasubramanian <vigneshv@google.com> | 2014-10-01 10:13:30 -0700 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-10-01 20:47:11 +0200 |
commit | 8acb76567aba59be91c9af4aa45b3a0900c57439 (patch) | |
tree | c8e55cff5842af04162d61f08a59a5ffbfe96ea0 | |
parent | acebff8e5dc0789c228b10ffcae2f2eb6c30a91d (diff) | |
download | ffmpeg-8acb76567aba59be91c9af4aa45b3a0900c57439.tar.gz |
lavf/webm_dash: fix hardcode in cues_end computation
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>
-rw-r--r-- | libavformat/matroskadec.c | 11 | ||||
-rw-r--r-- | tests/ref/fate/webm-dash-manifest | 4 | ||||
-rw-r--r-- | tests/ref/fate/webm-dash-manifest-unaligned-audio-streams | 2 | ||||
-rw-r--r-- | tests/ref/fate/webm-dash-manifest-unaligned-video-streams | 2 |
4 files changed, 11 insertions, 8 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index b8ddf67b79..d856fccfc0 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -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; diff --git a/tests/ref/fate/webm-dash-manifest b/tests/ref/fate/webm-dash-manifest index 1c1a6793e1..4b88040ff5 100644 --- a/tests/ref/fate/webm-dash-manifest +++ b/tests/ref/fate/webm-dash-manifest @@ -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> diff --git a/tests/ref/fate/webm-dash-manifest-unaligned-audio-streams b/tests/ref/fate/webm-dash-manifest-unaligned-audio-streams index 5e1743e7bf..6e9de211fb 100644 --- a/tests/ref/fate/webm-dash-manifest-unaligned-audio-streams +++ b/tests/ref/fate/webm-dash-manifest-unaligned-audio-streams @@ -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> diff --git a/tests/ref/fate/webm-dash-manifest-unaligned-video-streams b/tests/ref/fate/webm-dash-manifest-unaligned-video-streams index 3576b605cb..ce205638b6 100644 --- a/tests/ref/fate/webm-dash-manifest-unaligned-video-streams +++ b/tests/ref/fate/webm-dash-manifest-unaligned-video-streams @@ -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> |