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

Commit 305443c9 authored by Eric Laurent's avatar Eric Laurent
Browse files

LVM release 1.09 delivery

- Reverb:
	- 1 channel mixed has gain zero
	- core componenet now only outputs STEREO samples
	- wrapper now handles only STEREO from the Reverb Core
- Bass Boost:
	- increase scratch memory

Change-Id: I00ae31051cc40a7006fc993420facfeb4d30dc52
parent f6936a3a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ extern "C" {
#define LVDBE_PERSISTENT_COEF_ALIGN      4       /* 32-bit alignment for coef */
#define LVDBE_SCRATCH_ALIGN              4       /* 32-bit alignment for long data */

#define LVDBE_SCRATCHBUFFERS_INPLACE     4       /* Number of buffers required for inplace processing */
#define LVDBE_SCRATCHBUFFERS_INPLACE     6       /* Number of buffers required for inplace processing */

#define LVDBE_MIXER_TC                   5       /* Mixer time  */
#define LVDBE_BYPASS_MIXER_TC            100     /* Bypass mixer time */
+1 −6
Original line number Diff line number Diff line
@@ -496,7 +496,6 @@ LVREV_ReturnStatus_en LVREV_ApplyNewSettings (LVREV_Instance_st *pPrivate)
     * Update the bypass mixer time constant
     */
    if((pPrivate->NewParams.SampleRate   != pPrivate->CurrentParams.SampleRate)   ||
       (pPrivate->NewParams.SourceFormat != pPrivate->CurrentParams.SourceFormat) ||
       (pPrivate->bFirstControl          == LVM_TRUE))
    {
        LVM_UINT16   NumChannels = 1;                       /* Assume MONO format */
@@ -508,11 +507,7 @@ LVREV_ReturnStatus_en LVREV_ApplyNewSettings (LVREV_Instance_st *pPrivate)
        pPrivate->FeedbackMixer[2].Alpha=Alpha;
        pPrivate->FeedbackMixer[3].Alpha=Alpha;

        if (pPrivate->NewParams.SourceFormat != LVM_MONO)
        {
            /* Stereo or Mono-in-Stereo format data */
            NumChannels = 2;
        }
        NumChannels = 2;                                    /* Always stereo output */
        pPrivate->BypassMixer.Alpha1 = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_BYPASSMIXER_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), NumChannels);
        pPrivate->BypassMixer.Alpha2 = pPrivate->BypassMixer.Alpha1;
        pPrivate->GainMixer.Alpha    = pPrivate->BypassMixer.Alpha1;
+55 −111
Original line number Diff line number Diff line
@@ -54,7 +54,8 @@ LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t hInstance,
   LVREV_Instance_st     *pLVREV_Private = (LVREV_Instance_st *)hInstance;
   LVM_INT32             *pInput  = (LVM_INT32 *)pInData;
   LVM_INT32             *pOutput = pOutData;
   LVM_INT32             SamplesToProcess, RemainingSamples, format;
   LVM_INT32             SamplesToProcess, RemainingSamples;
   LVM_INT32             format = 1;

    /*
     * Check for error conditions
@@ -66,7 +67,6 @@ LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t hInstance,
        return LVREV_NULLADDRESS;
    }


    /*
     * Apply the new controls settings if required
     */
