From 6b7b8227cc8753fde4094ca8af2d381c2740826f Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Fri, 20 Apr 2012 15:47:48 -0700 Subject: Make sure we restore our input buffer to its original state if we want to revisit it. Change-Id: Iab62562c4dea13520751c37c9448c0b19c82d739 --- media/libstagefright/codecs/aacdec/SoftAAC.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'media/libstagefright/codecs/aacdec/SoftAAC.cpp') 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; -- cgit v1.1