diff options
author | Andreas Huber <andih@google.com> | 2012-04-20 15:47:48 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2012-04-20 15:47:48 -0700 |
commit | 6b7b8227cc8753fde4094ca8af2d381c2740826f (patch) | |
tree | 032b06700dcc8c468d8aa0ddae5e984aee1716ce /media/libstagefright/codecs/aacdec/SoftAAC2.cpp | |
parent | fc554559032e394de1b28b918efb8ba9f72162fd (diff) | |
download | frameworks_av-6b7b8227cc8753fde4094ca8af2d381c2740826f.zip frameworks_av-6b7b8227cc8753fde4094ca8af2d381c2740826f.tar.gz frameworks_av-6b7b8227cc8753fde4094ca8af2d381c2740826f.tar.bz2 |
Make sure we restore our input buffer to its original state if we want to revisit it.
Change-Id: Iab62562c4dea13520751c37c9448c0b19c82d739
Diffstat (limited to 'media/libstagefright/codecs/aacdec/SoftAAC2.cpp')
-rw-r--r-- | media/libstagefright/codecs/aacdec/SoftAAC2.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
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; |