@@ -95,45 +95,41 @@ LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t hInstance,
        return LVREV_SUCCESS;
    }

    RemainingSamples = (LVM_INT32)NumSamples;

    format = 1;
    if (pLVREV_Private->CurrentParams.SourceFormat != LVM_MONO)
    {
        format = 2;
    }

    while (RemainingSamples!=0)
    {
    /*
     * If OFF copy and reformat the data as necessary
     */
    if (pLVREV_Private->CurrentParams.OperatingMode == LVM_MODE_OFF)
    {
            if((pInput != pOutput) || (pLVREV_Private->CurrentParams.SourceFormat == LVM_MONO))
        if(pInput != pOutput)
        {
            /*
                 * Copy the data to the output buffer
             * Copy the data to the output buffer, convert to stereo is required
             */

                if (pLVREV_Private->CurrentParams.SourceFormat != LVM_MONO)
                {
                    RemainingSamples = (RemainingSamples << 1);           /* Stereo data */
                }

            if(pLVREV_Private->CurrentParams.SourceFormat == LVM_MONO){
                MonoTo2I_32(pInput, pOutput, NumSamples);
            } else {
                Copy_16((LVM_INT16 *)pInput,
                        (LVM_INT16 *)pOutput,
                        (LVM_INT16)(RemainingSamples << 1));
                        (LVM_INT16)(NumSamples << 2)); // 32 bit data, stereo
            }
        }

            RemainingSamples = 0;
        return LVREV_SUCCESS;
    }

    RemainingSamples = (LVM_INT32)NumSamples;

    if (pLVREV_Private->CurrentParams.SourceFormat != LVM_MONO)
    {
        format = 2;
    }

    while (RemainingSamples!=0)
    {
        /*
         * Process the data
         */
        else
        {

        if(RemainingSamples >  pLVREV_Private->MaxBlkLen)
        {
@@ -149,8 +145,7 @@ LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t hInstance,
        ReverbBlock(pInput, pOutput, pLVREV_Private, (LVM_UINT16)SamplesToProcess);

        pInput  = (LVM_INT32 *)(pInput +(SamplesToProcess*format));
            pOutput = (LVM_INT32 *)(pOutput+(SamplesToProcess*format));
        }
        pOutput = (LVM_INT32 *)(pOutput+(SamplesToProcess*2));      // Always stereo output
    }

    return LVREV_SUCCESS;
@@ -420,26 +415,13 @@ void ReverbBlock(LVM_INT32 *pInput, LVM_INT32 *pOutput, LVREV_Instance_st *pPriv
                            pPrivate->pScratchDelayLine[1],
                            (LVM_INT16)NumSamples);

             if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
             {

            JoinTo2i_32x32(pPrivate->pScratchDelayLine[0],
                           pPrivate->pScratchDelayLine[1],
                           pTemp,
                           (LVM_INT16)NumSamples);

             }
             else
             {
                 Add2_Sat_32x32(pPrivate->pScratchDelayLine[1],
                                pPrivate->pScratchDelayLine[0],
                                (LVM_INT16)NumSamples);

                /*Apply 3-dB gain in-order to compensate for the gain change in stereo mode*/
                Mult3s_32x16(pPrivate->pScratchDelayLine[0],
                             LVREV_MIN3DB,
                             pTemp,
                             (LVM_INT16)NumSamples);
             }
            break;
        case LVREV_DELAYLINES_2:

@@ -447,49 +429,25 @@ void ReverbBlock(LVM_INT32 *pInput, LVM_INT32 *pOutput, LVREV_Instance_st *pPriv
                      (LVM_INT16*)pScratch,
                      (LVM_INT16)(NumSamples << 1));



             if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
             {

            Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[0],
                            -0x8000,
                            pScratch,
                            (LVM_INT16)NumSamples);
             }

             Add2_Sat_32x32(pPrivate->pScratchDelayLine[1],
                            pPrivate->pScratchDelayLine[0],
                            (LVM_INT16)NumSamples);


             if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
             {
             JoinTo2i_32x32(pPrivate->pScratchDelayLine[0],
                            pScratch,
                            pTemp,
                            (LVM_INT16)NumSamples);
             }
             else
             {
                Copy_16(    (LVM_INT16*)pPrivate->pScratchDelayLine[0],
                            (LVM_INT16*)pTemp,
                            (LVM_INT16)(NumSamples << 1));

             }
            break;
        case LVREV_DELAYLINES_1:
            if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
            {

            MonoTo2I_32(pPrivate->pScratchDelayLine[0],
                        pTemp,
                        (LVM_INT16)NumSamples);
            }
            else
            {
                pTemp = pPrivate->pScratchDelayLine[0];
            }
            break;
        default:
            break;
