summaryrefslogtreecommitdiff
path: root/libavformat/matroskadec.c
diff options
context:
space:
mode:
authorVignesh Venkatasubramanian <vigneshv@google.com>2014-10-01 10:13:30 -0700
committerMichael Niedermayer <michaelni@gmx.at>2014-10-01 20:47:11 +0200
commit8acb76567aba59be91c9af4aa45b3a0900c57439 (patch)
treec8e55cff5842af04162d61f08a59a5ffbfe96ea0 /libavformat/matroskadec.c
parentacebff8e5dc0789c228b10ffcae2f2eb6c30a91d (diff)
downloadffmpeg-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>
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r--libavformat/matroskadec.c11
1 files changed, 7 insertions, 4 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;