diff options
author | Andreas Huber <andih@google.com> | 2012-05-10 14:54:48 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2012-05-10 14:56:40 -0700 |
commit | a9605efa3edfae96fa618a4b78f6c2276f941fab (patch) | |
tree | c0950e78e3e0a11c67a0b366f2a92545a1af9959 /media | |
parent | 5c36fc8701eb7468c268c47dae5dba58dbd8e83e (diff) | |
download | frameworks_av-a9605efa3edfae96fa618a4b78f6c2276f941fab.zip frameworks_av-a9605efa3edfae96fa618a4b78f6c2276f941fab.tar.gz frameworks_av-a9605efa3edfae96fa618a4b78f6c2276f941fab.tar.bz2 |
Add "support" for AMR WB comfort noise, no data and speech lost frame types
by emitting silence.
Change-Id: I27b7f31051f0c9a14adde866305bbc91a827a00c
related-to-bug: 6478154
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp b/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp index 796caa4..c5f733b 100644 --- a/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp +++ b/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp @@ -258,10 +258,14 @@ bool SoftAMR::isConfigured() const { } static size_t getFrameSize(unsigned FT) { - static const size_t kFrameSizeWB[9] = { - 132, 177, 253, 285, 317, 365, 397, 461, 477 + static const size_t kFrameSizeWB[10] = { + 132, 177, 253, 285, 317, 365, 397, 461, 477, 40 }; + if (FT >= 10) { + return 1; + } + size_t frameSize = kFrameSizeWB[FT]; // Round up bits to bytes and add 1 for the header byte. @@ -336,30 +340,47 @@ void SoftAMR::onQueueFilled(OMX_U32 portIndex) { } } else { int16 mode = ((inputPtr[0] >> 3) & 0x0f); - size_t frameSize = getFrameSize(mode); - CHECK_GE(inHeader->nFilledLen, frameSize); - int16 frameType; - RX_State_wb rx_state; - mime_unsorting( - const_cast<uint8_t *>(&inputPtr[1]), - mInputSampleBuffer, - &frameType, &mode, 1, &rx_state); + if (mode >= 10 && mode <= 13) { + ALOGE("encountered illegal frame type %d in AMR WB content.", + mode); - int16_t *outPtr = (int16_t *)outHeader->pBuffer; + notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); + mSignalledError = true; - int16_t numSamplesOutput; - pvDecoder_AmrWb( - mode, mInputSampleBuffer, - outPtr, - &numSamplesOutput, - mDecoderBuf, frameType, mDecoderCookie); + return; + } - CHECK_EQ((int)numSamplesOutput, (int)kNumSamplesPerFrameWB); + size_t frameSize = getFrameSize(mode); + CHECK_GE(inHeader->nFilledLen, frameSize); - for (int i = 0; i < kNumSamplesPerFrameWB; ++i) { - /* Delete the 2 LSBs (14-bit output) */ - outPtr[i] &= 0xfffC; + int16_t *outPtr = (int16_t *)outHeader->pBuffer; + + if (mode >= 9) { + // Produce silence instead of comfort noise and for + // speech lost/no data. + memset(outPtr, 0, kNumSamplesPerFrameWB * sizeof(int16_t)); + } else if (mode < 9) { + int16 frameType; + RX_State_wb rx_state; + mime_unsorting( + const_cast<uint8_t *>(&inputPtr[1]), + mInputSampleBuffer, + &frameType, &mode, 1, &rx_state); + + int16_t numSamplesOutput; + pvDecoder_AmrWb( + mode, mInputSampleBuffer, + outPtr, + &numSamplesOutput, + mDecoderBuf, frameType, mDecoderCookie); + + CHECK_EQ((int)numSamplesOutput, (int)kNumSamplesPerFrameWB); + + for (int i = 0; i < kNumSamplesPerFrameWB; ++i) { + /* Delete the 2 LSBs (14-bit output) */ + outPtr[i] &= 0xfffC; + } } numBytesRead = frameSize; |