Loading lib_com/options.h +0 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,6 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT_FIX_2527 /* Fix crash from issue #2527 */ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ #define FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 /* FhG: part 2 of basop issue 2346: Review potentially duplicated IGF functions */ #define FIX_BASOP_2563_CRASH_HQ_GENERIC_DEC /* Eri: BASOP issue 2563: Crash in hq_generic decoding. EVS code --> solve with _sat operator */ #define FIX_2095_REMOVE_UNUSED_ISAR_TABLES /* Dolby: remove unused ISAR */ #define FIX_BASOP_2560_STEREO_DFT_DEC_RESET /* FhG: BASOP issue 2560: align reset of hStereoDft->res_gains_ind_fx[][] between BASOP and float */ Loading lib_enc/igf_enc_fx.c +0 −245 Original line number Diff line number Diff line Loading @@ -65,188 +65,6 @@ static void IGF_write_bits( return; } #ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 /**********************************************************************/ /* envelope estimation **************************************************************************/ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ Word32 *pMDCTSpectrum, /**< in: Q31 | MDCT spectrum */ Word16 MDCTSpectrum_e, /**< in: | exponent of MDCT spectrum */ Word32 *pPowerSpectrum, /**< in: Q31 | MDCT^2 + MDST^2 spectrum, or estimate */ Word16 PowerSpectrum_e, /**< in: | exponent of MDCT^2 + MDST^2 spectrum, or estimate */ const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; H_IGF_GRID hGrid; Word16 *swb_offset; Word16 sfb; /* this is the actual scalefactor band */ Word16 width; /* this is width in subbands of the actual scalefactor band */ Word16 tile_idx; Word16 strt_cpy; Word16 gain; /* the gain which has to be applied to the source tile to get the destination energy */ Word16 gain_exp; Word16 tb; Word16 zeroNrg; /* Q0 | flag indicating if the signal contains almost no energy */ Word32 sfbEnergyR[IGF_MAX_SFB]; Word16 sfbEnergyR_exp[IGF_MAX_SFB]; Word32 sfbEnergyC[IGF_MAX_SFB]; /* the energy of the destination region of the tile */ Word16 sfbEnergyC_exp[IGF_MAX_SFB]; Word32 sfbEnergyTileR[IGF_MAX_SFB]; Word16 sfbEnergyTileR_exp[IGF_MAX_SFB]; Word32 sfbEnergyTileC[IGF_MAX_SFB]; /* the energy of the destination region of the tile */ Word16 sfbEnergyTileC_exp[IGF_MAX_SFB]; Word32 LFMDCTSpectrum[N_MAX]; Word16 LFMDCTSpectrum_exp; Word32 LFPowerSpectrum[N_MAX]; Word16 tmp; Word16 tmp_exp; Word32 L_tmp; Word16 shift; /* initialize variables */ Copy32( pMDCTSpectrum + IGF_START_MN, hInstance->spec_be_igf, hInstance->infoStopLine - IGF_START_MN ); hPrivateData = &hInstance->igfData; hGrid = &hPrivateData->igfInfo.grid[igfGridIdx]; swb_offset = hGrid->swb_offset; move16(); hInstance->spec_be_igf_e = MDCTSpectrum_e; move16(); zeroNrg = 0; move16(); IF( pPowerSpectrum != NULL ) { FOR( tile_idx = 0; tile_idx < hGrid->nTiles; tile_idx++ ) { strt_cpy = hGrid->sbWrap[tile_idx]; move16(); FOR( sfb = hGrid->sfbWrap[tile_idx]; sfb < hGrid->sfbWrap[tile_idx + 1]; sfb++ ) { FOR( tb = swb_offset[sfb]; tb < swb_offset[sfb + 1]; tb++ ) { LFMDCTSpectrum[tb] = pMDCTSpectrum[strt_cpy]; move32(); LFPowerSpectrum[tb] = pPowerSpectrum[strt_cpy]; move32(); strt_cpy = add( strt_cpy, 1 ); } } } IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, pPowerSpectrum, &PowerSpectrum_e, sfbEnergyC, sfbEnergyC_exp ); IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, LFPowerSpectrum, &PowerSpectrum_e, sfbEnergyTileC, sfbEnergyTileC_exp ); IGFCommonFuncsMDCTSquareSpec( hGrid->startLine, hGrid->stopLine, LFMDCTSpectrum, MDCTSpectrum_e, LFMDCTSpectrum, &LFMDCTSpectrum_exp, 0, EVS_MONO ); IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, LFMDCTSpectrum, &LFMDCTSpectrum_exp, sfbEnergyTileR, sfbEnergyTileR_exp ); } ELSE { IGFCommonFuncsMDCTSquareSpec( hGrid->startLine, hGrid->stopLine, pMDCTSpectrum, MDCTSpectrum_e, LFMDCTSpectrum, &LFMDCTSpectrum_exp, 0, EVS_MONO ); IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, LFMDCTSpectrum, &LFMDCTSpectrum_exp, sfbEnergyR, sfbEnergyR_exp ); } FOR( tile_idx = 0; tile_idx < hGrid->nTiles; tile_idx++ ) { FOR( sfb = hGrid->sfbWrap[tile_idx]; sfb < hGrid->sfbWrap[tile_idx + 1]; sfb++ ) { width = sub( swb_offset[sfb + 1], swb_offset[sfb] ); L_tmp = 0; move16(); gain_exp = 0; move16(); IF( pPowerSpectrum ) { IF( sfbEnergyTileR[sfb] == 0 ) { sfbEnergyTileR[sfb] = 0x00010000; move32(); sfbEnergyTileR_exp[sfb] = 0; move16(); zeroNrg = 1; move16(); } IF( sfbEnergyTileC[sfb] == 0 ) { sfbEnergyTileC[sfb] = 0x00010000; move32(); sfbEnergyTileC_exp[sfb] = 0; move16(); zeroNrg = 1; move16(); } IF( sfbEnergyC[sfb] == 0 ) { sfbEnergyC[sfb] = 0x00010000; move32(); sfbEnergyC_exp[sfb] = 0; move16(); zeroNrg = 1; move16(); } BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyTileR[sfb] ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyC[sfb] ), sfbEnergyC_exp[sfb], round_fx_sat( sfbEnergyTileC[sfb] ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); L_tmp = L_mult( gain, tmp ); gain_exp = add( gain_exp, tmp_exp ); } ELSE { IF( sfbEnergyR[sfb] == 0 ) { sfbEnergyR[sfb] = 0x00010000; move32(); sfbEnergyR_exp[sfb] = 0; move16(); zeroNrg = 1; move16(); } BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyR[sfb] ), sfbEnergyR_exp[sfb], width, 15, &gain, &gain_exp ); L_tmp = L_deposit_h( gain ); } /* gain = 0.5f + (float)((2.885390081777927f * log(gain) + 16.f)); */ L_tmp = BASOP_Util_Log2( L_tmp ); L_tmp = L_add( L_tmp, L_deposit_h( shl( gain_exp, 15 - 6 ) ) ); shift = norm_l( L_tmp ); gain = round_fx_sat( L_shl( L_tmp, shift ) ); gain_exp = sub( 7, shift ); gain_exp = BASOP_Util_Add_MantExp( gain, gain_exp, 32767 /*16 Q11*/, 4, &gain ); gain_exp = BASOP_Util_Add_MantExp( gain, gain_exp, 0x4000, 0, &gain ); gain = shr( gain, s_min( sub( 15, gain_exp ), 15 ) ); if ( gain > 91 ) { gain = s_min( gain, 91 ); /* 13+15+63, see arithocde encode residual */ } if ( gain < 0 ) { gain = s_max( gain, 0 ); } /* set gain to zero if the signal contains too less energy */ if ( zeroNrg != 0 ) { gain = 0; move16(); } hPrivateData->igfScfQuantized[sfb] = gain; move16(); } } return; } #endif /*-------------------------------------------------------------------* Loading Loading @@ -2011,11 +1829,7 @@ static Word32 IGF_getTNR_ivas_fx( * envelope estimation *-------------------------------------------------------------------*/ #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 static void IGF_CalculateEnvelope_fx( #else static void IGF_CalculateEnvelope_ivas_fx( #endif const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ Word32 *pMDCTSpectrum_fx, /* i : MDCT spectrum */ Word16 e_mdct, /* i : exp of MDCT spectrum */ Loading Loading @@ -2062,25 +1876,21 @@ static void IGF_CalculateEnvelope_ivas_fx( Word16 crest_exp; /*Stores the exponent of the result(return value)*/ Word16 sfm_exp; /*stores exponent for ouput from sfm*/ Word16 tmp_e; #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 Word32 LFMDCTSpectrum[N_MAX]; Word16 sfbEnergyTileR16; Word16 sfbEnergyR16; Word16 gain16; /* the EVS gain which has to be applied to the source tile to get the destination energy */ Word16 zeroNrg; /* flag indicating if the signal contains almost no energy */ #endif hPrivateData = &hIGFEnc->igfData; hGrid = &hPrivateData->igfInfo.grid[(Word16) igfGridIdx]; swb_offset = hGrid->swb_offset; #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 zeroNrg = 0; sfbEnergyTileR16 = 0; temp = 0; move16(); move16(); move16(); #endif IF( element_mode > EVS_MONO ) { Loading Loading @@ -2114,7 +1924,6 @@ static void IGF_CalculateEnvelope_ivas_fx( } } } #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 ELSE { Copy32( pMDCTSpectrum_fx + IGF_START_MN, hIGFEnc->spec_be_igf, hIGFEnc->infoStopLine - IGF_START_MN ); Loading @@ -2137,13 +1946,8 @@ static void IGF_CalculateEnvelope_ivas_fx( } } } #endif #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( pPowerSpectrum_fx && ( element_mode > EVS_MONO ) ) #else IF( pPowerSpectrum_fx ) #endif { FOR( sb = hGrid->sbWrap[0]; sb < swb_offset[hGrid->sfbWrap[hGrid->nTiles]]; sb++ ) { Loading Loading @@ -2185,10 +1989,8 @@ static void IGF_CalculateEnvelope_ivas_fx( { tmp = strt_cpy; move16(); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode > EVS_MONO ) { #endif FOR( sb = swb_offset[sfb]; sb < swb_offset[sfb + 1]; sb++ ) { Word16 shift = norm_l( pPowerSpectrum_fx[sb] ); Loading @@ -2207,7 +2009,6 @@ static void IGF_CalculateEnvelope_ivas_fx( sfbEnergyTileR = L_deposit_h( BASOP_Util_Divide3232_Scale( sfbEnergyTileR, width, &tmp_e ) ); sfbEnergyTileR_e = add( sub( sfbEnergyTileR_e, Q31 ), tmp_e ); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 } ELSE { Loading Loading @@ -2248,7 +2049,6 @@ static void IGF_CalculateEnvelope_ivas_fx( strt_cpy += swb_offset[sfb + 1] - swb_offset[sfb]; } #endif IF( sfbEnergyTileR == 0 ) { Loading @@ -2259,37 +2059,24 @@ static void IGF_CalculateEnvelope_ivas_fx( } IF( sfbEnergyC == 0 ) { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 sfbEnergyC = ( element_mode > EVS_MONO ) ? EPSILON_FX : 0x00010000; #else sfbEnergyC = EPSILON_FX; #endif sfbEnergyC_e = 0; move32(); move16(); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode == EVS_MONO ) { zeroNrg = 1; move16(); } #endif } IF( sfbEnergyTileC == 0 ) { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 sfbEnergyTileC = ( element_mode > EVS_MONO ) ? EPSILON_FX : 0x00010000; #else sfbEnergyTileC = EPSILON_FX; #endif sfbEnergyTileC_e = 0; #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode > EVS_MONO ) { #endif temp = BASOP_Util_Divide3232_Scale( sfbEnergyC, sfbEnergyTileC, &tmp_e ); tmp_e = add( tmp_e, sub( sfbEnergyC_e, sfbEnergyTileC_e ) ); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 } ELSE { Loading @@ -2297,40 +2084,31 @@ static void IGF_CalculateEnvelope_ivas_fx( zeroNrg = 1; move16(); } #endif move32(); move16(); } ELSE { /*gain = (float) ( sfbEnergyTileR * ( sfbEnergyC / sfbEnergyTileC ) );*/ #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode > EVS_MONO ) { #endif temp = BASOP_Util_Divide3232_Scale( sfbEnergyC, sfbEnergyTileC, &tmp_e ); tmp_e = add( tmp_e, sub( sfbEnergyC_e, sfbEnergyTileC_e ) ); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 } ELSE { BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyC ), sfbEnergyC_e, round_fx_sat( sfbEnergyTileC ), sfbEnergyTileC_e, &tmp, &tmp_e ); } #endif } #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode > EVS_MONO ) { #endif gain = Mult_32_16( sfbEnergyTileR, temp ); // gain_e #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 } ELSE { gain = L_mult( sfbEnergyTileR16, tmp ); // gain_e } #endif gain_e = add( tmp_e, sfbEnergyTileR_e ); IF( element_mode > EVS_MONO ) Loading Loading @@ -2647,10 +2425,8 @@ static void IGF_CalculateEnvelope_ivas_fx( } ELSE { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode > EVS_MONO ) { #endif tmp_e = e_mdct; move16(); sfbEnergyR = add_sat( EPSILON_FX, BASOP_Util_Divide3216_Scale( sum2_32_fx( pMDCTSpectrum_fx + swb_offset[sfb], width, &tmp_e ) /*exp: tmp_e*/, width, &sfbEnergyR_e ) ); // sfbEnergyR_e Loading Loading @@ -2680,7 +2456,6 @@ static void IGF_CalculateEnvelope_ivas_fx( move16(); move16(); move16(); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 } ELSE { Loading Loading @@ -2713,21 +2488,14 @@ static void IGF_CalculateEnvelope_ivas_fx( BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyR ), sfbEnergyR_e, width, 15, &sfbEnergyR16, &gain_e ); gain = L_deposit_h( sfbEnergyR16 ); } #endif } #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode > EVS_MONO ) { #endif gain = Mult_32_16( gain, att ); // gain_e gain_e = add( gain_e, 0 ); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 /*gain=0.5f+log2f(gain)*2+16 because 2.885390081777927f=2*1/loge(2) so 2*1/loge(2)*loge(x) can be written as 2*log2(x)*/ #else /*gain=0.5f+log2f(gain)*2+16 becuase 2.885390081777927f=2*1/loge(2) so 2*1/loge(2)*loge(x) can be written as 2*log2(x)*/ #endif gain = L_add( ONE_IN_Q22, L_add( L_add( L_shr( BASOP_Util_Log2( gain ), 1 ), L_shl( gain_e, Q24 ) ), L_shl( 16, Q23 ) ) ); /*Q23*/ test(); test(); Loading @@ -2747,7 +2515,6 @@ static void IGF_CalculateEnvelope_ivas_fx( move16(); hPrivateData->igfScfQuantized[sfb] = extract_l( L_shr( gain, Q23 ) ); /*Q0*/ move16(); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 } ELSE { Loading Loading @@ -2781,7 +2548,6 @@ static void IGF_CalculateEnvelope_ivas_fx( hPrivateData->igfScfQuantized[sfb] = gain16; move16(); } #endif } } Loading Loading @@ -3553,18 +3319,7 @@ void IGFEncApplyMono_fx( calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); } #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IGF_CalculateEnvelope_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx ); #else IF( EQ_16( st->element_mode, EVS_MONO ) ) { IGF_CalculateEnvelope( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, *e_ps, igfGridIdx ); } ELSE { IGF_CalculateEnvelope_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx ); } #endif IF( isTCX20 ) { Loading Loading
lib_com/options.h +0 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,6 @@ #define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */ #define NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT_FIX_2527 /* Fix crash from issue #2527 */ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ #define FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 /* FhG: part 2 of basop issue 2346: Review potentially duplicated IGF functions */ #define FIX_BASOP_2563_CRASH_HQ_GENERIC_DEC /* Eri: BASOP issue 2563: Crash in hq_generic decoding. EVS code --> solve with _sat operator */ #define FIX_2095_REMOVE_UNUSED_ISAR_TABLES /* Dolby: remove unused ISAR */ #define FIX_BASOP_2560_STEREO_DFT_DEC_RESET /* FhG: BASOP issue 2560: align reset of hStereoDft->res_gains_ind_fx[][] between BASOP and float */ Loading
lib_enc/igf_enc_fx.c +0 −245 Original line number Diff line number Diff line Loading @@ -65,188 +65,6 @@ static void IGF_write_bits( return; } #ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 /**********************************************************************/ /* envelope estimation **************************************************************************/ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ Word32 *pMDCTSpectrum, /**< in: Q31 | MDCT spectrum */ Word16 MDCTSpectrum_e, /**< in: | exponent of MDCT spectrum */ Word32 *pPowerSpectrum, /**< in: Q31 | MDCT^2 + MDST^2 spectrum, or estimate */ Word16 PowerSpectrum_e, /**< in: | exponent of MDCT^2 + MDST^2 spectrum, or estimate */ const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ ) { IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; H_IGF_GRID hGrid; Word16 *swb_offset; Word16 sfb; /* this is the actual scalefactor band */ Word16 width; /* this is width in subbands of the actual scalefactor band */ Word16 tile_idx; Word16 strt_cpy; Word16 gain; /* the gain which has to be applied to the source tile to get the destination energy */ Word16 gain_exp; Word16 tb; Word16 zeroNrg; /* Q0 | flag indicating if the signal contains almost no energy */ Word32 sfbEnergyR[IGF_MAX_SFB]; Word16 sfbEnergyR_exp[IGF_MAX_SFB]; Word32 sfbEnergyC[IGF_MAX_SFB]; /* the energy of the destination region of the tile */ Word16 sfbEnergyC_exp[IGF_MAX_SFB]; Word32 sfbEnergyTileR[IGF_MAX_SFB]; Word16 sfbEnergyTileR_exp[IGF_MAX_SFB]; Word32 sfbEnergyTileC[IGF_MAX_SFB]; /* the energy of the destination region of the tile */ Word16 sfbEnergyTileC_exp[IGF_MAX_SFB]; Word32 LFMDCTSpectrum[N_MAX]; Word16 LFMDCTSpectrum_exp; Word32 LFPowerSpectrum[N_MAX]; Word16 tmp; Word16 tmp_exp; Word32 L_tmp; Word16 shift; /* initialize variables */ Copy32( pMDCTSpectrum + IGF_START_MN, hInstance->spec_be_igf, hInstance->infoStopLine - IGF_START_MN ); hPrivateData = &hInstance->igfData; hGrid = &hPrivateData->igfInfo.grid[igfGridIdx]; swb_offset = hGrid->swb_offset; move16(); hInstance->spec_be_igf_e = MDCTSpectrum_e; move16(); zeroNrg = 0; move16(); IF( pPowerSpectrum != NULL ) { FOR( tile_idx = 0; tile_idx < hGrid->nTiles; tile_idx++ ) { strt_cpy = hGrid->sbWrap[tile_idx]; move16(); FOR( sfb = hGrid->sfbWrap[tile_idx]; sfb < hGrid->sfbWrap[tile_idx + 1]; sfb++ ) { FOR( tb = swb_offset[sfb]; tb < swb_offset[sfb + 1]; tb++ ) { LFMDCTSpectrum[tb] = pMDCTSpectrum[strt_cpy]; move32(); LFPowerSpectrum[tb] = pPowerSpectrum[strt_cpy]; move32(); strt_cpy = add( strt_cpy, 1 ); } } } IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, pPowerSpectrum, &PowerSpectrum_e, sfbEnergyC, sfbEnergyC_exp ); IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, LFPowerSpectrum, &PowerSpectrum_e, sfbEnergyTileC, sfbEnergyTileC_exp ); IGFCommonFuncsMDCTSquareSpec( hGrid->startLine, hGrid->stopLine, LFMDCTSpectrum, MDCTSpectrum_e, LFMDCTSpectrum, &LFMDCTSpectrum_exp, 0, EVS_MONO ); IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, LFMDCTSpectrum, &LFMDCTSpectrum_exp, sfbEnergyTileR, sfbEnergyTileR_exp ); } ELSE { IGFCommonFuncsMDCTSquareSpec( hGrid->startLine, hGrid->stopLine, pMDCTSpectrum, MDCTSpectrum_e, LFMDCTSpectrum, &LFMDCTSpectrum_exp, 0, EVS_MONO ); IGFCommonFuncsCalcSfbEnergyPowerSpec( hGrid->startSfb, hGrid->stopSfb, hGrid->swb_offset, LFMDCTSpectrum, &LFMDCTSpectrum_exp, sfbEnergyR, sfbEnergyR_exp ); } FOR( tile_idx = 0; tile_idx < hGrid->nTiles; tile_idx++ ) { FOR( sfb = hGrid->sfbWrap[tile_idx]; sfb < hGrid->sfbWrap[tile_idx + 1]; sfb++ ) { width = sub( swb_offset[sfb + 1], swb_offset[sfb] ); L_tmp = 0; move16(); gain_exp = 0; move16(); IF( pPowerSpectrum ) { IF( sfbEnergyTileR[sfb] == 0 ) { sfbEnergyTileR[sfb] = 0x00010000; move32(); sfbEnergyTileR_exp[sfb] = 0; move16(); zeroNrg = 1; move16(); } IF( sfbEnergyTileC[sfb] == 0 ) { sfbEnergyTileC[sfb] = 0x00010000; move32(); sfbEnergyTileC_exp[sfb] = 0; move16(); zeroNrg = 1; move16(); } IF( sfbEnergyC[sfb] == 0 ) { sfbEnergyC[sfb] = 0x00010000; move32(); sfbEnergyC_exp[sfb] = 0; move16(); zeroNrg = 1; move16(); } BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyTileR[sfb] ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyC[sfb] ), sfbEnergyC_exp[sfb], round_fx_sat( sfbEnergyTileC[sfb] ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); L_tmp = L_mult( gain, tmp ); gain_exp = add( gain_exp, tmp_exp ); } ELSE { IF( sfbEnergyR[sfb] == 0 ) { sfbEnergyR[sfb] = 0x00010000; move32(); sfbEnergyR_exp[sfb] = 0; move16(); zeroNrg = 1; move16(); } BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyR[sfb] ), sfbEnergyR_exp[sfb], width, 15, &gain, &gain_exp ); L_tmp = L_deposit_h( gain ); } /* gain = 0.5f + (float)((2.885390081777927f * log(gain) + 16.f)); */ L_tmp = BASOP_Util_Log2( L_tmp ); L_tmp = L_add( L_tmp, L_deposit_h( shl( gain_exp, 15 - 6 ) ) ); shift = norm_l( L_tmp ); gain = round_fx_sat( L_shl( L_tmp, shift ) ); gain_exp = sub( 7, shift ); gain_exp = BASOP_Util_Add_MantExp( gain, gain_exp, 32767 /*16 Q11*/, 4, &gain ); gain_exp = BASOP_Util_Add_MantExp( gain, gain_exp, 0x4000, 0, &gain ); gain = shr( gain, s_min( sub( 15, gain_exp ), 15 ) ); if ( gain > 91 ) { gain = s_min( gain, 91 ); /* 13+15+63, see arithocde encode residual */ } if ( gain < 0 ) { gain = s_max( gain, 0 ); } /* set gain to zero if the signal contains too less energy */ if ( zeroNrg != 0 ) { gain = 0; move16(); } hPrivateData->igfScfQuantized[sfb] = gain; move16(); } } return; } #endif /*-------------------------------------------------------------------* Loading Loading @@ -2011,11 +1829,7 @@ static Word32 IGF_getTNR_ivas_fx( * envelope estimation *-------------------------------------------------------------------*/ #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 static void IGF_CalculateEnvelope_fx( #else static void IGF_CalculateEnvelope_ivas_fx( #endif const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ Word32 *pMDCTSpectrum_fx, /* i : MDCT spectrum */ Word16 e_mdct, /* i : exp of MDCT spectrum */ Loading Loading @@ -2062,25 +1876,21 @@ static void IGF_CalculateEnvelope_ivas_fx( Word16 crest_exp; /*Stores the exponent of the result(return value)*/ Word16 sfm_exp; /*stores exponent for ouput from sfm*/ Word16 tmp_e; #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 Word32 LFMDCTSpectrum[N_MAX]; Word16 sfbEnergyTileR16; Word16 sfbEnergyR16; Word16 gain16; /* the EVS gain which has to be applied to the source tile to get the destination energy */ Word16 zeroNrg; /* flag indicating if the signal contains almost no energy */ #endif hPrivateData = &hIGFEnc->igfData; hGrid = &hPrivateData->igfInfo.grid[(Word16) igfGridIdx]; swb_offset = hGrid->swb_offset; #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 zeroNrg = 0; sfbEnergyTileR16 = 0; temp = 0; move16(); move16(); move16(); #endif IF( element_mode > EVS_MONO ) { Loading Loading @@ -2114,7 +1924,6 @@ static void IGF_CalculateEnvelope_ivas_fx( } } } #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 ELSE { Copy32( pMDCTSpectrum_fx + IGF_START_MN, hIGFEnc->spec_be_igf, hIGFEnc->infoStopLine - IGF_START_MN ); Loading @@ -2137,13 +1946,8 @@ static void IGF_CalculateEnvelope_ivas_fx( } } } #endif #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( pPowerSpectrum_fx && ( element_mode > EVS_MONO ) ) #else IF( pPowerSpectrum_fx ) #endif { FOR( sb = hGrid->sbWrap[0]; sb < swb_offset[hGrid->sfbWrap[hGrid->nTiles]]; sb++ ) { Loading Loading @@ -2185,10 +1989,8 @@ static void IGF_CalculateEnvelope_ivas_fx( { tmp = strt_cpy; move16(); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode > EVS_MONO ) { #endif FOR( sb = swb_offset[sfb]; sb < swb_offset[sfb + 1]; sb++ ) { Word16 shift = norm_l( pPowerSpectrum_fx[sb] ); Loading @@ -2207,7 +2009,6 @@ static void IGF_CalculateEnvelope_ivas_fx( sfbEnergyTileR = L_deposit_h( BASOP_Util_Divide3232_Scale( sfbEnergyTileR, width, &tmp_e ) ); sfbEnergyTileR_e = add( sub( sfbEnergyTileR_e, Q31 ), tmp_e ); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 } ELSE { Loading Loading @@ -2248,7 +2049,6 @@ static void IGF_CalculateEnvelope_ivas_fx( strt_cpy += swb_offset[sfb + 1] - swb_offset[sfb]; } #endif IF( sfbEnergyTileR == 0 ) { Loading @@ -2259,37 +2059,24 @@ static void IGF_CalculateEnvelope_ivas_fx( } IF( sfbEnergyC == 0 ) { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 sfbEnergyC = ( element_mode > EVS_MONO ) ? EPSILON_FX : 0x00010000; #else sfbEnergyC = EPSILON_FX; #endif sfbEnergyC_e = 0; move32(); move16(); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode == EVS_MONO ) { zeroNrg = 1; move16(); } #endif } IF( sfbEnergyTileC == 0 ) { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 sfbEnergyTileC = ( element_mode > EVS_MONO ) ? EPSILON_FX : 0x00010000; #else sfbEnergyTileC = EPSILON_FX; #endif sfbEnergyTileC_e = 0; #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode > EVS_MONO ) { #endif temp = BASOP_Util_Divide3232_Scale( sfbEnergyC, sfbEnergyTileC, &tmp_e ); tmp_e = add( tmp_e, sub( sfbEnergyC_e, sfbEnergyTileC_e ) ); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 } ELSE { Loading @@ -2297,40 +2084,31 @@ static void IGF_CalculateEnvelope_ivas_fx( zeroNrg = 1; move16(); } #endif move32(); move16(); } ELSE { /*gain = (float) ( sfbEnergyTileR * ( sfbEnergyC / sfbEnergyTileC ) );*/ #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode > EVS_MONO ) { #endif temp = BASOP_Util_Divide3232_Scale( sfbEnergyC, sfbEnergyTileC, &tmp_e ); tmp_e = add( tmp_e, sub( sfbEnergyC_e, sfbEnergyTileC_e ) ); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 } ELSE { BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyC ), sfbEnergyC_e, round_fx_sat( sfbEnergyTileC ), sfbEnergyTileC_e, &tmp, &tmp_e ); } #endif } #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode > EVS_MONO ) { #endif gain = Mult_32_16( sfbEnergyTileR, temp ); // gain_e #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 } ELSE { gain = L_mult( sfbEnergyTileR16, tmp ); // gain_e } #endif gain_e = add( tmp_e, sfbEnergyTileR_e ); IF( element_mode > EVS_MONO ) Loading Loading @@ -2647,10 +2425,8 @@ static void IGF_CalculateEnvelope_ivas_fx( } ELSE { #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode > EVS_MONO ) { #endif tmp_e = e_mdct; move16(); sfbEnergyR = add_sat( EPSILON_FX, BASOP_Util_Divide3216_Scale( sum2_32_fx( pMDCTSpectrum_fx + swb_offset[sfb], width, &tmp_e ) /*exp: tmp_e*/, width, &sfbEnergyR_e ) ); // sfbEnergyR_e Loading Loading @@ -2680,7 +2456,6 @@ static void IGF_CalculateEnvelope_ivas_fx( move16(); move16(); move16(); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 } ELSE { Loading Loading @@ -2713,21 +2488,14 @@ static void IGF_CalculateEnvelope_ivas_fx( BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyR ), sfbEnergyR_e, width, 15, &sfbEnergyR16, &gain_e ); gain = L_deposit_h( sfbEnergyR16 ); } #endif } #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IF( element_mode > EVS_MONO ) { #endif gain = Mult_32_16( gain, att ); // gain_e gain_e = add( gain_e, 0 ); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 /*gain=0.5f+log2f(gain)*2+16 because 2.885390081777927f=2*1/loge(2) so 2*1/loge(2)*loge(x) can be written as 2*log2(x)*/ #else /*gain=0.5f+log2f(gain)*2+16 becuase 2.885390081777927f=2*1/loge(2) so 2*1/loge(2)*loge(x) can be written as 2*log2(x)*/ #endif gain = L_add( ONE_IN_Q22, L_add( L_add( L_shr( BASOP_Util_Log2( gain ), 1 ), L_shl( gain_e, Q24 ) ), L_shl( 16, Q23 ) ) ); /*Q23*/ test(); test(); Loading @@ -2747,7 +2515,6 @@ static void IGF_CalculateEnvelope_ivas_fx( move16(); hPrivateData->igfScfQuantized[sfb] = extract_l( L_shr( gain, Q23 ) ); /*Q0*/ move16(); #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 } ELSE { Loading Loading @@ -2781,7 +2548,6 @@ static void IGF_CalculateEnvelope_ivas_fx( hPrivateData->igfScfQuantized[sfb] = gain16; move16(); } #endif } } Loading Loading @@ -3553,18 +3319,7 @@ void IGFEncApplyMono_fx( calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); } #ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 IGF_CalculateEnvelope_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx ); #else IF( EQ_16( st->element_mode, EVS_MONO ) ) { IGF_CalculateEnvelope( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, *e_ps, igfGridIdx ); } ELSE { IGF_CalculateEnvelope_ivas_fx( st->hIGFEnc, pMDCTSpectrum_fx, e_mdct, pPowerSpectrumParameter_fx, pPowerSpectrumParameter_exp, igfGridIdx, st->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, st->element_mode, att_fx ); } #endif IF( isTCX20 ) { Loading