libeffects: Fix to resolve glitch with disabling LVCS

LVCS requires separate input and output buffers to process
stereo data out of multi channel audio.
In case of multi channel use case, actual number of inplace
scratch buffers required for LVCS module is 8. So, correct
the value of LVCS_SCRATCHBUFFERS to 8.

Test: Solotester
Bug: 132949357
Bug: 137835997

Change-Id: I27ad3d1a8e3b0f0ad32aaa538bf25850fb43ebe8
gugelfrei
Puneeth Prabhu 5 years ago committed by Andy Hung
parent 107fd5a178
commit d1b4d4b24d

@ -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);

@ -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

@ -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

@ -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);

Loading…
Cancel
Save