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

Commit 2687b899 authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "libeffects: Fix to resolve glitch with disabling LVCS"

parents 0615e566 d1b4d4b2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ void Copy_Float_Mc_Stereo( const LVM_FLOAT *src,
                                 LVM_INT16 NrFrames,
                                 LVM_INT32 NrChannels);
void Copy_Float_Stereo_Mc(       const LVM_FLOAT *src,
                                 LVM_FLOAT *StereoOut,
                                 LVM_FLOAT *dst,
                                 LVM_INT16 NrFrames,
                                 LVM_INT32 NrChannels);
+7 −6
Original line number Diff line number Diff line
@@ -117,30 +117,31 @@ void Copy_Float_Mc_Stereo(const LVM_FLOAT *src,
    }
}

// Merge a multichannel source with stereo contained in dst, to dst.
// Merge a multichannel source with stereo contained in StereoOut, to dst.
void Copy_Float_Stereo_Mc(const LVM_FLOAT *src,
                 LVM_FLOAT *StereoOut,
                 LVM_FLOAT *dst,
                 LVM_INT16 NrFrames, /* Number of frames*/
                 LVM_INT32 NrChannels)
{
    LVM_INT16 ii, jj;
    LVM_FLOAT *src_st = dst + 2 * (NrFrames - 1);

    // repack dst which carries stereo information
    // pack dst with stereo information of StereoOut
    // together with the upper channels of src.
    StereoOut += 2 * (NrFrames - 1);
    dst += NrChannels * (NrFrames - 1);
    src += NrChannels * (NrFrames - 1);
    for (ii = NrFrames; ii != 0; ii--)
    {
        dst[1] = src_st[1];
        dst[0] = src_st[0]; // copy 1 before 0 is required for NrChannels == 3.
        dst[1] = StereoOut[1];
        dst[0] = StereoOut[0]; // copy 1 before 0 is required for NrChannels == 3.
        for (jj = 2; jj < NrChannels; jj++)
        {
            dst[jj] = src[jj];
        }
        dst    -= NrChannels;
        src    -= NrChannels;
        src_st -= 2;
        StereoOut -= 2;
    }
}
#endif
+4 −0
Original line number Diff line number Diff line
@@ -60,7 +60,11 @@ extern "C" {
#define LVCS_COMPGAINFRAME          64          /* Compressor gain update interval */

/* Memory */
#ifdef SUPPORT_MC
#define LVCS_SCRATCHBUFFERS              8      /* Number of buffers required for inplace processing */
#else
#define LVCS_SCRATCHBUFFERS              6      /* Number of buffers required for inplace processing */
#endif
#ifdef SUPPORT_MC
/*
 * The Concert Surround module applies processing only on the first two
+45 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ LVCS_ReturnStatus_en LVCS_Process_CS(LVCS_Handle_t hInstance,
     * The Concert Surround module carries out processing only on L, R.
     */
    pInput = pScratch + (2 * NrFrames);
    pStIn  = pScratch + (LVCS_SCRATCHBUFFERS * NrFrames);
    pStIn  = pScratch + ((LVCS_SCRATCHBUFFERS - 2) * NrFrames);
    /* The first two channel data is extracted from the input data and
     * copied into pInput buffer
     */
@@ -303,13 +303,45 @@ LVCS_ReturnStatus_en LVCS_Process(LVCS_Handle_t hInstance,
     */
    if (pInstance->Params.OperatingMode != LVCS_OFF)
    {
#ifdef SUPPORT_MC
        LVM_FLOAT *pStereoOut;
        /*
         * LVCS_Process_CS uses output buffer to store intermediate outputs of StereoEnhancer,
         * Equalizer, ReverbGenerator and BypassMixer.
         * So, to avoid i/o data overlapping, when i/o buffers are common, use scratch buffer
         * to store intermediate outputs.
         */
        if (pOutData == pInData)
        {
          /*
           * Scratch memory is used in 4 chunks of (2 * NrFrames) size.
           * First chunk of memory is used by LVCS_StereoEnhancer and LVCS_ReverbGenerator,
           * second and fourth are used as input buffers by pInput and pStIn in LVCS_Process_CS.
           * Hence, pStereoOut is pointed to use unused third portion of scratch memory.
           */
            pStereoOut = (LVM_FLOAT *) \
                          pInstance->MemoryTable. \
                          Region[LVCS_MEMREGION_TEMPORARY_FAST].pBaseAddress +
                          ((LVCS_SCRATCHBUFFERS - 4) * NrFrames);
        }
        else
        {
            pStereoOut = pOutData;
        }

        /*
         * Call CS process function
         */
            err = LVCS_Process_CS(hInstance,
                                  pInData,
                                  pStereoOut,
                                  NrFrames);
#else
            err = LVCS_Process_CS(hInstance,
                                  pInData,
                                  pOutData,
                                  NumSamples);
#endif


        /*
@@ -329,10 +361,17 @@ LVCS_ReturnStatus_en LVCS_Process(LVCS_Handle_t hInstance,

            if(NumSamples < LVCS_COMPGAINFRAME)
            {
#ifdef SUPPORT_MC
                NonLinComp_Float(Gain,                    /* Compressor gain setting */
                                 pStereoOut,
                                 pStereoOut,
                                 (LVM_INT32)(2 * NrFrames));
#else
                NonLinComp_Float(Gain,                    /* Compressor gain setting */
                                 pOutData,
                                 pOutData,
                                 (LVM_INT32)(2 * NumSamples));
#endif
            }
            else
            {
@@ -361,7 +400,11 @@ LVCS_ReturnStatus_en LVCS_Process(LVCS_Handle_t hInstance,

                FinalGain = Gain;
                Gain = pInstance->CompressGain;
#ifdef SUPPORT_MC
                pOutPtr = pStereoOut;
#else
                pOutPtr = pOutData;
#endif

                while(SampleToProcess > 0)
                {
@@ -428,6 +471,7 @@ LVCS_ReturnStatus_en LVCS_Process(LVCS_Handle_t hInstance,
        }
#ifdef SUPPORT_MC
        Copy_Float_Stereo_Mc(pInData,
                             pStereoOut,
                             pOutData,
                             NrFrames,
                             channels);