summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Burke <daveburke@google.com>2012-05-17 23:08:08 -0700
committerDave Burke <daveburke@google.com>2012-05-17 23:08:08 -0700
commit3748b71a7fe73b0365a93f1fd28ced14219f85e5 (patch)
treea5e0c03adcfc5cc78531f36e13cd6a46ce856418
parent3eda271f8b1879467759f98e5538577b1b6804f4 (diff)
downloadframeworks_av-3748b71a7fe73b0365a93f1fd28ced14219f85e5.zip
frameworks_av-3748b71a7fe73b0365a93f1fd28ced14219f85e5.tar.gz
frameworks_av-3748b71a7fe73b0365a93f1fd28ced14219f85e5.tar.bz2
Handle stream changes at any point in the stream.
Also, handle discontinuity properly (was using wrong flag before). Bug: 6498711 Change-Id: I18a6684f7dc96aa04b1e8113b54ec1053895ca98
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC2.cpp48
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC2.h1
2 files changed, 15 insertions, 34 deletions
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<INT_PCM *>(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;