diff options
author | Andreas Huber <andih@google.com> | 2012-04-23 08:42:31 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-04-23 08:42:31 -0700 |
commit | 0818e739bdbcf16f6dfb21d507002ceaaf664ee4 (patch) | |
tree | a4689ae348be4c1dc9b718578ada4d1215025d28 | |
parent | a08f041125c7688aa33aef1b229278641ae1c375 (diff) | |
parent | 6b7b8227cc8753fde4094ca8af2d381c2740826f (diff) | |
download | frameworks_av-0818e739bdbcf16f6dfb21d507002ceaaf664ee4.zip frameworks_av-0818e739bdbcf16f6dfb21d507002ceaaf664ee4.tar.gz frameworks_av-0818e739bdbcf16f6dfb21d507002ceaaf664ee4.tar.bz2 |
Merge "Make sure we restore our input buffer to its original state if we want to revisit it."
-rw-r--r-- | media/libstagefright/codecs/aacdec/SoftAAC.cpp | 17 | ||||
-rw-r--r-- | media/libstagefright/codecs/aacdec/SoftAAC2.cpp | 19 |
2 files changed, 26 insertions, 10 deletions
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC.cpp b/media/libstagefright/codecs/aacdec/SoftAAC.cpp index 90f96c6..d509383 100644 --- a/media/libstagefright/codecs/aacdec/SoftAAC.cpp +++ b/media/libstagefright/codecs/aacdec/SoftAAC.cpp @@ -315,6 +315,7 @@ void SoftAAC::onQueueFilled(OMX_U32 portIndex) { mNumSamplesOutput = 0; } + size_t adtsHeaderSize = 0; if (mIsADTS) { // skip 30 bits, aac_frame_length follows. // ssssssss ssssiiip ppffffPc ccohCCll llllllll lll????? @@ -332,13 +333,13 @@ void SoftAAC::onQueueFilled(OMX_U32 portIndex) { CHECK_GE(inHeader->nFilledLen, aac_frame_length); - size_t headerSize = (protectionAbsent ? 7 : 9); + adtsHeaderSize = (protectionAbsent ? 7 : 9); - mConfig->pInputBuffer = (UChar *)adtsHeader + headerSize; - mConfig->inputBufferCurrentLength = aac_frame_length - headerSize; + mConfig->pInputBuffer = (UChar *)adtsHeader + adtsHeaderSize; + mConfig->inputBufferCurrentLength = aac_frame_length - adtsHeaderSize; - inHeader->nOffset += headerSize; - inHeader->nFilledLen -= headerSize; + inHeader->nOffset += adtsHeaderSize; + inHeader->nFilledLen -= adtsHeaderSize; } else { mConfig->pInputBuffer = inHeader->pBuffer + inHeader->nOffset; mConfig->inputBufferCurrentLength = inHeader->nFilledLen; @@ -387,6 +388,12 @@ void SoftAAC::onQueueFilled(OMX_U32 portIndex) { // We'll hold onto the input buffer and will decode // it again once the output port has been reconfigured. + // We're going to want to revisit this input buffer, but + // may have already advanced the offset. Undo that if + // necessary. + inHeader->nOffset -= adtsHeaderSize; + inHeader->nFilledLen += adtsHeaderSize; + notify(OMX_EventPortSettingsChanged, 1, 0, NULL); mOutputPortSettingsChange = AWAITING_DISABLED; return; diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp index 27cf5b9..aa65a0b 100644 --- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp +++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp @@ -312,6 +312,7 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) { mNumSamplesOutput = 0; } + size_t adtsHeaderSize = 0; if (mIsADTS) { // skip 30 bits, aac_frame_length follows. // ssssssss ssssiiip ppffffPc ccohCCll llllllll lll????? @@ -329,13 +330,13 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) { CHECK_GE(inHeader->nFilledLen, aac_frame_length); - size_t headerSize = (protectionAbsent ? 7 : 9); + adtsHeaderSize = (protectionAbsent ? 7 : 9); - inBuffer[0] = (UCHAR *)adtsHeader + headerSize; - inBufferLength[0] = aac_frame_length - headerSize; + inBuffer[0] = (UCHAR *)adtsHeader + adtsHeaderSize; + inBufferLength[0] = aac_frame_length - adtsHeaderSize; - inHeader->nOffset += headerSize; - inHeader->nFilledLen -= headerSize; + inHeader->nOffset += adtsHeaderSize; + inHeader->nFilledLen -= adtsHeaderSize; } else { inBuffer[0] = inHeader->pBuffer + inHeader->nOffset; inBufferLength[0] = inHeader->nFilledLen; @@ -352,10 +353,12 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) { inBuffer, inBufferLength, bytesValid); + decoderErr = aacDecoder_DecodeFrame(mAACDecoder, outBuffer, outHeader->nAllocLen, flags); + mInputDiscontinuity = false; /* @@ -374,6 +377,12 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) { */ if (decoderErr == AAC_DEC_OK && mInputBufferCount <= 2) { if (mStreamInfo->sampleRate != prevSampleRate) { + // We're going to want to revisit this input buffer, but + // may have already advanced the offset. Undo that if + // necessary. + inHeader->nOffset -= adtsHeaderSize; + inHeader->nFilledLen += adtsHeaderSize; + notify(OMX_EventPortSettingsChanged, 1, 0, NULL); mOutputPortSettingsChange = AWAITING_DISABLED; return; |