summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MPEG4Extractor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright/MPEG4Extractor.cpp')
-rw-r--r--media/libstagefright/MPEG4Extractor.cpp108
1 files changed, 59 insertions, 49 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index 2550253..2c472dc 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -269,6 +269,8 @@ status_t MPEG4DataSource::setCachedRange(off64_t offset, size_t size) {
////////////////////////////////////////////////////////////////////////////////
+static const bool kUseHexDump = false;
+
static void hexdump(const void *_data, size_t size) {
const uint8_t *data = (const uint8_t *)_data;
size_t offset = 0;
@@ -611,7 +613,6 @@ status_t MPEG4Extractor::parseDrmSINF(
if (size < 0) {
return ERROR_IO;
}
- int32_t classSize = size;
data_offset += numOfBytes;
while(size >= 11 ) {
@@ -672,7 +673,6 @@ status_t MPEG4Extractor::parseDrmSINF(
if (size < 0) {
return ERROR_IO;
}
- classSize = size;
data_offset += numOfBytes;
while (size > 0) {
@@ -770,7 +770,7 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
return ERROR_IO;
}
uint64_t chunk_size = ntohl(hdr[0]);
- uint32_t chunk_type = ntohl(hdr[1]);
+ int32_t chunk_type = ntohl(hdr[1]);
off64_t data_offset = *offset + 8;
if (chunk_size == 1) {
@@ -810,23 +810,23 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
MakeFourCCString(chunk_type, chunk);
ALOGV("chunk: %s @ %lld, %d", chunk, *offset, depth);
-#if 0
- static const char kWhitespace[] = " ";
- const char *indent = &kWhitespace[sizeof(kWhitespace) - 1 - 2 * depth];
- printf("%sfound chunk '%s' of size %" PRIu64 "\n", indent, chunk, chunk_size);
+ if (kUseHexDump) {
+ static const char kWhitespace[] = " ";
+ const char *indent = &kWhitespace[sizeof(kWhitespace) - 1 - 2 * depth];
+ printf("%sfound chunk '%s' of size %" PRIu64 "\n", indent, chunk, chunk_size);
- char buffer[256];
- size_t n = chunk_size;
- if (n > sizeof(buffer)) {
- n = sizeof(buffer);
- }
- if (mDataSource->readAt(*offset, buffer, n)
- < (ssize_t)n) {
- return ERROR_IO;
- }
+ char buffer[256];
+ size_t n = chunk_size;
+ if (n > sizeof(buffer)) {
+ n = sizeof(buffer);
+ }
+ if (mDataSource->readAt(*offset, buffer, n)
+ < (ssize_t)n) {
+ return ERROR_IO;
+ }
- hexdump(buffer, n);
-#endif
+ hexdump(buffer, n);
+ }
PathAdder autoAdder(&mPath, chunk_type);
@@ -1176,6 +1176,11 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
return ERROR_IO;
}
+ if (!timescale) {
+ ALOGE("timescale should not be ZERO.");
+ return ERROR_MALFORMED;
+ }
+
mLastTrack->timescale = ntohl(timescale);
// 14496-12 says all ones means indeterminate, but some files seem to use
@@ -1305,7 +1310,7 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
return ERROR_IO;
}
- uint16_t data_ref_index = U16_AT(&buffer[6]);
+ uint16_t data_ref_index __unused = U16_AT(&buffer[6]);
uint32_t num_channels = U16_AT(&buffer[16]);
uint16_t sample_size = U16_AT(&buffer[18]);
@@ -1358,7 +1363,7 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
return ERROR_IO;
}
- uint16_t data_ref_index = U16_AT(&buffer[6]);
+ uint16_t data_ref_index __unused = U16_AT(&buffer[6]);
uint16_t width = U16_AT(&buffer[6 + 18]);
uint16_t height = U16_AT(&buffer[6 + 20]);
@@ -1552,13 +1557,13 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
break;
}
- // @xyz
- case FOURCC('\xA9', 'x', 'y', 'z'):
+ // ©xyz
+ case FOURCC(0xA9, 'x', 'y', 'z'):
{
*offset += chunk_size;
- // Best case the total data length inside "@xyz" box
- // would be 8, for instance "@xyz" + "\x00\x04\x15\xc7" + "0+0/",
+ // Best case the total data length inside "©xyz" box
+ // would be 8, for instance "©xyz" + "\x00\x04\x15\xc7" + "0+0/",
// where "\x00\x04" is the text string length with value = 4,
// "\0x15\xc7" is the language code = en, and "0+0" is a
// location (string) value with longitude = 0 and latitude = 0.
@@ -1888,7 +1893,6 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
if (chunk_data_size < 24) {
return ERROR_IO;
}
- uint32_t duration;
Trex trex;
if (!mDataSource->getUInt32(data_offset + 4, &trex.track_ID) ||
!mDataSource->getUInt32(data_offset + 8, &trex.default_sample_description_index) ||
@@ -2172,7 +2176,7 @@ status_t MPEG4Extractor::parseTrackHeader(
return ERROR_IO;
}
- uint64_t ctime, mtime, duration;
+ uint64_t ctime __unused, mtime __unused, duration __unused;
int32_t id;
if (version == 1) {
@@ -2194,12 +2198,13 @@ status_t MPEG4Extractor::parseTrackHeader(
size_t matrixOffset = dynSize + 16;
int32_t a00 = U32_AT(&buffer[matrixOffset]);
int32_t a01 = U32_AT(&buffer[matrixOffset + 4]);
- int32_t dx = U32_AT(&buffer[matrixOffset + 8]);
int32_t a10 = U32_AT(&buffer[matrixOffset + 12]);
int32_t a11 = U32_AT(&buffer[matrixOffset + 16]);
- int32_t dy = U32_AT(&buffer[matrixOffset + 20]);
#if 0
+ int32_t dx = U32_AT(&buffer[matrixOffset + 8]);
+ int32_t dy = U32_AT(&buffer[matrixOffset + 20]);
+
ALOGI("x' = %.2f * x + %.2f * y + %.2f",
a00 / 65536.0f, a01 / 65536.0f, dx / 65536.0f);
ALOGI("y' = %.2f * x + %.2f * y + %.2f",
@@ -2260,7 +2265,7 @@ status_t MPEG4Extractor::parseITunesMetaData(off64_t offset, size_t size) {
char chunk[5];
MakeFourCCString(mPath[4], chunk);
ALOGV("meta: %s @ %lld", chunk, offset);
- switch (mPath[4]) {
+ switch ((int32_t)mPath[4]) {
case FOURCC(0xa9, 'a', 'l', 'b'):
{
metadataKey = kKeyAlbum;
@@ -2677,6 +2682,11 @@ status_t MPEG4Extractor::verifyTrack(Track *track) {
return ERROR_MALFORMED;
}
+ if (track->timescale == 0) {
+ ALOGE("timescale invalid.");
+ return ERROR_MALFORMED;
+ }
+
return OK;
}
@@ -2762,10 +2772,10 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio(
return ERROR_MALFORMED;
}
-#if 0
- printf("ESD of size %d\n", csd_size);
- hexdump(csd, csd_size);
-#endif
+ if (kUseHexDump) {
+ printf("ESD of size %d\n", csd_size);
+ hexdump(csd, csd_size);
+ }
if (csd_size == 0) {
// There's no further information, i.e. no codec specific data
@@ -2816,7 +2826,7 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio(
if (objectType == AOT_SBR || objectType == AOT_PS) {//SBR specific config per 14496-3 table 1.13
uint32_t extFreqIndex = br.getBits(4);
- int32_t extSampleRate;
+ int32_t extSampleRate __unused;
if (extFreqIndex == 15) {
if (csd_size < 8) {
return ERROR_MALFORMED;
@@ -2866,12 +2876,12 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio(
if (objectType == AOT_AAC_LC || objectType == AOT_ER_AAC_LC ||
objectType == AOT_ER_AAC_LD || objectType == AOT_ER_AAC_SCAL ||
objectType == AOT_ER_BSAC) {
- const int32_t frameLengthFlag = br.getBits(1);
+ const int32_t frameLengthFlag __unused = br.getBits(1);
const int32_t dependsOnCoreCoder = br.getBits(1);
if (dependsOnCoreCoder ) {
- const int32_t coreCoderDelay = br.getBits(14);
+ const int32_t coreCoderDelay __unused = br.getBits(14);
}
int32_t extensionFlag = -1;
@@ -2900,54 +2910,54 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio(
if (numChannels == 0) {
int32_t channelsEffectiveNum = 0;
int32_t channelsNum = 0;
- const int32_t ElementInstanceTag = br.getBits(4);
- const int32_t Profile = br.getBits(2);
- const int32_t SamplingFrequencyIndex = br.getBits(4);
+ const int32_t ElementInstanceTag __unused = br.getBits(4);
+ const int32_t Profile __unused = br.getBits(2);
+ const int32_t SamplingFrequencyIndex __unused = br.getBits(4);
const int32_t NumFrontChannelElements = br.getBits(4);
const int32_t NumSideChannelElements = br.getBits(4);
const int32_t NumBackChannelElements = br.getBits(4);
const int32_t NumLfeChannelElements = br.getBits(2);
- const int32_t NumAssocDataElements = br.getBits(3);
- const int32_t NumValidCcElements = br.getBits(4);
+ const int32_t NumAssocDataElements __unused = br.getBits(3);
+ const int32_t NumValidCcElements __unused = br.getBits(4);
const int32_t MonoMixdownPresent = br.getBits(1);
if (MonoMixdownPresent != 0) {
- const int32_t MonoMixdownElementNumber = br.getBits(4);
+ const int32_t MonoMixdownElementNumber __unused = br.getBits(4);
}
const int32_t StereoMixdownPresent = br.getBits(1);
if (StereoMixdownPresent != 0) {
- const int32_t StereoMixdownElementNumber = br.getBits(4);
+ const int32_t StereoMixdownElementNumber __unused = br.getBits(4);
}
const int32_t MatrixMixdownIndexPresent = br.getBits(1);
if (MatrixMixdownIndexPresent != 0) {
- const int32_t MatrixMixdownIndex = br.getBits(2);
- const int32_t PseudoSurroundEnable = br.getBits(1);
+ const int32_t MatrixMixdownIndex __unused = br.getBits(2);
+ const int32_t PseudoSurroundEnable __unused = br.getBits(1);
}
int i;
for (i=0; i < NumFrontChannelElements; i++) {
const int32_t FrontElementIsCpe = br.getBits(1);
- const int32_t FrontElementTagSelect = br.getBits(4);
+ const int32_t FrontElementTagSelect __unused = br.getBits(4);
channelsNum += FrontElementIsCpe ? 2 : 1;
}
for (i=0; i < NumSideChannelElements; i++) {
const int32_t SideElementIsCpe = br.getBits(1);
- const int32_t SideElementTagSelect = br.getBits(4);
+ const int32_t SideElementTagSelect __unused = br.getBits(4);
channelsNum += SideElementIsCpe ? 2 : 1;
}
for (i=0; i < NumBackChannelElements; i++) {
const int32_t BackElementIsCpe = br.getBits(1);
- const int32_t BackElementTagSelect = br.getBits(4);
+ const int32_t BackElementTagSelect __unused = br.getBits(4);
channelsNum += BackElementIsCpe ? 2 : 1;
}
channelsEffectiveNum = channelsNum;
for (i=0; i < NumLfeChannelElements; i++) {
- const int32_t LfeElementTagSelect = br.getBits(4);
+ const int32_t LfeElementTagSelect __unused = br.getBits(4);
channelsNum += 1;
}
ALOGV("mpeg4 audio channelsNum = %d", channelsNum);