Commit fd251cbb authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch 'basop-2457' into 'main'

Basop 2457 fix " Harmonize generate_comfort_noise_dec_hf_fx() and generate_comfort_noise_dec_hf_ivas_fx() "

See merge request !2880
parents 29645fa7 0cc06cb2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@
#define FIX_BASOP_2475_ASSERT_IN_MASA2_REND_TO_MONO     /* Nokia: basop issue 2475: Fix MASA2 to MONO rendering within IVAS_rend */
#define FIX_2346_DUPLICATED_IGF_FUNCTIONS               /* FhG: basop issue 2346: Review potentially duplicated IGF functions */
#define FIX_1525_UNINIT_FORMAT_SWITCHING_DEC            /* VA: float issue 1525: fix reading of uninitialized memory in format switching at the decoder */
#define FIX_BASOP_2457_HARM_GEN                         /* FhG: harmonization of function generate_comfort_noise_dec_hf_ivas_fx()*/
#define HARMONIZE_2446_CON_TCX_FX                       /* FhG: basop issue: 2446 harmonization of function con_tcx_fx() */
#define FIX_BASOP_2478_HARM_ENC_PRM_HM                  /* FhG: basop issue 2478: harmonize enc_prm_hm() and enc_prm_hm_ivas_fx() */
#define FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC            /* Nokia: Fix to convert non-converted binary operations */
+11 −9
Original line number Diff line number Diff line
@@ -6751,19 +6751,21 @@ void generate_comfort_noise_dec_ivas_fx(
    const Word16 nchan_out /* i  : number of output channels     */
);

void generate_comfort_noise_dec_hf_fx(
    Word32 **bufferReal, /* o   : matrix to real part of i   bands */
    Word32 **bufferImag, /* o   : matrix to imaginary part of i   bands */
    Word16 *bufferScale, /* o   : pointer to scalefactor for real and imaginary part of i   bands */
    Decoder_State *stdec );

#ifndef FIX_BASOP_2457_HARM_GEN
void generate_comfort_noise_dec_hf_ivas_fx(
    Word32 **bufferReal,         /* o   : matrix to real part of input bands */
    Word32 **bufferImag,         /* o   : matrix to imaginary part of input bands */
    Word32 **bufferReal,         /* o   : matrix to real part of input bands   bufferScale*/
    Word32 **bufferImag,         /* o   : matrix to imaginary part of input bands  bufferScale*/
    Word16 *bufferScale,         /* o   : pointer to scalefactor for real and imaginary part of input bands */
    HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables  */
    const Word16 cng_coh_flag    /* i  : CNG Flag for coherence handling                        */
    const Word16 cng_coh_flag    /* i  : CNG Flag for coherence handling                        Q0*/
);
#endif

void generate_comfort_noise_dec_hf_fx(
    Word32 **bufferReal, /* o   : matrix to real part of input bands   bufferScale*/
    Word32 **bufferImag, /* o   : matrix to imaginary part of input bands  bufferScale*/
    Word16 *bufferScale, /* o   : pointer to scalefactor for real and imaginary part of input bands */
    Decoder_State *st );

