Loading lib_dec/igf_dec_fx.c +109 −11 Original line number Diff line number Diff line Loading @@ -255,7 +255,8 @@ static Word16 IGF_replaceTCXNoise_1( /**< out: Q0 | n replaces TCX noise **************************************************************************/ static void IGF_replaceTCXNoise_2( Word32* in, /**< in/out: Q31 | MDCT spectrum */ const Word16 in_exp, /**< in: | MDCT spectrum exponent */ Word16* in_exp_arr, /**< in/out: Q15 | MDCT spectrum exponent array */ const Word16 in_exp, /**< in: | MDCT spectrum base exponent (used if in_exp_arr==NULL) */ const Word16 s_l, /**< in: Q0 | noise headroom */ const Word16* TCXNoise, /**< in: Q0 | tcx noise indicator vector */ const Word16 start, /**< in: Q0 | start MDCT subband index */ Loading Loading @@ -294,16 +295,20 @@ static void IGF_replaceTCXNoise_2( Word32* in, /**< in move16(); in[sb] = L_deposit_l( val ); // Q0 move32(); IF( in_exp_arr != NULL ) { in_exp_arr[sb] = 31; move16(); } val = shr( val, 5 ); // Q-5 rE = L_mac( rE, val, val ); // Q-9 n_noise_bands_tile = add( n_noise_bands_tile, 1 ); } } /* compute noise gain factor */ /* compute and apply noise gain factor */ IF( NE_16( n_noise_bands_tile, 0 ) ) { IF( EQ_16( element_mode, EVS_MONO ) ) { totalNoiseNrg = L_shr( totalNoiseNrg, 1 ); // Q-9 Loading @@ -321,6 +326,7 @@ static void IGF_replaceTCXNoise_2( Word32* in, /**< in rE = L_max( rE, 0x00010000 ); // Q-9 } /* calculate noise gain factor */ IF( EQ_16( element_mode, EVS_MONO ) ) { g = getSqrtWord32( L_mult( divide3232( totalNoiseNrg, rE ), 8192 /*1.0f / 4.0f Q15*/ ) ); // ((Q15 + Q15 + Q1) / 2) -> Q15 Loading @@ -335,8 +341,17 @@ static void IGF_replaceTCXNoise_2( Word32* in, /**< in g = Sqrt16( tmp, &tmp_e ); } /* apply noise gain factor */ FOR( sb = start; sb < stop; sb++ ) { Word16 nrm = norm_l( in[sb] ); Word32 in_tmp = L_shl( in[sb], nrm ); // exp: 31 - tmp Word16 in_exp_tmp = 0; IF( in_exp_arr != NULL ) { in_exp_tmp = sub( in_exp_arr[sb], nrm ); } IF( TCXNoise[sb] ) { IF( EQ_16( element_mode, EVS_MONO ) ) Loading @@ -346,17 +361,30 @@ static void IGF_replaceTCXNoise_2( Word32* in, /**< in } ELSE { Word16 nrm = norm_l( in[sb] ); in[sb] = L_shl( in[sb], nrm ); // exp: 31 - tmp move32(); in[sb] = Mpy_32_16_1( in[sb], g ); // exp: 31 - tmp + tmp_e in[sb] = Mpy_32_16_1( in_tmp, g ); // exp: 31 - tmp + tmp_e move32(); /* To handle corner cases */ IF( in_exp_arr != NULL ) { in_exp_arr[sb] = add( in_exp_tmp, tmp_e ); move16(); } ELSE { /* handle corner cases */ in[sb] = L_shr_sat( in[sb], sub( in_exp, sub( add( 31, tmp_e ), nrm ) ) ); // Making the exponent same as original move32(); } } } ELSE IF( in_exp_arr != NULL ) { /* don't apply noise gain factor */ in[sb] = in_tmp; move32(); in_exp_arr[sb] = in_exp_tmp; move16(); } } } } Loading Loading @@ -525,7 +553,6 @@ static void IGF_replaceTCXNoise_2_new_ivas( Word32 *in, /**< in } } } #endif /**********************************************************************/ /* replaces TCX noise with noise band ratio (for IVAS) Loading Loading @@ -612,6 +639,7 @@ static void IGF_replaceTCXNoise_2_new_ivas_with_var_shift( Word32 *in, } } } #endif /**********************************************************************/ /* reads whitening levels Loading Loading @@ -906,7 +934,9 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in Word16 n_noise_bands; Word16 n_noise_bands_off; Word16 strt_cpy; #ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS Word16 startLine; #endif Word16 minSrcSubband; Word16 tile_idx; Word32 totalNoiseNrg; Loading @@ -932,8 +962,10 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in move16(); nTiles = hGrid->nTiles; move16(); #ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS startLine = hGrid->startLine; move16(); #endif minSrcSubband = hGrid->minSrcSubband; move16(); tile_idx = 0; Loading Loading @@ -1004,6 +1036,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { Word16 start = (EQ_16( element_mode, EVS_MONO ) ? minSrcSubband : strt_cpy); IGF_replaceTCXNoise_2( igf_spec, NULL, specMed_e, hPrivateData->headroom_TCX_noise_white, TCXNoise, Loading Loading @@ -1063,6 +1096,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { Word16 start = ( EQ_16( element_mode, EVS_MONO ) ? minSrcSubband : strt_cpy ); IGF_replaceTCXNoise_2( src_spec, NULL, src_spec_e, hPrivateData->headroom_TCX_noise, TCXNoise, Loading Loading @@ -1192,6 +1226,20 @@ static void IGF_prepStereo( { IF( hPrivateDataL->n_noise_bands ) { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( igf_specL_fx, igf_specL_e_arr, 0, 0, TCXNoiseL, strt_cpy, stop, hPrivateDataL->totalNoiseNrg, hPrivateDataL->totalNoiseNrg_exp, hPrivateDataL->n_noise_bands, hInfoL->nfSeed, IVAS_CPE_MDCT ); #else IGF_replaceTCXNoise_2_new_ivas_with_var_shift( igf_specL_fx, igf_specL_e_arr, TCXNoiseL, Loading @@ -1201,6 +1249,7 @@ static void IGF_prepStereo( hPrivateDataL->totalNoiseNrg_exp, hPrivateDataL->n_noise_bands, hInfoL->nfSeed ); #endif } selectionL = 0; move16(); Loading @@ -1211,6 +1260,7 @@ static void IGF_prepStereo( { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( src_specL_fx, NULL, src_specL_e, 0, TCXNoiseL, Loading Loading @@ -1241,6 +1291,20 @@ static void IGF_prepStereo( { IF( hPrivateDataR->n_noise_bands ) { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( igf_specR_fx, igf_specR_e_arr, 0, 0, TCXNoiseR, strt_cpy, stop, hPrivateDataR->totalNoiseNrg, hPrivateDataR->totalNoiseNrg_exp, hPrivateDataR->n_noise_bands, hInfoR->nfSeed, IVAS_CPE_MDCT ); #else IGF_replaceTCXNoise_2_new_ivas_with_var_shift( igf_specR_fx, igf_specR_e_arr, TCXNoiseR, Loading @@ -1250,6 +1314,7 @@ static void IGF_prepStereo( hPrivateDataR->totalNoiseNrg_exp, hPrivateDataR->n_noise_bands, hInfoR->nfSeed ); #endif } selectionR = 0; move16(); Loading @@ -1260,6 +1325,7 @@ static void IGF_prepStereo( { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( src_specR_fx, NULL, src_specR_e, 0, TCXNoiseR, Loading Loading @@ -1385,6 +1451,20 @@ static void IGF_prepStereo( { IF( hPrivateDataL->n_noise_bands ) { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( igf_specL_fx, igf_specL_e_arr, 0, 0, TCXNoiseL, strt_cpy, stop, hPrivateDataL->totalNoiseNrg, hPrivateDataL->totalNoiseNrg_exp, hPrivateDataL->n_noise_bands, hInfoL->nfSeed, IVAS_CPE_MDCT ); #else IGF_replaceTCXNoise_2_new_ivas_with_var_shift( igf_specL_fx, igf_specL_e_arr, TCXNoiseL, Loading @@ -1394,6 +1474,7 @@ static void IGF_prepStereo( hPrivateDataL->totalNoiseNrg_exp, hPrivateDataL->n_noise_bands, hInfoL->nfSeed ); #endif } selectionL = 0; move16(); Loading @@ -1404,6 +1485,7 @@ static void IGF_prepStereo( { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( src_specL_fx, NULL, src_specL_e, 0, TCXNoiseL, Loading Loading @@ -1434,6 +1516,20 @@ static void IGF_prepStereo( { IF( hPrivateDataR->n_noise_bands ) { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( igf_specR_fx, igf_specR_e_arr, 0, 0, TCXNoiseR, strt_cpy, stop, hPrivateDataR->totalNoiseNrg, hPrivateDataR->totalNoiseNrg_exp, hPrivateDataR->n_noise_bands, hInfoR->nfSeed, IVAS_CPE_MDCT ); #else IGF_replaceTCXNoise_2_new_ivas_with_var_shift( igf_specR_fx, igf_specR_e_arr, TCXNoiseR, Loading @@ -1443,6 +1539,7 @@ static void IGF_prepStereo( hPrivateDataR->totalNoiseNrg_exp, hPrivateDataR->n_noise_bands, hInfoR->nfSeed ); #endif } selectionR = 0; move16(); Loading @@ -1453,6 +1550,7 @@ static void IGF_prepStereo( { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( src_specR_fx, NULL, src_specR_e, 0, TCXNoiseR, Loading Loading
lib_dec/igf_dec_fx.c +109 −11 Original line number Diff line number Diff line Loading @@ -255,7 +255,8 @@ static Word16 IGF_replaceTCXNoise_1( /**< out: Q0 | n replaces TCX noise **************************************************************************/ static void IGF_replaceTCXNoise_2( Word32* in, /**< in/out: Q31 | MDCT spectrum */ const Word16 in_exp, /**< in: | MDCT spectrum exponent */ Word16* in_exp_arr, /**< in/out: Q15 | MDCT spectrum exponent array */ const Word16 in_exp, /**< in: | MDCT spectrum base exponent (used if in_exp_arr==NULL) */ const Word16 s_l, /**< in: Q0 | noise headroom */ const Word16* TCXNoise, /**< in: Q0 | tcx noise indicator vector */ const Word16 start, /**< in: Q0 | start MDCT subband index */ Loading Loading @@ -294,16 +295,20 @@ static void IGF_replaceTCXNoise_2( Word32* in, /**< in move16(); in[sb] = L_deposit_l( val ); // Q0 move32(); IF( in_exp_arr != NULL ) { in_exp_arr[sb] = 31; move16(); } val = shr( val, 5 ); // Q-5 rE = L_mac( rE, val, val ); // Q-9 n_noise_bands_tile = add( n_noise_bands_tile, 1 ); } } /* compute noise gain factor */ /* compute and apply noise gain factor */ IF( NE_16( n_noise_bands_tile, 0 ) ) { IF( EQ_16( element_mode, EVS_MONO ) ) { totalNoiseNrg = L_shr( totalNoiseNrg, 1 ); // Q-9 Loading @@ -321,6 +326,7 @@ static void IGF_replaceTCXNoise_2( Word32* in, /**< in rE = L_max( rE, 0x00010000 ); // Q-9 } /* calculate noise gain factor */ IF( EQ_16( element_mode, EVS_MONO ) ) { g = getSqrtWord32( L_mult( divide3232( totalNoiseNrg, rE ), 8192 /*1.0f / 4.0f Q15*/ ) ); // ((Q15 + Q15 + Q1) / 2) -> Q15 Loading @@ -335,8 +341,17 @@ static void IGF_replaceTCXNoise_2( Word32* in, /**< in g = Sqrt16( tmp, &tmp_e ); } /* apply noise gain factor */ FOR( sb = start; sb < stop; sb++ ) { Word16 nrm = norm_l( in[sb] ); Word32 in_tmp = L_shl( in[sb], nrm ); // exp: 31 - tmp Word16 in_exp_tmp = 0; IF( in_exp_arr != NULL ) { in_exp_tmp = sub( in_exp_arr[sb], nrm ); } IF( TCXNoise[sb] ) { IF( EQ_16( element_mode, EVS_MONO ) ) Loading @@ -346,17 +361,30 @@ static void IGF_replaceTCXNoise_2( Word32* in, /**< in } ELSE { Word16 nrm = norm_l( in[sb] ); in[sb] = L_shl( in[sb], nrm ); // exp: 31 - tmp move32(); in[sb] = Mpy_32_16_1( in[sb], g ); // exp: 31 - tmp + tmp_e in[sb] = Mpy_32_16_1( in_tmp, g ); // exp: 31 - tmp + tmp_e move32(); /* To handle corner cases */ IF( in_exp_arr != NULL ) { in_exp_arr[sb] = add( in_exp_tmp, tmp_e ); move16(); } ELSE { /* handle corner cases */ in[sb] = L_shr_sat( in[sb], sub( in_exp, sub( add( 31, tmp_e ), nrm ) ) ); // Making the exponent same as original move32(); } } } ELSE IF( in_exp_arr != NULL ) { /* don't apply noise gain factor */ in[sb] = in_tmp; move32(); in_exp_arr[sb] = in_exp_tmp; move16(); } } } } Loading Loading @@ -525,7 +553,6 @@ static void IGF_replaceTCXNoise_2_new_ivas( Word32 *in, /**< in } } } #endif /**********************************************************************/ /* replaces TCX noise with noise band ratio (for IVAS) Loading Loading @@ -612,6 +639,7 @@ static void IGF_replaceTCXNoise_2_new_ivas_with_var_shift( Word32 *in, } } } #endif /**********************************************************************/ /* reads whitening levels Loading Loading @@ -906,7 +934,9 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in Word16 n_noise_bands; Word16 n_noise_bands_off; Word16 strt_cpy; #ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS Word16 startLine; #endif Word16 minSrcSubband; Word16 tile_idx; Word32 totalNoiseNrg; Loading @@ -932,8 +962,10 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in move16(); nTiles = hGrid->nTiles; move16(); #ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS startLine = hGrid->startLine; move16(); #endif minSrcSubband = hGrid->minSrcSubband; move16(); tile_idx = 0; Loading Loading @@ -1004,6 +1036,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { Word16 start = (EQ_16( element_mode, EVS_MONO ) ? minSrcSubband : strt_cpy); IGF_replaceTCXNoise_2( igf_spec, NULL, specMed_e, hPrivateData->headroom_TCX_noise_white, TCXNoise, Loading Loading @@ -1063,6 +1096,7 @@ static void IGF_prep_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in { Word16 start = ( EQ_16( element_mode, EVS_MONO ) ? minSrcSubband : strt_cpy ); IGF_replaceTCXNoise_2( src_spec, NULL, src_spec_e, hPrivateData->headroom_TCX_noise, TCXNoise, Loading Loading @@ -1192,6 +1226,20 @@ static void IGF_prepStereo( { IF( hPrivateDataL->n_noise_bands ) { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( igf_specL_fx, igf_specL_e_arr, 0, 0, TCXNoiseL, strt_cpy, stop, hPrivateDataL->totalNoiseNrg, hPrivateDataL->totalNoiseNrg_exp, hPrivateDataL->n_noise_bands, hInfoL->nfSeed, IVAS_CPE_MDCT ); #else IGF_replaceTCXNoise_2_new_ivas_with_var_shift( igf_specL_fx, igf_specL_e_arr, TCXNoiseL, Loading @@ -1201,6 +1249,7 @@ static void IGF_prepStereo( hPrivateDataL->totalNoiseNrg_exp, hPrivateDataL->n_noise_bands, hInfoL->nfSeed ); #endif } selectionL = 0; move16(); Loading @@ -1211,6 +1260,7 @@ static void IGF_prepStereo( { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( src_specL_fx, NULL, src_specL_e, 0, TCXNoiseL, Loading Loading @@ -1241,6 +1291,20 @@ static void IGF_prepStereo( { IF( hPrivateDataR->n_noise_bands ) { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( igf_specR_fx, igf_specR_e_arr, 0, 0, TCXNoiseR, strt_cpy, stop, hPrivateDataR->totalNoiseNrg, hPrivateDataR->totalNoiseNrg_exp, hPrivateDataR->n_noise_bands, hInfoR->nfSeed, IVAS_CPE_MDCT ); #else IGF_replaceTCXNoise_2_new_ivas_with_var_shift( igf_specR_fx, igf_specR_e_arr, TCXNoiseR, Loading @@ -1250,6 +1314,7 @@ static void IGF_prepStereo( hPrivateDataR->totalNoiseNrg_exp, hPrivateDataR->n_noise_bands, hInfoR->nfSeed ); #endif } selectionR = 0; move16(); Loading @@ -1260,6 +1325,7 @@ static void IGF_prepStereo( { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( src_specR_fx, NULL, src_specR_e, 0, TCXNoiseR, Loading Loading @@ -1385,6 +1451,20 @@ static void IGF_prepStereo( { IF( hPrivateDataL->n_noise_bands ) { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( igf_specL_fx, igf_specL_e_arr, 0, 0, TCXNoiseL, strt_cpy, stop, hPrivateDataL->totalNoiseNrg, hPrivateDataL->totalNoiseNrg_exp, hPrivateDataL->n_noise_bands, hInfoL->nfSeed, IVAS_CPE_MDCT ); #else IGF_replaceTCXNoise_2_new_ivas_with_var_shift( igf_specL_fx, igf_specL_e_arr, TCXNoiseL, Loading @@ -1394,6 +1474,7 @@ static void IGF_prepStereo( hPrivateDataL->totalNoiseNrg_exp, hPrivateDataL->n_noise_bands, hInfoL->nfSeed ); #endif } selectionL = 0; move16(); Loading @@ -1404,6 +1485,7 @@ static void IGF_prepStereo( { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( src_specL_fx, NULL, src_specL_e, 0, TCXNoiseL, Loading Loading @@ -1434,6 +1516,20 @@ static void IGF_prepStereo( { IF( hPrivateDataR->n_noise_bands ) { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( igf_specR_fx, igf_specR_e_arr, 0, 0, TCXNoiseR, strt_cpy, stop, hPrivateDataR->totalNoiseNrg, hPrivateDataR->totalNoiseNrg_exp, hPrivateDataR->n_noise_bands, hInfoR->nfSeed, IVAS_CPE_MDCT ); #else IGF_replaceTCXNoise_2_new_ivas_with_var_shift( igf_specR_fx, igf_specR_e_arr, TCXNoiseR, Loading @@ -1443,6 +1539,7 @@ static void IGF_prepStereo( hPrivateDataR->totalNoiseNrg_exp, hPrivateDataR->n_noise_bands, hInfoR->nfSeed ); #endif } selectionR = 0; move16(); Loading @@ -1453,6 +1550,7 @@ static void IGF_prepStereo( { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS IGF_replaceTCXNoise_2( src_specR_fx, NULL, src_specR_e, 0, TCXNoiseR, Loading