From 3748b71a7fe73b0365a93f1fd28ced14219f85e5 Mon Sep 17 00:00:00 2001 From: Dave Burke Date: Thu, 17 May 2012 23:08:08 -0700 Subject: Handle stream changes at any point in the stream. Also, handle discontinuity properly (was using wrong flag before). Bug: 6498711 Change-Id: I18a6684f7dc96aa04b1e8113b54ec1053895ca98 --- media/libstagefright/codecs/aacdec/SoftAAC2.cpp | 48 ++++++++----------------- media/libstagefright/codecs/aacdec/SoftAAC2.h | 1 - 2 files changed, 15 insertions(+), 34 deletions(-) (limited to 'media/libstagefright/codecs/aacdec') diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp index 953b0c5..8eefc07 100644 --- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp +++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp @@ -46,7 +46,6 @@ SoftAAC2::SoftAAC2( mIsADTS(false), mInputBufferCount(0), mSignalledError(false), - mInputDiscontinuity(false), mAnchorTimeUs(0), mNumSamplesOutput(0), mOutputPortSettingsChange(NONE) { @@ -364,7 +363,6 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) { INT_PCM *outBuffer = reinterpret_cast(outHeader->pBuffer + outHeader->nOffset); bytesValid[0] = inBufferLength[0]; - int flags = mInputDiscontinuity ? AACDEC_INTR : 0; int prevSampleRate = mStreamInfo->sampleRate; int prevNumChannels = mStreamInfo->numChannels; @@ -378,38 +376,22 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) { decoderErr = aacDecoder_DecodeFrame(mAACDecoder, outBuffer, outHeader->nAllocLen, - flags); + 0 /* flags */); } - mInputDiscontinuity = false; - - /* - * AAC+/eAAC+ streams can be signalled in two ways: either explicitly - * or implicitly, according to MPEG4 spec. AAC+/eAAC+ is a dual - * rate system and the sampling rate in the final output is actually - * doubled compared with the core AAC decoder sampling rate. - * - * Explicit signalling is done by explicitly defining SBR audio object - * type in the bitstream. Implicit signalling is done by embedding - * SBR content in AAC extension payload specific to SBR, and hence - * requires an AAC decoder to perform pre-checks on actual audio frames. - * - * Thus, we could not say for sure whether a stream is - * AAC+/eAAC+ until the first data frame is decoded. - */ - if (mInputBufferCount <= 2) { - if (mStreamInfo->sampleRate != prevSampleRate || - mStreamInfo->numChannels != prevNumChannels) { - // 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; - } + + // Check if stream info has changed + if (mStreamInfo->sampleRate != prevSampleRate || + mStreamInfo->numChannels != prevNumChannels) { + // 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; } size_t numOutBytes = @@ -477,7 +459,7 @@ void SoftAAC2::onPortFlushCompleted(OMX_U32 portIndex) { if (portIndex == 0) { // Make sure that the next buffer output does not still // depend on fragments from the last one decoded. - mInputDiscontinuity = true; + aacDecoder_SetParam(mAACDecoder, AAC_TPDEC_CLEAR_BUFFER, 1); mIsFirst = true; } } diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.h b/media/libstagefright/codecs/aacdec/SoftAAC2.h index 57565ab..29c9484 100644 --- a/media/libstagefright/codecs/aacdec/SoftAAC2.h +++ b/media/libstagefright/codecs/aacdec/SoftAAC2.h @@ -54,7 +54,6 @@ private: bool mIsFirst; size_t mInputBufferCount; bool mSignalledError; - bool mInputDiscontinuity; int64_t mAnchorTimeUs; int64_t mNumSamplesOutput; -- cgit v1.1