summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/aacdec
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-04-20 15:47:48 -0700
committerAndreas Huber <andih@google.com>2012-04-20 15:47:48 -0700
commit6b7b8227cc8753fde4094ca8af2d381c2740826f (patch)
tree032b06700dcc8c468d8aa0ddae5e984aee1716ce /media/libstagefright/codecs/aacdec
parentfc554559032e394de1b28b918efb8ba9f72162fd (diff)
downloadframeworks_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')
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC.cpp17
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC2.cpp19
2 files changed, 26 insertions, 10 deletions
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;
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;