Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c0e003f authored by Andreas Huber's avatar Andreas Huber Committed by Android Git Automerger
Browse files

am 96409203: Merge "Add "support" for AMR WB comfort noise, no data and speech...

am 96409203: Merge "Add "support" for AMR WB comfort noise, no data and speech lost frame types" into jb-dev

* commit '96409203':
  Add "support" for AMR WB comfort noise, no data and speech lost frame types
parents 8ab086d0 96409203
Loading
Loading
Loading
Loading
+42 −21
Original line number Original line Diff line number Diff line
@@ -258,10 +258,14 @@ bool SoftAMR::isConfigured() const {
}
}


static size_t getFrameSize(unsigned FT) {
static size_t getFrameSize(unsigned FT) {
    static const size_t kFrameSizeWB[9] = {
    static const size_t kFrameSizeWB[10] = {
        132, 177, 253, 285, 317, 365, 397, 461, 477
        132, 177, 253, 285, 317, 365, 397, 461, 477, 40
    };
    };


    if (FT >= 10) {
        return 1;
    }

    size_t frameSize = kFrameSizeWB[FT];
    size_t frameSize = kFrameSizeWB[FT];


    // Round up bits to bytes and add 1 for the header byte.
    // Round up bits to bytes and add 1 for the header byte.
@@ -336,9 +340,27 @@ void SoftAMR::onQueueFilled(OMX_U32 portIndex) {
            }
            }
        } else {
        } else {
            int16 mode = ((inputPtr[0] >> 3) & 0x0f);
            int16 mode = ((inputPtr[0] >> 3) & 0x0f);

            if (mode >= 10 && mode <= 13) {
                ALOGE("encountered illegal frame type %d in AMR WB content.",
                      mode);

                notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
                mSignalledError = true;

                return;
            }

            size_t frameSize = getFrameSize(mode);
            size_t frameSize = getFrameSize(mode);
            CHECK_GE(inHeader->nFilledLen, frameSize);
            CHECK_GE(inHeader->nFilledLen, frameSize);


            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;
                int16 frameType;
                RX_State_wb rx_state;
                RX_State_wb rx_state;
                mime_unsorting(
                mime_unsorting(
@@ -346,8 +368,6 @@ void SoftAMR::onQueueFilled(OMX_U32 portIndex) {
                        mInputSampleBuffer,
                        mInputSampleBuffer,
                        &frameType, &mode, 1, &rx_state);
                        &frameType, &mode, 1, &rx_state);


            int16_t *outPtr = (int16_t *)outHeader->pBuffer;

                int16_t numSamplesOutput;
                int16_t numSamplesOutput;
                pvDecoder_AmrWb(
                pvDecoder_AmrWb(
                        mode, mInputSampleBuffer,
                        mode, mInputSampleBuffer,
@@ -361,6 +381,7 @@ void SoftAMR::onQueueFilled(OMX_U32 portIndex) {
                    /* Delete the 2 LSBs (14-bit output) */
                    /* Delete the 2 LSBs (14-bit output) */
                    outPtr[i] &= 0xfffC;
                    outPtr[i] &= 0xfffC;
                }
                }
            }


            numBytesRead = frameSize;
            numBytesRead = frameSize;
        }
        }