diff --git a/lib_com/options.h b/lib_com/options.h index 3ef84898de0946f1c57bb500cf0a2f04a19f1076..b124f8bc1c36a4bdb2ece1f1202391d91436d725 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -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 */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index a40fba65999325dbb29a2012c44a91ad84ac4aee..fb70f1932f97b5ca5cb33be9874cf4429d9f2d7d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -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( diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 760c12224c735303d59fa337a576473cf1c2af3e..b192eb852ae0d07c3e79752f8b7e66247344b99c 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -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++ ) { diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index d1e11efabd4d6a89fa9e6807ce5cbbaf0caade0d..a737a4908a3ebcdddb3d3798e940432d1b5be419 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -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,7 @@ 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(); @@ -3616,6 +3652,30 @@ void generate_comfort_noise_dec_hf_ivas_fx( /* 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(); + + /* Imaginary part in CLDFB band */ + 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*/