diff options
author | Marco Nelissen <marcone@google.com> | 2012-04-26 14:18:25 -0700 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2012-04-26 14:54:22 -0700 |
commit | 41914becfd019c619783d875c61ef71db0e67400 (patch) | |
tree | 00b42f8006f15f864811199dd6feb31725cf6d65 /media/libstagefright/codecs/aacdec | |
parent | 0756aa99dffd5740d963fdda60699fdefe58ce85 (diff) | |
download | frameworks_av-41914becfd019c619783d875c61ef71db0e67400.zip frameworks_av-41914becfd019c619783d875c61ef71db0e67400.tar.gz frameworks_av-41914becfd019c619783d875c61ef71db0e67400.tar.bz2 |
Account for new AAC decoder's delay
This drops the first block of decoded samples, and flushes the decoder
at the end of the stream to get the last bit of valid data.
b/774846
Change-Id: I1ae61b3e0619444441d160f33903eb61f57c6d31
Diffstat (limited to 'media/libstagefright/codecs/aacdec')
-rw-r--r-- | media/libstagefright/codecs/aacdec/SoftAAC2.cpp | 19 | ||||
-rw-r--r-- | media/libstagefright/codecs/aacdec/SoftAAC2.h | 1 |
2 files changed, 19 insertions, 1 deletions
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp index 7706bf6..547a554 100644 --- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp +++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp @@ -108,6 +108,7 @@ status_t SoftAAC2::initDecoder() { status = OK; } } + mIsFirst = true; return status; } @@ -298,7 +299,16 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) { inInfo->mOwnedByUs = false; notifyEmptyBufferDone(inHeader); - outHeader->nFilledLen = 0; + // flush out the decoder's delayed data by calling DecodeFrame one more time, with + // the AACDEC_FLUSH flag set + INT_PCM *outBuffer = + reinterpret_cast<INT_PCM *>(outHeader->pBuffer + outHeader->nOffset); + decoderErr = aacDecoder_DecodeFrame(mAACDecoder, + outBuffer, + outHeader->nAllocLen, + AACDEC_FLUSH); + outHeader->nFilledLen = + mStreamInfo->frameSize * sizeof(int16_t) * mStreamInfo->numChannels; outHeader->nFlags = OMX_BUFFERFLAG_EOS; outQueue.erase(outQueue.begin()); @@ -412,6 +422,12 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) { // We'll only output data if we successfully decoded it or // we've previously decoded valid data, in the latter case // (decode failed) we'll output a silent frame. + if (mIsFirst) { + mIsFirst = false; + // the first decoded frame should be discarded to account for decoder delay + numOutBytes = 0; + } + outHeader->nFilledLen = numOutBytes; outHeader->nFlags = 0; @@ -447,6 +463,7 @@ void SoftAAC2::onPortFlushCompleted(OMX_U32 portIndex) { // Make sure that the next buffer output does not still // depend on fragments from the last one decoded. mInputDiscontinuity = true; + mIsFirst = true; } } diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.h b/media/libstagefright/codecs/aacdec/SoftAAC2.h index d93685c..e5a1e3e 100644 --- a/media/libstagefright/codecs/aacdec/SoftAAC2.h +++ b/media/libstagefright/codecs/aacdec/SoftAAC2.h @@ -50,6 +50,7 @@ private: HANDLE_AACDECODER mAACDecoder; CStreamInfo *mStreamInfo; bool mIsADTS; + bool mIsFirst; size_t mInputBufferCount; bool mSignalledError; bool mInputDiscontinuity; |