diff options
-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; |