/* Generate the comfort noise based on the target noise level */
void generate_masking_noise_fx(
+5 −0
Original line number Diff line number Diff line
@@ -2003,7 +2003,12 @@ ivas_error acelp_core_dec_fx(
                {
                    Word16 tmpBufferScale = 0;
                    move16();
#ifndef FIX_BASOP_2457_HARM_GEN
                    generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag );
#else
                    generate_comfort_noise_dec_hf_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st );
#endif // !FIX_BASOP_2457_HARM_GEN


                    FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ )
                    {
+61 −1
Original line number Diff line number Diff line
@@ -3434,6 +3434,7 @@ void generate_comfort_noise_dec_ivas_fx(
    return;
}

#ifndef FIX_BASOP_2457_HARM_GEN
void generate_comfort_noise_dec_hf_fx(
    Word32 **bufferReal, /* o   : matrix to real part of input bands  bufferScale*/
    Word32 **bufferImag, /* o   : matrix to imaginary part of input bands  bufferScale*/
@@ -3503,6 +3504,9 @@ void generate_comfort_noise_dec_hf_fx(
    }
}

#endif // !FIX_BASOP_2457_HARM_GEN

#ifndef FIX_BASOP_2457_HARM_GEN
void generate_comfort_noise_dec_hf_ivas_fx(
    Word32 **bufferReal,         /* o   : matrix to real part of input bands   bufferScale*/
    Word32 **bufferImag,         /* o   : matrix to imaginary part of input bands  bufferScale*/
@@ -3510,6 +3514,13 @@ void generate_comfort_noise_dec_hf_ivas_fx(
    HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables  */
    const Word16 cng_coh_flag    /* i  : CNG Flag for coherence handling                        Q0*/
)
#else
void generate_comfort_noise_dec_hf_fx(
    Word32 **bufferReal, /* o   : matrix to real part of input bands   bufferScale*/
    Word32 **bufferImag, /* o   : matrix to imaginary part of input bands  bufferScale*/
    Word16 *bufferScale, /* o   : pointer to scalefactor for real and imaginary part of input bands */
    Decoder_State *st )
#endif
{
    Word16 i, j, s, sc, sn;
    Word16 scaleCLDFB;
@@ -3522,6 +3533,10 @@ void generate_comfort_noise_dec_hf_ivas_fx(
    Word32 *ptr_level;
    Word32 *cngNoiseLevel;
    Word32 tmp1, tmp2;
#ifdef FIX_BASOP_2457_HARM_GEN
    HANDLE_FD_CNG_COM hFdCngCom = st->hFdCngDec->hFdCngCom;
    Word16 cng_coh_flag = st->cng_ism_flag;
#endif // FIX_BASOP_2457_HARM_GEN

    cngNoiseLevel = hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); /*Q31 - hFdCngCom->cngNoiseLevelExp*/
    cngNoiseLevelExp = hFdCngCom->cngNoiseLevelExp;
@@ -3566,8 +3581,19 @@ void generate_comfort_noise_dec_hf_ivas_fx(
        cngNoiseLevelExp = add( cngNoiseLevelExp, sn );
        move16();
    }

#ifndef FIX_BASOP_2457_HARM_GEN
    randGaussExp = CNG_RAND_GAUSS_SHIFT + 1;
#else
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        randGaussExp = CNG_RAND_GAUSS_SHIFT;
    }
    ELSE
    {
        randGaussExp = CNG_RAND_GAUSS_SHIFT + 1;
    }
#endif // !FIX_BASOP_2457_HARM_GEN

    move16();

    /*
@@ -3582,12 +3608,21 @@ void generate_comfort_noise_dec_hf_ivas_fx(

        FOR( j = hFdCngCom->numCoreBands; j < hFdCngCom->regularStopBand; j++ )
        {
#ifdef FIX_BASOP_2457_HARM_GEN
            /* scaleCLDFB:  CLDFBinvScalingFactor_EXP + 1 */
            s = 0;
            move16();
            sqrtNoiseLevel = Sqrt32( L_shr( Mpy_32_16_1( *ptr_level, scaleCLDFB ), sn ), &s ); /*Q31 - s*/
#endif                                                                                         // FIX_BASOP_2457_HARM_GEN
            FOR( i = 0; i < hFdCngCom->numSlots; i++ )
            {
#ifndef FIX_BASOP_2457_HARM_GEN
                /* scaleCLDFB:  CLDFBinvScalingFactor_EXP + 1 */
                s = 0;
                move16();
                sqrtNoiseLevel = Sqrt32( L_shr( Mpy_32_16_1( *ptr_level, scaleCLDFB ), sn ), &s ); /*Q31 - s*/
#endif                                                                                             // FIX_BASOP_2457_HARM_GEN


                IF( cng_coh_flag )
                {
@@ -3609,6 +3644,29 @@ void generate_comfort_noise_dec_hf_ivas_fx(
                }
                ELSE
                {
#ifndef FIX_BASOP_2457_HARM_GEN
                    /* Real part in CLDFB band */
                    bufferReal[i][j] = L_shl( Mpy_32_32( L_shr( rand_gauss( seed ), 1 ), sqrtNoiseLevel ), s ); /*bufferScale*/
                    move32();

                    /* Imaginary part in CLDFB band */
                    bufferImag[i][j] = L_shl( Mpy_32_32( L_shr( rand_gauss( seed ), 1 ), sqrtNoiseLevel ), s ); /*bufferScale*/
                    move32();
#else
                    IF( EQ_16( st->element_mode, EVS_MONO ) )
                    {
                        /* Real part in CLDFB band */
                        bufferReal[i][j] = L_shl( Mpy_32_32( rand_gauss( seed ), sqrtNoiseLevel ), s ); /*bufferScale*/
                        move32();
                        /*fprintf(pFile,"%13.10f\n",WORD322FL_SCALE(bufferReal[i][j],sc));*/

                        /* Imaginary part in CLDFB band */
                        bufferImag[i][j] = L_shl( Mpy_32_32( rand_gauss( seed ), sqrtNoiseLevel ), s ); /*bufferScale*/
                        move32();
                        /*fprintf(pFile,"%13.10f\n",WORD322FL_SCALE(bufferImag[i][j],sc));*/
                    }
                    ELSE
                    {
                        /* Real part in CLDFB band */
                        bufferReal[i][j] = L_shl( Mpy_32_32( L_shr( rand_gauss( seed ), 1 ), sqrtNoiseLevel ), s ); /*bufferScale*/
                        move32();
@@ -3617,6 +3675,8 @@ void generate_comfort_noise_dec_hf_ivas_fx(
                        bufferImag[i][j] = L_shl( Mpy_32_32( L_shr( rand_gauss( seed ), 1 ), sqrtNoiseLevel ), s ); /*bufferScale*/
                        move32();
                    }
#endif // !FIX_BASOP_2457_HARM_GEN
                }
            }
            ptr_level = ptr_level + 1; /*Q31 - hFdCngCom->cngNoiseLevelExp*/
        }