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

Commit b6478dda authored by Andy Hung's avatar Andy Hung Committed by Automerger Merge Worker
Browse files

Merge "lvm: Use fmin, fmax for clamping output" am: bdbd489a am: 8110c0e9

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1543602

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Idd3142c9f747899588bbbf2fb3000283762dc280
parents 7defb0e6 8110c0e9
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -167,15 +167,6 @@ LVDBE_ReturnStatus_en LVDBE_Process(
                                   pScratch,                       /* Destination    */
                                   NrFrames,                       /* Number of frames     */
                                   NrChannels);                    /* Number of channels     */

        for (LVM_INT32 ii = 0; ii < NrSamples; ++ii) {
            // TODO: replace with existing clamping function
            if (pScratch[ii] < -1.0) {
                pScratch[ii] = -1.0;
            } else if (pScratch[ii] > 1.0) {
                pScratch[ii] = 1.0;
            }
        }
    } else {
        // clear DBE processed path
        memset(pScratch, 0, sizeof(*pScratch) * NrSamples);
+4 −0
Original line number Diff line number Diff line
@@ -34,6 +34,10 @@ static inline LVM_FLOAT Abs_Float(LVM_FLOAT input) {
    return fabs(input);
}

static inline LVM_FLOAT LVM_Clamp(LVM_FLOAT val) {
    return fmin(fmax(val, -1.0f), 1.0f);
}

/****************************************************************************************
 *  Name        : dB_to_Lin32()
 *  Input       : Signed 16-bit integer
+1 −2
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
/*    Includes                                                                          */
/*                                                                                      */
/****************************************************************************************/

#include "AGC.h"
#include "ScalarArithmetic.h"

@@ -126,7 +125,7 @@ void AGC_MIX_VOL_Mc1Mon_D32_WRA(AGC_MIX_VOL_2St1Mon_FLOAT_t* pInstance, const LV
             */
            SampleVal = SampleVal * Vol_Mult;

            *pDst++ = SampleVal; /* Save the results */
            *pDst++ = LVM_Clamp(SampleVal); /* Save the results */

            /*
             * Update the AGC gain
+3 −12
Original line number Diff line number Diff line
@@ -18,24 +18,15 @@
/**********************************************************************************
   INCLUDE FILES
***********************************************************************************/

#include "ScalarArithmetic.h"
#include "VectorArithmetic.h"

void Add2_Sat_Float(const LVM_FLOAT* src, LVM_FLOAT* dst, LVM_INT16 n) {
    LVM_FLOAT Temp;
    LVM_INT16 ii;
    for (ii = n; ii != 0; ii--) {
        Temp = ((LVM_FLOAT)*src) + ((LVM_FLOAT)*dst);
        src++;

        if (Temp > 1.000000f) {
            *dst = 1.000000f;
        } else if (Temp < -1.000000f) {
            *dst = -1.000000f;
        } else {
            *dst = Temp;
        }
        dst++;
        Temp = *src++ + *dst;
        *dst++ = LVM_Clamp(Temp);
    }
    return;
}
+3 −16
Original line number Diff line number Diff line
@@ -18,9 +18,9 @@
/**********************************************************************************
   INCLUDE FILES
***********************************************************************************/

#include "Mixer_private.h"
#include "LVM_Macros.h"
#include "ScalarArithmetic.h"

/**********************************************************************************
   FUNCTION CORE_MIXSOFT_1ST_D32C31_WRA
@@ -52,14 +52,7 @@ void Core_MixInSoft_D32C31_SAT(Mix_1St_Cll_FLOAT_t* pInstance, const LVM_FLOAT*
            Temp2 = *dst;

            Temp3 = Temp1 * (pInstance->Current);
            Temp1 = Temp2 + Temp3;

            if (Temp1 > 1.0f)
                Temp1 = 1.0f;
            else if (Temp1 < -1.0f)
                Temp1 = -1.0f;

            *dst++ = Temp1;
            *dst++ = LVM_Clamp(Temp2 + Temp3);
        }
    }

@@ -72,13 +65,7 @@ void Core_MixInSoft_D32C31_SAT(Mix_1St_Cll_FLOAT_t* pInstance, const LVM_FLOAT*
            Temp2 = *dst;

            Temp3 = Temp1 * (pInstance->Current);
            Temp1 = Temp2 + Temp3;

            if (Temp1 > 1.0f)
                Temp1 = 1.0f;
            else if (Temp1 < -1.0f)
                Temp1 = -1.0f;
            *dst++ = Temp1;
            *dst++ = LVM_Clamp(Temp2 + Temp3);
        }
    }
}
Loading