From 83e90762e0ce4470e5174ae3b38afdfca0b9e42f Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Wed, 4 May 2011 09:48:46 -0700 Subject: DO NOT MERGE: Properly construct the ESDS metadata even if sizeof(codec-specific-data) != 2 Change-Id: Ie711ea8d6956fa8370c78e23bf795325627164d1 related-to-bug: 4381047 --- media/libstagefright/matroska/MatroskaExtractor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'media/libstagefright') diff --git a/media/libstagefright/matroska/MatroskaExtractor.cpp b/media/libstagefright/matroska/MatroskaExtractor.cpp index 733de92..642835a 100644 --- a/media/libstagefright/matroska/MatroskaExtractor.cpp +++ b/media/libstagefright/matroska/MatroskaExtractor.cpp @@ -660,7 +660,8 @@ static void addESDSFromAudioSpecificInfo( // AudioSpecificInfo (with size prefix) follows }; - CHECK(asiSize < 128); + // Make sure all sizes can be coded in a single byte. + CHECK(asiSize + 22 - 2 < 128); size_t esdsSize = sizeof(kStaticESDS) + asiSize + 1; uint8_t *esds = new uint8_t[esdsSize]; memcpy(esds, kStaticESDS, sizeof(kStaticESDS)); @@ -668,6 +669,11 @@ static void addESDSFromAudioSpecificInfo( *ptr++ = asiSize; memcpy(ptr, asi, asiSize); + // Increment by codecPrivateSize less 2 bytes that are accounted for + // already in lengths of 22/17 + esds[1] += asiSize - 2; + esds[6] += asiSize - 2; + meta->setData(kKeyESDS, 0, esds, esdsSize); delete[] esds; -- cgit v1.1