summaryrefslogtreecommitdiff
path: root/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp')
-rw-r--r--media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp77
1 files changed, 11 insertions, 66 deletions
diff --git a/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp b/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
index 43751a3550fc..11d9c220959c 100644
--- a/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
+++ b/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
@@ -201,33 +201,13 @@ static status_t parseAudioSpecificConfig(ABitReader *bits, sp<ABuffer> *asc) {
CHECK_EQ(parseAudioObjectType(bits, &extensionAudioObjectType),
(status_t)OK);
- if (extensionAudioObjectType == 5) {
- sbrPresent = bits->getBits(1);
- if (sbrPresent == 1) {
- unsigned extensionSamplingFreqIndex = bits->getBits(4);
- if (extensionSamplingFreqIndex == 0x0f) {
- /* unsigned extensionSamplingFrequency = */bits->getBits(24);
- }
- if (bits->numBitsLeft() >= 12) {
- syncExtensionType = bits->getBits(11);
- if (syncExtensionType == 0x548) {
- /* unsigned psPresent */bits->getBits(1);
- } else {
- // Rewind bitstream so that the reading of second
- // syncExtensionType has no effect
- bits->rewindBits(11);
- }
- }
- }
- } else if (extensionAudioObjectType == 22) {
- sbrPresent = bits->getBits(1);
- if (sbrPresent == 1) {
- unsigned extensionSamplingFreqIndex = bits->getBits(4);
- if (extensionSamplingFreqIndex == 0x0f) {
- /* unsigned extensionSamplingFrequency = */bits->getBits(24);
- }
+ sbrPresent = bits->getBits(1);
+
+ if (sbrPresent == 1) {
+ unsigned extensionSamplingFreqIndex = bits->getBits(4);
+ if (extensionSamplingFreqIndex == 0x0f) {
+ /* unsigned extensionSamplingFrequency = */bits->getBits(24);
}
- /* unsigned extensionChannelConfiguration = */bits->getBits(4);
}
size_t numBitsInExtension =
@@ -243,7 +223,7 @@ static status_t parseAudioSpecificConfig(ABitReader *bits, sp<ABuffer> *asc) {
bits->skipBits(8 - (numBitsInExtension & 7));
}
} else {
- bits->rewindBits(11);
+ bits->putBits(syncExtensionType, 11);
}
}
@@ -355,14 +335,11 @@ static status_t parseStreamMuxConfig(
break;
}
- status_t parseResult = OK;
*otherDataPresent = bits->getBits(1);
*otherDataLenBits = 0;
if (*otherDataPresent) {
if (audioMuxVersion == 1) {
TRESPASS(); // XXX to be implemented
- } else if (bits->numBitsLeft() < 9) {
- parseResult = ERROR_MALFORMED;
} else {
*otherDataLenBits = 0;
@@ -372,45 +349,13 @@ static status_t parseStreamMuxConfig(
otherDataLenEsc = bits->getBits(1);
unsigned otherDataLenTmp = bits->getBits(8);
(*otherDataLenBits) += otherDataLenTmp;
- } while (otherDataLenEsc && bits->numBitsLeft() >= 9);
-
- if (otherDataLenEsc) {
- parseResult = ERROR_MALFORMED;
- }
- }
- }
-
- if (parseResult == OK && bits->numBitsLeft() >= 1) {
- unsigned crcCheckPresent = bits->getBits(1);
- if (crcCheckPresent && bits->numBitsLeft() >= 8) {
- /* unsigned crcCheckSum = */bits->getBits(8);
- } else if (crcCheckPresent && bits->numBitsLeft() < 8) {
- parseResult = ERROR_MALFORMED;
- }
- } else {
- parseResult = ERROR_MALFORMED;
- }
-
- // Verify that only bits are left for byte aligning and that
- // any remaining bits are 0
- if (bits->numBitsLeft() / 8 > 0) {
- parseResult = ERROR_MALFORMED;
- } else {
- unsigned remainder = bits->getBits(bits->numBitsLeft());
- if (remainder != 0) {
- parseResult = ERROR_MALFORMED;
+ } while (otherDataLenEsc);
}
}
- // Check if config string parsing has failed (then probably due to a
- // malformed AudioSpecificConfig) and if so, assume most common
- // configuration for the variables after AudioSpecificConfig.
- if (parseResult != OK) {
- LOGW("LATM config string parsing has failed, assuming most common case "
- "of frameLengthType=0, otherDataPresent=0, and otherDataLenBits=0");
- *frameLengthType = 0;
- *otherDataPresent = 0;
- *otherDataLenBits = 0;
+ unsigned crcCheckPresent = bits->getBits(1);
+ if (crcCheckPresent) {
+ /* unsigned crcCheckSum = */bits->getBits(8);
}
return OK;