@@ -499,30 +457,15 @@ void ReverbBlock(LVM_INT32 *pInput, LVM_INT32 *pOutput, LVREV_Instance_st *pPriv
    /*
     *  Dry/wet mixer
     */
    if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
    {
        size = (LVM_INT16)(NumSamples << 1);
    }
    else
    {
        size = (LVM_INT16)NumSamples;
    }

    size = (LVM_INT16)(NumSamples << 1);
    MixSoft_2St_D32C31_SAT(&pPrivate->BypassMixer,
                           pInput,
                           pTemp,
                           pTemp,
                           pOutput,
                           size);

    /* Apply Gain*/
    if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
    {
        size = (LVM_INT16)(NumSamples << 1);
    }
    else
    {
        size = (LVM_INT16)NumSamples;
    }

    Shift_Sat_v32xv32 (LVREV_OUTPUTGAIN_SHIFT,
                       pOutput,
@@ -533,6 +476,7 @@ void ReverbBlock(LVM_INT32 *pInput, LVM_INT32 *pOutput, LVREV_Instance_st *pPriv
                           pOutput,
                           pOutput,
                           size);

    return;
}

+12 −17
Original line number Diff line number Diff line
@@ -431,26 +431,15 @@ int process( LVM_INT16 *pIn,
        pContext->InFrames32[i] = (LVM_INT32)pIn[i]<<8;
    }

     // If the input was MONO, convert to STEREO
    if(pContext->config.inputCfg.channels == CHANNEL_MONO){
        //LOGV("\tConverting Output from MONO to STEREO");
        MonoTo2I_32(pContext->InFrames32, pContext->InFrames32, frameCount);
    }

    //LOGV("\tProcess, frames: %d, InFormat: %d(MONO=%d), OutFormat: %d(STEREO=%d)",
    //frameCount, pContext->config.inputCfg.channels, CHANNEL_MONO,
    //pContext->config.outputCfg.channels, CHANNEL_STEREO);

    if (pContext->preset && pContext->curPreset == REVERB_PRESET_NONE) {
        memset(pContext->OutFrames32, 0, frameCount * sizeof(LVM_INT32) * 2); //always stereo here
    } else {
        if(pContext->bEnabled == LVM_FALSE && pContext->SamplesToExitCount > 0) {
            memset(pContext->InFrames32,
                   0,
                   frameCount * sizeof(LVM_INT32) * 2); //always stereo here
            memset(pContext->InFrames32,0,frameCount * sizeof(LVM_INT32) * samplesPerFrame);
            LOGV("\tZeroing %d samples per frame at the end of call", samplesPerFrame);
        }

        /* Process the samples */
        /* Process the samples, producing a stereo output */
        LvmStatus = LVREV_Process(pContext->hInstance,      /* Instance handle */
                                  pContext->InFrames32,     /* Input buffer */
                                  pContext->OutFrames32,    /* Output buffer */
@@ -677,7 +666,7 @@ int Reverb_init(ReverbContext *pContext){

    /* Set the capabilities */
    InstParams.MaxBlockSize  = MAX_CALL_SIZE;
    InstParams.SourceFormat  = LVM_STEREO;
    InstParams.SourceFormat  = LVM_STEREO;          // Max format, could be mono during process
    InstParams.NumDelays     = LVREV_DELAYLINES_4;

    /* Allocate memory, forcing alignment */
@@ -742,7 +731,12 @@ int Reverb_init(ReverbContext *pContext){
    /* General parameters */
    params.OperatingMode  = LVM_MODE_ON;
    params.SampleRate     = LVM_FS_44100;

    if(pContext->config.inputCfg.channels == CHANNEL_MONO){
        params.SourceFormat   = LVM_MONO;
    } else {
        params.SourceFormat   = LVM_STEREO;
    }

    /* Reverb parameters */
    params.Level          = 0;
@@ -1790,8 +1784,9 @@ extern "C" int Reverb_process(effect_interface_t self,
    if (pContext->bEnabled == LVM_FALSE){
        if( pContext->SamplesToExitCount > 0){
            pContext->SamplesToExitCount -= outBuffer->frameCount;
            LOGV("\tReverb_process() Effect is being stopped %d", pContext->SamplesToExitCount);
        }else{
            LOGV("\tReverb_process() ERROR Effect is not enabled %d", pContext->SamplesToExitCount);
            LOGV("\tReverb_process() Effect is being stopped");
            return -ENODATA;
        }
    }