diff --git a/apps/decoder.c b/apps/decoder.c index 12f6b1786123a7304669100e28103e8b0f86e2ed..eadb854f3e47cb8114d8ac10112c9f1c9e601b05 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -911,9 +911,7 @@ static bool parseCmdlIVAS_dec( arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192; arg->non_diegetic_pan_enabled = false; arg->non_diegetic_pan_gain = 0.f; -#ifdef FIX_2318_CLANG_DECODER arg->non_diegetic_pan_gain_fx = 0; -#endif arg->tsmEnabled = false; arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS; arg->aeSequence.count = 0; diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index 4d2d76baab7721f43e108f7afa85e6c893642d61..3ce3e518fe806c97ac7831f7f4bc966dcdeaf86e 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -602,112 +602,6 @@ return; *-------------------------------------------------------*/ void cng_params_postupd_fx( -#ifndef HARM_NON_LINEARITY - const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ - Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ - const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ - const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ - const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[] /* i/o: Envelope buffer Q6 */ -) -{ - Word16 i, j; - Word16 Q_exc; - const Word16 *exc2; - Word16 fft_io[L_FFT]; - Word32 sp[129]; - Word16 *ptR, *ptI; - Word32 env[NUM_ENV_CNG]; - Word32 L_tmp; - Word16 tmp; - Word16 temp_lo_fx, temp_hi_fx; - Word16 exp_pow; - Word16 exp1; - Word16 CNG_mode; - Word16 ptr; - Word32 last_active_brate; - - ptr = add( sub( ho_circ_ptr, *cng_buf_cnt ), 1 ); - IF( ptr < 0 ) - { - ptr = add( ptr, HO_HIST_SIZE ); - } - - FOR( j = 0; j < *cng_buf_cnt; j++ ) - { - exc2 = &cng_exc2_buf[ptr * L_FFT]; - Q_exc = cng_Qexc_buf[ptr]; - move16(); - last_active_brate = cng_brate_buf[ptr]; - move32(); - - /* calculate the spectrum of residual signal */ - Copy( exc2, fft_io, L_FFT ); - - fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT ); - - ptR = &fft_io[1]; - ptI = &fft_io[L_FFT - 1]; - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - /* sp[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ - L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_exc+1 */ - L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_exc+1 */ - L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_exc+1 */ - L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_exc+1 */ - tmp = add( add( Q_exc, Q_exc ), 1 ); - sp[i] = L_shr( L_tmp, sub( tmp, 6 ) ); - move32(); /* Q6 */ - - ptR++; - ptI--; - } - - Copy32( sp, env, NUM_ENV_CNG ); - { - - CNG_mode = get_cng_mode( last_active_brate ); - - /* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */ - L_tmp = L_shl( L_deposit_l( ENR_ATT_fx[CNG_mode] ), 8 ); /* 16 */ - temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx ); - - exp_pow = sub( 14, temp_hi_fx ); - L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */ - L_tmp = L_shl( L_tmp, sub( 13, exp_pow ) ); /* Q13 */ - tmp = extract_l( L_tmp ); /* Q13 */ - - exp1 = norm_s( tmp ); - tmp = shl( tmp, exp1 ); /*Q(exp1+13) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp1-13) */ - tmp = shr( tmp, sub( 1, exp1 ) ); /* Q15 */ - } - - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - env[i] = Mult_32_16( env[i], tmp ); - move32(); - } - - /* update the circular buffer of old residual envelope */ - Copy32( env, &( ho_env_circ[(ptr) *NUM_ENV_CNG] ), NUM_ENV_CNG ); - - ptr = add( ptr, 1 ); - if ( EQ_16( ptr, HO_HIST_SIZE ) ) - { - ptr = 0; - move16(); - } - } - - *cng_buf_cnt = 0; - move16(); - - return; -} - -void cng_params_postupd_ivas_fx( -#endif const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ @@ -833,183 +727,8 @@ void cng_params_postupd_ivas_fx( * * update CNG parameters *-------------------------------------------------------*/ -#ifndef HARM_NON_LINEARITY -void cng_params_upd_fx( - const Word16 lsp_new[], /* i : LSP aprameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer Q6 */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate /* i : Last active bit rate Q0 */ -) -{ - Word32 L_ener, L_tmp; - Word16 i, j; - const Word16 *pt_exc2; - Word16 tmpv, maxv, scale; - Word16 fft_io[L_FRAME16k]; - Word32 sp[129]; - Word16 *ptR, *ptI; - Word32 env[NUM_ENV_CNG]; - Word16 exp1; - Word16 CNG_mode; - Word16 tmp; - Word16 temp_lo_fx, temp_hi_fx; - Word16 exp_pow; - - /* update the pointer to circular buffer of old LSP vectors */ - *ho_circ_ptr = add( *ho_circ_ptr, 1 ); - move16(); - - if ( EQ_16( *ho_circ_ptr, HO_HIST_SIZE ) ) - { - *ho_circ_ptr = 0; - move16(); - } - - /* update the circular buffer of old LSP vectors with the new LSP vector */ - Copy( lsp_new, &( ho_lsp_circ[( *ho_circ_ptr ) * M] ), M ); - - /* calculate the residual signal energy */ - /*enr = dotp( exc2, exc2, L_frame ) / L_frame; */ - - maxv = 0; - move16(); - FOR( i = 0; i < L_frame; i++ ) - { - maxv = s_max( maxv, abs_s( exc2[i] ) ); - } - scale = norm_s( maxv ); - - pt_exc2 = exc2; - L_ener = 0; - move32(); - IF( EQ_16( L_frame, L_FRAME ) ) - { - FOR( j = 0; j < 128; j++ ) - { - tmpv = shl( *pt_exc2, scale ); - L_tmp = L_mult0( tmpv, tmpv ); /* 2*(Q_exc+scale) */ - pt_exc2++; - tmpv = shl( *pt_exc2, scale ); - L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); - pt_exc2++; - L_ener = L_add_sat( L_ener, L_shr_sat( L_tmp, 7 ) ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ - } - } - ELSE /* L_FRAME16k */ - { - FOR( j = 0; j < 160; j++ ) - { - tmpv = shl( *pt_exc2, scale ); - L_tmp = L_mult0( tmpv, tmpv ); /* 2*(Q_exc+scale) */ - pt_exc2++; - tmpv = shl( *pt_exc2, scale ); - L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); - pt_exc2++; - L_ener = L_add_sat( L_ener, L_shr_sat( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* Q(2*(Q_exc+scale)+15+1-16+1) ,division by L_frame done here */ - } - } - L_ener = L_shr_sat( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ - - /* update the circular buffer of old energies */ - ho_ener_circ[*ho_circ_ptr] = L_ener; - move32(); - - IF( enc_dec_flag == ENC ) - { - /* Store residual signal for postponed FFT-processing*/ - *cng_buf_cnt = add( *cng_buf_cnt, 1 ); - move16(); - if ( GT_16( *cng_buf_cnt, HO_HIST_SIZE ) ) - { - *cng_buf_cnt = HO_HIST_SIZE; - move16(); - } - Copy( exc2, &( cng_exc2_buf[( *ho_circ_ptr ) * L_FFT] ), L_FFT ); - cng_Qexc_buf[*ho_circ_ptr] = Q_exc; - move16(); - cng_brate_buf[*ho_circ_ptr] = last_active_brate; - move32(); - } - ELSE - { - /* calculate the spectrum of residual signal */ - Copy( exc2, fft_io, L_frame ); - - fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT ); - - ptR = &fft_io[1]; - ptI = &fft_io[L_FFT - 1]; - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - /* sp[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ - L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_exc+1 */ - L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_exc+1 */ - L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_exc+1 */ - L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_exc+1 */ - tmp = add( add( Q_exc, Q_exc ), 1 ); - sp[i] = L_shr( L_tmp, sub( tmp, 6 ) ); - move32(); /* Q6 */ - - ptR++; - ptI--; - } - - Copy32( sp, env, NUM_ENV_CNG ); - { - CNG_mode = get_cng_mode( last_active_brate ); - /* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */ - L_tmp = L_shl( L_deposit_l( ENR_ATT_fx[CNG_mode] ), 8 ); /* 16 */ - temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx ); - - exp_pow = sub( 14, temp_hi_fx ); - L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */ - L_tmp = L_shl( L_tmp, sub( 13, exp_pow ) ); /* Q13 */ - tmp = extract_l( L_tmp ); /* Q13 */ - - exp1 = norm_s( tmp ); - tmp = shl( tmp, exp1 ); /*Q(exp1+13) */ - tmp = div_s( 16384, tmp ); /*Q(15+14-exp1-13) */ - tmp = shr( tmp, sub( 1, exp1 ) ); /* Q15 */ - } - - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - env[i] = Mult_32_16( env[i], tmp ); - move32(); - } - - /* update the circular buffer of old residual envelope */ - /* Copy32( env, &(ho_env_circ[add(shl(*ho_circ_ptr,4),shl(*ho_circ_ptr,2))]), NUM_ENV_CNG ); */ - Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG ); - } - *ho_circ_size = add( *ho_circ_size, 1 ); - move16(); - if ( GT_16( *ho_circ_size, HO_HIST_SIZE ) ) - { - *ho_circ_size = HO_HIST_SIZE; - move16(); - } - - return; -} -#endif -#ifdef HARM_NON_LINEARITY void cng_params_upd_fx( -#else -void cng_params_upd_ivas_fx( -#endif const Word16 lsp_new[], /* i : LSP aprameters Q15 */ const Word16 exc2[], /* i : current enhanced excitation Q_exc */ const Word16 L_frame, /* i : frame length Q0 */ @@ -1187,9 +906,7 @@ void cng_params_upd_ivas_fx( /* update the circular buffer of old residual envelope */ /* Copy32( env, &(ho_env_circ[add(shl(*ho_circ_ptr,4),shl(*ho_circ_ptr,2))]), NUM_ENV_CNG ); */ Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG ); -#ifdef HARM_NON_LINEARITY IF( NE_16( element_mode, EVS_MONO ) ) -#endif { scale_sig32( &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG, shift ); // Q(6+shift) } diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index c8da9fea14c9ed02acf27b68d6689bc07d0370be..4e380b17cb53c5d82323615496cef9aa501059c0 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5827,11 +5827,7 @@ ivas_error ivas_mct_enc_fx( const Word16 nb_bits_metadata /* i : number of metadata bits */ ); -#ifdef FIX_2344_ALIGN_PREPROC void ivas_compute_core_buffers_fx( -#else -ivas_error ivas_compute_core_buffers_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame */ Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz */ @@ -5936,11 +5932,7 @@ void ivas_mct_enc_close_fx( MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */ ); -#ifdef FIX_2344_ALIGN_PREPROC void pre_proc_front_ivas_fx( -#else -ivas_error pre_proc_front_ivas_fx( -#endif SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ @@ -5996,11 +5988,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 *Q_new /* i/o : Q factor of speech buffers */ ); -#ifdef FIX_2344_ALIGN_PREPROC void pre_proc_ivas_fx( -#else -ivas_error pre_proc_ivas_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode Q0*/ const Word32 element_brate, /* i : element bitrate Q0*/ diff --git a/lib_com/options.h b/lib_com/options.h index 929c05624b79d078928722c0644ed24cb455ba46..e11d5dffab853e09fe1daea965fdc29a823aa50d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,28 +87,8 @@ #define FIX_2255_ISAR_RENDER_POSES /* VA: issue 2255: fix missing check in isar_render_poses() */ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ -#define FIX_2318_CLANG_DECODER /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */ -#define HARM_NON_LINEARITY /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */ -#define FIX_2344_ALIGN_PREPROC /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */ -#define FIX_2334_HARM_CODER_MODIF /* VA: basop issue 2334 : harmonizing coder_modif_function */ -#define FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA /* Nokia: Fix float issue 1501, uninitialized value in ivas_masa_combine_directions for OMASA */ -#define FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT /* Nokia/FhG: basop issue 2323: Use correct init size */ -#define FIX_BASOP_2324_MISSING_SET_TO_ZERO /* Nokia: basop issue 2324: Fix issue by setting the exponent to zero where it should be */ -#define FIX_BASOP_2326_WRONG_SIG_LENGTH /* Nokia: basop issue 2326: Fix issue by using correct signal length in multiple places */ -#define FIX_BASOP_2327_WRONG_LOOP_END /* Nokia: basop inssue 2327: Correct loop end to solve MSAN error */ -#define FIX_BASOP_2328_MSAN_WRONG_ASSIGNMENT /* Nokia: basop issue 2328: Fix MSAN error by correcting the variable assignment */ -#define FIX_BASOP_2329_UNINIT_VALUE /* Nokia: basop issue 2329: Fix issue by checking for structure instead of length */ -#define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ -#define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ -#define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ #define FIX_BASOP_2358_SCALING_OOB /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */ -#define FIX_BASOP_2351_EXTREND_SCALE /* FhG: basop issue 2351: Only scale initialized samples in renderer, related to 2326 */ -#define FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE /* FhG: Fix issue 2331: Uninitialized variable */ -#define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ -#define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ -#define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_BASOP_2350_HARM_0B_BWE_2 /* VA: basop issue 2350: Simplify calling of hf_synth_fx() */ -#define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2364_HARM_MULT_HARM /* VA: basop issue 2364 : harmonizing multi_harm_fx function */ #define FIX_2363_FIND_WSP /* VA: basop issue 2363 : harmonizing find_wsp function */ #define FIX_2370_UNUSED_BUFFERS_CORE_ENC /* VA: basop issue 2370: remove temporary input buffers in core-encoder */ @@ -129,10 +109,6 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ -#define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ -#define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ -#define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ -#define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ #define FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG /* Eri: Basop issue 2317: Uninitialized value read in case of DTX and BW switching */ diff --git a/lib_com/parameter_bitmaping_fx.c b/lib_com/parameter_bitmaping_fx.c index 412ab4647ed74d1f26df5dedf68acadcca24ec82..4225879e6b20e56584e35c4bc40240cfc0112337 100644 --- a/lib_com/parameter_bitmaping_fx.c +++ b/lib_com/parameter_bitmaping_fx.c @@ -25,26 +25,6 @@ static Word16 PutIntoBitstream_fx( return value; } -#ifndef HARM_COREDECODER_FUNCTIONS -static Word16 PutIntoBitstream_ivas_fx( - const Word16 **pStream, - TEncodeValue EncodeValue, - Word16 index, - BSTR_ENC_HANDLE hBstr, - const Word16 nBits ) -{ - Word16 value; - Word16 codedValue; - - move16(); - value = *( *pStream )++; - codedValue = EncodeValue( value, index ); - - push_next_indice( hBstr, codedValue, nBits ); - - return value; -} -#endif static Word16 FixedWidthEncoding( Word16 value, Word16 index ) { @@ -327,75 +307,6 @@ void WriteToBitstream_fx( return; } -#ifndef HARM_COREDECODER_FUNCTIONS -void WriteToBitstream_ivas_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ) -{ - Word16 index; - Word16 iParam, nParams; - - - assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pStream != NULL ) && ( pnSize != NULL ) && ( hBstr != NULL ) && ( pnBits != NULL ) ); - nParams = paramsBitMap->nParams; - move16(); - - FOR( index = 0; index < nArrayLength; index++ ) - { - - FOR( iParam = 0; iParam < nParams; iParam++ ) - { - ParamBitMap const *param; - Word16 nBits; - /* If a function for encoding/decoding value is defined than it should take care of 0 */ - Word16 fShiftValue; - TEncodeValue EncodeValue; - Word16 value; - - move16(); - param = ¶msBitMap->params[iParam]; - - move16(); - nBits = param->nBits; - IF( param->nBits == 0 ) - { -#define WMC_TOOL_SKIP - nBits = param->GetNumberOfBits( **pStream, index ); -#undef WMC_TOOL_SKIP - } - - fShiftValue = s_and( param->fZeroAllowed == 0, param->EncodeValue == NULL ); - - EncodeValue = param->EncodeValue; - if ( param->EncodeValue == NULL ) - { - move16(); - EncodeValue = &FixedWidthEncoding; - } - value = PutIntoBitstream_ivas_fx( pStream, EncodeValue, index, hBstr, nBits ); - IF( fShiftValue ) - { - value = add( value, 1 ); - } - - move16(); - *pnSize = add( *pnSize, 1 ); - move16(); - *pnBits = add( *pnBits, nBits ); - - test(); - IF( ( param->pSubParamBitMap != NULL ) && ( value > 0 ) ) - { - WriteToBitstream_ivas_fx( param->pSubParamBitMap, value, pStream, pnSize, hBstr, pnBits ); - } - } - } -} -#endif /** Get nBits long value from bitstream into *pStream. */ static Word16 GetFromBitstream( diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 6c3d24ce4c4187cd3d0e2512c4dd3a3b26d76ee0..3b93fda3b80ef0349421a8b29b784c656d3022be 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3103,31 +3103,17 @@ void ScaleShapedWB_fx( ); void non_linearity_fx( -#ifdef HARM_NON_LINEARITY const Word16 element_mode, /* i : element mode */ -#endif - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - const Word16 Q_inp, /* i : scaling of input */ - const Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ -); - -#ifndef HARM_NON_LINEARITY -void non_linearity_ivas_fx( - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ + const Word16 i[], /* i : i signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : i length */ + Word32 *prev_scale, /* i/o: memory Q30 */ + const Word16 Q_inp, /* i : scaling of input */ + const Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ ); -#endif + void interp_code_5over2_fx( const Word16 inp_code[], /* i : i vector */ Word16 interp_code[], /* o : output vector */ @@ -3919,17 +3905,6 @@ void CNG_exc_fx( ); void cng_params_postupd_fx( -#ifndef HARM_NON_LINEARITY - const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ - Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ - const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ - const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ - const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[] /* i/o: Envelope buffer */ -); - -void cng_params_postupd_ivas_fx( -#endif const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ @@ -3941,26 +3916,6 @@ void cng_params_postupd_ivas_fx( ); void cng_params_upd_fx( -#ifndef HARM_NON_LINEARITY - const Word16 lsp_new[], /* i : LSP parameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate /* i : Last active bit rate Q0 */ -); - -void cng_params_upd_ivas_fx( -#endif const Word16 lsp_new[], /* i : LSP aprameters Q15 */ const Word16 exc2[], /* i : current enhanced excitation Q_exc */ const Word16 L_frame, /* i : frame length Q0 */ @@ -6070,15 +6025,6 @@ void swb_CNG_dec_fx( const Word16 Qsyn /* i : Q value of ACELP core synthesis */ ); -#ifndef HARM_NON_LINEARITY -void swb_CNG_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn /* i : Q value of ACELP core synthesis */ -); -#endif void td_cng_dec_init_fx( DEC_CORE_HANDLE st /* i/o: decoder state structure */ ); @@ -6092,11 +6038,9 @@ void concealment_init_x( const Word16 L_frameTCX, T_PLCInfo_HANDLE hPlcInfo ); -#ifdef HARM_COREDECODER_FUNCTIONS void concealment_init_ivas_fx( const Word16 L_frameTCX, T_PLCInfo_HANDLE hPlcInfo ); -#endif void concealment_update_x( const Word16 bfi, const Word16 core, @@ -6395,35 +6339,9 @@ void hf_synth_reset_fx( ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ ); -#ifndef FIX_BASOP_2350_HARM_0B_BWE void hf_synth_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ -); -void hf_synth_ivas_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ -); -#else -void hf_synth_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ -#ifdef FIX_BASOP_2350_HARM_0B_BWE const Word16 element_mode, /* i : element mode Q0*/ -#endif const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_frame, /* i : output frame length Q0*/ const Word16 *Aq, /* i : quantized Az Q12*/ @@ -6434,7 +6352,6 @@ void hf_synth_fx( const Word16 Q_syn2 /* i : synthesis scaling */ ); -#endif void hf_synth_amr_wb_init_fx( AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ ); @@ -6492,21 +6409,6 @@ void formant_post_filt_fx( const Word16 off_flag /* i : off flag */ ); -#ifndef HARM_COREDECODER_FUNCTIONS -void Filt_mu_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - Word16 L_subfr /* i : the length of subframe */ -); - -void Filt_mu_ivas_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - Word16 L_subfr, /* i : the length of subframe */ - const Word16 extl ); -#endif void scale_st_fx( const Word16 *sig_in, /* i : postfilter i signal */ Word16 *sig_out, /* i/o: postfilter o signal */ @@ -6693,18 +6595,6 @@ void gain_dec_tc_fx( Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ ); -#ifndef HARM_COREDECODER_FUNCTIONS -void gain_dec_tc_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : pitch gain */ - Word32 *gain_code_fx, /* o : Quantized codeebook gain */ - Word16 *gain_inov_fx, /* o : unscaled innovation gain */ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ -); -#endif void gain_dec_mless_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 L_frame_fx, /* i : length of the frame */ @@ -8660,14 +8550,6 @@ Word16 dlpc_avq_fx( Word32 sr_core ); Word16 decode_lpc_avq_fx( -#ifndef HARM_COREDECODER_FUNCTIONS - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc /* o : lpc parameters */ -); - -Word16 decode_lpc_avq_ivas_fx( -#endif Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ Word16 *param_lpc, /* o : lpc parameters */ @@ -10569,13 +10451,6 @@ void writeTCXparam_fx( const Word16 target_bitsTCX10[2], const Word16 pre_past_flag ); -#ifndef HARM_NON_LINEARITY -void calculate_hangover_attenuation_gain_ivas_fx( - Encoder_State *st, /* i : encoder state structure */ - Word16 *att, /* o : attenuation factor */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ -); -#endif void init_coder_ace_plus_ivas_fx( Encoder_State *st, /* i : Encoder state */ const Word32 last_total_brate, /* i : last total bitrate */ @@ -10675,21 +10550,6 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ ); -#ifndef FIX_2348_REPLACE_FEC_ENC -void FEC_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ - const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ - const Word16 coder_type, /* i : type of coder Q0*/ - Word16 clas, /* i : signal clas for current frame Q0*/ - const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ - const Word16 *res, /* i : LP residual signal frame Qx*/ - Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ - const Word16 L_frame, /* i : Frame length Q0*/ - const Word32 total_brate, /* i : total codec bitrate Q0*/ - const Word16 Q_synth /* i : input scaling */ -); -#endif ivas_error IGF_Reconfig_fx( IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ const Word16 igf, /* i : IGF on/off */ @@ -10717,15 +10577,6 @@ void WriteToBitstream_fx( BSTR_ENC_HANDLE hBstr, Word16 *pnBits ); -#ifndef HARM_COREDECODER_FUNCTIONS -void WriteToBitstream_ivas_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); -#endif /*===========================================================================================*/ /*----------------------------------------------------------------------------------* diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 9b4db81b74cd36d0eedb93e6d210dc4541766577..e06c8c4f6dad19a1a405f68ca90234158f2ee838 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -5534,260 +5534,16 @@ static Word32 non_linearity_scaled_copy_ivas( /*==========================================================================*/ void non_linearity_fx( -#ifdef HARM_NON_LINEARITY const Word16 element_mode, /* i : element mode */ -#endif - const Word16 input[], /* i : input signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : input length */ - Word32 *pPrevScale, /* i/o: memory Q30 */ - const Word16 Q_inp, /* i : scaling of input */ - const Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ + const Word16 input[], /* i : input signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : input length */ + Word32 *pPrevScale, /* i/o: memory Q30 */ + const Word16 Q_inp, /* i : scaling of input */ + const Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ ) -#ifndef HARM_NON_LINEARITY -{ - Word16 i, j; - Word16 max_val = 0; - move16(); - Word32 scale; - Word16 scale_step; - Word16 exp, tmp; - Word16 e_tmp, f_tmp; - Word16 frac; - Word32 L_tmp; - Word32 L_tmp1; - - Word16 en_abs = 0; - Word16 v_fac = 0; - move16(); - move16(); - Word16 ths; - Word16 nframes; - Word32 prev_scale; - Word16 length_half; - - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - nframes = 5; - move16(); - ths = 17817; - move16(); /* 0.87*5 in Q12 */ - } - ELSE - { - nframes = 4; - move16(); - ths = 15400; - move16(); /* 0.94*4 in Q12 */ - } - - - FOR( i = 0; i < nframes; i++ ) - { - v_fac = add( v_fac, shr( voice_factors[i], 3 ) ); /* Q12 */ - } - - test(); - if ( EQ_16( coder_type, VOICED ) && GT_16( v_fac, ths ) ) - { - en_abs = 1; - move16(); - } - - length_half = shr( length, 1 ); - prev_scale = *pPrevScale; - move32(); - - - /* Delay Alignment in FX is done inside swb_tbe_enc_fx() */ - - FOR( i = j = 0; i < length_half; i++ ) - { - tmp = abs_s( input[i] ); - if ( GT_16( tmp, max_val ) ) - { - j = i; - move16(); - } - max_val = s_max( max_val, tmp ); - } - - - IF( GT_16( max_val, shl( 1, Q_inp ) ) ) - { - exp = norm_s( max_val ); - tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */ - scale = L_shl( L_mult( 21955, tmp ), add( exp, sub( Q_inp, 14 ) ) ); /* Q31 */ - } - ELSE - { - scale = 1438814044; - move32(); /* Q31; 0.67 in Q31 */ - } - - test(); - IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 32 ), scale ) ) - { - scale_step = 16384; - move16(); /* Q14 */ - prev_scale = L_shr( scale, 1 ); /* Q30 */ - } - ELSE - { - - /* Computing log2(scale) */ - IF( j == 0 ) - { - scale_step = 32767; - move16(); - } - ELSE - { - e_tmp = norm_l( scale ); - f_tmp = Log2_norm_lc( L_shl( scale, e_tmp ) ); - e_tmp = sub( -1, e_tmp ); - L_tmp = Mpy_32_16( e_tmp, f_tmp, MAX_16 ); /* Q16 */ - - /* Computing log2(prev_scale) */ - e_tmp = norm_l( prev_scale ); - f_tmp = Log2_norm_lc( L_shl( prev_scale, e_tmp ) ); - e_tmp = negate( e_tmp ); - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, MAX_16 ); /* Q16 */ - - /* log2(scale / prev_scale) = log2(scale) - log2(prev_scale) */ - L_tmp = L_sub( L_tmp, L_tmp1 ); /* Q16 */ - - /* Computing 1/j */ - exp = norm_s( j ); - tmp = div_s( shl( 1, sub( 14, exp ) ), j ); /* Q(29-exp) */ - - /* (log2(scale / prev_scale))/length */ - L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /* Q(16+29-exp+1-16+exp-14)->Q16 */ - frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ - tmp = extract_l( Pow2( 14, frac ) ); - scale_step = shl_sat( tmp, exp ); /* Q14 */ - } - } - - prev_scale = non_linearity_scaled_copy( input, j, length_half, output, prev_scale, scale_step, en_abs ); - - max_val = 0; - move16(); - j = shr( length, 1 ); - FOR( i = length_half; i < length; i++ ) - { - tmp = abs_s( input[i] ); - if ( GT_16( tmp, max_val ) ) - { - j = i; - move16(); - } - max_val = s_max( max_val, tmp ); - } - - IF( GT_16( max_val, shl( 1, Q_inp ) ) ) - { - exp = norm_s( max_val ); - tmp = div_s( shl( 1, sub( 14, exp ) ), max_val ); /* Q(29-exp-Q_inp) */ - scale = L_shl_sat( L_mult( 21955 /* 0.67 in Q15 */, tmp ), add( exp, sub( Q_inp, 14 ) ) ); /* Q31 */ - } - ELSE - { - scale = 1438814044; - move32(); /* Q31; 0.67 in Q31 */ - } - - test(); - IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 32 ), scale ) ) - { - scale_step = 16384; - move16(); /*Q14 */ - prev_scale = L_shr( scale, 1 ); /*Q30 */ - } - ELSE - { - /*scale_step = (float) exp(1.0f / (float) (j - length/2) * (float) log(scale / prev_scale)); */ - /* Computing log2(scale) */ - IF( EQ_16( j, length_half ) ) - { - scale_step = 32767; - move16(); /*Q14 */ - } - ELSE - { - e_tmp = norm_l( scale ); - f_tmp = Log2_norm_lc( L_shl( scale, e_tmp ) ); - e_tmp = sub( -e_tmp, 1 ); - L_tmp = Mpy_32_16( e_tmp, f_tmp, 32767 ); /* Q16 */ - - /* Computing log2(prev_scale) */ - e_tmp = norm_l( prev_scale ); - f_tmp = Log2_norm_lc( L_shl( prev_scale, e_tmp ) ); - e_tmp = negate( e_tmp ); - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 32767 ); /* Q16 */ - - /* log2(scale / prev_scale) = log2(scale) - log2(prev_scale) */ - L_tmp = L_sub( L_tmp, L_tmp1 ); /* Q16 */ - - /* Computing 1/(j - length/2) */ - tmp = sub( j, length_half ); - exp = norm_s( tmp ); - tmp = div_s( shl( 1, sub( 14, exp ) ), tmp ); /* Q(29-exp) */ - - /* (log2(scale / prev_scale))/length */ - L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /*Q(16+29-exp+1-16+exp-14)->Q16 */ - frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ - tmp = extract_l( Pow2( 14, frac ) ); - scale_step = shl_sat( tmp, exp ); /*Q14 */ - } - } - - prev_scale = non_linearity_scaled_copy( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs ); - - *pPrevScale = prev_scale; - move32(); - - /* Delay Alignment in FX is done inside swb_tbe_enc_fx() */ - - return; -} - - -/*==========================================================================*/ -/* FUNCTION : void non_linearity_ivas_fx() */ -/*--------------------------------------------------------------------------*/ -/* PURPOSE : Apply a non linearity to the SHB excitation */ -/*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* Word16 input[] i : input signal Q_inp */ -/* Word16 length i : input length */ -/*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* Word32 output[] o : output signal 2*Q_inp */ -/*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* Word32 *prev_scale i/o: memory Q30 */ -/*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*--------------------------------------------------------------------------*/ -/* CALLED FROM : */ -/*==========================================================================*/ - -void non_linearity_ivas_fx( - const Word16 input[], /* i : input signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : input length */ - Word32 *pPrevScale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ - -) -#endif { Word16 i, j; Word16 max_val = 0; @@ -5809,9 +5565,7 @@ void non_linearity_ivas_fx( Word32 prev_scale; Word16 length_half; Word16 sc_factor; -#ifdef HARM_NON_LINEARITY Word32 prev_scale_factor; -#endif IF( EQ_16( L_frame, L_FRAME16k ) ) { @@ -5869,7 +5623,6 @@ void non_linearity_ivas_fx( move32(); /* Q31; 0.67 in Q31 */ } -#ifdef HARM_NON_LINEARITY IF( element_mode == EVS_MONO ) { prev_scale_factor = Mult_32_16( prev_scale, 32 ); @@ -5883,13 +5636,6 @@ void non_linearity_ivas_fx( test(); IF( prev_scale <= 0 || ( GT_32( prev_scale_factor, scale /*Q31*/ ) ) ) -#else - sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position */ - sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ - - test(); - IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ -#endif { scale_step = 16384; move16(); /* Q14 */ @@ -5933,13 +5679,11 @@ void non_linearity_ivas_fx( } } -#ifdef HARM_NON_LINEARITY IF( element_mode == EVS_MONO ) { prev_scale = non_linearity_scaled_copy( input, j, length_half, output, prev_scale, scale_step, en_abs ); } ELSE -#endif { prev_scale = non_linearity_scaled_copy_ivas( input, j, length_half, output, prev_scale, scale_step, en_abs ); } @@ -5970,7 +5714,6 @@ void non_linearity_ivas_fx( move32(); /* Q31; 0.67 in Q31 */ } -#ifdef HARM_NON_LINEARITY IF( element_mode == EVS_MONO ) { prev_scale_factor = Mult_32_16( prev_scale, 32 ); @@ -5984,14 +5727,6 @@ void non_linearity_ivas_fx( test(); IF( prev_scale <= 0 || ( GT_32( prev_scale_factor, scale /*Q31*/ ) ) ) -#else - /* if ( element_mode > EVS_MONO ) */ /* element mode is not needed because the function is duplicated for IVAS */ - sc_factor = s_max( sub( 12, norm_s( add( sub( j, length_half ), 1 ) ) ), 0 ); /* allowed intra frame jump is smaller */ - sc_factor = s_max( sc_factor, 1 ); /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */ - - test(); - IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */ -#endif { scale_step = 16384; move16(); /*Q14 */ @@ -6035,13 +5770,11 @@ void non_linearity_ivas_fx( } } -#ifdef HARM_NON_LINEARITY IF( element_mode == EVS_MONO ) { prev_scale = non_linearity_scaled_copy( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs ); } ELSE -#endif { prev_scale = non_linearity_scaled_copy_ivas( input + length_half, sub( j, length_half ), sub( length, length_half ), output + length_half, prev_scale, scale_step, en_abs ); } @@ -6092,7 +5825,7 @@ void create_random_vector_fx( j = extract_l( L_shr( L_tmp, 23 ) ); } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ j = extract_l( L_shr( L_tmp, 23 ) ); #endif j = s_and( j, 0xff ); diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index bdb8c5d85693250f1b207af24b429158ce8798ba..bbf4a85149c6745a123b235c4940c9edf75fc0d3 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2234,20 +2234,12 @@ ivas_error acelp_core_dec_fx( #else IF( EQ_16( st->element_mode, EVS_MONO ) ) { -#ifndef FIX_BASOP_2350_HARM_0B_BWE - hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); -#else hf_synth_fx( st->hBWE_zero, EVS_MONO, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); -#endif } ELSE { Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0 -#ifndef FIX_BASOP_2350_HARM_0B_BWE - hf_synth_ivas_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); -#else hf_synth_fx( st->hBWE_zero, st->element_mode, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); -#endif Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 ); } #endif @@ -2301,20 +2293,12 @@ ivas_error acelp_core_dec_fx( { IF( EQ_16( st->element_mode, EVS_MONO ) ) { -#ifdef HARM_NON_LINEARITY non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); -#else - non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); -#endif } ELSE { Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), st->hBWE_TD->q_old_bwe_exc_extended_fx ) ) ); /* Q(q_old_bwe_exc_extended_fx) -> Q(2 * Q_exc) */ -#ifdef HARM_NON_LINEARITY non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); -#else - non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); -#endif exp = sub( L_norm_arr( bwe_exc_extended_fx + L_FRAME32k, NL_BUFF_OFFSET ), 16 ); Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, exp ); /* Q(2 * Q_exc) -> Q(q_old_bwe_exc_extended_fx) */ st->hBWE_TD->q_old_bwe_exc_extended_fx = add( shl( st->Q_exc, 1 ), exp ); @@ -2341,22 +2325,8 @@ ivas_error acelp_core_dec_fx( IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) { /* update CNG parameters in active frames */ -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); -#else - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, - st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); - } - ELSE - { - cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, - st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, - st->hFdCngDec->hFdCngCom->CngBandwidth ); - } -#endif /* Set 16k LSP flag for CNG buffer */ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0; diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index 27c528b243574bb084a685113b874eaacba8423b..56d2bd29c3e33ac9724922d7936ab0c301c0c909 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -9,11 +9,6 @@ #include "prot_fx.h" #include "ivas_cnst.h" -#ifndef HARM_NON_LINEARITY -/*Temporary location to be move in prot* when merge is done*/ -void E_LPC_f_isp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m ); -void E_LPC_f_lsp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m ); -#endif /*-----------------------------------------------------------------* * Local function prototypes @@ -21,10 +16,6 @@ void E_LPC_f_lsp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m ); static void shb_CNG_decod_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word16 *shb_synth_fx, const Word16 sid_bw, const Word16 Qsyn ); -#ifndef HARM_NON_LINEARITY -static void shb_CNG_decod_ivas_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word16 *shb_synth_fx, const Word16 sid_bw, const Word16 Qsyn ); -#endif - /*-----------------------------------------------------------------* * CNG_dec_fx() @@ -728,11 +719,7 @@ void swb_CNG_dec_fx( { st_fx->last_vad_fx = 1; move16(); -#ifdef HARM_NON_LINEARITY st_fx->hTdCngDec->burst_cnt_fx = add_sat( st_fx->hTdCngDec->burst_cnt_fx, 1 ); -#else - st_fx->hTdCngDec->burst_cnt_fx = add( st_fx->hTdCngDec->burst_cnt_fx, 1 ); -#endif move16(); if ( GT_16( st_fx->hTdCngDec->burst_cnt_fx, 10 ) ) { @@ -744,45 +731,6 @@ void swb_CNG_dec_fx( return; } -#ifndef HARM_NON_LINEARITY -void swb_CNG_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn /* i : Q value of ACELP core synthesis */ -) -{ - test(); - IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - /* SHB SID decoding and CNG */ - test(); - IF( EQ_16( st_fx->cng_type, LP_CNG ) && EQ_16( st_fx->extl, SWB_CNG ) ) - { - shb_CNG_decod_ivas_fx( st_fx, synth_fx, shb_synth_fx, sid_bw, Qsyn ); - } - st_fx->last_vad_fx = 0; - move16(); - st_fx->hTdCngDec->burst_cnt_fx = 0; - move16(); - } - ELSE - { - st_fx->last_vad_fx = 1; - move16(); - st_fx->hTdCngDec->burst_cnt_fx = add_sat( st_fx->hTdCngDec->burst_cnt_fx, 1 ); // saturation reached? - move16(); - if ( GT_16( st_fx->hTdCngDec->burst_cnt_fx, 10 ) ) - { - st_fx->hTdCngDec->burst_cnt_fx = 0; - move16(); - } - } - - return; -} -#endif /*---------------------------------------------------------------------* * shb_CNG_decod() @@ -791,284 +739,12 @@ void swb_CNG_dec_ivas_fx( *---------------------------------------------------------------------*/ static void shb_CNG_decod_fx( -#ifdef HARM_NON_LINEARITY - Decoder_State *st, /* i/o: State structure */ -#else - Decoder_State *st_fx, /* i/o: State structure */ -#endif + Decoder_State *st, /* i/o: State structure */ const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ const Word16 Qsyn /* i : Q value of ACELP core synthesis */ ) -#ifndef HARM_NON_LINEARITY -{ - Word16 i; - Word16 idx_ener_fx; - TD_CNG_DEC_HANDLE hTdCngDec; - Word16 shb_lpcCNG_fx[LPC_SHB_ORDER + 1]; - Word16 shb_lspCNG_fx[LPC_SHB_ORDER]; - Word16 excTmp_fx[L_FRAME16k]; - Word16 excSHB_fx[L_FRAME16k]; - Word16 tmp_lsp[LPC_SHB_ORDER]; - Word16 ener_excSHB_fx; - Word32 wb_ener_fx; - Word16 wb_ener16_fx; - Word32 L_gain_fx; - Word16 gain_fx; - Word16 shb_syn16k_fx[L_FRAME16k]; - Word16 tmp; - Word16 step_fx; - Word16 interp_fx; - Word16 ener_fx; - Word16 exp, exp1; - Word16 fra; - Word32 L_tmp; - Word16 tmp2; - Word16 allow_cn_step_fx = 0; - move16(); - Word16 q; - TD_BWE_DEC_HANDLE hBWE_TD; - - hBWE_TD = st_fx->hBWE_TD; - hTdCngDec = st_fx->hTdCngDec; - - IF( st_fx->bfi == 0 ) - { - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) ) - { - idx_ener_fx = get_next_indice_fx( st_fx, 4 ); - - if ( !idx_ener_fx ) - { - idx_ener_fx = -15; - move16(); - } - IF( st_fx->element_mode == EVS_MONO ) - { - /* de-quantization of SHB CNG parameters */ - L_tmp = L_mult( idx_ener_fx, 27400 ); /*Q14 */ - hTdCngDec->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 295924 ), 6 ) ); /*Q8 */ - move16(); - } - ELSE - { - } - } - } - - /* SHB spectrum estimation */ - - - interp_fx = s_min( hTdCngDec->shb_dtx_count_fx, 32 ); - interp_fx = shl_sat( interp_fx, 10 ); /*Q15*/ - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - tmp2 = mult( interp_fx, hTdCngDec->lsp_shb_prev_fx[i] ); /*Q14*/ - tmp = mult( sub( 32767, interp_fx ), hTdCngDec->lsp_shb_prev_prev_fx[i] ); /*Q14*/ - shb_lspCNG_fx[i] = add( tmp2, tmp ); - move16(); /*Q14*/ - } - - IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) ) - { - if ( LT_16( hTdCngDec->shb_dtx_count_fx, 1000 ) ) - { - hTdCngDec->shb_dtx_count_fx = add( hTdCngDec->shb_dtx_count_fx, 1 ); - move16(); - } - } - E_LPC_lsf_lsp_conversion( shb_lspCNG_fx, tmp_lsp, LPC_SHB_ORDER ); /*Q14*/ - E_LPC_f_lsp_a_conversion( tmp_lsp, shb_lpcCNG_fx, LPC_SHB_ORDER ); - - Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */ - - /* SHB energy estimation */ - wb_ener_fx = L_deposit_l( 1 ); /*Q1 */ - FOR( i = 0; i < L_FRAME32k; i++ ) - { - wb_ener_fx = L_add( wb_ener_fx, Mpy_32_16_1( L_mult0( synth_fx[i], synth_fx[i] ), 51 ) ); /* 2*Qsyn */ - } - exp = norm_l( wb_ener_fx ); - fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) ); - exp = sub( 30, add( exp, shl( Qsyn, 1 ) ) ); - wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); - wb_ener16_fx = round_fx( L_shl( wb_ener_fx, 10 ) ); /*wb_ener_fx in Q8 */ - if ( !st_fx->first_CNG ) - { - hTdCngDec->wb_cng_ener_fx = wb_ener16_fx; - move16(); /*Q8 */ - } - if ( GT_16( abs_s( sub( wb_ener16_fx, hTdCngDec->wb_cng_ener_fx ) ), 3072 ) ) - { - allow_cn_step_fx = 1; - move16(); - } - - IF( EQ_16( allow_cn_step_fx, 1 ) ) - { - hTdCngDec->wb_cng_ener_fx = wb_ener16_fx; - move16(); /*Q8 */ - } - ELSE - { - tmp = sub( wb_ener16_fx, hTdCngDec->wb_cng_ener_fx ); /*Q8 */ - tmp = mult_r( tmp, 29491 ); /*Q8 */ - hTdCngDec->wb_cng_ener_fx = add( hTdCngDec->wb_cng_ener_fx, tmp ); /*Q8 */ - move16(); - } - test(); - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) && EQ_16( sid_bw, 1 ) && ( st_fx->bfi == 0 ) ) - { - hTdCngDec->last_wb_cng_ener_fx = hTdCngDec->wb_cng_ener_fx; - move16(); - - if ( !st_fx->first_CNG ) - { - hTdCngDec->shb_cng_ener_fx = hTdCngDec->last_shb_cng_ener_fx; - move16(); - } - } - - gain_fx = sub( hTdCngDec->wb_cng_ener_fx, hTdCngDec->last_wb_cng_ener_fx ); /* Q8 */ - if ( GT_16( gain_fx, 15 ) ) - { - gain_fx = 15; - move16(); - } - step_fx = sub( add( gain_fx, hTdCngDec->last_shb_cng_ener_fx ), hTdCngDec->shb_cng_ener_fx ); /*Q8 */ - test(); - IF( EQ_16( allow_cn_step_fx, 1 ) || GT_32( st_fx->last_core_brate, SID_2k40 ) ) - { - hTdCngDec->shb_cng_ener_fx = add( hTdCngDec->shb_cng_ener_fx, step_fx ); /* Q8 */ - move16(); - } - ELSE - { - hTdCngDec->shb_cng_ener_fx = add( hTdCngDec->shb_cng_ener_fx, mult( 8192, step_fx ) ); /*Q8 */ - move16(); - } - /* generate white noise excitation */ - FOR( i = 0; i < L_FRAME16k; i++ ) - { - excTmp_fx[i] = shr_r( Random( &hTdCngDec->swb_cng_seed ), 8 ); - move16(); /*Q-8*/ - } - - /* synthesis filtering */ - Syn_filt_s( 0, shb_lpcCNG_fx, LPC_SHB_ORDER, excTmp_fx, excSHB_fx, L_FRAME16k, hBWE_TD->state_lpc_syn_fx, 1 ); - - - /* synthesis signal gain shaping */ - L_tmp = 0; - move32(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - L_tmp = L_add( L_tmp, Mpy_32_16_1( L_mult0( excSHB_fx[i], excSHB_fx[i] ), 102 ) ); /*Q-16*/ - } - q = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, q ); - q = sub( q, 32 ); - ener_excSHB_fx = round_fx( L_tmp ); /*Qq */ - IF( EQ_16( st_fx->last_vad_fx, 1 ) ) - { - hTdCngDec->trans_cnt_fx = 0; - move16(); - test(); - IF( GT_16( hTdCngDec->burst_cnt_fx, 3 ) && NE_16( st_fx->last_core, HQ_CORE ) ) - { - hTdCngDec->trans_cnt_fx = 5; - move16(); - } - } - - ener_fx = hTdCngDec->shb_cng_ener_fx; - move16(); /*Q8 */ - IF( hTdCngDec->trans_cnt_fx > 0 ) - { - i = extract_l( L_mult0( hTdCngDec->trans_cnt_fx, 17 ) ); /*Q0 */ - ener_fx = add_sat( hTdCngDec->shb_cng_ener_fx, mult( sin_table256_fx[i], sub_sat( hTdCngDec->last_shb_ener_fx, hTdCngDec->shb_cng_ener_fx ) ) ); /*Q8 */ - hTdCngDec->trans_cnt_fx = sub( hTdCngDec->trans_cnt_fx, 1 ); - move16(); - } - - tmp = mult( 3277, ener_fx ); /*Q8 */ - L_tmp = L_mult( 27213, tmp ); /*Q22, 27213=3.321928 in Q13 */ - L_tmp = L_shr( L_tmp, 6 ); /*Q16 */ - L_tmp = L_add( L_tmp, 10 << 16 ); - if ( L_tmp < 0 ) - { - L_tmp = 0; - move32(); - } - fra = L_Extract_lc( L_tmp, &exp ); - L_tmp = L_shl_sat( Pow2( exp, fra ), 5 ); /*Q5 */ - L_tmp = L_shr( L_tmp, 10 ); - if ( !L_tmp ) - { - L_tmp = 1; /*Q5 */ - } - exp = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp ); /*Q31*/ - tmp = extract_h( L_tmp ); /*Q15*/ - exp = sub( exp, 16 ); - exp1 = norm_s( ener_excSHB_fx ); - fra = shl( ener_excSHB_fx, exp1 ); /*Q15*/ - - IF( GT_16( fra, tmp ) ) - { - fra = shr( fra, 1 ); /*Q15*/ - exp1 = sub( exp1, 1 ); - } - tmp = div_s( fra, tmp ); /*Q15*/ - - L_tmp = L_deposit_h( tmp ); /*Q31 */ - tmp = sub( add( 5, exp ), add( q, exp1 ) ); - L_gain_fx = Isqrt_lc( L_tmp, &tmp ); /*Q31-Qtmp */ - - FOR( i = 0; i < L_FRAME16k; i++ ) - { - shb_syn16k_fx[i] = extract_l( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), sub( 5, tmp ) ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */ - move16(); - } - - test(); - IF( EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) ) - { - /* rescale the Hilbert memories to Q0 */ - FOR( i = 0; i < HILBERT_MEM_SIZE; i++ ) - { - hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i] = L_shr( hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i], hBWE_TD->prev_Q_bwe_syn2 ); /* hBWE_TD->prev_Q_bwe_syn2 */ - move32(); - } - - FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ ) - { - hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i] = shr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i], hBWE_TD->prev_Q_bwe_syn2 ); /* hBWE_TD->prev_Q_bwe_syn2 */ - move16(); - } - } - GenSHBSynth_fx( shb_syn16k_fx, shb_synth_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, st_fx->L_frame, &( hBWE_TD->syn_dm_phase ) ); - - IF( EQ_32( st_fx->output_Fs, 48000 ) ) - { - interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, hTdCngDec->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 ); - } - - ResetSHBbuffer_Dec_fx( st_fx->hBWE_TD, st_fx->extl ); - - return; -} - -static void shb_CNG_decod_ivas_fx( - Decoder_State *st, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn ) -#endif { Word16 i; Word16 idx_ener; @@ -1091,9 +767,7 @@ static void shb_CNG_decod_ivas_fx( Word16 exp, exp1; Word16 fra; Word32 L_tmp; -#ifdef HARM_NON_LINEARITY Word16 tmp_16, tmp_16_2, step_fx16, gain_fx16, ener_fx16; -#endif Word16 allow_cn_step_fx; Word16 q; TD_BWE_DEC_HANDLE hBWE_TD; @@ -1119,14 +793,9 @@ static void shb_CNG_decod_ivas_fx( /* de-quantization of SHB CNG parameters */ IF( st->element_mode == EVS_MONO ) { -#ifdef HARM_NON_LINEARITY L_tmp = L_mult( idx_ener, 27400 ); /*Q14 */ hTdCngDec->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 295924 ), 6 ) ); /*Q8 */ move16(); -#else - hTdCngDec->last_shb_cng_ener_fx_32 = L_sub( L_mult0( idx_ener, 6850 ), 36991 ); // Q11 - move32(); -#endif } ELSE { @@ -1140,7 +809,6 @@ static void shb_CNG_decod_ivas_fx( interp_fx = s_min( hTdCngDec->shb_dtx_count_fx, 32 ); interp_fx = shl_sat( interp_fx, 10 ); /*Q15*/ -#ifdef HARM_NON_LINEARITY IF( st->element_mode == EVS_MONO ) { FOR( i = 0; i < LPC_SHB_ORDER; i++ ) @@ -1152,7 +820,6 @@ static void shb_CNG_decod_ivas_fx( } } ELSE -#endif { FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { @@ -1170,16 +837,13 @@ static void shb_CNG_decod_ivas_fx( E_LPC_lsf_lsp_conversion( shb_lspCNG_fx, tmp_lsp, LPC_SHB_ORDER ); /*Q14*/ E_LPC_f_lsp_a_conversion( tmp_lsp, shb_lpcCNG_fx, LPC_SHB_ORDER ); -#ifdef HARM_NON_LINEARITY IF( st->element_mode != EVS_MONO ) -#endif { Copy_Scale_sig( shb_lpcCNG_fx, hTdCngDec->shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), -1 ) ); /* Q15 */ } Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */ /* SHB energy estimation */ -#ifdef HARM_NON_LINEARITY IF( st->element_mode == EVS_MONO ) { wb_ener_fx = L_deposit_l( 1 ); /*Q1 */ @@ -1251,7 +915,6 @@ static void shb_CNG_decod_ivas_fx( } } ELSE -#endif { wb_ener_fx = L_deposit_l( 1 ); /*Q1 */ IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) @@ -1360,7 +1023,6 @@ static void shb_CNG_decod_ivas_fx( } } -#ifdef HARM_NON_LINEARITY IF( st->element_mode == EVS_MONO ) { ener_fx16 = hTdCngDec->shb_cng_ener_fx; @@ -1409,7 +1071,6 @@ static void shb_CNG_decod_ivas_fx( } ELSE { -#endif ener_fx = hTdCngDec->shb_cng_ener_fx_32; move32(); /*Q11 */ IF( GT_16( st->hTdCngDec->trans_cnt_fx, 0 ) ) @@ -1423,9 +1084,6 @@ static void shb_CNG_decod_ivas_fx( tmp = L_shr( Mpy_32_16_1( ener_fx, 3277 ), 3 ); /*Q8 */ IF( GT_32( tmp, 32767 ) ) abort(); -#ifndef HARM_NON_LINEARITY - Word16 tmp_16; -#endif tmp_16 = (Word16) tmp; move16(); L_tmp = L_mult( 27213, tmp_16 ); /*Q22, 27213=3.321928 in Q13 */ @@ -1462,9 +1120,7 @@ static void shb_CNG_decod_ivas_fx( L_gain_fx = Isqrt_lc( L_tmp, &tmp_16 ); /*Q31-Qtmp */ hTdCngDec->shb_cng_gain_fx_32 = ener_fx; move32(); -#ifdef HARM_NON_LINEARITY } -#endif FOR( i = 0; i < L_FRAME16k; i++ ) { @@ -1495,7 +1151,6 @@ static void shb_CNG_decod_ivas_fx( interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, hTdCngDec->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 ); } -#ifdef HARM_NON_LINEARITY IF( st->element_mode != EVS_MONO ) { IF( EQ_32( st->output_Fs, 32000 ) ) @@ -1507,9 +1162,6 @@ static void shb_CNG_decod_ivas_fx( Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */ } } -#else - Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */ -#endif ResetSHBbuffer_Dec_fx( st->hBWE_TD, st->extl ); diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 2ff4ce84f31fd2578e0aa20444fb6420c7385b34..79b75b02f20db6120e5428c92ecf95e417a4a391 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -1978,11 +1978,7 @@ void open_decoder_LPD_ivas_fx( IF( st->hTcxDec != NULL && ( st->ini_frame == 0 || LT_32( last_total_brate, HQ_48k ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) ) { -#ifdef HARM_COREDECODER_FUNCTIONS concealment_init_x( st->hTcxDec->L_frameTCX, st->hPlcInfo ); -#else - concealment_init_ivas_fx( st->hTcxDec->L_frameTCX, st->hPlcInfo ); -#endif } } ELSE diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index c24d338cbff53241c7946634ba37d6c6dcd16a4e..00ff81afedaba35ac89a81a7cc2ebca47e030fe1 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -931,26 +931,13 @@ void decoder_LPD_fx( E_LPC_a_lsp_conversion( A, lsptmp, &xspnew_uw[0], M ); Residu3_fx( A, buf + L_LP - L_FRAME, res, L_FRAME, 1 ); -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, Qexc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, EVS_MONO, -1 ); -#else - cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, - st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, - Qexc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); -#endif } ELSE { -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( &lsp[M], st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, EVS_MONO, -1 ); -#else - cng_params_upd_fx( &lsp[M], st->old_exc_fx + L_EXC_MEM_DEC - st->L_frame, - st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, - &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, - st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); -#endif } /* Set 16k LSP flag for CNG buffer */ diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index b475a31d73412acb29abff6e345dbeb46f802d46..1eccbfeab0344714846a2e1d48fb2330596446d6 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -479,11 +479,7 @@ Word16 dec_acelp_tcx_frame_fx( test(); IF( st->core == ACELP_CORE && st->igf != 0 && st->con_tcx == 0 ) { -#ifdef HARM_NON_LINEARITY non_linearity_fx( EVS_MONO, ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors, st->L_frame ); -#else - non_linearity_fx( ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors, st->L_frame ); -#endif /* update the old BWE exe memory */ Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 ); } diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index 596b8574cad9fed54e3a72587da37147c85df3ea..1a568cbf9a109fabc600841fc3ed3afab2f9aad7 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -35,11 +35,7 @@ static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); -#ifdef HARM_COREDECODER_FUNCTIONS static void Filt_mu_fx( Word16 *sig_in, Word16 *sig_out, Word16 parcor0, Word16 L_subfr ); -#else -static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl ); -#endif /*-------------------------------------------------------------------------- @@ -448,11 +444,7 @@ static void Dec_formant_postfilt_fx( } /* Controls short term pst filter gain and compute parcor0 */ -#ifdef HARM_COREDECODER_FUNCTIONS calc_st_filt_local_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero ); -#else - calc_st_filt_ivas_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero, -1 ); -#endif /* 1/A(gamma1) filtering, mem_stp is updated */ resynth[0] = *( hPFstat->mem_stp + sub( L_SYN_MEM, 1 ) ); @@ -470,11 +462,7 @@ static void Dec_formant_postfilt_fx( } /* Tilt filtering */ -#ifdef HARM_COREDECODER_FUNCTIONS Filt_mu_fx( resynth, sig_out, parcor0, L_SUBFR ); -#else - Filt_mu_ivas_fx( resynth, sig_out, parcor0, L_SUBFR, -1 ); -#endif IF( scale_down ) { @@ -1345,62 +1333,6 @@ static void calc_st_filt_local_fx( return; } -#ifndef HARM_COREDECODER_FUNCTIONS -static void calc_st_filt_ivas_fx( - Word16 *apond2, /* i : coefficients of numerator Q12 */ - Word16 *apond1, /* i : coefficients of denominator Q12 */ - Word16 *parcor0, /* o : 1st parcor calcul. on composed filter Q15 */ - Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 Qx*/ - Word16 *mem_zero, /* i : All zero memory */ - const Word16 extl /* i : extension layer info */ -) -{ - Word32 L_g0; - - Word16 h[LONG_H_ST]; // Q12 - - Word16 g0, temp; - Word16 i; - - - temp = sub( 2, norm_s( apond2[0] ) ); - - /* compute i.r. of composed filter apond2 / apond1 */ - IF( EQ_16( extl, SWB_TBE ) ) - { - E_UTIL_synthesis( temp, apond1, apond2, h, LONG_H_ST, mem_zero, 0, LPC_SHB_ORDER ); - } - ELSE - { - E_UTIL_synthesis( temp, apond1, apond2, h, LONG_H_ST, mem_zero, 0, M ); - } - - /* compute 1st parcor */ - Calc_rc0_h( h, parcor0 ); - - /* compute g0 */ - L_g0 = L_mult0( 1, abs_s( h[0] ) ); // Q12 - FOR( i = 1; i < LONG_H_ST; i++ ) - { - L_g0 = L_mac0( L_g0, 1, abs_s( h[i] ) ); // Q12 - } - g0 = extract_h( L_shl( L_g0, 14 ) ); // Q10 - - /* Scale signal i of 1/A(gamma1) */ - IF( GT_16( g0, 1024 ) ) /*1024 = 1.Q10*/ - { - temp = div_s( 1024, g0 ); /* temp => Q15 / gain0 */ /*1024 = 1.Q10*/ - FOR( i = 0; i < L_SUBFR; i++ ) - { - sig_ltp_ptr[i] = mult_r( sig_ltp_ptr[i], temp ); // Qx - move16(); - } - } - - - return; -} -#endif /*---------------------------------------------------------------------------- * filt_mu @@ -1409,11 +1341,7 @@ static void calc_st_filt_ivas_fx( * computes y[n] = (1/1-|mu|) (x[n]+mu*x[n-1]) *---------------------------------------------------------------------------*/ -#ifdef HARM_COREDECODER_FUNCTIONS static void Filt_mu_fx( -#else -void Filt_mu_fx( -#endif Word16 *sig_in, /* i : signal (beginning at sample -1) */ Word16 *sig_out, /* o : signal with tilt */ Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ @@ -1474,98 +1402,6 @@ void Filt_mu_fx( return; } -#ifndef HARM_COREDECODER_FUNCTIONS -void Filt_mu_ivas_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) Q15 */ - Word16 L_subfr, /* i : the length of subframe */ - const Word16 extl ) -{ - Word32 L_acc, L_temp, L_fact; - - Word16 *ptrs; - - Word16 n; - Word16 mu, mu2, ga, temp; - Word16 fact, sh_fact; - - IF( EQ_16( extl, SWB_TBE ) ) - { - IF( parcor0 > 0 ) - { - mu = mult_r( parcor0, GAMMA3_PLUS_WB_FX ); // Q15 - /* GAMMA3_PLUS_FX < 0.5 */ - sh_fact = 14; - move16(); /* sh_fact */ - fact = (Word16) 0x4000; - move16(); /* Q(sh_fact) */ - L_fact = L_deposit_l( 0x2000 ); /* fact >> 1 */ - } - ELSE - { - mu = mult_r( parcor0, GAMMA3_MINUS_WB_FX ); // Q15 - /* GAMMA3_MINUS_FX < 0.9375 */ - sh_fact = 11; - move16(); /* sh_fact */ - fact = (Word16) 0x0800; - move16(); /* Q(sh_fact) */ - L_fact = L_deposit_l( 0x0400 ); /* fact >> 1 */ - } - } - ELSE - { - IF( parcor0 > 0 ) - { - mu = mult_r( parcor0, GAMMA3_PLUS_FX ); // Q15 - /* GAMMA3_PLUS_FX < 0.5 */ - sh_fact = 14; - move16(); /* sh_fact */ - fact = (Word16) 0x4000; - move16(); /* Q(sh_fact) */ - L_fact = L_deposit_l( 0x2000 ); /* fact >> 1 */ - } - ELSE - { - mu = mult_r( parcor0, GAMMA3_MINUS_FX ); // Q15 - /* GAMMA3_MINUS_FX < 0.9375 */ - sh_fact = 11; - move16(); /* sh_fact */ - fact = (Word16) 0x0800; - move16(); /* Q(sh_fact) */ - L_fact = L_deposit_l( 0x0400 ); /* fact >> 1 */ - } - } - - temp = sub( 1, abs_s( mu ) ); - BASOP_SATURATE_WARNING_OFF_EVS; - mu2 = add_sat( 32767, temp ); /* Q15 (1 - |mu|) */ - BASOP_SATURATE_WARNING_ON_EVS; - ga = div_s( fact, mu2 ); /* Q(sh_fact) / (1 - |mu|) */ - - ptrs = sig_in; /* points on sig_in(-1) */ - - sh_fact = sub( sh_fact, 16 ); /* to remove the saturate(), should shl by 16 before rounding */ - - FOR( n = 0; n < L_subfr; n++ ) - { - L_acc = L_mult0( mu, *ptrs++ ); - L_temp = L_mac( L_acc, 16384, *ptrs ); /* sig_in(n) * 2**15 */ - - L_temp = Madd_32_16( L_fact, L_temp, ga ); - L_temp = L_shr( L_temp, sh_fact ); /* mult. temp x ga */ - - BASOP_SATURATE_WARNING_OFF_EVS; - /*sig_out[n] = saturate(L_temp); move16();*/ - sig_out[n] = round_fx_sat( L_temp ); - BASOP_SATURATE_WARNING_ON_EVS; - } - - - return; -} - -#endif /*---------------------------------------------------------------------------- * scale_st_fx() diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 91a5a671f262d5355b70bce378c49e70088ce7ff..41a2e9842cd2657b9f28f019e4a75462e9e93f22 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -52,11 +52,7 @@ void getLPCparam_fx( { IF( st->lpcQuantization == 0 ) { -#ifdef HARM_COREDECODER_FUNCTIONS decode_lpc_avq_fx( st0, st->numlpc, param_lpc, ch, st->element_mode, sns_low_br_mode ); -#else - decode_lpc_avq_ivas_fx( st0, st->numlpc, param_lpc, ch, st->element_mode, sns_low_br_mode ); -#endif } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) { @@ -1007,11 +1003,7 @@ void dec_prm_fx( { IF( st->lpcQuantization == 0 ) { -#ifdef HARM_COREDECODER_FUNCTIONS decode_lpc_avq_fx( st, st->numlpc, param_lpc, 0, EVS_MONO, 0 ); -#else - decode_lpc_avq_fx( st, st->numlpc, param_lpc ); -#endif move16(); } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index 93a9cf8ca4472234f83d3c239635c04b9f049f19..20d5f4b22bfec94ffa76a46023927e9d4511f8bc 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -145,18 +145,7 @@ void decod_tran_fx( IF( Jopt_flag == 0 ) { /* 2/3-bit decoding */ -#ifdef HARM_COREDECODER_FUNCTIONS gain_dec_tc_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); -#else - IF( st_fx->element_mode == EVS_MONO ) - { - gain_dec_tc_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); - } - ELSE - { - gain_dec_tc_ivas_fx( st_fx, code_fx, i_subfr, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); - } -#endif } ELSE { diff --git a/lib_dec/dlpc_avq_fx.c b/lib_dec/dlpc_avq_fx.c index 2b126421895c7b76cbcac3f1f3fd1f168a805f5c..9080fd5aa2693b1a960bedf79275a55cd42b6be2 100644 --- a/lib_dec/dlpc_avq_fx.c +++ b/lib_dec/dlpc_avq_fx.c @@ -146,147 +146,6 @@ static Word16 pack4bits_fx( } Word16 decode_lpc_avq_fx( -#ifndef HARM_COREDECODER_FUNCTIONS - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc /* o : lpc parameters */ -) -{ - Word16 k, j; - Word16 nb, qn1, qn2, avqBits, q_type; - Word16 start_bit_pos; - move16(); - move16(); - move16(); - j = 0; - start_bit_pos = st->next_bit_pos; - - FOR( k = 0; k < numlpc; k++ ) - { - /* Decode quantizer type */ - - IF( k == 0 ) - { - move16(); - move16(); - q_type = 0; - nb = 0; - } - ELSE - { - move16(); - nb = 1; - q_type = get_next_indice_fx( st, nb ); - move16(); - param_lpc[j] = q_type; - j = add( j, 1 ); - } - /* Decode quantization indices */ - - IF( q_type == 0 ) - { - /* Absolute quantizer with 1st stage stochastic codebook */ - { - move16(); - param_lpc[j] = get_next_indice_fx( st, 8 ); - } - j = add( j, 1 ); - } - /* - * 2nd stage decoding is skipped if: - * - we are in low bitrate mode and no joint SNS coding is used - * - OR the side-SNS-is-zero flag is set for joint SNS - */ - { - /* 2 bits to specify Q2,Q3,Q4,ext */ - qn1 = add( 2, get_next_indice_fx( st, 2 ) ); - qn2 = add( 2, get_next_indice_fx( st, 2 ) ); - - /* Unary code */ - /* Q5 = 0, Q6=10, Q0=110, Q7=1110, ... */ - - IF( GT_16( qn1, 4 ) ) - { - nb = unary_decode_fx( st, &qn1 ); - - if ( EQ_16( nb, 1 ) ) - { - qn1 = add( qn1, 5 ); - } - if ( EQ_16( nb, 2 ) ) - { - qn1 = add( qn1, 4 ); - } - if ( EQ_16( nb, 3 ) ) - { - move16(); - qn1 = 0; - } - if ( GT_16( nb, 3 ) ) - { - qn1 = add( qn1, 3 ); - } - } - - IF( GT_16( qn2, 4 ) ) - { - nb = unary_decode_fx( st, &qn2 ); - - if ( EQ_16( nb, 1 ) ) - { - qn2 = add( qn2, 5 ); - } - if ( EQ_16( nb, 2 ) ) - { - qn2 = add( qn2, 4 ); - } - if ( EQ_16( nb, 3 ) ) - { - move16(); - qn2 = 0; - } - if ( GT_16( nb, 3 ) ) - { - qn2 = add( qn2, 3 ); - } - } - - /* check for potential bit errors */ - test(); - IF( ( GT_16( qn1, NB_SPHERE ) ) || ( GT_16( qn2, NB_SPHERE ) ) ) - { - qn1 = 0; - move16(); - qn2 = 0; - move16(); - st->BER_detect = 1; - move16(); - } - - move16(); - param_lpc[j] = qn1; - j = add( j, 1 ); - move16(); - param_lpc[j] = qn2; - j = add( j, 1 ); - - /* Decode Split-by-2 algebraic VQ */ - avqBits = shl( qn1, 2 ); - - pack4bits_fx( avqBits, st, ¶m_lpc[j] ); - j = add( j, qn1 ); - - avqBits = shl( qn2, 2 ); - pack4bits_fx( avqBits, st, ¶m_lpc[j] ); - j = add( j, qn2 ); - } - } - - return sub( st->next_bit_pos, start_bit_pos ); -} - -Word16 decode_lpc_avq_ivas_fx( -#endif Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ Word16 *param_lpc, /* o : lpc parameters */ diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 3ac75b9c74de134bac261414ba301fe92ca312a1..551e04205f4030c9b5c74c55883e0f286a580299 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -90,140 +90,6 @@ void Es_pred_dec_fx( /*======================================================================================*/ void gain_dec_tc_fx( -#ifndef HARM_COREDECODER_FUNCTIONS - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : pitch gain */ - Word32 *gain_code_fx, /* o : Quantized codeebook gain */ - Word16 *gain_inov_fx, /* o : unscaled innovation gain */ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ -) -{ - Word16 index, nBits; - Word16 gcode0_fx; - Word16 Ei_fx; - Word16 expg, expg2, e_tmp, f_tmp, exp_gcode0, tmp_fx, frac; - Word32 L_tmp, L_tmp1; - Word16 wgain_code = 0; - move16(); - *gain_pit_fx = 0; - move16(); - - /*----------------------------------------------------------------* - * find number of bits for gain dequantization - *----------------------------------------------------------------*/ - nBits = st_fx->acelp_cfg.gains_mode[( i_subfr_fx / 64 )]; - move16(); - /*-----------------------------------------------------------------* - * calculate the predicted gain code - *-----------------------------------------------------------------*/ - - /*Ecode = (dotp( code, code, L_SUBFR) + 0.01f) / L_SUBFR; - *gain_inov = 1.0f / (float)sqrt( Ecode );*/ - L_tmp = Dot_product12( code_fx, code_fx, L_SUBFR, &expg ); /*Q31 - expg*/ - expg = sub( expg, 18 + 6 ); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */ - expg2 = expg; - move16(); - L_tmp1 = L_tmp; /* sets to 'L_tmp' in 1 clock */ - move32(); - L_tmp = Isqrt_lc( L_tmp, &expg ); /*Q31 - expg*/ - - *gain_inov_fx = extract_h( L_shl( L_tmp, sub( expg, 3 ) ) ); - move16(); /* gain_inov in Q12 */ - - - /* Ei = 10 * (float)log10( Ecode );*/ - e_tmp = norm_l( L_tmp1 ); - f_tmp = Log2_norm_lc( L_shl( L_tmp1, e_tmp ) ); /*Q15*/ - e_tmp = sub( expg2, add( 1, e_tmp ) ); - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 12330 ); /* Q13 */ /* 10*log10(2) in Q12*/ - Ei_fx = round_fx( L_shl( L_tmp1, 11 ) ); /* Q8 */ - /* gcode0 = (float) pow(10, 0.05 * (Es_pred - Ei));*/ - gcode0_fx = sub( Es_pred_fx, Ei_fx ); /* Q8 */ - - /*-----------------------------------------------------------------* - * gcode0 = pow(10.0, gcode0/20) - * = pow(2, 3.321928*gcode0/20) - * = pow(2, 0.166096*gcode0) - *-----------------------------------------------------------------*/ - L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */ - L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ - frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ - gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ - /* output of Pow2() will be: */ - /* 16384 < Pow2() <= 32767 */ - exp_gcode0 = sub( exp_gcode0, 14 ); - /*------------------------------------------------------------------------------------------* - * Select the gain quantization table and dequantize the gain - *------------------------------------------------------------------------------------------*/ - - /* index = (Word16)get_indice( st_fx,"gain_code", i_subfr_fx, ACELP_CORE);move16();*/ - index = (Word16) get_next_indice_fx( st_fx, nBits ); - move16(); - - - IF( GT_16( nBits, 3 ) ) - { - wgain_code = gain_dequant_fx( index, G_CODE_MIN_TC_Q15, G_CODE_MAX_TC_Q0, nBits, &expg ); - wgain_code = shl_sat( wgain_code, add( expg, 13 ) ); /* wgain_code in Q13*/ - } - ELSE /* nBits == 3 */ - { - wgain_code = tbl_gain_code_tc_fx[index]; /*Q13*/ - move16(); - } - - /*-----------------------------------------------------------------* - * decode normalized codebook gain - *-----------------------------------------------------------------*/ - - /* *gain_code *= gcode0;*/ - L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); /*Q16*/ - move32(); - - /**norm_gain_code = *gain_code / *gain_inov;*/ - expg = sub( norm_s( *gain_inov_fx ), 1 ); - expg = s_max( expg, 0 ); - - tmp_fx = div_s( shr( 8192, expg ), *gain_inov_fx ); - *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) ); /*Q16*/ - move32(); - - return; -} - -/*======================================================================================*/ -/* FUNCTION : void gain_dec_tc_ivas_fx () */ -/*--------------------------------------------------------------------------------------*/ -/* PURPOSE : Decoding of pitch and codebook gains and updating long term energies */ -/*--------------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* Word32 core_brate_fx i : core bitrate */ -/* Word16 *code_fx i : algebraic code excitation */ -/* Word16 L_frame_fx i : length of the frame */ -/* Word16 i_subfr_fx i : subframe number */ -/* Word16 tc_subfr_fx i : TC subframe index */ -/* Word16 Es_pred_fx i : predicted scaled innov. energy Q8 */ -/*--------------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* Word16 *gain_pit_fx o : pitch gain Q14 */ -/* Word32 *gain_code_fx o : Quantized codeebook gain Q16 */ -/* Word16 *gain_inov_fx o : unscaled innovation gain Q12 */ -/* Word32 *norm_gain_code_fx o : norm. gain of the codebook excit. Q16 */ -/*--------------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/*--------------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*--------------------------------------------------------------------------------------*/ -/* CALLED FROM : */ -/*======================================================================================*/ - -void gain_dec_tc_ivas_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *code_fx, /* i : algebraic code excitation */ const Word16 i_subfr_fx, /* i : subframe number */ @@ -297,7 +163,6 @@ void gain_dec_tc_ivas_fx( index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/ -#ifdef HARM_COREDECODER_FUNCTIONS IF( st_fx->element_mode == EVS_MONO ) { IF( GT_16( nBits, 3 ) ) @@ -312,7 +177,6 @@ void gain_dec_tc_ivas_fx( } } ELSE -#endif { IF( GT_16( nBits, 3 ) ) { @@ -331,14 +195,12 @@ void gain_dec_tc_ivas_fx( *-----------------------------------------------------------------*/ /* *gain_code *= gcode0;*/ -#ifdef HARM_COREDECODER_FUNCTIONS IF( st_fx->element_mode == EVS_MONO ) { L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q13*Q0 -> Q14 */ *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 2 ) ); /*Q16*/ } ELSE -#endif { L_tmp = L_mult( wgain_code, gcode0_fx ); /* Q12*Q0 -> Q13 */ *gain_code_fx = L_shl( L_tmp, add( exp_gcode0, 3 ) ); /* Q13 -> Q16 */ diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index a2dc8803bb05c4e9376ecc63ed296d32ac92f9f0..153b760804e41756ed7400e9d6731de8e8332579 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -20,12 +20,7 @@ *---------------------------------------------------------------------*/ static void filt_6k_7k_scale_fx( Word16 signal[], Word16 lg, Word16 mem[], Word16 fact, Word16 exp ); -#ifdef FIX_BASOP_2350_HARM_0B_BWE static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word16 element_mode, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn ); -#else -static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn ); -static void hf_synthesis_ivas_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, const Word32 core_brate, const Word16 output_subfr, const Word16 Aq[], const Word16 exc[], const Word16 Q_exc, Word16 synth[], Word16 synth16k[], const Word16 Q_syn ); -#endif static void hf_synthesis_amr_wb_fx( const Word32 core_brate, const Word16 output_subfr, const Word16 Ap[], Word16 exc16k[], Word16 synth_out[], Word16 *mem_syn_hf, Word16 *delay_syn_hf, Word16 *mem_hp_interp, Word16 p_r, Word16 HF_corr_gain, Word16 til, Word16 voice_factors, const Word16 exc[], const Word16 Q_exc, const Word16 Q_out, Word16 qhf ); static void envelope_fx( AMRWB_IO_DEC_HANDLE hAmrwb_IO, const Word32 core_brate, const Word16 Aq[], Word16 Ap[], Word16 *r, Word16 tilt0, Word16 tilt, Word16 voice_factor ); static void AdaptiveStartBand_fx( Word16 *start_band, const Word32 rate, const Word16 *lsf, const Word16 voicing_fac, const Word16 clas, Word16 *voicing_flag, Word16 *start_band_old, Word32 *OptCrit_old ); @@ -84,17 +79,15 @@ void hf_synth_reset_fx( void hf_synth_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ -#ifdef FIX_BASOP_2350_HARM_0B_BWE - const Word16 element_mode, /* i : element mode Q0*/ -#endif - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ ) { const Word16 *p_Aq; @@ -106,11 +99,7 @@ void hf_synth_fx( p_Aq = Aq; /* Q12 */ FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) { -#ifdef FIX_BASOP_2350_HARM_0B_BWE hf_synthesis_fx( hBWE_zero, element_mode, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[i_subfr * output_subfr / L_SUBFR], Q_syn2 ); -#else - hf_synthesis_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[i_subfr * output_subfr / L_SUBFR], Q_syn2 ); -#endif p_Aq += ( M + 1 ); /* Q12 */ } @@ -130,9 +119,7 @@ void hf_synth_fx( static void hf_synthesis_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, -#ifdef FIX_BASOP_2350_HARM_0B_BWE const Word16 element_mode, /* i : element mode Q0*/ -#endif const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_subfr, /* i : output sub-frame length Q0*/ const Word16 Aq[], /* i : quantized Az Q12*/ @@ -148,11 +135,9 @@ static void hf_synthesis_fx( Word16 HF_exc[L_SUBFR16k]; Word16 tmp, ener, exp1, exp2, scale; Word32 L_tmp; -#ifdef FIX_BASOP_2350_HARM_0B_BWE Word16 Q_tmp, Q_ener, sft; Word32 ONE, P_ONE; Word64 prod; -#endif Word16 Ap[M16k + 1]; /*-----------------------------------------------------------------* @@ -176,10 +161,8 @@ static void hf_synthesis_fx( L_tmp = Dot_product12( HF_exc, HF_exc, L_SUBFR16k, &exp1 ); tmp = round_fx( L_tmp ); /* Q15 */ -#ifdef FIX_BASOP_2350_HARM_0B_BWE IF( element_mode == EVS_MONO ) { -#endif /* tmp = (float)(sqrt(ener/tmp)) */ /* scale is -1 if tmp > ener */ scale = shr( sub( ener, tmp ), 15 ); /* Q0 */ @@ -243,7 +226,6 @@ static void hf_synthesis_fx( /*scale *= fac;*/ tmp = mult_r( scale, tmp ); -#ifdef FIX_BASOP_2350_HARM_0B_BWE } ELSE { @@ -319,7 +301,6 @@ static void hf_synthesis_fx( tmp = mult_r( scale, tmp ); /* Q = (15 - exp1) + Q_tmp - 15 */ Q_tmp = sub( Q_tmp, exp1 ); } -#endif /*-----------------------------------------------------------------* * modify HF excitation according to both calculated scaling factors @@ -386,213 +367,6 @@ static void hf_synthesis_fx( return; } -#ifndef FIX_BASOP_2350_HARM_0B_BWE -void hf_synth_ivas_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ -) -{ - const Word16 *p_Aq; - Word16 i_subfr, output_subfr; - - output_subfr = shr( output_frame, 2 ); - - p_Aq = Aq; /* Q12 */ - FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) - { - hf_synthesis_ivas_fx( hBWE_zero, core_brate, output_subfr, p_Aq, &exc[i_subfr], Q_exc, &synth[i_subfr], &synth16k[i_subfr * output_subfr / L_SUBFR], Q_syn2 ); - - p_Aq += ( M + 1 ); /* Q12 */ - } - - return; -} -static void hf_synthesis_ivas_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_subfr, /* i : output sub-frame length Q0*/ - const Word16 Aq[], /* i : quantized Az Q12*/ - const Word16 exc[], /* i : excitation at 12.8 kHz Q_exc*/ - const Word16 Q_exc, /* i : excitation scaling */ - Word16 synth[], /* i : 12.8kHz synthesis signal Q_syn*/ - Word16 synth16k[], /* i/o: 16kHz synthesis signal Q_syn*/ - const Word16 Q_syn /* i : synthesis scaling */ -) -{ - Word16 i, s; - Word16 HF_syn[L_SUBFR16k], upsampled_HF_syn[L_FRAME48k / NB_SUBFR]; - Word16 HF_exc[L_SUBFR16k]; - Word16 exp1, exp2, scale, tmp, ener, Q_tmp, Q_ener, sft; - Word32 L_tmp, ONE, P_ONE; - Word16 Ap[M16k + 1]; - Word64 prod; - - /*-----------------------------------------------------------------* - * generate white noise vector - *-----------------------------------------------------------------*/ - - Random_Fill( &hBWE_zero->seed2, L_SUBFR16k, HF_exc, 3 ); /* 3 = Shift Right by 3 */ - - /* o: HF_exc in Q(-3) */ - - /*-----------------------------------------------------------------* - * calculate energy scaling factor so that white noise would have the - * same energy as exc12k8 - *-----------------------------------------------------------------*/ - - /*ener = sum2_f( exc, L_SUBFR ) + 0.01f*/ - ener = extract_h( Dot_product12( exc, exc, L_SUBFR, &exp2 ) ); - exp2 = sub( exp2, add( Q_exc, Q_exc ) ); // ener exponent - - /*tmp = round_fx(Dot_product12(HF_exc, HF_exc, output_subfr, &exp1)); */ - L_tmp = Dot_product12( HF_exc, HF_exc, L_SUBFR16k, &exp1 ); - tmp = round_fx( L_tmp ); - exp1 = add( exp1, 6 ); /* tmp exponent */ - - ener = shr( ener, 1 ); /* to avoid the assertion in div_s() further*/ - exp2 = add( exp2, 1 ); - - tmp = div_s( ener, tmp ); - exp1 = sub( exp2, exp1 ); - - scale = Sqrt16( tmp, &exp1 ); /* scale exponent = exp1 */ - - /*-----------------------------------------------------------------* - * calculate energy scaling factor to respect tilt of synth12k8 - * (tilt: 1=voiced, -1=unvoiced) - *-----------------------------------------------------------------*/ - - hp400_12k8_ivas_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx ); - - /* i: mem_hp400 in Q_syn */ - /* i: synth in Q_syn */ - /* o: synth in Q_syn-3 */ - prod = W_mac0_16_16( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3) */ - FOR( i = 1; i < L_SUBFR; i++ ) - { - prod = W_mac0_16_16( prod, synth[i], synth[i] ); /* 2*(Q_syn-3) */ - } - sft = W_norm( prod ); - ener = extract_h( W_extract_h( W_shl( prod, sft ) ) ); - Q_ener = sub( add( shl( sub( Q_syn, 3 ), 1 ), sft ), 48 ); - - prod = W_mac0_16_16( 1L, synth[1], synth[0] ); /* 2*(Q_syn-3) */ - FOR( i = 2; i < L_SUBFR; i++ ) - { - prod = W_mac0_16_16( prod, synth[i], synth[i - 1] ); /* 2*(Q_syn-3) */ - } - sft = sub( W_norm( prod ), 1 ); - tmp = extract_h( W_extract_h( W_shl( prod, sft ) ) ); - Q_tmp = sub( add( shl( sub( Q_syn, 3 ), 1 ), sft ), 48 ); - - tmp = s_max( 0, tmp ); - IF( tmp > 0 ) - { - tmp = div_s( tmp, ener ); - Q_tmp = add( 15, sub( Q_tmp, Q_ener ) ); - } - - /*-----------------------------------------------------------------* - * modify energy of white noise according to synthesis tilt - *-----------------------------------------------------------------*/ - /* tmp = 1.0 - fac */ - ONE = L_shl( 1, Q_tmp ); - P_ONE = L_shl( 3277 /* 0.1 in Q15 */, sub( Q_tmp, 15 ) ); - L_tmp = L_msu0( ONE, tmp, 1 ); - test(); - if ( core_brate == FRAME_NO_DATA || EQ_32( core_brate, SID_2k40 ) ) - { - /* emphasize HF noise in CNG */ - /*fac *= 2.0f;*/ - L_tmp = L_add( L_tmp, L_tmp ); - } - L_tmp = L_max( L_tmp, P_ONE ); - L_tmp = L_min( L_tmp, ONE ); - - sft = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, sft ); - - tmp = round_fx( L_tmp ); - Q_tmp = sub( add( Q_tmp, sft ), 16 ); - - /*scale *= fac;*/ - tmp = mult_r( scale, tmp ); /* Q = (15 - exp1) + Q_tmp - 15 */ - Q_tmp = sub( Q_tmp, exp1 ); - /*-----------------------------------------------------------------* - * modify HF excitation according to both calculated scaling factors - * high pass filtering (0.94ms of delay) - *-----------------------------------------------------------------*/ - - exp2 = sub( hBWE_zero->memExp1, exp1 ); - hBWE_zero->memExp1 = exp1; - move16(); - - filt_6k_7k_scale_fx( HF_exc, L_SUBFR16k, hBWE_zero->mem_hf_fx, tmp, exp2 ); - /* i: HF_exc in Q(-3) */ - /* o: HF_exc in ((-3) + Q_tmp - 17) */ - /* o: hBWE_zero->mem_hf_fx in Q(HF_exc)-2 */ - - /*-----------------------------------------------------------------* - * synthesis of noise: 4.8kHz..5.6kHz --> 6kHz..7kHz - *-----------------------------------------------------------------*/ - - /*weight_a( Aq, Ap, 0.6f, M );*/ - weight_a_lc_fx( Aq, Ap, Gamma_19661_Tbl_fx, M ); - /* o: Ap in Q14 */ - - Syn_filt_s( 0, Ap, M, HF_exc, HF_syn, L_SUBFR16k, hBWE_zero->mem_syn_hf_fx, 1 ); - /* o: HF_syn in same Q as HF_exc */ - /* o: mem_syn_hf_fx same Q as HF_syn */ - - Scale_sig( HF_syn, L_SUBFR16k, ( add( Q_syn, exp1 ) ) ); /* bring HF_syn to (Q_syn+exp1) */ - - /*-----------------------------------------------------------------* - * add filtered HF noise to speech synthesis - *-----------------------------------------------------------------*/ - - /* delay by 5 samples @16kHz to compensate CLDFB resampling delay (20samples) and HP filtering delay (roughly 15 samples) */ - delay_signal_fx( HF_syn, L_SUBFR16k, hBWE_zero->delay_syn_hf_fx, NS2SA_FX2( 16000, DELAY_CLDFB_NS ) - 15 ); - - /* interpolate the HF synthesis */ - IF( EQ_16( output_subfr, L_SUBFR48k ) ) /* 48kHz sampled output */ - { - s = s_max( s_min( sub( s_min( Find_Max_Norm16( HF_syn, L_SUBFR16k ), Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN - 3 ) ), 3 ), - sub( Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx + INTERP_3_1_MEM_LEN - 3, 3 ), 1 ) ), - 0 ); - Scale_sig( HF_syn, L_SUBFR16k, s ); /* Q_syn+exp1+s */ - Scale_sig( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN, s ); /* Qx + s */ - interpolate_3_over_1_allpass_fx( HF_syn, L_SUBFR16k, upsampled_HF_syn, hBWE_zero->mem_hp_interp_fx ); - Scale_sig( upsampled_HF_syn, 3 * L_SUBFR16k, -s ); /* Q_syn + exp1 + s */ - Scale_sig( hBWE_zero->mem_hp_interp_fx, INTERP_3_1_MEM_LEN, -s ); /* Qx */ - Scale_sig( HF_syn, L_SUBFR16k, -s ); /* Q_syn+exp1 */ - Scale_sig( upsampled_HF_syn, L_SUBFR48k, -1 ); - } - ELSE IF( EQ_16( output_subfr, L_SUBFR32k ) ) /* 32kHz sampled output */ - { - s = s_max( sub( s_min( Find_Max_Norm16( HF_syn, L_SUBFR16k ), Find_Max_Norm16( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP ) ), 2 ), 0 ); - Scale_sig( HF_syn, L_SUBFR16k, s ); /* Q_syn+exp1+s */ - Scale_sig( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP, s ); /* Qx + s */ - Interpolate_allpass_steep_fx( HF_syn, hBWE_zero->mem_hp_interp_fx, L_SUBFR16k, upsampled_HF_syn ); - Scale_sig( upsampled_HF_syn, 2 * L_SUBFR16k, -s ); /* Q_syn + exp1 */ - Scale_sig( hBWE_zero->mem_hp_interp_fx, 2 * ALLPASSSECTIONS_STEEP, -s ); /* Qx */ - Scale_sig( HF_syn, L_SUBFR16k, -s ); /* Q_syn+exp1 */ - } - ELSE /* 16kHz sampled output */ - { - Copy( HF_syn, upsampled_HF_syn, L_SUBFR16k ); /* Q_syn */ - } - Vr_add( synth16k, upsampled_HF_syn, synth16k, output_subfr ); - - return; -} -#endif /*-------------------------------------------------------------------* * filt_6k_7k: diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 459d1b45094f7962c2e1aa9aa5513c09b4cd4c89..9838195ccaecf9eb9fed068d5a9c6eaa296dd75c 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1141,29 +1141,17 @@ ivas_error ivas_core_dec_fx( q = 2; move16(); -#ifdef HARM_NON_LINEARITY - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 -#else - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 -#endif + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 Copy_Scale_sig_32_16( synth_32_fx[n], synth_fxl, output_frame, negate( add( Q11, q ) ) ); // Q0 Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2 -#ifdef HARM_NON_LINEARITY swb_CNG_dec_fx( st, synth_fxl, hb_synth_16_fx[n], sid_bw[n], negate( q ) ); -#else - swb_CNG_dec_ivas_fx( st, synth_fxl, hb_synth_16_fx[n], sid_bw[n], negate( q ) ); -#endif test(); IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) { -#ifdef HARM_NON_LINEARITY Copy_Scale_sig_16_32_DEPREC( hb_synth_16_fx[n], hb_synth_32_fx[n], output_frame, ( Q11 ) ); // Q11 -#else - Copy_Scale_sig_16_32_DEPREC( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, ( Q11 ) ); // Q11 -#endif } Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, negate( sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ) ); // Q0 diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 063f089d097ae2e4ae1ff200122567b7e0c2687b..e937b9dfe606c3389e295ffd22ca8efbde647b35 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -129,11 +129,7 @@ static void ism_metadata_smooth_fx( diff_fx = L_sub( hIsmMetaData->last_true_elevation_fx, hIsmMetaData->last_elevation_fx ); test(); -#ifdef FIX_1500_ISM_MD_DTX IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( L_abs( diff_fx ), IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_ELEVATION_FX ) ) -#else - IF( GT_32( ism_total_brate, IVAS_SID_5k2 ) && GT_32( diff_fx, IVAS_ISM_DTX_HO_MAX * CNG_MD_MAX_DIFF_ELEVATION_FX ) ) -#endif { /* skip the smoothing */ } diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 45588e7cc8542f364eb8d6986fb578e18ed8a976..a3feb62ff24c407342543da582dee56a38670a22 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -753,22 +753,14 @@ void stereo_tcx_core_dec_fx( IF( st->hTdCngDec != NULL ) { -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); -#else - cng_params_upd_ivas_fx( lsptmp, res, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); -#endif } } ELSE IF( st->hTdCngDec != NULL ) { -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( &lsp_fx[M], st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); -#else - cng_params_upd_ivas_fx( &lsp_fx[M], st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, st->hFdCngDec->hFdCngCom->CngBandwidth ); -#endif } /* Set 16k LSP flag for CNG buffer */ diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index c6b658a2d9bb84959d0e9308db6d55fe39f45ea6..1776d31a236c3d7bf2be8f6be3ce7be37bff2e3f 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -839,66 +839,6 @@ void concealment_init_x( return; } -#ifndef HARM_COREDECODER_FUNCTIONS -void concealment_init_ivas_fx( - const Word16 L_frameTCX, - T_PLCInfo_HANDLE hPlcInfo ) -{ - Word16 i; - - hPlcInfo->L_frameTCX = L_frameTCX; - move16(); - hPlcInfo->Pitch_fx = 0; - move16(); - hPlcInfo->T_bfi_fx = 0; - move16(); - hPlcInfo->outx_new_n1_fx = 0; - move16(); - hPlcInfo->nsapp_gain_fx = 0; - move16(); - hPlcInfo->nsapp_gain_n_fx = 0; - move16(); - hPlcInfo->ener_mean_fx = L_deposit_l( 15213 ); - hPlcInfo->ener_fx = L_deposit_l( 0 ); - hPlcInfo->zp_fx = L_frameTCX; - move16(); - hPlcInfo->recovery_gain = 0; - move16(); - hPlcInfo->step_concealgain_fx = 0; - move16(); - hPlcInfo->concealment_method = TCX_NONTONAL; - move16(); - hPlcInfo->subframe_fx = 0; - move16(); - hPlcInfo->nbLostCmpt = (Word16) L_deposit_l( 0 ); - move16(); - hPlcInfo->seed = RANDOM_INITSEED; - move16(); - - FOR( i = 0; i < TCX_TONALITY_INIT_CNT; i++ ) - { - hPlcInfo->TCX_Tonality[i] = 1; - move16(); - } - FOR( i = TCX_TONALITY_INIT_CNT; i < DEC_STATE_LEN; i++ ) - { - hPlcInfo->TCX_Tonality[i] = 0; - move16(); - } - FOR( i = 0; i < MAX_POST_LEN; i++ ) - { - hPlcInfo->Transient[i] = 1; - move16(); - } - - FOR( i = 0; i < L_FRAME_MAX; i++ ) - { - hPlcInfo->data_reci2_fx[i] = L_deposit_l( 0 ); - move32(); - } - return; -} -#endif static Word16 own_random_fix( /* o : output random value */ Word16 *seed /* i/o: random seed Q0 */ diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c index 2cbb7da222ab3fd032d7ed890e22b064c467fef7..3be0ff74c399dafafe2093c70288201e6cbd9585 100644 --- a/lib_enc/FEC_enc_fx.c +++ b/lib_enc/FEC_enc_fx.c @@ -299,176 +299,3 @@ void FEC_lsf_estim_enc_fx( return; } -#ifndef FIX_2348_REPLACE_FEC_ENC -/*-------------------------------------------------------------------* - * FEC_encode() - * - * Encoder supplementary information for FEC - *-------------------------------------------------------------------*/ - -void FEC_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ - const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ - const Word16 coder_type, /* i : type of coder Q0*/ - Word16 clas, /* i : signal clas for current frame Q0*/ - const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ - const Word16 *res, /* i : LP residual signal frame Qx*/ - Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ - const Word16 L_frame, /* i : Frame length Q0*/ - const Word32 total_brate, /* i : total codec bitrate Q0*/ - const Word16 Q_synth /* i : input scaling */ -) -{ - Word16 tmpS, index; - Word16 maxi, sign, tmp_FER_pitch; - Word32 enr_q, Ltmp; - Word16 exp_enrq; - - tmpS = 0; - move16(); - enr_q = 1; - move16(); - sign = 0; - move16(); - test(); - test(); - IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && acelp_cfg.FEC_mode > 0 ) - { - /*-----------------------------------------------------------------* - * encode signal class (not needed for VC mode since it is clearly voiced) (2 bits) - *-----------------------------------------------------------------*/ - IF( NE_16( coder_type, VOICED ) ) - { - /* encode signal clas with 2 bits */ - test(); - IF( clas == UNVOICED_CLAS ) - { - index = 0; - move16(); - } - ELSE IF( EQ_16( clas, VOICED_TRANSITION ) || EQ_16( clas, UNVOICED_TRANSITION ) ) - { - index = 1; - move16(); - } - ELSE IF( EQ_16( clas, VOICED_CLAS ) ) - { - index = 2; - move16(); - } - ELSE - { - index = 3; - move16(); - } - push_indice( hBstr, IND_FEC_CLAS, index, FEC_BITS_CLS ); - } - - /*-----------------------------------------------------------------* - * encode frame energy (5 bits) - *-----------------------------------------------------------------*/ - IF( GT_16( acelp_cfg.FEC_mode, 1 ) ) /* GENERIC and VOICED frames */ - { - /* frame energy (maximum energy per pitch period for voiced frames or mean energy per sample over 2nd halframe for unvoiced frames) */ - /*frame_ener( L_frame, clas, synth, fpit[(L_frame>>6)-1], &enr_q, 0 );*/ - Word32 synth32[L_FRAME16k]; - Copy_Scale_sig_16_32_DEPREC( synth, synth32, L_FRAME16k, 0 ); /* Qsynth */ - fer_energy_fx( L_frame, clas, synth32, Q_synth, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), &enr_q, L_frame ); - exp_enrq = sub( 31, shl( Q_synth, 1 ) ); - - test(); - test(); - if ( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, ONSET ) || EQ_16( clas, SIN_ONSET ) ) /* Voiced or Onset current frame */ - { - exp_enrq = 31; - move16(); - } - /* linearly quantize the energy in the range 0 : FEC_ENR_STEP : 96 dB */ - /*tmpS = (short)( 10.0 * log10( enr_q + 0.001f ) / FEC_ENR_STEP )*/ /*To be converted fl_2_fx*/ - - Ltmp = Mpy_32_32( BASOP_Util_Log10( enr_q, exp_enrq ), 894784853 /* 10 / FEC_ENR_STEP Q28 */ ); // Q 25 + 28 - 31 = Q22 - IF( Ltmp < 0 ) - { - tmpS = extract_l( L_negate( L_shr( L_negate( Ltmp ), Q22 ) ) ); /* Q0 */ - } - ELSE - { - tmpS = extract_l( L_shr( Ltmp, Q22 ) ); /* Q0 */ - } - - tmpS = s_min( tmpS, FEC_ENR_QLIMIT ); - tmpS = s_max( tmpS, 0 ); - - push_indice( hBstr, IND_FEC_ENR, tmpS, FEC_BITS_ENR ); - } - /*-----------------------------------------------------------------* - * Encode last glottal pulse position (8 bits) - *-----------------------------------------------------------------*/ - - IF( GT_16( acelp_cfg.FEC_mode, 2 ) ) /* GENERIC frames */ - { - /* retrieve the last glottal pulse position of the previous frame */ - /* use the current pitch information to scale or not the quantization */ - tmp_FER_pitch = shr( fpit[0], 6 ); /* take the 1st subframe pit, since it is easier to get on decoder side */ - sign = 0; - move16(); - maxi = *last_pulse_pos; /* Q0 */ - move16(); - IF( maxi < 0 ) - { - sign = 1; - move16(); - /*maxi = -maxi; */ - maxi = negate( maxi ); - } - - if ( GE_16( tmp_FER_pitch, 128 ) ) - { - maxi = shr( maxi, 1 ); - } - - if ( GT_16( maxi, 127 ) ) - { - /* better not use the glottal pulse position at all instead of using a wrong pulse */ - /* can happen only with pitch > 254 and max pit = 289 and should happen very rarely */ - maxi = 0; - move16(); - } - - if ( EQ_16( sign, 1 ) ) - { - maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse) Q0*/ - } - - push_indice( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS ); - } - maxi = 0; - move16(); - - /* If bitrate < 24k4, then the pitch - is not represented in the same domain (12.k instead of 16k) */ - test(); - IF( GE_16( clas, VOICED_CLAS ) && GE_32( total_brate, ACELP_24k40 ) ) - { - /*maxi = findpulse( L_frame, res, (short)(fpit[(L_frame>>6)-1]), 0, &sign ); */ - maxi = findpulse_fx( L_frame, res, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), 0, &sign ); - if ( EQ_16( sign, 1 ) ) - { - /*maxi = -maxi;*/ - maxi = negate( maxi ); - } - } - - *last_pulse_pos = maxi; /* Q0 */ - move16(); - } - ELSE - { - *last_pulse_pos = 0; - move16(); - } - - return; -} -#endif diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index ad0ca1346dbbcb7be00c29c2a4452e64bb61984d..c5dc5e51196e8e1a18583a0705b8ce5f4728fe2a 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -97,9 +97,7 @@ ivas_error acelp_core_enc_fx( error = IVAS_ERR_OK; (void) hStereoTD; -#ifdef HARM_NON_LINEARITY (void) ener_fx; -#endif /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ @@ -277,20 +275,11 @@ ivas_error acelp_core_enc_fx( IF( EQ_16( st_fx->cng_type, LP_CNG ) ) { /* Run CNG post parameter update */ -#ifdef HARM_NON_LINEARITY cng_params_postupd_fx( hTdCngEnc->ho_circ_ptr, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hTdCngEnc->ho_env_circ_fx, EVS_MONO, -1 ); -#else - cng_params_postupd_fx( hTdCngEnc->ho_circ_ptr, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, - hTdCngEnc->cng_brate_buf, hTdCngEnc->ho_env_circ_fx ); -#endif /* encode CNG parameters */ -#ifdef HARM_NON_LINEARITY CNG_enc_fx( st_fx, Aq_fx, inp_fx, lsp_mid_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sub( Q_new, 1 ), q_env, &sid_bw ); -#else - CNG_enc_fx( st_fx, Aq_fx, inp_fx, ener_fx, lsp_mid_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sub( Q_new, 1 ), q_env, &sid_bw ); -#endif /* comfort noise generation */ CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &hTdCngEnc->Enew_fx, &hTdCngEnc->cng_seed, exc_fx, exc2_fx, &hTdCngEnc->lp_ener_fx, st_fx->last_core_brate, @@ -625,11 +614,7 @@ ivas_error acelp_core_enc_fx( IF( !st_fx->Opt_SC_VBR ) { /* Apply a non linearity to the SHB excitation */ -#ifdef HARM_NON_LINEARITY non_linearity_fx( st_fx->element_mode, bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, coder_type, voice_factors_fx, st_fx->L_frame ); -#else - non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, coder_type, voice_factors_fx, st_fx->L_frame ); -#endif } test(); if ( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, FRAME_NO_DATA ) ) @@ -647,14 +632,8 @@ ivas_error acelp_core_enc_fx( IF( hTdCngEnc != NULL && ( st_fx->Opt_DTX_ON != 0 ) && ( GT_32( st_fx->core_brate, SID_2k40 ) ) ) { /* update CNG parameters in active frames */ -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate, EVS_MONO, -1 ); -#else - cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, - &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, - hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate ); -#endif IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { @@ -974,18 +953,10 @@ ivas_error acelp_core_enc_ivas_fx( IF( st->cng_type == LP_CNG ) { /* Run CNG post parameter update */ -#ifdef HARM_NON_LINEARITY cng_params_postupd_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#else - cng_params_postupd_ivas_fx( st->hTdCngEnc->ho_circ_ptr, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hTdCngEnc->ho_env_circ_fx, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#endif /* encode CNG parameters */ -#ifdef HARM_NON_LINEARITY CNG_enc_fx( st, Aq, inp, lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw ); -#else - CNG_enc_ivas_fx( st, Aq, inp, /*ener_fx,*/ lsp_mid, lsp_new, lsf_new_fx, &allow_cn_step, sub( Q_new, 1 ), q_env_fx, &sid_bw ); -#endif /* comfort noise generation */ CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngEnc->Enew_fx, &st->hTdCngEnc->cng_seed, exc_fx, exc2_fx, &st->hTdCngEnc->lp_ener_fx, st->last_core_brate, @@ -1233,11 +1204,7 @@ ivas_error acelp_core_enc_ivas_fx( calc_residu_fx( st, inp, res_fx, Aq ); -#ifdef HARM_NON_LINEARITY calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); -#else - calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); -#endif IF( NE_16( att_fx, 32767 /* ONE_IN_Q15 */ ) ) { @@ -1369,13 +1336,7 @@ ivas_error acelp_core_enc_ivas_fx( * Encode supplementary information for Frame Error Concealment *-----------------------------------------------------------------*/ -#ifndef FIX_2348_REPLACE_FEC_ENC - Scale_sig( syn_fx, L_FRAME, sub( s_min( st->Q_syn, Q_new ), st->Q_syn ) ); // min( st->Q_syn, Q_new ) - Scale_sig( res_fx, st->L_frame, sub( s_min( st->Q_syn, Q_new ), Q_new ) ); // min( st->Q_syn, Q_new ) - FEC_encode_ivas_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, s_min( st->Q_syn, Q_new ) ); -#else FEC_encode_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, add( st->Q_syn, 1 ), 0 ); -#endif IF( st->hBWE_TD != NULL ) { @@ -1440,11 +1401,7 @@ ivas_error acelp_core_enc_ivas_fx( { /* Apply a non linearity to the SHB excitation */ Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc -#ifdef HARM_NON_LINEARITY non_linearity_fx( st->element_mode, bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); -#else - non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, Q_new, st->coder_type, voice_factors_fx, st->L_frame ); -#endif Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc } @@ -1491,15 +1448,8 @@ ivas_error acelp_core_enc_ivas_fx( move16(); } -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#else - cng_params_upd_ivas_fx( lsp_new, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, - &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, - st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, - st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#endif IF( EQ_16( st->L_frame, L_FRAME ) ) { diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 985c2852b5b80c67e2784e6a65e8c50c802f9757..876cc94fdea57a9c793cf063f1817efe14352b32 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -459,11 +459,7 @@ void amr_wb_enc_fx( IF( EQ_32( st->core_brate, SID_1k75 ) || EQ_32( st->core_brate, FRAME_NO_DATA ) ) { /* encode CNG parameters */ -#ifdef HARM_NON_LINEARITY CNG_enc_fx( st, Aq, inp, isp_new, isp_new, isf_new, &allow_cn_step, sub( Q_new, 1 ), q_env, &sid_bw ); -#else - CNG_enc_fx( st, Aq, inp, ener, isp_new, isp_new, isf_new, &allow_cn_step, sub( Q_new, 1 ), q_env, &sid_bw ); -#endif /* comfort noise generation */ CNG_exc_fx( st->core_brate, L_FRAME, &hTdCngEnc->Enew_fx, &hTdCngEnc->cng_seed, exc, exc2, &hTdCngEnc->lp_ener_fx, diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 7e63dc13932dd04ed85dcb62901d0c7aa5e36a71..e622c9857e3c3ffbd9c80d2769ad8e1cd079e62b 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -28,10 +28,6 @@ static void shb_CNG_encod_fx( Encoder_State *st_fx, const Word16 update_fx ); static Word16 shb_DTX_fx( Encoder_State *st_fx, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k ); -#ifndef HARM_NON_LINEARITY -static Word16 shb_DTX_ivas_fx( Encoder_State *st, const Word16 *shb_speech_fx, const Word16 *syn_12k8_16k_fx ); -static void shb_CNG_encod_ivas_fx( Encoder_State *st, const Word16 update ); -#endif /*---------------------------------------------------------------------* @@ -40,1143 +36,7 @@ static void shb_CNG_encod_ivas_fx( Encoder_State *st, const Word16 update ); * Confort noise generation for the coder *---------------------------------------------------------------------*/ -#ifndef HARM_NON_LINEARITY void CNG_enc_fx( - Encoder_State *st_fx, /* i/o: State structure */ - Word16 Aq[], /* o : LP coefficients Q12 */ - const Word16 *speech, /* i : pointer to current frame input speech buffer Q_new */ - Word32 L_enr, /* i : residual energy from Levinson-Durbin Q6 */ - const Word16 *lsp_mid, /* i : mid frame LSPs Q15 */ - Word16 *lsp_new, /* i/o: current frame ISPs Q15 */ - Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */ - Word16 *allow_cn_step, /* o : allow CN step Q0 */ - Word16 Q_new, /* i : Q value of speech */ - Word32 *q_env, - Word16 *sid_bw ) -{ - Word16 enr_index; - Word16 i, j, ptr; - Word16 m1; - Word16 res[L_FRAME16k]; - Word16 step_inv = 0; - move16(); - Word16 hi, lo; - Word16 maxl = 0; - move16(); - Word16 num_bits = 0; - move16(); - Word16 step = 0; - move16(); - Word16 *pt_res; - const Word16 *pt_sp; - Word16 enr; - Word32 L_tmp, L_ener; - Word16 k, tmp1; - Word16 weights; - Word16 sp_enr; - Word32 L_tmp1; - Word16 exp; - Word16 m = 0; - move16(); - Word16 tmp[HO_HIST_SIZE * M]; - Word16 ll, s_ptr; - Word16 tmpv, maxv, scale, att = 1; - move16(); - Word16 lsf_tmp[M]; - Word32 C[M]; - Word32 max_val[2]; - Word16 max_idx[2]; - Word16 ftmp_fx; - Word16 lsp_tmp[M]; - Word16 dev; - Word16 max_dev; - Word16 dist; - Word16 max_idx1[2] = { 0, 0 }; - move16(); - move16(); - Word16 fft_io[L_FRAME16k]; - Word16 *ptR, *ptI; - Word32 enr1 = 0; - move32(); - Word32 env[NUM_ENV_CNG]; - Word32 min1; - Word16 min1_idx; - Word32 d; - Word16 res1[L_FRAME16k]; - Word32 tmp_env[HO_HIST_SIZE * NUM_ENV_CNG]; - Word16 fra; - Word16 temp_lo_fx, temp_hi_fx; - Word16 exp_pow; - Word16 force_cn_step = 0; - move16(); - Word16 tmp_loop; - Word16 st_lp_sp_enr; - DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx; - move16(); - Word16 lp_ener_thr_scale; - - lp_ener_thr_scale = 8; /* 4.0f*/ /*IVAS_CODE Q2 */ - move16(); - if ( st_fx->element_mode != EVS_MONO ) - { - lp_ener_thr_scale = 7; /* 3.5f;*/ - move16(); - } - /*sp_enr = (float) log10( sum2_f( speech, L_frame )/L_frame + 0.1f )/ (float)log10(2.0f);*/ /*9.1 */ - pt_sp = speech; - L_ener = L_deposit_l( 1 ); - /* L_ener = L_add(L_shr(sum2_f_fx( speech, L_frame ), 8) , L_ener);*/ - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - FOR( j = 0; j < 128; j++ ) - { - L_tmp = L_mult0( *pt_sp, *pt_sp ); - pt_sp++; - L_tmp = L_mac0( L_tmp, *pt_sp, *pt_sp ); - pt_sp++; - L_ener = L_add( L_ener, L_shr( L_tmp, 7 ) ); /* 2*Q_new + 1, divide by L_frame done here */ - } - } - ELSE /* L_FRAME16k */ - { - FOR( i = 0; i < 2; i++ ) - { - FOR( j = 0; j < 80; j++ ) - { - L_tmp = L_mult0( *pt_sp, *pt_sp ); - pt_sp++; - L_tmp = L_mac0( L_tmp, *pt_sp, *pt_sp ); - pt_sp++; - L_ener = L_add( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*Q_new + 1, divide by L_frame done here */ - } - } - } - - hi = norm_l( L_ener ); - lo = Log2_norm_lc( L_shl( L_ener, hi ) ); - hi = sub( 29, hi ); /* log2 exp in Q2*Q_new */ - hi = sub( hi, shl( Q_new, 1 ) ); /* Q0 */ - L_tmp = L_Comp( hi, lo ); /* Q16 */ - sp_enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */ - - if ( sp_enr < 0 ) - { - sp_enr = 0; - move16(); - } - test(); - IF( hDtxEnc->first_CNG == 0 || hTdCngEnc->old_enr_index < 0 ) - { - hTdCngEnc->lp_sp_enr_fx = sp_enr; - move16(); /* Q8 */ - } - ELSE - { - test(); - test(); - test(); - test(); - test(); - IF( GT_32( st_fx->last_core_brate, SID_2k40 ) && ( EQ_16( st_fx->last_core, HQ_CORE ) || st_fx->hTdCngEnc->burst_ho_cnt > 0 ) && LT_16( hTdCngEnc->lp_sp_enr_fx, 1536 /*6.0f in Q8*/ ) && - GT_16( sub( sp_enr, hTdCngEnc->lp_sp_enr_fx ), 1024 /*4.0f in Q8*/ ) && GT_16( sp_enr, 1536 /*6.0f in Q8*/ ) ) - { - hTdCngEnc->lp_sp_enr_fx = sp_enr; - move16(); - force_cn_step = 1; - move16(); - } - ELSE - { - hTdCngEnc->lp_sp_enr_fx = round_fx( L_mac( L_mult( 29491 /* 0.9, Q15 */, hTdCngEnc->lp_sp_enr_fx ), 3277 /* 0.1, Q15 */, sp_enr ) ); /* Q8 (8+15+1-16) */ - move16(); - } - } - /* update the pointer to circular buffer of old LSP vectors */ - hTdCngEnc->cng_hist_ptr = add( hTdCngEnc->cng_hist_ptr, 1 ); - move16(); - if ( EQ_16( hTdCngEnc->cng_hist_ptr, DTX_HIST_SIZE ) ) - { - hTdCngEnc->cng_hist_ptr = 0; - move16(); - } - - /* update the circular buffer of old LSP vectors with the new LSP vector */ - Copy( lsp_new, &( hTdCngEnc->cng_lsp_hist_fx[( hTdCngEnc->cng_hist_ptr ) * M] ), M ); - - /*-----------------------------------------------------------------* - * Find CNG spectral envelope - * Find LSP median - *-----------------------------------------------------------------*/ - test(); - test(); - IF( ( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) && GE_16( hDtxEnc->cng_cnt, sub( hDtxEnc->cng_hist_size, 1 ) ) ) - { - set32_fx( max_val, 0, 2 ); - set16_fx( max_idx, 0, 2 ); - - FOR( i = 0; i < hDtxEnc->cng_hist_size; i++ ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_FX ); - ftmp_fx = 964; /*(6400/(M+1))X2.56 */ - move16(); /*QX2.56 */ - tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */ - L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */ - } - ELSE - { - lsp2lsf_fx( &hTdCngEnc->cng_lsp_hist_fx[i * M], lsf_tmp, M, INT_FS_16k ); - ftmp_fx = 1205; /*(8000/(M+1))X2.56*/ - move16(); /*QX2.56 */ - tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */ - L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */ - } - - tmpv = sub( lsf_tmp[0], ftmp_fx ); /*QX2.56 */ - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */ - FOR( j = 0; j < M - 1; j++ ) - { - tmpv = sub( sub( lsf_tmp[j + 1], lsf_tmp[j] ), ftmp_fx ); /*QX2.56 */ - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */ - } - - C[i] = Mpy_32_16_1( L_tmp, 1928 /*.0588235f Q15*/ ); - move32(); /*QX6.5536 */ - - IF( GT_32( C[i], max_val[0] ) ) - { - max_val[1] = max_val[0]; - move32(); - max_idx[1] = max_idx[0]; - move16(); - max_val[0] = C[i]; - move32(); - max_idx[0] = i; - move16(); - } - ELSE IF( GT_32( C[i], max_val[1] ) ) - { - max_val[1] = C[i]; - move32(); - max_idx[1] = i; - move16(); - } - } - - FOR( i = 0; i < M; i++ ) - { - L_tmp = 0; - move32(); - FOR( j = 0; j < hDtxEnc->cng_hist_size; j++ ) - { - L_tmp = L_add( L_tmp, L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[j * M + i] ) ); /*Q15 */ - } - - L_tmp = L_sub( L_tmp, L_add( L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[max_idx[0] * M + i] ), L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[max_idx[1] * M + i] ) ) ); /*Q15 */ - tmpv = div_s( 1, sub( hDtxEnc->cng_hist_size, 2 ) ); /*Q15 */ - L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ - lsp_new[i] = extract_l( L_tmp ); /*Q15 */ - move16(); - } - max_idx1[0] = max_idx[0]; - move16(); - max_idx1[1] = max_idx[1]; - move16(); - } - - /*-----------------------------------------------------------------* - * Quantize CNG spectral envelope (only in SID frame) - * Quantize the LSF vector - *-----------------------------------------------------------------*/ - *allow_cn_step = 0; - move16(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( hDtxEnc->cng_cnt == 0 ) && - GT_16( hTdCngEnc->lp_sp_enr_fx, 1536 /* 6.0, Q8 */ ) && - ( LT_16( add( st_lp_sp_enr, 1024 /* 4.0, Q8 */ ), sp_enr ) ) && - ( hDtxEnc->first_CNG != 0 ) && - ( hTdCngEnc->old_enr_index >= 0 ) && - ( GT_32( st_fx->last_core_brate, SID_2k40 ) ) ) || - EQ_16( force_cn_step, 1 ) ) - { - *allow_cn_step = 1; - move16(); - } - - /* Initialize the CNG spectral envelope in case of the very first CNG frame */ - IF( hDtxEnc->first_CNG == 0 ) - { - Copy( st_fx->lsp_old_fx, hDtxEnc->lspCNG_fx, M ); - - /* Average the CNG spectral envelope in case of the very first CNG frame */ - IF( st_fx->element_mode != EVS_MONO ) - { - FOR( i = 0; i < M; i++ ) - { - /*lsp_new[i] = 0.5f * (lsp_mid[i] + lsp_new[i]);*/ - lsp_new[i] = mac_r( L_mult( lsp_mid[i], 16384 ), lsp_new[i], 16384 /*.5 Q15*/ ); - move16(); - } - } - } - - - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) - { - /* LSF quantization */ - IF( st_fx->Opt_AMR_WB != 0 ) - { - isf_enc_amr_wb_fx( st_fx, lsf_new, lsp_new, 0 ); - } - ELSE - { - lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); - } - - /* Reset CNG history if CNG frame length is changed */ - test(); - test(); - if ( EQ_16( st_fx->bwidth, WB ) && hDtxEnc->first_CNG != 0 && NE_16( st_fx->L_frame, hDtxEnc->last_CNG_L_frame ) ) - { - hTdCngEnc->ho_hist_size = 0; - move16(); - } - } - ELSE - { - /* Use old LSP vector */ - Copy( st_fx->lsp_old_fx, lsp_new, M ); - Copy( st_fx->lsf_old_fx, lsf_new, M ); - } - - /*---------------------------------------------------------------------* - * CNG spectral envelope update - * Find A(z) coefficients - *---------------------------------------------------------------------*/ - - IF( LE_32( st_fx->last_core_brate, SID_2k40 ) ) - { - /* Reset hangover counter if not first SID period */ - if ( GT_32( st_fx->core_brate, FRAME_NO_DATA ) ) - { - hTdCngEnc->num_ho = 0; - move16(); - } - /* Update LSPs if last SID energy not outlier or insufficient number of hangover frames */ - test(); - IF( LT_16( hTdCngEnc->num_ho, 3 ) || LT_32( Mult_32_16( hTdCngEnc->Enew_fx, 21845 /*1/1.5f, Q15*/ ), hTdCngEnc->lp_ener_fx ) ) - { - FOR( i = 0; i < M; i++ ) - { - /* AR low-pass filter */ - hDtxEnc->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, hDtxEnc->lspCNG_fx[i] ), 32768 - CNG_ISF_FACT_FX, lsp_new[i] ); - move16(); /* Q15 (15+15+1-16) */ - } - } - } - ELSE - { - /* Update CNG_mode if allowed */ - test(); - test(); - test(); - test(); - IF( st_fx->element_mode == EVS_MONO && ( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !hDtxEnc->first_CNG || GE_16( hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) ) ) - { - IF( GT_32( hDtxEnc->last_active_brate, ACELP_16k40 ) ) - { - hDtxEnc->CNG_mode = -1; - move16(); - } - ELSE - { - hDtxEnc->CNG_mode = get_cng_mode( hDtxEnc->last_active_brate ); - move16(); - } - } - - /* If first sid after active burst update LSF history from circ buffer */ - hTdCngEnc->burst_ho_cnt = s_min( hTdCngEnc->burst_ho_cnt, hTdCngEnc->ho_circ_size ); - move16(); - hTdCngEnc->act_cnt = 0; - move16(); - s_ptr = add( sub( hTdCngEnc->ho_circ_ptr, hTdCngEnc->burst_ho_cnt ), 1 ); - - if ( s_ptr < 0 ) - { - s_ptr = add( s_ptr, hTdCngEnc->ho_circ_size ); - } - - FOR( ll = hTdCngEnc->burst_ho_cnt; ll > 0; ll-- ) - { - hTdCngEnc->ho_hist_ptr = add( hTdCngEnc->ho_hist_ptr, 1 ); - move16(); - if ( EQ_16( hTdCngEnc->ho_hist_ptr, HO_HIST_SIZE ) ) - { - hTdCngEnc->ho_hist_ptr = 0; - move16(); - } - - /* Conversion between 12.8k and 16k LSPs */ - test(); - test(); - IF( EQ_16( st_fx->L_frame, L_FRAME ) && EQ_16( hTdCngEnc->ho_16k_lsp[s_ptr], 1 ) ) - { - /* Conversion from 16k LPSs to 12k8 */ - lsp_convert_poly_fx( &( hTdCngEnc->ho_lsp_circ_fx[s_ptr * M] ), st_fx->L_frame, 0 ); - } - ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && hTdCngEnc->ho_16k_lsp[s_ptr] == 0 ) - { - /* 16k LSPs already converted and stored, just copy to the other buffer */ - Copy( &( hTdCngEnc->ho_lsp_circ2_fx[s_ptr * M] ), &( hTdCngEnc->ho_lsp_circ_fx[s_ptr * M] ), M ); - } - /* update the circular buffers */ - Copy( &( hTdCngEnc->ho_lsp_circ_fx[s_ptr * M] ), &( hTdCngEnc->ho_lsp_hist_fx[hTdCngEnc->ho_hist_ptr * M] ), M ); - Copy32( &( hTdCngEnc->ho_ener_circ_fx[s_ptr] ), &( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 1 ); - hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); - move32(); - Copy32( &( hTdCngEnc->ho_env_circ_fx[s_ptr * NUM_ENV_CNG] ), &( hTdCngEnc->ho_env_hist_fx[hTdCngEnc->ho_hist_ptr * NUM_ENV_CNG] ), NUM_ENV_CNG ); - - hTdCngEnc->ho_hist_size = add( hTdCngEnc->ho_hist_size, 1 ); - move16(); - if ( GT_16( hTdCngEnc->ho_hist_size, HO_HIST_SIZE ) ) - { - hTdCngEnc->ho_hist_size = HO_HIST_SIZE; - move16(); - } - - s_ptr = add( s_ptr, 1 ); - - if ( EQ_16( s_ptr, hTdCngEnc->ho_circ_size ) ) - { - s_ptr = 0; - move16(); - } - } - - IF( hTdCngEnc->burst_ho_cnt > 0 ) - { - /**allow_cn_step |= ( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] > 4 * hTdCngEnc->lp_ener_fx ); */ - /*allow_cn_step |= (hDtxEnc->first_CNG || st->element_mode == EVS_MONO) && (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener);*/ - /* (hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener); */ - L_tmp1 = L_shr( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], 2 ); - IF( NE_16( lp_ener_thr_scale, 8 ) ) - { - L_tmp1 = L_add( L_tmp1, L_shr( hTdCngEnc->lp_ener_fx, 8 ) ); - } - L_tmp1 = L_sub( L_tmp1, hTdCngEnc->lp_ener_fx ); - test(); - test(); - IF( ( hDtxEnc->first_CNG > 0 || st_fx->element_mode == EVS_MONO ) && L_tmp1 > 0 ) - { - *allow_cn_step = s_or( *allow_cn_step, 1 ); - move16(); - } - } - test(); - IF( *allow_cn_step == 0 && hTdCngEnc->ho_hist_size > 0 ) - { - /* Use average of energies below last energy */ - ptr = hTdCngEnc->ho_hist_ptr; - move16(); - Copy( &( hTdCngEnc->ho_lsp_hist_fx[ptr * M] ), tmp, M ); - m1 = 0; - move16(); - IF( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x1 ) == 0 ) - { - Copy32( &hTdCngEnc->ho_env_hist_fx[ptr * NUM_ENV_CNG], tmp_env, NUM_ENV_CNG ); - m1 = 1; - move16(); - } - L_enr = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[0] ); /* Q6+15-15->Q6 */ - - weights = W_DTX_HO_FX[0]; /* Q15 */ - move16(); - m = 1; - move16(); - FOR( k = 1; k < hTdCngEnc->ho_hist_size; k++ ) - { - ptr = sub( ptr, 1 ); - if ( ptr < 0 ) - { - ptr = HO_HIST_SIZE - 1; - move16(); - } - - test(); - IF( LT_32( Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], ONE_OVER_BUF_H_NRG_FX ), hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ) && - GT_32( hTdCngEnc->ho_ener_hist_fx[ptr], Mult_32_16( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr], BUF_L_NRG_FX ) ) ) - { - /*enr += W_DTX_HO[k] * st_fx->ho_ener_hist[ptr]; */ - L_tmp1 = Mult_32_16( hTdCngEnc->ho_ener_hist_fx[ptr], W_DTX_HO_FX[k] ); /* Q6+15-15->Q6 */ - L_enr = L_add( L_enr, L_tmp1 ); /* Q6 */ - - /*weights += W_DTX_HO[k]; */ - weights = add( weights, W_DTX_HO_FX[k] ); /* Q15 */ - - Copy( &hTdCngEnc->ho_lsp_hist_fx[ptr * M], &tmp[m * M], M ); - IF( L_and( hTdCngEnc->ho_sid_bw, L_shl( (Word32) 0x1, k ) ) == 0 ) - { - Copy32( &hTdCngEnc->ho_env_hist_fx[ptr * NUM_ENV_CNG], &tmp_env[m1 * NUM_ENV_CNG], NUM_ENV_CNG ); - m1 = add( m1, 1 ); - } - m = add( m, 1 ); - } - } - - /*enr /= weights; */ - exp = norm_s( weights ); - tmp1 = div_s( shl( 1, sub( 14, exp ) ), weights ); /* Q(15+14-exp-15) */ - L_tmp1 = Mult_32_16( L_enr, tmp1 ); /* Q(14-exp+6-15)->Q(5-exp) */ - L_enr = L_shl( L_tmp1, add( exp, 1 ) ); /* Q6 */ - - hTdCngEnc->lp_ener_fx = L_enr; - move32(); /* Q6 */ - - set32_fx( max_val, 0, 2 ); - set16_fx( max_idx, 0, 2 ); - - FOR( i = 0; i < m; i++ ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_FX ); - ftmp_fx = 964; /*(6400/(M+1))X2.56*/ - move16(); /*QX2.56 */ - tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */ - L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */ - } - ELSE - { - lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_16k ); - ftmp_fx = 1205; /*(8000/(M+1))X2.56*/ - move16(); /*QX2.56 */ - tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56 */ - L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536 */ - } - - tmpv = sub( lsf_tmp[0], ftmp_fx ); /*QX2.56 */ - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */ - FOR( j = 0; j < M - 1; j++ ) - { - tmpv = sub( sub( lsf_tmp[j + 1], lsf_tmp[j] ), ftmp_fx ); /*QX2.56 */ - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536 */ - } - - C[i] = Mpy_32_16_1( L_tmp, 1928 ); - move32(); /*QX6.5536 */ - - IF( GT_32( C[i], max_val[0] ) ) - { - max_val[1] = max_val[0]; - move32(); - max_idx[1] = max_idx[0]; - move16(); - max_val[0] = C[i]; - move32(); - max_idx[0] = i; - move16(); - } - ELSE IF( GT_32( C[i], max_val[1] ) ) - { - max_val[1] = C[i]; - move32(); - max_idx[1] = i; - move16(); - } - } - - IF( EQ_16( m, 1 ) ) - { - Copy( tmp, lsp_tmp, M ); - } - ELSE IF( LT_16( m, 4 ) ) - { - FOR( i = 0; i < M; i++ ) - { - L_tmp = L_deposit_l( 0 ); - FOR( j = 0; j < m; j++ ) - { - L_tmp = L_add( L_tmp, L_deposit_l( tmp[j * M + i] ) ); - } - - L_tmp = L_sub( L_tmp, L_deposit_l( tmp[max_idx[0] * M + i] ) ); - tmpv = div_s( 1, sub( m, 1 ) ); /*Q15 */ - L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ - lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */ - } - } - ELSE - { - FOR( i = 0; i < M; i++ ) - { - L_tmp = L_deposit_l( 0 ); - FOR( j = 0; j < m; j++ ) - { - L_tmp = L_add( L_tmp, L_deposit_l( tmp[j * M + i] ) ); - } - - L_tmp = L_sub( L_tmp, L_add( L_deposit_l( tmp[max_idx[0] * M + i] ), L_deposit_l( tmp[max_idx[1] * M + i] ) ) ); /*Q15 */ - tmpv = div_s( 1, sub( m, 2 ) ); /*Q15 */ - L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ - lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */ - } - } - - dist = 0; /*Q15 */ - max_dev = 0; /*Q15 */ - move16(); - move16(); - FOR( i = 0; i < M; i++ ) - { - dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */ - dist = add_sat( dist, dev ); /*Q15 */ - if ( GT_16( dev, max_dev ) ) - { - max_dev = dev; - move16(); - } - } - - test(); - IF( GT_16( dist, 13107 ) || GT_16( max_dev, 3277 ) ) - { - FOR( i = 0; i < M; i++ ) - { - hDtxEnc->lspCNG_fx[i] = lsp_tmp[i]; - move16(); /*Q15 */ - } - } - ELSE - { - FOR( i = 0; i < M; i++ ) - { - /* AR low-pass filter */ - hDtxEnc->lspCNG_fx[i] = add( mult_r( 26214, lsp_tmp[i] ), mult_r( 6554, lsp_new[i] ) ); - move16(); - } - } - IF( m1 > 0 ) - { - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - L_tmp = L_deposit_l( 0 ); - FOR( j = 0; j < m1; j++ ) - { - /* env[i] += tmp_env[j*NUM_ENV_CNG+i]; */ - L_tmp = L_add_sat( L_tmp, tmp_env[j * NUM_ENV_CNG + i] ); - } - /* env[i] /= (float)m1; */ - /* env[i] = env[i] - 2*hTdCngEnc->lp_ener_fx; */ - IF( EQ_16( m1, 1 ) ) - { - L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); - } - ELSE - { - tmp1 = div_s( 1, m1 ); - L_tmp = Mult_32_16( L_tmp, tmp1 ); - L_tmp = L_sub_sat( L_tmp, L_add_sat( hTdCngEnc->lp_ener_fx, hTdCngEnc->lp_ener_fx ) ); - } - - env[i] = L_tmp; - move32(); - } - Copy32( env, hTdCngEnc->lp_env_fx, NUM_ENV_CNG ); - } - } - ELSE - { - Copy( lsp_new, hDtxEnc->lspCNG_fx, M ); /* use newly analyzed ISFs */ - } - } - IF( st_fx->Opt_AMR_WB != 0 ) - { - E_LPC_f_isp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M ); - } - ELSE - { - E_LPC_f_lsp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M ); /* Find A(z) (not interpolated) */ - } - - tmp_loop = shr( st_fx->L_frame, 6 ); - FOR( i = 1; i < tmp_loop; i++ ) - { - Copy( Aq, &Aq[i * ( M + 1 )], M + 1 ); - } - /*-----------------------------------------------------------------* - * Find residual signal - * Calculate residual signal energy per sample - *-----------------------------------------------------------------*/ - - /* calculate the residual signal */ - Residu3_fx( Aq, speech, res, st_fx->L_frame, 0 ); - Copy( res, res1, st_fx->L_frame ); - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - } - ELSE IF( NE_16( st_fx->bwidth, NB ) ) - { - test(); - IF( EQ_16( st_fx->bwidth, WB ) && hDtxEnc->CNG_mode >= 0 ) - { - ftmp_fx = HO_ATT_FX[hDtxEnc->CNG_mode]; - move16(); - } - ELSE - { - ftmp_fx = 19661; /*0.6f in Q15*/ - move16(); - } - - att = mult( ftmp_fx, 5461 /*1/6f in Q15*/ ); /* Q15 */ - L_tmp = L_mult( att, 8 ); /* Q16 */ - tmp1 = extract_l( L_shr( L_tmp, 2 ) ); /* Q14 */ - tmp1 = add( 16384, tmp1 ); - att = div_s( 16374, tmp1 ); /* Q15 */ - - att = s_max( att, ftmp_fx ); - FOR( i = 0; i < st_fx->L_frame; i++ ) - { - /*res1[i] *= att;*/ - res1[i] = mult( res1[i], att ); - move16(); /* Q_new */ - } - att = shr( att, 7 ); /* Q8 */ - } - - /* calculate the spectrum of residual signal */ - Copy( res1, fft_io, st_fx->L_frame ); - - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, hTdCngEnc->exc_mem2_fx, 0 ); - } - - fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT ); - ptR = &fft_io[1]; - ptI = &fft_io[L_FFT - 1]; - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ - L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_new+1 */ - L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */ - L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */ - L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */ - tmp1 = add( add( Q_new, Q_new ), 1 ); - env[i] = L_shr( L_tmp, sub( tmp1, 6 ) ); - move32(); /* Q6 */ - ptR++; - ptI--; - } - - Copy32( env, &( hTdCngEnc->cng_res_env_fx[( hTdCngEnc->cng_hist_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG ); - - /* calculate the residual signal energy */ - /*enr = dotp( res, res, L_frame ) / L_frame; */ - maxv = 0; - move16(); - FOR( i = 0; i < st_fx->L_frame; i++ ) - { - maxv = s_max( maxv, abs_s( res[i] ) ); - } - scale = norm_s( maxv ); - pt_res = res; - L_ener = L_deposit_l( 1 ); - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - FOR( j = 0; j < 128; j++ ) - { - tmpv = shl( *pt_res, scale ); - L_tmp = L_mult0( tmpv, tmpv ); - pt_res++; - tmpv = shl( *pt_res, scale ); - L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */ - pt_res++; - L_ener = L_add_sat( L_ener, L_shr( L_tmp, 7 ) ); /* 2*(Q_new+scale)+1, divide by L_frame done here */ - } - } - ELSE /* L_FRAME16k */ - { - FOR( j = 0; j < 160; j++ ) - { - tmpv = shl( *pt_res, scale ); - L_tmp = L_mult0( tmpv, tmpv ); - pt_res++; - tmpv = shl( *pt_res, scale ); - L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv ); /* 2*(Q_new+scale) */ - pt_res++; - L_ener = L_add_sat( L_ener, L_shr( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* 2*(Q_new+scale)+15+1-16+1, divide by L_frame done here */ - } - } - /* convert log2 of residual signal energy */ - /*enr = (float)log10( enr + 0.1f ) / (float)log10( 2.0f ); */ - hi = norm_l( L_ener ); - lo = Log2_norm_lc( L_shl( L_ener, hi ) ); - hi = sub( 29, hi ); /* log2 exp in Q2*(Q_new+scale) */ - hi = sub( hi, shl( add( Q_new, scale ), 1 ) ); /* Q0 */ - L_tmp = L_Comp( hi, lo ); /* Q16 */ - enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */ - - /* update the circular buffer of old energies */ - hTdCngEnc->cng_ener_hist_fx[hTdCngEnc->cng_hist_ptr] = enr; - move16(); /* Q8 */ - - /*-----------------------------------------------------------------* - * Quantize residual signal energy (only in SID frame) - *-----------------------------------------------------------------*/ - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) - { - IF( GE_16( hDtxEnc->cng_cnt, sub( hDtxEnc->cng_hist_size, 1 ) ) ) - { - /* average the envelope except outliers */ - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - L_tmp1 = L_add( env[i], 0 ); - FOR( j = 0; j < hDtxEnc->cng_hist_size; j++ ) - { - L_tmp1 = L_add_sat( L_tmp1, hTdCngEnc->cng_res_env_fx[j * NUM_ENV_CNG + i] ); - } - L_tmp = L_add( hTdCngEnc->cng_res_env_fx[max_idx1[0] * NUM_ENV_CNG + i], hTdCngEnc->cng_res_env_fx[max_idx1[1] * NUM_ENV_CNG + i] ); - L_tmp1 = L_sub( L_tmp1, L_tmp ); - - /* env[i] /= (float)(st_fx->cng_hist_size - 2); */ - tmp1 = sub( hDtxEnc->cng_hist_size, 2 ); - IF( GT_16( tmp1, 1 ) ) - { - tmp1 = div_s( 1, tmp1 ); - L_tmp1 = Mult_32_16( L_tmp1, tmp1 ); - } - - env[i] = L_tmp1; - move32(); - } - /* compute average excitation energy */ - L_tmp = L_deposit_l( 0 ); - ptr = hTdCngEnc->cng_hist_ptr; - move16(); - - FOR( k = 0; k < hDtxEnc->cng_hist_size; k++ ) - { - /* enr += W_HIST[k]*cng_ener_hist[ptr] */ - L_tmp = L_mac0( L_tmp, W_HIST_FX[k], hTdCngEnc->cng_ener_hist_fx[ptr] ); /* Q24 (8+16) */ - ptr = sub( ptr, 1 ); - if ( ptr < 0 ) /* check for circular pointer */ - { - ptr = DTX_HIST_SIZE - 1; - move16(); - } - } - /*----------------------------------------------------------- - * here we want to divide L_tmp by the sum - * of all the coefs used W_HIST[0..cng_hist_size-1] - * The table W_HIST_S already contains the inverted sum. - * That is - * W_HIST_S[k] 1 - * ------------- = --------------------------- - * 4096 W_HIST[0] + ... + W_HIST[k] - * - * 1 / Sum(W_HIST[0..k]) is always > 1 since the sum - * of the coefs 0..k is always < 1 but > 0 - * enr is in Q8 since the history buffer constains Q8 energies - *-----------------------------------------------------------*/ - /*L_tmp = Mpy_32_16_1(L_tmp, W_HIST_S_FX[k-1]); */ /* normalize average value */ - L_tmp = Mult_32_16( L_tmp, W_HIST_S_FX[k - 1] ); /* Q21 (24+12+1-16) */ - L_tmp = L_shl( L_tmp, 3 ); /* Q24 */ - enr = round_fx( L_tmp ); /* Q8 */ - } - /* decrease the energy in case of WB input */ - test(); - IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) - { - } - ELSE IF( NE_16( st_fx->bwidth, NB ) ) - { - IF( EQ_16( st_fx->bwidth, WB ) ) - { - IF( hDtxEnc->CNG_mode >= 0 ) - { - /* Bitrate adapted attenuation */ - att = ENR_ATT_fx[hDtxEnc->CNG_mode]; - move16(); - } - ELSE - { - /* Use least attenuation for higher bitrates */ - att = ENR_ATT_fx[4]; - move16(); - } - } - ELSE - { - att = 384; - move16(); /*Q8*/ - } - enr = sub( enr, att ); - } - /* intialize the energy quantization parameters */ - IF( st_fx->Opt_AMR_WB == 0 ) - { - step = STEP_SID_FX; - move16(); - step_inv = ISTEP_SID_FX; - move16(); - maxl = 127; - move16(); - num_bits = 7; - move16(); - } - ELSE - { - step = STEP_AMR_WB_SID_FX; - move16(); - step_inv = ISTEP_AMR_WB_SID_FX; - move16(); - maxl = 63; - move16(); - num_bits = 6; - move16(); - } - - /* calculate the energy quantization index */ - enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */ - enr_index = extract_l( L_shr( L_mult0( enr_index, step ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */ - - /* limit the energy quantization index */ - enr_index = s_min( enr_index, maxl ); - enr_index = s_max( enr_index, 0 ); - - /* allow only slow energy increase */ - test(); - IF( hTdCngEnc->old_enr_index >= 0 && GT_16( enr_index, add( hTdCngEnc->old_enr_index, MAX_DELTA ) ) ) - { - IF( *allow_cn_step != 0 ) - { - tmp1 = mult( 27853 /* Q15(0.85) */, sub( enr_index, hTdCngEnc->old_enr_index ) ); - enr_index = add( hTdCngEnc->old_enr_index, tmp1 ); - } - ELSE - { - enr_index = add( hTdCngEnc->old_enr_index, MAX_DELTA ); - } - } - hTdCngEnc->old_enr_index = enr_index; - move16(); - - push_indice( hBstr, IND_ENERGY, enr_index, num_bits ); - if ( enr_index == 0 ) - { - enr_index = -5; - move16(); - } - /* Find quantized energy */ - /* *Enew = (float)enr_index / step - 2.0 */ - /* *Enew = (float)pow(2.0, *Enew) */ - L_tmp = L_mult( enr_index, step_inv ); /* Q16(0+15+1) */ - /* substract by 2 not done to leave Energy in Q2 */ - lo = L_Extract_lc( L_tmp, &hi ); - hTdCngEnc->Enew_fx = Pow2( add( hi, 4 ), lo ); /* Q6 */ - move32(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - /* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/ - exp = norm_l( hTdCngEnc->Enew_fx ); - L_tmp = L_shl( hTdCngEnc->Enew_fx, exp ); /*Q(exp+6) */ - L_tmp = Mult_32_16( L_tmp, shl( st_fx->L_frame, 5 ) ); /* Q(exp+6+5-15=exp-4) */ - - L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /* Q6 */ - - exp = norm_l( L_tmp ); - fra = Log2_norm_lc( L_shl( L_tmp, exp ) ); - exp = sub( sub( 30, exp ), 6 ); - L_tmp = L_Comp( exp, fra ); - enr1 = L_shr( L_tmp, 10 ); /* Q6 */ - - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - /* env[i] -= 2 * st->Enew;*/ - L_tmp1 = L_add( env[i], 0 ); - L_tmp = L_add( hTdCngEnc->Enew_fx, hTdCngEnc->Enew_fx ); - L_tmp1 = L_sub( L_tmp1, L_tmp ); /*Q6*/ - - IF( L_tmp1 < 0 ) - { - L_tmp1 = L_deposit_l( 6 ); /* (0.1)Q6 */ - } - /* env[i] = (float)log10( env[i] + 0.1f ) / (float)log10( 2.0f ); */ - exp = norm_l( L_tmp1 ); - fra = Log2_norm_lc( L_shl( L_tmp1, exp ) ); - exp = sub( sub( 30, exp ), 6 ); - L_tmp = L_Comp( exp, fra ); - L_tmp1 = L_shr( L_tmp, 10 ); /* Q6 */ - - L_tmp = L_shr( L_deposit_l( att ), 2 ); /* Q6 */ - L_tmp1 = L_sub( L_tmp1, L_tmp ); - - IF( L_tmp1 < 0 ) - { - L_tmp1 = L_deposit_l( 0 ); - } - - L_tmp1 = L_sub( enr1, L_tmp1 ); - - env[i] = L_tmp1; - move32(); - } - - /* codebook search */ - min1 = L_add( 1310588928, 0 ); /* Q17 */ - min1_idx = 0; - move16(); - - FOR( i = 0; i < 64; i++ ) - { - d = L_deposit_l( 0 ); - FOR( j = 0; j < NUM_ENV_CNG; j++ ) - { - /* d += (env[j] - CNG_details_codebook_fx[i][j]) * (env[j] - CNG_details_codebook_fx[i][j]);*/ - L_tmp = L_sub( env[j], L_deposit_l( CNG_details_codebook_fx[i][j] ) ); /* Q6 */ - exp = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ - tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ - L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ - L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */ - d = L_add( d, L_tmp ); - } - - IF( LT_32( d, min1 ) ) - { - min1 = L_add( d, 0 ); - min1_idx = i; - move16(); - } - } - push_indice( hBstr, IND_CNG_ENV1, min1_idx, 6 ); - /* get quantized res_env_details */ - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - q_env[i] = L_deposit_l( CNG_details_codebook_fx[min1_idx][i] ); - move32(); - } - } - /* Update hangover memory during CNG */ - test(); - IF( *allow_cn_step == 0 && LT_32( Mult_32_16( hTdCngEnc->Enew_fx, 21845 /*1/1.5f, Q15*/ ), hTdCngEnc->lp_ener_fx ) ) - { - /* update the pointer to circular buffer of old LSP vectors */ - hTdCngEnc->ho_hist_ptr = add( hTdCngEnc->ho_hist_ptr, 1 ); - move16(); - if ( EQ_16( hTdCngEnc->ho_hist_ptr, HO_HIST_SIZE ) ) - { - hTdCngEnc->ho_hist_ptr = 0; - move16(); - } - - /* update the circular buffer of old LSP vectors with the new LSP vector */ - Copy( lsp_new, &( hTdCngEnc->ho_lsp_hist_fx[( hTdCngEnc->ho_hist_ptr ) * M] ), M ); - - /* update the hangover energy buffer */ - hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] = hTdCngEnc->Enew_fx; - move32(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - /* get quantized envelope */ - /* env[i] = pow(2.0f,(enr1 - q_env[i])) + 2*st->Enew;*/ - L_tmp = L_sub( enr1, q_env[i] ); /* Q6 */ - L_tmp = L_shl( L_tmp, 10 ); /* 16 */ - temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx ); - - exp_pow = sub( 14, temp_hi_fx ); - L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */ - env[i] = L_shl( L_tmp, sub( 6, exp_pow ) ); - move32(); /* Q6 */ - L_tmp = L_add( hTdCngEnc->Enew_fx, hTdCngEnc->Enew_fx ); - env[i] = L_add( env[i], L_tmp ); - move32(); /* Q6 */ - } - Copy32( env, &( hTdCngEnc->ho_env_hist_fx[( hTdCngEnc->ho_hist_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG ); - } - hTdCngEnc->ho_hist_size = add( hTdCngEnc->ho_hist_size, 1 ); - move16(); - if ( GT_16( hTdCngEnc->ho_hist_size, HO_HIST_SIZE ) ) - { - hTdCngEnc->ho_hist_size = HO_HIST_SIZE; - move16(); - } - } - } - /* dithering bit for AMR-WB IO mode is always set to 0 */ - IF( EQ_32( st_fx->core_brate, SID_1k75 ) ) - { - push_indice( hBstr, IND_DITHERING, 0, 1 ); - } - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - push_indice( hBstr, IND_ACELP_16KHZ, 1, 1 ); - } - ELSE - { - push_indice( hBstr, IND_ACELP_16KHZ, 0, 1 ); - } - - push_indice( hBstr, IND_CNG_HO, s_min( hTdCngEnc->burst_ho_cnt, 7 ), 3 ); - hTdCngEnc->num_ho = m; - move16(); - push_indice( hBstr, IND_SID_TYPE, 0, 1 ); - - test(); - IF( LT_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->element_mode, IVAS_CPE_DFT ) ) - { - push_indice( hBstr, IND_SID_BW, 0, 1 ); - *sid_bw = 0; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Updates - *-----------------------------------------------------------------*/ - /* update the SID frames counter */ - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) - { - hDtxEnc->cng_cnt = 0; - move16(); - hTdCngEnc->cng_hist_ptr = -1; - move16(); - /* update frame length memory */ - hDtxEnc->last_CNG_L_frame = st_fx->L_frame; - move16(); - } - ELSE - { - hDtxEnc->cng_cnt = add( hDtxEnc->cng_cnt, 1 ); - move16(); - } - - return; -} - -void CNG_enc_ivas_fx( -#else -void CNG_enc_fx( -#endif Encoder_State *st_fx, /* i/o: State structure */ Word16 Aq[], /* o : LP coefficients Q12 */ const Word16 *speech, /* i : pointer to current frame input speech buffer Q_new */ @@ -1214,14 +74,8 @@ void CNG_enc_fx( Word16 max_idx[2]; Word16 ftmp_fx; Word16 lsp_tmp[M]; -#ifdef HARM_NON_LINEARITY Word32 dev, max_dev, dist; Word16 dev16, max_dev16, dist16; -#else - Word32 dev; - Word32 max_dev; - Word32 dist; -#endif Word16 max_idx1[2]; Word16 fft_io[L_FRAME16k]; Word16 *ptR, *ptI; @@ -1245,10 +99,8 @@ void CNG_enc_fx( Word64 w_temp; Word32 inv_frame_len; Word32 L_ener; -#ifdef HARM_NON_LINEARITY Word16 *pt_res; const Word16 *pt_sp; -#endif step_inv = 0; move16(); @@ -1281,7 +133,6 @@ void CNG_enc_fx( move16(); } -#ifdef HARM_NON_LINEARITY IF( st_fx->element_mode == EVS_MONO ) { pt_sp = speech; @@ -1314,7 +165,6 @@ void CNG_enc_fx( } } ELSE -#endif { w_temp = 1; move64(); @@ -1685,7 +535,6 @@ void CNG_enc_fx( IF( hTdCngEnc->burst_ho_cnt > 0 ) { -#ifdef HARM_NON_LINEARITY IF( st_fx->element_mode == EVS_MONO ) { /**allow_cn_step |= ( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] > 4 * hTdCngEnc->lp_ener_fx ); */ @@ -1700,7 +549,6 @@ void CNG_enc_fx( w_temp = W_deposit32_l( L_tmp1 ); } ELSE -#endif { /**allow_cn_step |= ( hDtxEnc->first_CNG || st->element_mode == EVS_MONO ) && ( hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener );*/ w_temp = W_msu_32_16( W_shl( W_deposit32_l( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 2 ), hTdCngEnc->lp_ener_fx, lp_ener_thr_scale ); /*Q8*/ @@ -1867,7 +715,6 @@ void CNG_enc_fx( } } -#ifdef HARM_NON_LINEARITY IF( st_fx->element_mode == EVS_MONO ) { dist16 = 0; /*Q15 */ @@ -1889,7 +736,6 @@ void CNG_enc_fx( max_dev = L_deposit_l( max_dev16 ); } ELSE -#endif { dist = 0; /*Q15 */ move32(); @@ -1967,9 +813,7 @@ void CNG_enc_fx( ELSE { E_LPC_f_lsp_a_conversion( hDtxEnc->lspCNG_fx, Aq, M ); -#ifdef HARM_NON_LINEARITY IF( st_fx->element_mode != EVS_MONO ) -#endif { exp = sub( Q14, norm_s( Aq[0] ) ); Scale_sig( Aq, M + 1, sub( Q12, exp ) ); // Q12 @@ -2057,7 +901,6 @@ void CNG_enc_fx( /* calculate the residual signal energy */ /*enr = dotp( res, res, L_frame ) / L_frame; */ -#ifdef HARM_NON_LINEARITY IF( st_fx->element_mode == EVS_MONO ) { Word16 maxv, scale; @@ -2108,7 +951,6 @@ void CNG_enc_fx( enr = round_fx( L_shl( L_tmp, 8 ) ); /* Q8 (16+8-16) */ } ELSE -#endif { w_temp = 1; move64(); @@ -2527,310 +1369,6 @@ void CNG_enc_fx( return; } -#ifndef HARM_NON_LINEARITY -/*---------------------------------------------------------------------* - * swb_CNG_enc() - * - * SWB DTX/CNG encoding - *---------------------------------------------------------------------*/ -void swb_CNG_enc_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz (Q0) */ - const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz (st_fx->Q_syn = 0) */ -) -{ - Word16 shb_SID_updt_fx = 0; - move16(); - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) || st_fx->core_brate == FRAME_NO_DATA ) - { - IF( EQ_16( st_fx->cng_type, LP_CNG ) ) - { - IF( GE_32( st_fx->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) ) - { - /* decide if SHB SID encoding or not */ - shb_SID_updt_fx = shb_DTX_fx( st_fx, shb_speech_fx, syn_12k8_16k_fx ); - - /* SHB CNG encoding */ - shb_CNG_encod_fx( st_fx, shb_SID_updt_fx ); - } - ELSE IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - } - } - hTdCngEnc->last_vad = 0; - move16(); - } - ELSE - { - hTdCngEnc->last_vad = 1; - move16(); - } - - return; -} - -/*---------------------------------------------------------------------* - * shb_CNG_encod() - * - * SID parameters encoding for SHB signal - *---------------------------------------------------------------------*/ -static void shb_CNG_encod_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 update_fx /* i : SID update flag */ -) -{ - Word16 idx_ener_fx; - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - - idx_ener_fx = 0; - move16(); - IF( EQ_16( update_fx, 1 ) ) - { - /* SHB energy quantization */ - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - idx_ener_fx = shr( add( mult( hTdCngEnc->mov_shb_cng_ener_fx, 9797 ), 1510 ), 8 ); /* Q0 */ - } - ELSE - { - } - - if ( LT_16( st_fx->bwidth, SWB ) ) - { - idx_ener_fx = 0; - move16(); - } - - IF( GT_16( idx_ener_fx, 15 ) ) - { - idx_ener_fx = 15; - move16(); - } - ELSE - { - idx_ener_fx = s_max( idx_ener_fx, 0 ); - } - - push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4 ); - push_indice( hBstr, IND_SID_BW, 1, 1 ); - delete_indice( hBstr, IND_CNG_ENV1 ); - move16(); - move16(); - - if ( st_fx->element_mode == IVAS_CPE_DFT ) - { - } - else - { - push_indice( hBstr, IND_UNUSED, 0, 2 ); - } - hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); - hTdCngEnc->ho_sid_bw = L_or( hTdCngEnc->ho_sid_bw, 0x1L ); - move32(); - move32(); - } - ELSE - { - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - hTdCngEnc->ho_sid_bw = L_shl( L_and( hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); - push_indice( hBstr, IND_SID_BW, 0, 1 ); - } - } - - return; -} - -/*---------------------------------------------------------------------* - * shb_DTX() - * - * Decide if encoding SHB SID or not - *---------------------------------------------------------------------*/ - -static Word16 shb_DTX_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz (Q0) */ - const Word16 *syn_12k8_16k /* i : ACELP core synthesis at 12.8kHz or 16kHz (st_fx->Q_syn = 0) */ -) -{ - Word16 i; - Word16 update_fx; - Word16 shb_old_speech_fx[( ACELP_LOOK_12k8 + L_SUBFR + L_FRAME ) * 5 / 4]; - Word16 *shb_new_speech_fx; - Word32 wb_ener_fx; - Word32 shb_ener_fx; - Word16 log_wb_ener_fx; - Word16 log_shb_ener_fx; - Word16 tmp; - Word16 exp; - Word16 fra; - Word16 att; /*Q8*/ - Word16 allow_cn_step_fx = 0; - move16(); - DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; - TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; - - shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4; - Copy( hBWE_TD->old_speech_shb_fx, shb_old_speech_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 ); - Copy( shb_speech_fx, shb_new_speech_fx, L_FRAME16k ); - Copy( shb_old_speech_fx + L_FRAME16k, hBWE_TD->old_speech_shb_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 ); - - shb_ener_fx = L_deposit_l( 0 ); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - shb_ener_fx = L_mac_sat( shb_ener_fx, shb_old_speech_fx[i], shb_old_speech_fx[i] ); - } - - shb_ener_fx = L_add( Mpy_32_16_1( shb_ener_fx, 102 ), 1 ); /* 102 in Q15, shb_ener_fx in Q1 */ - - wb_ener_fx = L_deposit_l( 0 ); - FOR( i = 0; i < st_fx->L_frame; i++ ) - { - wb_ener_fx = L_mac_sat( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i] ); - } - - wb_ener_fx = L_add( Mpy_32_16_1( wb_ener_fx, 128 ), 1 ); /* 128 in Q15, wb_ener_fx in Q1 */ - - exp = norm_l( wb_ener_fx ); - fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) ); - exp = sub( 30 - 1, exp ); - wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); - log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ - exp = norm_l( shb_ener_fx ); - fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) ); - exp = sub( 30 - 1, exp ); - shb_ener_fx = Mpy_32_16( exp, fra, LG10 ); - - test(); - IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) - { - att = 0; - move16(); - } - ELSE - { - att = 1664; /*6.5 in Q8*/ - move16(); - } - - log_shb_ener_fx = sub_sat( round_fx_sat( L_shl_sat( shb_ener_fx, 10 ) ), att ); /* log_shb_ener_fx in Q8 */ - IF( hDtxEnc->first_CNG == 0 ) - { - hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; - move16(); - hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; - move16(); - hTdCngEnc->last_wb_cng_ener_fx = log_wb_ener_fx; - move16(); - hTdCngEnc->last_shb_cng_ener_fx = log_shb_ener_fx; - move16(); - } - - if ( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12.0f Q8*/ ) ) - { - allow_cn_step_fx = 1; - move16(); - } - - IF( EQ_16( allow_cn_step_fx, 1 ) ) - { - hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; - move16(); - hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; - move16(); - } - ELSE - { - tmp = sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ); /* Q8 */ - tmp = mult( tmp, 29491 /*.9f in Q15*/ ); /* Q8 */ - hTdCngEnc->mov_wb_cng_ener_fx = add( hTdCngEnc->mov_wb_cng_ener_fx, tmp ); /* Q8 */ - move16(); - tmp = sub( log_shb_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ); - tmp = mult( tmp, 8192 /*.25f in Q15*/ ); /* Q8 */ - hTdCngEnc->mov_shb_cng_ener_fx = add( hTdCngEnc->mov_shb_cng_ener_fx, tmp ); /* Q8 */ - move16(); - } - hTdCngEnc->shb_NO_DATA_cnt = add( hTdCngEnc->shb_NO_DATA_cnt, 1 ); - move16(); - update_fx = 0; - move16(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - test(); - test(); - IF( hDtxEnc->first_CNG == 0 || EQ_16( hTdCngEnc->last_vad, 1 ) || GE_16( hTdCngEnc->shb_NO_DATA_cnt, 100 ) ) - { - update_fx = 1; - move16(); - } - ELSE - { - IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) - { - update_fx = 1; - move16(); - hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); - move16(); - } - ELSE - { - IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 /*3.0f in Q8*/ ) ) - { - update_fx = 1; - move16(); - } - ELSE - { - test(); - IF( GE_16( st_fx->bwidth, SWB ) && LT_16( hTdCngEnc->last_SID_bwidth, SWB ) ) - { - update_fx = 1; - move16(); - } - ELSE - { - test(); - IF( LT_16( st_fx->bwidth, SWB ) && GE_16( hTdCngEnc->last_SID_bwidth, SWB ) ) - { - update_fx = 1; - move16(); - } - } - } - } - } - - hTdCngEnc->last_SID_bwidth = st_fx->bwidth; - move16(); - } - /* LF-boost not yet implemented in decoder which means that the specific wb_sid information is not used */ - test(); - test(); - if ( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) && EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - update_fx = 1; - move16(); - } - - IF( EQ_16( update_fx, 1 ) ) - { - hTdCngEnc->last_wb_cng_ener_fx = hTdCngEnc->mov_wb_cng_ener_fx; - move16(); - hTdCngEnc->last_shb_cng_ener_fx = hTdCngEnc->mov_shb_cng_ener_fx; - move16(); - hTdCngEnc->shb_NO_DATA_cnt = 0; - move16(); - } - - - return ( update_fx ); -} -#endif /*---------------------------------------------------------------------* * calculate_hangover_attenuation_gain_fx() @@ -2839,50 +1377,6 @@ static Word16 shb_DTX_fx( *---------------------------------------------------------------------*/ void calculate_hangover_attenuation_gain_fx( -#ifndef HARM_NON_LINEARITY - Encoder_State *st, /* i : encoder state structure */ - Word16 *att, /* o : attenuation factor Q15 */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ -) -{ - Word16 offset; - TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc; - - *att = 32767; // 1.0f in Q15 - - move16(); - /* smoothing in case of CNG */ - IF( hTdCngEnc != NULL ) - { - test(); - test(); - test(); - IF( hTdCngEnc->burst_ho_cnt > 0 && ( vad_hover_flag != 0 ) && ( NE_16( st->bwidth, NB ) || st->element_mode > EVS_MONO ) ) /* corresponds to line 504 in FLT acelp_core_enc.c */ - { - if ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) - { - } - else - { - offset = 5; - move16(); - test(); - if ( EQ_16( st->bwidth, WB ) && st->hDtxEnc->CNG_mode >= 0 ) - { - offset = st->hDtxEnc->CNG_mode; - move16(); - } - assert( hTdCngEnc->burst_ho_cnt > 0 ); - *att = CNG_burst_att_fx[offset][hTdCngEnc->burst_ho_cnt - 1]; /*Q15*/ - move16(); - } - } - } - return; -} - -void calculate_hangover_attenuation_gain_ivas_fx( -#endif Encoder_State *st, /* i : encoder state structure */ Word16 *att, /* o : attenuation factor Q15 */ const Word16 vad_hover_flag /* i : VAD hangover flag */ @@ -2907,7 +1401,6 @@ void calculate_hangover_attenuation_gain_ivas_fx( *att = extract_h( L_shl_sat( L_tmp, result_e ) ); move16(); } -#ifdef HARM_NON_LINEARITY ELSE IF( st->element_mode == EVS_MONO ) { Word16 offset = 5; @@ -2922,7 +1415,6 @@ void calculate_hangover_attenuation_gain_ivas_fx( *att = CNG_burst_att_fx[offset][st->hTdCngEnc->burst_ho_cnt - 1]; /*Q15*/ move16(); } -#endif ELSE { test(); @@ -2953,7 +1445,6 @@ void calculate_hangover_attenuation_gain_ivas_fx( } -#ifdef HARM_NON_LINEARITY /*---------------------------------------------------------------------* * swb_CNG_enc() * @@ -2961,9 +1452,6 @@ void calculate_hangover_attenuation_gain_ivas_fx( *---------------------------------------------------------------------*/ void swb_CNG_enc_fx( -#else -void swb_CNG_enc_ivas_fx( -#endif Encoder_State *st, /* i/o: State structure */ const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ @@ -2980,18 +1468,10 @@ void swb_CNG_enc_ivas_fx( IF( GE_32( st->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) ) { /* decide if SHB SID encoding or not */ -#ifdef HARM_NON_LINEARITY shb_SID_updt = shb_DTX_fx( st, shb_speech_fx, syn_12k8_16k_fx ); -#else - shb_SID_updt = shb_DTX_ivas_fx( st, shb_speech_fx, syn_12k8_16k_fx ); -#endif /* SHB CNG encoding */ -#ifdef HARM_NON_LINEARITY shb_CNG_encod_fx( st, shb_SID_updt ); -#else - shb_CNG_encod_ivas_fx( st, shb_SID_updt ); -#endif } ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_32( st->core_brate, SID_2k40 ) ) { @@ -3021,11 +1501,7 @@ void swb_CNG_enc_ivas_fx( * SID parameters encoding for SHB signal *---------------------------------------------------------------------*/ -#ifdef HARM_NON_LINEARITY static void shb_CNG_encod_fx( -#else -static void shb_CNG_encod_ivas_fx( -#endif Encoder_State *st, /* i/o: State structure */ const Word16 update /* i : SID update flag */ ) @@ -3039,11 +1515,7 @@ static void shb_CNG_encod_ivas_fx( { IF( st->element_mode == EVS_MONO ) { -#ifdef HARM_NON_LINEARITY idx_ener = shr( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 9797 ), 1510 ), 8 ); /* Q0 */ -#else - idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 29491 ), 8 ); /* Q0 */ -#endif } ELSE { @@ -3146,11 +1618,7 @@ static void shb_CNG_encod_ivas_fx( * Decide if encoding SHB SID or not *---------------------------------------------------------------------*/ -#ifdef HARM_NON_LINEARITY static Word16 shb_DTX_fx( -#else -static Word16 shb_DTX_ivas_fx( -#endif Encoder_State *st, /* i/o: State structure */ const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ @@ -3219,11 +1687,7 @@ static Word16 shb_DTX_ivas_fx( } ELSE { -#ifdef HARM_NON_LINEARITY att_fx = 1664; /*6.5 in Q8*/ -#else - att_fx = -1664; // Q8 -#endif move16(); } @@ -3291,11 +1755,7 @@ static Word16 shb_DTX_ivas_fx( update = 1; move16(); } -#ifdef HARM_NON_LINEARITY ELSE IF( st->element_mode != EVS_MONO && hTdCngEnc->shb_cng_ini_cnt > 0 ) -#else - ELSE IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) -#endif { hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); update = 1; @@ -3312,7 +1772,6 @@ static Word16 shb_DTX_ivas_fx( update = 1; move16(); } -#ifdef HARM_NON_LINEARITY ELSE IF( st->element_mode == EVS_MONO && hTdCngEnc->shb_cng_ini_cnt > 0 ) { hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); @@ -3320,7 +1779,6 @@ static Word16 shb_DTX_ivas_fx( move16(); move16(); } -#endif ELSE IF( GT_16( abs_s( sub( sub( hTdCngEnc->mov_wb_cng_ener_fx, hTdCngEnc->mov_shb_cng_ener_fx ), sub( hTdCngEnc->last_wb_cng_ener_fx, hTdCngEnc->last_shb_cng_ener_fx ) ) ), 768 ) ) { update = 1; diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 8e40d9530526cb03590365f4f444749d824cebc4..6c2f6100be95d2cf7bc54cab31aedf746ad3690d 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -3617,11 +3617,7 @@ void QuantizeTCXSpectrum_fx( test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { -#ifdef HARM_NON_LINEARITY calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); -#else - calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); -#endif *gain_tcx_fx = mult( *gain_tcx_fx, att_fx ); move16(); } diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index ce0a8f23e9eaba0c5d23dccb754279f2dfadc746..2cbbd5c9aa8454dd7513aeb90790cb99d7241afd 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -461,28 +461,13 @@ void core_encode_openloop_fx( E_LPC_a_lsp_conversion( A, lsptmp, lsp_new, M ); Residu3_fx( A, buf + L_LP - L_FRAME, res, L_FRAME, 1 ); -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsptmp, res, st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate, EVS_MONO, -1 ); -#else - cng_params_upd_fx( lsptmp, res, st->L_frame, &hTdCngEnc->ho_circ_ptr, - hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, - Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, - hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate ); -#endif } ELSE { -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsp_new, hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, hDtxEnc->last_active_brate, EVS_MONO, -1 ); -#else - cng_params_upd_fx( lsp_new, hLPDmem->old_exc + L_EXC_MEM - st->L_frame, - st->L_frame, &hTdCngEnc->ho_circ_ptr, hTdCngEnc->ho_ener_circ_fx, - &hTdCngEnc->ho_circ_size, hTdCngEnc->ho_lsp_circ_fx, Q_new, ENC, NULL, - &hTdCngEnc->cng_buf_cnt, hTdCngEnc->cng_exc2_buf, hTdCngEnc->cng_Qexc_buf, hTdCngEnc->cng_brate_buf, - hDtxEnc->last_active_brate ); -#endif } IF( EQ_16( st->L_frame, L_FRAME ) ) diff --git a/lib_enc/enc_acelp_tcx_main_fx.c b/lib_enc/enc_acelp_tcx_main_fx.c index 5e3c9241bc4cfcf81190db2bb71e82992fa81655..b3bd7d112b850a0f708343296bd577beb645013b 100644 --- a/lib_enc/enc_acelp_tcx_main_fx.c +++ b/lib_enc/enc_acelp_tcx_main_fx.c @@ -71,11 +71,7 @@ void enc_acelp_tcx_main_fx( test(); IF( EQ_16( st->core, ACELP_CORE ) && st->igf != 0 ) { -#ifdef HARM_NON_LINEARITY non_linearity_fx( EVS_MONO, ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, *Q_new, st->coder_type, voice_factors, st->L_frame ); -#else - non_linearity_fx( ptr_bwe_exc, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, *Q_new, st->coder_type, voice_factors, st->L_frame ); -#endif /* update the old BWE exe memory */ Copy( &old_bwe_exc[L_FRAME32k], hBWE_TD->old_bwe_exc_fx, PIT16k_MAX * 2 ); /*Q_exc*/ diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index dae4570cc3ef34f5c4391aa5fba665a04aeb50d1..e28dd0bf99392be34f6c528b1a6fc31db9afd3c2 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -975,11 +975,7 @@ void writeLPCparam_fx( IF( st->enableTcxLpc && st->core != ACELP_CORE ) { /* Encode the indices */ -#ifdef HARM_COREDECODER_FUNCTIONS *nbits_lpc = enc_lsf_tcxlpc_fx( ¶m_lpc, hBstr ); /* Q0 */ -#else - *nbits_lpc = enc_lsf_tcxlpc_ivas_fx( ¶m_lpc, hBstr ); /* Q0 */ -#endif move16(); } ELSE @@ -998,11 +994,7 @@ void writeLPCparam_fx( move16(); } -#ifdef HARM_COREDECODER_FUNCTIONS *nbits_lpc = encode_lpc_avq_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */ -#else - *nbits_lpc = encode_lpc_avq_ivas_fx( hBstr, numlpc, param_lpc, st->core, st->element_mode ); /* Q0 */ -#endif move16(); } ELSE IF( EQ_16( st->lpcQuantization, 1 ) ) @@ -1012,20 +1004,12 @@ void writeLPCparam_fx( IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->coder_type, VOICED ) && EQ_16( st->core, ACELP_CORE ) ) { assert( st->element_mode == EVS_MONO ); -#ifdef HARM_COREDECODER_FUNCTIONS *nbits_lpc = lsf_bctcvq_encprm_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */ -#else - *nbits_lpc = lsf_bctcvq_encprm_ivas_fx( hBstr, param_lpc, bits_param_lpc, no_param_lpc ); /* Q0 */ -#endif move16(); } ELSE { -#ifdef HARM_COREDECODER_FUNCTIONS *nbits_lpc = lsf_msvq_ma_encprm_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */ -#else - *nbits_lpc = lsf_msvq_ma_encprm_ivas_fx( hBstr, param_lpc, st->core, st->coder_type, st->acelp_cfg.midLpc, bits_param_lpc, no_param_lpc ); /* Q0 */ -#endif move16(); } } diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 66b5eac772c4757d17f5fe0124eb8de3a9f0928f..063989affe6fee9784922d101ecaa172c316fd8c 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -85,519 +85,24 @@ static Word16 find_ener_decrease_fx( * Decision about coder type *-------------------------------------------------------------------*/ -#ifndef FIX_2349_HARM_FIND_UV -Word16 find_uv_fx( /* o : coding type */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ - const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ - const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/ - const Word16 Q_new, - Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ - const Word16 shift, - const Word16 last_core_orig /* i : original last core Q0*/ -) -{ - Word16 coder_type, i; - Word32 mean_ee, dE1, fac_32; - const Word16 *pt_speech; - Word32 L_tmp, enr_ssf[2 * NB_SSF + 2 * NB_SSF + 2], E_min_th; - Word16 dE2; - Word16 ind_deltaMax, tmp_offset_flag; - Word32 Ltmp0, *pt_enr_ssf, *pt_enr_ssf1, dE2_th; - Word16 exp0, exp1, Q_in; - Word16 wtmp0, wtmp1; - Word16 fac, mean_voi3, dE3; - Word16 relE_thres; - Word16 mean_voi3_offset; - Word16 voicing_m, dpit1, dpit2, dpit3; - Word16 ee0_th, ee1_th, voi_th, nb_cond, flag_low_relE; - NOISE_EST_HANDLE hNoiseEst = st_fx->hNoiseEst; - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - Word16 Last_Resort; - Word16 vadnoise; - - IF( hSC_VBR != NULL ) - { - Last_Resort = hSC_VBR->Last_Resort; /* Q0 */ - vadnoise = hSC_VBR->vadnoise_fx; - move16(); - move16(); - } - ELSE - { - Last_Resort = 0; - vadnoise = 0; - move16(); - move16(); - } - - Q_in = sub( Q_new, 1 ); - - /*-----------------------------------------------------------------* - * Detect sudden energy increases to catch voice and music - * temporal events (dE1) - * - * - Find maximum energy per short subblocks. - * Two subblock sets are used shifted by half the subblock length - * - Find maximum energy ratio between adjacent subblocks - *-----------------------------------------------------------------*/ - - /* Find maximum energy per short subblocks */ - pt_speech = speech - SSF; /* Q_new */ - pt_enr_ssf = enr_ssf + 2 * NB_SSF; - FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ ) - { - emaximum_fx( Q_in, pt_speech, SSF, pt_enr_ssf ); - pt_speech += ( SSF / 2 ); - pt_enr_ssf++; - } - - dE1 = 0; - move16(); - ind_deltaMax = 0; - move16(); - pt_enr_ssf = enr_ssf + 2 * NB_SSF; - pt_enr_ssf1 = pt_enr_ssf + 2; - - /* Test on energy increase between adjacent sub-subframes */ - exp1 = 0; - move16(); - FOR( i = 0; i < 2 * NB_SSF; i++ ) - { - /*fac = *pt_enr_ssf1 / (*pt_enr_ssf + 1);*/ - Ltmp0 = L_max( *pt_enr_ssf, 1 ); - exp0 = norm_l( Ltmp0 ); - wtmp0 = extract_h( L_shl( Ltmp0, exp0 ) ); - exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); - wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); - fac = div_s( wtmp1, wtmp0 ); - fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ - - if ( GT_32( fac_32, dE1 ) ) - { - ind_deltaMax = i; - move16(); - } - - dE1 = L_max( dE1, fac_32 ); /* Q13 */ - - pt_enr_ssf++; - pt_enr_ssf1++; - } - - /*-----------------------------------------------------------------* - * Average spectral tilt - * Average voicing (normalized correlation) - *-----------------------------------------------------------------*/ - - /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ - mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ - mean_ee = Mult_32_16( mean_ee, 10923 /* 1/3 in Q15 */ ); /*Q6*/ - - /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/ - Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */ - Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 /* 1/3 in Q15 */ ); /* Q31 */ - mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/ - /*-----------------------------------------------------------------* - * Total frame energy difference (dE3) - *-----------------------------------------------------------------*/ - - dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/ - - /*-----------------------------------------------------------------* - * Energy decrease after spike (dE2) - *-----------------------------------------------------------------*/ - - /* set different thresholds and conditions for NB and WB input */ - dE2_th = 30 << 10; - move32(); - nb_cond = 1; - move16(); /* no additional condition for WB input */ - IF( EQ_16( st_fx->input_bwidth, NB ) ) - { - dE2_th = 21 << 10; - move32(); - if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ - { - nb_cond = 0; - move16(); - } - } - - /* calcualte maximum energy decrease */ - dE2 = 0; - move16(); /* Test on energy decrease after an energy spike */ - pt_enr_ssf = enr_ssf + 2 * NB_SSF; - - test(); - IF( GT_32( dE1, 30 << 13 ) && nb_cond ) /*>30 Q13*/ - { - IF( LT_16( sub( shl( NB_SSF, 1 ), ind_deltaMax ), L_ENR ) ) - { - st_fx->old_ind_deltaMax = ind_deltaMax; /* Q0 */ - move16(); - Copy32( pt_enr_ssf, st_fx->old_enr_ssf_fx, 2 * NB_SSF ); /* Qx */ - } - ELSE - { - st_fx->old_ind_deltaMax = -1; - move16(); - dE2 = find_ener_decrease_fx( ind_deltaMax, pt_enr_ssf ); /*Q10*/ - - if ( GT_32( dE2, dE2_th ) ) - { - st_fx->spike_hyst = 0; - move16(); - } - } - } - ELSE - { - IF( st_fx->old_ind_deltaMax >= 0 ) - { - Copy32( st_fx->old_enr_ssf_fx, enr_ssf, 2 * NB_SSF ); /* Qx */ - dE2 = find_ener_decrease_fx( st_fx->old_ind_deltaMax, enr_ssf ); /* Q10 */ - - if ( GT_32( dE2, dE2_th ) ) - { - st_fx->spike_hyst = 1; - move16(); - } - } - - st_fx->old_ind_deltaMax = -1; - move16(); - } - - /*-----------------------------------------------------------------* - * Detection of voiced offsets (tmp_offset_flag) - *-----------------------------------------------------------------*/ - - tmp_offset_flag = 1; - move16(); - - IF( NE_16( st_fx->input_bwidth, NB ) ) - { - ee0_th = 154; /*2.4 in Q6 */ - move16(); - voi_th = 24248; /*0.74f Q15 */ - move16(); - } - ELSE - { - ee0_th = 627; /*9.8f Q6 */ - move16(); - voi_th = 24904; /*0.76f Q15*/ - move16(); - } - - test(); - test(); - test(); - if ( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ - ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], L_shl( E_MIN_FX, Q_new ) ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ - ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ - { - tmp_offset_flag = 0; - move16(); - } - - /*-----------------------------------------------------------------* - * Decision about UC - *-----------------------------------------------------------------*/ - - /* SC-VBR - set additional parameters and thresholds for SC-VBR */ - mean_voi3_offset = 0; - move16(); - flag_low_relE = 0; - move16(); - ee1_th = 608; /*9.5 Q6*/ - move16(); - IF( st_fx->Opt_SC_VBR || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) /* Allow the low energy flag for the secondary channel */ - { - ee1_th = 544; /*8.5f Q6*/ - move16(); - - /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */ - IF( NE_16( st_fx->input_bwidth, NB ) ) - { - /*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */ - L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, st_fx->lp_noise_fx ); // Q24 - if ( Last_Resort == 0 ) - { - /*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, st_fx->lp_noise_fx ); // Q24 - } - relE_thres = round_fx( L_tmp ); - } - ELSE - { - - /*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, st_fx->lp_noise_fx ); // Q24 - relE_thres = round_fx( L_tmp ); - } - relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */ - - /* SC-VBR = set flag on low relative energy */ - if ( LT_16( relE, relE_thres ) ) - { - flag_low_relE = 1; - move16(); - } - - /* SC-VBR - correction of voicing threshold for NB inputs (important only in noisy conditions) */ - test(); - if ( EQ_16( st_fx->input_bwidth, NB ) && LT_16( vadnoise, 20 << 8 ) ) /* vadnoise in Q8, constant Q0<<8 */ - { - mean_voi3_offset = 1638; /*0.05f Q15*/ - move16(); - } - } - - /* make decision whether frame is unvoiced */ - E_min_th = L_shl( E_MIN_FX, Q_new ); - coder_type = GENERIC; - move16(); - IF( EQ_16( st_fx->input_bwidth, NB ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ - { - coder_type = UNVOICED; - move16(); - } - } - ELSE - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.8 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ - { - coder_type = UNVOICED; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Decision about VC - *-----------------------------------------------------------------*/ - if ( st_fx->Opt_SC_VBR ) - { - hSC_VBR->set_ppp_generic = 0; - } - move16(); - - test(); - test(); - IF( EQ_16( st_fx->localVAD, 1 ) && EQ_16( coder_type, GENERIC ) && NE_16( last_core_orig, AMR_WB_CORE ) ) - { - dpit1 = abs_s( sub( T_op_fr[1], T_op_fr[0] ) ); // Q6 - dpit2 = abs_s( sub( T_op_fr[2], T_op_fr[1] ) ); // Q6 - dpit3 = abs_s( sub( T_op_fr[3], T_op_fr[2] ) ); // Q6 - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( GT_16( voicing_fr[0], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 1st sf. */ - ( GT_16( voicing_fr[1], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ - ( GT_16( voicing_fr[2], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */ - ( GT_16( voicing_fr[3], 19825 /* 0.605 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */ - ( GT_32( mean_ee, 256 /* 4.0f in Q6 */ ) ) && /* energy concentrated in low frequencies */ - ( LT_16( dpit1, 3 << 6 ) ) && - ( LT_16( dpit2, 3 << 6 ) ) && - ( LT_16( dpit3, 3 << 6 ) ) ) - { - coder_type = VOICED; - move16(); - } - ELSE IF( st_fx->Opt_SC_VBR && EQ_16( st_fx->input_bwidth, NB ) && LT_16( vadnoise, 20 << 8 ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( GT_16( voicing_fr[0], 8192 /* 0.25 in Q15 */ ) && /* normalized correlation high in 1st sf. */ - ( GT_16( voicing_fr[1], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ - ( GT_16( voicing_fr[2], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 3st sf. */ - ( GT_16( voicing_fr[3], 8192 /* 0.25 in Q15 */ ) ) && /* normalized correlation high in 4st sf. */ - ( GT_32( mean_ee, 64 ) ) && /* energy concentrated in low frequencies */ - ( LT_16( dpit1, 5 << 6 ) ) && - ( LT_16( dpit2, 5 << 6 ) ) && - ( LT_16( dpit3, 5 << 6 ) ) ) - { - hSC_VBR->set_ppp_generic = 1; - move16(); - coder_type = VOICED; - move16(); - } - } - - /* set VOICED mode for frames with very stable pitch and high correlation - and avoid to switch to AUDIO/MUSIC later */ - voicing_m = mac_r( L_mac( L_mac( L_mult( voicing_fr[3], 8192 /* 0.25 in Q15 */ ), voicing_fr[2], 8192 /* 0.25 in Q15 */ ), voicing_fr[1], 8192 /* 0.25 in Q15 */ ), voicing_fr[0], 8192 /* 0.25 in Q15 */ ); - test(); - test(); - test(); - test(); - test(); - IF( *flag_spitch || ( LE_16( dpit1, 3 << 6 ) && LE_16( dpit2, 3 << 6 ) && LE_16( dpit3, 3 << 6 ) && - GT_16( voicing_m, 31130 /* 0.95f in Q15 */ ) && GT_16( st_fx->voicing_sm_fx, 31785 /* 0.97f in Q15 */ ) ) ) - { - coder_type = VOICED; - move16(); - *flag_spitch = 1; - move16(); /*to avoid switch to AUDIO/MUSIC later*/ - } - } - - /*-----------------------------------------------------------------* - * Channel-aware mode - set RF mode and total bitrate - *-----------------------------------------------------------------*/ - - st_fx->rf_mode = st_fx->Opt_RF_ON; /* Q0 */ - move16(); - - IF( EQ_16( coder_type, GENERIC ) ) - { - test(); - test(); - test(); - test(); - IF( ( LT_16( voicing_fr[0], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ - ( LT_16( voicing_fr[1], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 2st sf. */ - ( LT_16( voicing_fr[2], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 3rd sf. */ - ( LT_16( voicing_fr[3], 6554 /* 0.2f in Q15 */ ) ) && /* normalized correlation high in 4th sf. */ - ( GT_16( vadnoise, 25 << 8 ) ) ) /* when speech is clean */ - - { - st_fx->rf_mode = 0; - move16(); - /* Current frame cannot be compressed to pack the partial redundancy;*/ - - if ( st_fx->rf_mode != st_fx->Opt_RF_ON ) - { - core_coder_mode_switch_fx( st_fx, st_fx->last_total_brate, 0, shift ); - } - } - } - - /*-----------------------------------------------------------------* - * Updates - *-----------------------------------------------------------------*/ - - /* update spike hysteresis parameters */ - test(); - if ( st_fx->spike_hyst >= 0 && LT_16( st_fx->spike_hyst, 2 ) ) - { - st_fx->spike_hyst = add( st_fx->spike_hyst, 1 ); /* Q0 */ - } - - /* reset spike hysteresis */ - test(); - test(); - test(); - if ( ( GT_16( st_fx->spike_hyst, 1 ) ) && - ( GT_16( dE3, 5 << 8 ) || /* energy increases */ - ( GT_16( relE, -3328 ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 ) ) ) ) ) /* normalized correlation is high */ - { - st_fx->spike_hyst = -1; - move16(); - } - - /* update tilt parameters */ - st_fx->ee_old_fx = ee[1]; - move32(); /*Q6*/ - st_fx->old_dE1_fx = dE1; - move32(); /*Q13*/ - - /* save the raw coder_type for various modules later in the codec (the reason is that e.g. UNVOICED is lost at higher rates) */ - st_fx->coder_type_raw = coder_type; - move16(); - - return coder_type; -} - -/*-------------------------------------------------------------------* - * find_uv() - * - * Decision about coder type - *-------------------------------------------------------------------*/ -Word16 find_uv_ivas_fx( /* o : coding type */ -#else /*! r: coder type */ Word16 find_uv_fx( -#endif - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ - const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ - const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ - Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/ - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF q_hp_E*/ - Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ - const Word16 last_core_orig, /* i : original last core Q0*/ - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - const Word16 Q_new, -#ifdef FIX_2349_HARM_FIND_UV - const Word16 shift, -#endif - const Word16 q_hp_E ) + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ + const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ + const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ + const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ + Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/ + const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ + const Word16 relE, /* i : relative frame energy Q8*/ + const Word16 Etot, /* i : total energy Q8*/ + const Word32 hp_E[], /* i : energy in HF q_hp_E*/ + Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ + const Word16 last_core_orig, /* i : original last core Q0*/ + STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ + const Word16 Q_new, + const Word16 shift, + const Word16 q_hp_E ) { Word16 coder_type, i; Word32 mean_ee, dE1, fac_32; @@ -622,12 +127,10 @@ Word16 find_uv_fx( Q_in = Q_new; move16(); -#ifdef FIX_2349_HARM_FIND_UV if ( st_fx->element_mode == EVS_MONO ) { Q_in = sub( Q_new, 1 ); } -#endif IF( hSC_VBR != NULL ) { @@ -738,7 +241,6 @@ Word16 find_uv_fx( * Total frame energy difference (dE3) *-----------------------------------------------------------------*/ -#ifdef FIX_2349_HARM_FIND_UV IF( st_fx->element_mode == EVS_MONO ) /* Overwrite dE3 in case of EVS */ { dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/ @@ -747,9 +249,6 @@ Word16 find_uv_fx( { dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/ } -#else - dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/ -#endif /*-----------------------------------------------------------------* * Energy decrease after spike (dE2) @@ -839,12 +338,10 @@ Word16 find_uv_fx( } E_min_th = L_shl( E_MIN_IVAS_FX_Q31, sub( q_hp_E, Q31 ) ); -#ifdef FIX_2349_HARM_FIND_UV if ( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */ { E_min_th = L_shl( E_MIN_FX, Q_new ); } -#endif test(); test(); @@ -877,7 +374,6 @@ Word16 find_uv_fx( ee1_th = 544; /*8.5f Q6*/ move16(); -#ifdef FIX_2349_HARM_FIND_UV IF( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */ { loc_lp_noise = st_fx->lp_noise_fx; @@ -886,9 +382,6 @@ Word16 find_uv_fx( { loc_lp_noise = extract_h( st_fx->lp_noise_32fx ); } -#else - loc_lp_noise = extract_h( st_fx->lp_noise_32fx ); -#endif /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */ IF( st_fx->input_bwidth != NB ) @@ -958,7 +451,6 @@ Word16 find_uv_fx( move16(); } } -#ifdef FIX_2349_HARM_FIND_UV ELSE IF( st_fx->element_mode == EVS_MONO ) { if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ @@ -976,7 +468,6 @@ Word16 find_uv_fx( move16(); } } -#endif ELSE { test(); @@ -1112,11 +603,7 @@ Word16 find_uv_fx( /* Current frame cannot be compressed to pack the partial redundancy */ IF( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) ) /* can happen only for EVS format */ { -#ifdef FIX_2349_HARM_FIND_UV core_coder_mode_switch_fx( st_fx, st_fx->last_total_brate, 0, shift ); -#else - core_coder_mode_switch_ivas_fx( st_fx, st_fx->last_total_brate, 0 ); -#endif } } } diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c index 8f70a5b3642a8cc15c5ba7d1c23d6c0b5b6b73e5..7c5a7884c757ea1d20486bd3448ccba0261f3a83 100644 --- a/lib_enc/hq_hr_enc_fx.c +++ b/lib_enc/hq_hr_enc_fx.c @@ -337,11 +337,7 @@ void hq_hr_enc_ivas_fx( test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { -#ifdef HARM_NON_LINEARITY calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); -#else - calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); -#endif v_multc_att32( t_audio_fx, att_fx, t_audio_fx, sfm_end[( num_sfm - 1 )] ); /* Q12 */ } diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 1037fb6c4c565e5ea365550b61a63f236b3c5f9f..deed347b32a9f41063d9c8a734806a8016cefb5a 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -4141,11 +4141,7 @@ void IGFEncApplyMono_ivas_fx( test(); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) { -#ifdef HARM_NON_LINEARITY calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); -#else - calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); -#endif } 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 ); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 35d7f45b3e1d45fc04749bb7e561ff2b5d737710..14230d021674e65e1fa61dd5b6a8e52deb6601bc 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -232,7 +232,6 @@ ivas_error ivas_core_enc_fx( Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12 } -#ifdef FIX_2344_ALIGN_PREPROC Word32 last_element_brate_tmp = element_brate; move32(); IF( EQ_32( ivas_format, SBA_FORMAT ) ) @@ -244,28 +243,6 @@ ivas_error ivas_core_enc_fx( pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate_tmp, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ); -#else - IF( EQ_32( ivas_format, SBA_FORMAT ) ) - { - IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, - &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], - vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), - IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE - { - IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, - &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], - vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), - IVAS_ERR_OK ) ) - { - return error; - } - } -#endif test(); IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || EQ_16( st->element_mode, IVAS_SCE ) ) @@ -771,10 +748,8 @@ ivas_error ivas_core_enc_fx( #ifndef REMOVE_SCALING_SHB_SPEECH Word16 Q_shb_spch_16 = Q_shb_spch; move16(); -#ifdef FIX_2344_ALIGN_PREPROC IF( st->tcxonly == 0 || hStereoICBWE != NULL || st->core == ACELP_CORE ) // temp. fix to keep BE until #1504 (FLP) is solved, then it will become: // IF( st->tcxonly == 0 ) -#endif { shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch @@ -852,11 +827,7 @@ ivas_error ivas_core_enc_fx( #ifndef REMOVE_SCALING_SHB_SPEECH Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, negate( Q_shb_spch ) ); // Q0 #endif -#ifdef HARM_NON_LINEARITY swb_CNG_enc_fx( st, shb_speech_fx, old_syn_12k8_16k_fx[n] ); -#else - swb_CNG_enc_ivas_fx( st, shb_speech_fx /* Unmodified */, old_syn_12k8_16k_fx[n] ); -#endif } /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index b8d10c06fb496818ff397ea9ca7f0d3df6fda3dd..8541b3fd9f4134151535894ee2319b61a04dfb43 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -76,11 +76,7 @@ static Word16 get_zero_flag( const Word32 arr[], const Word16 len ) * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification) *--------------------------------------------------------------------*/ -#ifdef FIX_2344_ALIGN_PREPROC void pre_proc_front_ivas_fx( -#else -ivas_error pre_proc_front_ivas_fx( -#endif SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ @@ -161,9 +157,6 @@ ivas_error pre_proc_front_ivas_fx( STEREO_CLASSIF_HANDLE hStereoClassif; Word16 old_pitch1; /* previous frame OL pitch[1] @12.8 kHz */ Word16 LR_localVAD; -#ifndef FIX_2344_ALIGN_PREPROC - ivas_error error; -#endif Word16 *signal_in_fx; Word32 *signal32_in_fx; Word16 *inp_12k8_fx, *new_inp_12k8_fx; /* pointers to current frame and new data */ @@ -214,30 +207,15 @@ ivas_error pre_proc_front_ivas_fx( Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX]; Word16 Q_inp_const = -1; move16(); -#ifdef FIX_2344_ALIGN_PREPROC Word16 headroom, preemp_len, inp_max; -#else - Word16 headroom = 0, preemp_len = 0, inp_max = 0; - move16(); - move16(); - move16(); -#endif Word16 *preemp_start_idx = NULL; -#ifdef FIX_2344_ALIGN_PREPROC Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32; -#else - Word32 sig_out[960], max_32; -#endif push_wmops( "pre_proc_front" ); /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ -#ifndef FIX_2344_ALIGN_PREPROC - error = IVAS_ERR_OK; - move32(); -#endif cldfbScale.lb_scale = Q31; cldfbScale.hb_scale = Q31; move16(); @@ -542,17 +520,10 @@ ivas_error pre_proc_front_ivas_fx( * Perform fixed preemphasis (12.8 kHz signal) through 1 - g*z^-1 *-----------------------------------------------------------------*/ -#ifndef FIX_2344_ALIGN_PREPROC - *Q_new = 0; - move16(); - set32_fx( sig_out, 0, 960 ); -#endif headroom = 2; move16(); -#ifdef FIX_2344_ALIGN_PREPROC preemp_len = 0; move16(); -#endif st->mem_preemph_fx_q_inp = shl_sat( st->mem_preemph_fx_q_inp, sub( st->q_inp, st->mem_preemph_q ) ); /*st->q_inp*/ move16(); @@ -1268,13 +1239,8 @@ ivas_error pre_proc_front_ivas_fx( find_tilt_ivas_fx( fr_bands_fx, fr_bands_fx_q, bckr_temp, scale, ee_fx, st->pitch, st->voicing_fx, lf_E_fx, q_lf_E_fx, corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); -#ifdef FIX_2349_HARM_FIND_UV st->coder_type = find_uv_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx, &flag_spitch, last_core_orig, hStereoClassif, *Q_new, 0, fr_bands_fx_q ); // Q0 -#else - st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx, - &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0 -#endif Copy_Scale_sig_16_32_no_sat( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) ); @@ -1477,15 +1443,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); /* Compute core-coder buffers at internal sampling rate */ -#ifdef FIX_2344_ALIGN_PREPROC ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); -#else - error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); - IF( NE_32( error, IVAS_ERR_OK ) ) - { - return error; - } -#endif *epsP_fx_q = add( Q_r[0], 1 ); move16(); @@ -1572,11 +1530,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); pop_wmops(); -#ifdef FIX_2344_ALIGN_PREPROC return; -#else - return error; -#endif } diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index e6dc79e2fa955b2c9e019409a90bfd786d92467d..e83973437cfbbb2478041afa7aa458d0749b5d95 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -46,11 +46,7 @@ * Decision matrix, Preprocessing at other Fs, core switching decision, ...) *--------------------------------------------------------------------*/ -#ifdef FIX_2344_ALIGN_PREPROC void pre_proc_ivas_fx( -#else -ivas_error pre_proc_ivas_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode Q0*/ const Word32 element_brate, /* i : element bitrate Q0*/ @@ -86,16 +82,9 @@ ivas_error pre_proc_ivas_fx( Word16 *inp_16k_fx, *new_inp_12k8_fx, *inp_12k8_fx; /* pointers to current frame and new data */ Word16 *wsp_fx; /* weighted input signal buffer */ Word32 sr_core_tmp, total_brate_tmp; -#ifndef FIX_2344_ALIGN_PREPROC - ivas_error error; -#endif push_wmops( "pre_proc" ); -#ifndef FIX_2344_ALIGN_PREPROC - error = IVAS_ERR_OK; - move32(); -#endif /*----------------------------------------------------------------* * Initialization *----------------------------------------------------------------*/ @@ -173,7 +162,6 @@ ivas_error pre_proc_ivas_fx( move16(); } -#ifdef FIX_2344_ALIGN_PREPROC IF( EQ_16( st->L_frame, L_FRAME16k ) ) { total_brate_tmp = ACELP_16k40; @@ -192,27 +180,6 @@ ivas_error pre_proc_ivas_fx( { configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate_tmp ); } -#else - test(); - test(); - test(); - Word16 flag_1 = 0; - move16(); - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - flag_1 = ACELP_16k40; - move16(); - } - ELSE - { - flag_1 = ACELP_9k60; - move16(); - } - IF( st->hFdCngEnc != NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) && ( ( NE_16( st->hFdCngEnc->hFdCngCom->frameSize, st->L_frame ) ) || ( NE_16( st->hFdCngEnc->hFdCngCom->CngBandwidth, st->input_bwidth ) ) ) ) - { - configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), flag_1 ); - } -#endif if ( st->ini_frame == 0 ) { @@ -503,16 +470,6 @@ ivas_error pre_proc_ivas_fx( } } -#ifndef FIX_2344_ALIGN_PREPROC - /* channel-aware mode - due to lack of signaling bit, sharpFlag is 1 always in RF mode */ - test(); - test(); - if ( st->rf_mode && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, GENERIC ) ) ) - { - st->sharpFlag = 1; - move16(); - } -#endif /* TD stereo, secondary channel - due to lack of signaling bits, sharpFlag is always 1 */ test(); IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) @@ -601,28 +558,14 @@ ivas_error pre_proc_ivas_fx( move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); -#ifndef FIX_2344_ALIGN_PREPROC - Word16 Q_inp_12k8 = *Q_new; - move16(); - Word16 Q_inp_16k = *Q_new; - move16(); -#endif IF( !flag_16k_smc ) { -#ifdef FIX_2344_ALIGN_PREPROC Word16 Q_inp_12k8 = *Q_new; move16(); Word16 Q_inp_16k; ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k ); -#else - error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, - A_fx, Aw_fx, - epsP_fx, - lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k ); - -#endif IF( GT_16( Q_inp_16k, Q_inp_12k8 ) ) { @@ -636,12 +579,6 @@ ivas_error pre_proc_ivas_fx( } move16(); -#ifndef FIX_2344_ALIGN_PREPROC - IF( error != IVAS_ERR_OK ) - { - return error; - } -#endif test(); IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) { @@ -727,11 +664,7 @@ ivas_error pre_proc_ivas_fx( } pop_wmops(); -#ifdef FIX_2344_ALIGN_PREPROC return; -#else - return error; -#endif } @@ -741,11 +674,7 @@ ivas_error pre_proc_ivas_fx( * Compute core-coder buffers at internal sampling rate *--------------------------------------------------------------------*/ -#ifdef FIX_2344_ALIGN_PREPROC void ivas_compute_core_buffers_fx( -#else -ivas_error ivas_compute_core_buffers_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame Q_new-1*/ Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz Q_new-1*/ @@ -775,32 +704,15 @@ ivas_error ivas_compute_core_buffers_fx( Word16 Q_tmp, mem_decim16k_size, size_modified; Word16 epsP_h[M + 1]; Word16 epsP_l[M + 1]; -#ifdef FIX_2344_ALIGN_PREPROC Word16 i, shift, Q_min; Word16 preemp_len, inp_max; -#else - Word16 headroom = 1, preemp_len = 0, inp_max = 0; - move16(); - move16(); - move16(); -#endif Word16 *preemp_start_idx = NULL; -#ifdef FIX_2344_ALIGN_PREPROC #ifdef FIX_2376_FIX_USAN_PRE_PROC Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k + L_FILT16k], max_32; #else Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32; #endif -#else - Word32 sig_out[960], max_32; -#endif -#ifndef FIX_2344_ALIGN_PREPROC - set16_fx( new_inp_resamp16k_fx, 0, L_FRAME16k ); - set16_fx( epsP_h, 0, M + 1 ); - set16_fx( epsP_l, 0, M + 1 ); - set16_fx( input_buf_fx, 0, L_FRAME48k * 2 ); -#endif Copy_Scale_sig( st->input_fx - input_frame, input_buf_fx, input_frame, sub( -1, st->q_old_inp ) ); Copy_Scale_sig( st->input_fx, input_buf_fx + input_frame, input_frame, sub( -1, st->q_inp ) ); @@ -917,23 +829,14 @@ ivas_error ivas_compute_core_buffers_fx( Scale_sig( new_inp_16k_fx - lMemRecalc_16k - length_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ } -#ifdef FIX_2344_ALIGN_PREPROC size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - lMemRecalc_16k, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ Scale_sig( new_inp_16k_fx - lMemRecalc_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ -#else - size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ - Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ -#endif Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX ); IF( lMemRecalc > 0 ) { -#ifdef FIX_2344_ALIGN_PREPROC size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - lMemRecalc_16k, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - lMemRecalc_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ -#else - size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ -#endif } set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); @@ -1017,37 +920,14 @@ ivas_error ivas_compute_core_buffers_fx( move16(); } -#ifdef FIX_2344_ALIGN_PREPROC *Q_new = 0; move16(); -#else - test(); - test(); - *Q_new = 0; - move16(); - set32_fx( sig_out, 0, 960 ); test(); - test(); - if ( ( ( st->bwidth == NB ) || ( st->max_bwidth == NB ) ) && ( GT_32( st->input_Fs, 8000 ) ) ) - { - headroom = add( headroom, 1 ); - } - -#endif - - test(); -#ifdef FIX_2344_ALIGN_PREPROC IF( EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) -#else - test(); - IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) -#endif { -#ifdef FIX_2344_ALIGN_PREPROC preemp_len = 0; move16(); -#endif IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { @@ -1134,12 +1014,7 @@ ivas_error ivas_compute_core_buffers_fx( maximum_abs_32_fx( sig_out, preemp_len, &max_32 ); inp_max = s_max( extract_h( max_32 ), 1 ); -#ifdef FIX_2344_ALIGN_PREPROC shift = sub( norm_s( inp_max ), 1 /* headroom */ ); -#else - Word16 shift = sub( norm_s( inp_max ), headroom ); - Word16 Q_min, i; -#endif shift = s_max( shift, 0 ); shift = s_min( shift, Q_MAX ); minimum_fx( st->Q_max_16k, L_Q_MEM, &Q_min ); @@ -1164,25 +1039,8 @@ ivas_error ivas_compute_core_buffers_fx( Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, add( *Q_new, 1 ) ); Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), *Q_new ); } -#ifdef FIX_2344_ALIGN_PREPROC ELSE /* keep memory up-to-date in case of bitrate switching */ -#else - ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */ -#endif { -#ifndef FIX_2344_ALIGN_PREPROC - IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) - { - st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1]; /* Q_new - 1 */ - move16(); - } - ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) ) - { - st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1]; /* Q_new - 1 */ - move16(); - } - ELSE -#endif IF( EQ_16( element_mode, IVAS_CPE_MDCT ) ) { st->mem_preemph16k_fx = 0; @@ -1206,9 +1064,6 @@ ivas_error ivas_compute_core_buffers_fx( IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) { /* update signal buffers */ -#ifndef FIX_2344_ALIGN_PREPROC - Word16 shift; -#endif shift = negate( *Q_new ); move16(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) @@ -1244,14 +1099,12 @@ ivas_error ivas_compute_core_buffers_fx( analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r ); } -#ifdef FIX_2344_ALIGN_PREPROC FOR( i = 0; i < M + 1; i++ ) { epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] ); move32(); } -#endif /*--------------------------------------------------------------* * Compute Weighted Input *---------------------------------------------------------------*/ @@ -1270,30 +1123,19 @@ ivas_error ivas_compute_core_buffers_fx( /* update old input signal @16kHz buffer */ test(); test(); -#ifndef FIX_2344_ALIGN_PREPROC - test(); -#endif IF( ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) { set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM ); st->exp_old_inp_16k = 0; move16(); } -#ifdef FIX_2344_ALIGN_PREPROC ELSE IF( EQ_32( sr_core, INT_FS_16k ) ) -#else - ELSE IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) ) -#endif { Copy( &old_inp_16k_fx[L_frame_tmp], st->old_inp_16k_fx, L_INP_MEM ); st->exp_old_inp_16k = sub( Q16, *Q_new ); //(*Q_new - 1) move16(); } -#ifdef FIX_2344_ALIGN_PREPROC ELSE -#else - ELSE IF( GT_32( input_Fs, 8000 ) ) -#endif { lerp( st->old_inp_12k8_fx + L_INP_MEM - L_INP_MEM * 4 / 5, st->old_inp_16k_fx, L_INP_MEM, L_INP_MEM * 4 / 5 ); Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( -1 /* Q st->old_inp_16k_fx = -1 */, sub( 15, st->exp_old_inp_12k8 ) ) ); @@ -1311,18 +1153,5 @@ ivas_error ivas_compute_core_buffers_fx( Copy( new_inp_resamp16k_fx, new_inp_resamp16k_out_fx, L_FRAME16k ); } -#ifndef FIX_2344_ALIGN_PREPROC - test(); - IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) - { - FOR( Word16 i = 0; i < M + 1; i++ ) - { - epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] ); - move32(); - } - } - return IVAS_ERR_OK; -#else return; -#endif } diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 04bf8c197a61e73e23d494e16734fdc78d72cabd..9c845eb400fa2b3c81e21df8ec80810198f2917a 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -236,13 +236,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp, shift ); move16(); q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ); -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, input_frame ), Q1 ); scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ -#else - shift = sub( getScaleFactor16( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); - scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ -#endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp, shift ); move16(); q_com_sce = s_min( q_com_sce, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ); @@ -252,13 +247,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32, shift ); move16(); q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 ); -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, input_frame ), Q1 ); scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, input_frame, shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ -#else - shift = sub( getScaleFactor32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); - scale_sig32( st_ivas->hSCE[k]->hCoreCoder[0]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hSCE[k]->hCoreCoder[0]->q_inp + shift */ -#endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32, shift ); move16(); q_com_sce32 = s_min( q_com_sce32, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 ); @@ -277,13 +267,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp, shift ); move16(); q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ); -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, input_frame ), Q1 ); scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ -#else - shift = sub( getScaleFactor16( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); - scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ -#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp, shift ); move16(); q_com_cpe = s_min( q_com_cpe, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ); @@ -293,13 +278,8 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32, shift ); move16(); q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 ); -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, input_frame ), Q1 ); scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, input_frame, shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ -#else - shift = sub( getScaleFactor32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ) ), Q1 ); - scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input32_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), shift ); /* st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp + shift */ -#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32, shift ); move16(); q_com_cpe32 = s_min( q_com_cpe32, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 ); @@ -314,18 +294,10 @@ ivas_error ivas_corecoder_enc_reconfig_fx( scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp ) ); /* q_com */ st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp = q_com; move16(); -#ifdef FIX_2320_OOB_SCE_SWITCHING scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, input_frame, sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ -#else - scale_sig( st_ivas->hSCE[k]->hCoreCoder[0]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hSCE[k]->hCoreCoder[0]->q_inp ) ); /* q_com */ -#endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp = q_com; move16(); -#ifdef FIX_2320_OOB_SCE_SWITCHING Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, shl( input_frame, 1 ), Q6 ); /* Q6 + q_com */ -#else - Copy_Scale_sig_16_32_DEPREC( st_ivas->hSCE[k]->hCoreCoder[0]->input_buff_fx, st_ivas->hSCE[k]->hCoreCoder[0]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ -#endif st_ivas->hSCE[k]->hCoreCoder[0]->q_inp32 = add( Q6, q_com ); st_ivas->hSCE[k]->hCoreCoder[0]->q_old_inp32 = add( Q6, q_com ); move16(); @@ -342,18 +314,10 @@ ivas_error ivas_corecoder_enc_reconfig_fx( scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->old_input_signal_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp ) ); /* q_com */ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp = q_com; move16(); -#ifdef FIX_2320_OOB_SCE_SWITCHING scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, input_frame, sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ -#else - scale_sig( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_fx, sub( L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_frame ), sub( q_com, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp ) ); /* q_com */ -#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp = q_com; move16(); -#ifdef FIX_2320_OOB_SCE_SWITCHING Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, shl( input_frame, 1 ), Q6 ); /* Q6 + q_com */ -#else - Copy_Scale_sig_16_32_DEPREC( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff_fx, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->input_buff32_fx, L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS ) + L_FRAME48k, Q6 ); /* Q6 + q_com */ -#endif st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_inp32 = add( Q6, q_com ); st_ivas->hCPE[cpe_id]->hCoreCoder[n]->q_old_inp32 = add( Q6, q_com ); move16(); diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 6e7455d638a3ce3a16aef14950e5274e80ce177c..be1caae8320de6582080ec6b5cebfd1181d5ba63 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -130,9 +130,7 @@ ivas_error ivas_cpe_enc_fx( Word16 NFFT_inner; move16(); move16(); -#ifdef FIX_2320_OOB_SCE_SWITCHING Word16 input_frame_2; -#endif Word16 i, j, q_com, shift, q_min, gb; error = IVAS_ERR_OK; @@ -159,9 +157,7 @@ ivas_error ivas_cpe_enc_fx( * Initialization - general *-----------------------------------------------------------------*/ -#ifdef FIX_2320_OOB_SCE_SWITCHING input_frame_2 = shl( input_frame, 1 ); -#endif set16_fx( q_re_im_buf, 0, CPE_CHANNELS ); tdm_SM_or_LRTD_Pri = 0; @@ -412,13 +408,8 @@ ivas_error ivas_cpe_enc_fx( IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { gb = find_guarded_bits_fx( sts[0]->encoderLookahead_FB ); -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = L_norm_arr( sts[1]->old_input_signal32_fx, input_frame_2 ); shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, input_frame_2 ) ); -#else - shift = L_norm_arr( sts[1]->old_input_signal32_fx, shl( input_frame, 1 ) ); - shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, shl( input_frame, 1 ) ) ); -#endif IF( LT_16( shift, gb ) ) { @@ -444,17 +435,10 @@ ivas_error ivas_cpe_enc_fx( * Temporal inter-channel alignment, stereo adjustment *----------------------------------------------------------------*/ -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, input_frame_2 ), L_norm_arr( sts[1]->input_buff32_fx, input_frame_2 ) ); q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); scale_sig32( sts[1]->input_buff32_fx, input_frame_2, sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ scale_sig32( sts[0]->input_buff32_fx, input_frame_2, sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ -#else - shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ); - q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); - scale_sig32( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ - scale_sig32( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ -#endif sts[0]->q_inp32 = sts[1]->q_inp32 = sts[0]->q_old_inp32 = sts[1]->q_old_inp32 = q_min; move16(); move16(); @@ -463,17 +447,10 @@ ivas_error ivas_cpe_enc_fx( stereo_tca_enc_fx( hCPE, input_frame ); -#ifdef FIX_2320_OOB_SCE_SWITCHING shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, input_frame_2 ), sts[0]->q_inp32 ), 16 ); shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, input_frame_2 ), sts[1]->q_inp32 ), 16 ) ); Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, input_frame_2, sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, input_frame_2, sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift -#else - shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 ); - shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[1]->q_inp32 ), 16 ) ); - Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift - Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift -#endif sts[0]->q_inp = sts[1]->q_inp = sts[0]->q_old_inp = sts[1]->q_old_inp = shift; move16(); move16(); @@ -630,7 +607,6 @@ ivas_error ivas_cpe_enc_fx( { sts[n]->bits_frame_nominal = extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */ sts[n]->bits_frame_channel = idiv1616( extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ), n_CoreChannels ); /* Q0 */ -#ifdef FIX_2362_TOTAL_BRATE_CALCULATION /* sts[n]->total_brate = hCPE->element_brate / n_CoreChannels; */ assert( n_CoreChannels == 1 || n_CoreChannels == 2 ); sts[n]->total_brate = hCPE->element_brate; @@ -638,9 +614,6 @@ ivas_error ivas_cpe_enc_fx( { sts[n]->total_brate = L_shr( hCPE->element_brate, 1 ); } -#else - sts[n]->total_brate = L_shl( div_l( hCPE->element_brate, n_CoreChannels ), 1 ); /* Q0 */ -#endif move32(); move16(); move16(); @@ -871,19 +844,11 @@ ivas_error ivas_cpe_enc_fx( // Normalise the input buffer from Q15 Word16 input_norm, q_inp; //, common_q, fir_delay_len; -#ifdef FIX_2320_OOB_SCE_SWITCHING input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, input_frame_2 ); -#else - input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, shl( input_frame, 1 ) ); -#endif q_inp = sub( add( Q15, input_norm ), 16 ); // Rescale the old input, input and FIR delay section of input buffer -#ifdef FIX_2320_OOB_SCE_SWITCHING Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, input_frame_2, sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp -#else - Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, shl( input_frame, 1 ), sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp -#endif // Update the Q-factors sts[0]->q_inp = q_inp; @@ -957,21 +922,12 @@ ivas_error ivas_cpe_enc_fx( } move16(); -#ifndef FIX_2344_ALIGN_PREPROC - error = -#endif - pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n], - &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], - realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], - fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, - band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] ); + pre_proc_front_ivas_fx( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8_16fx[n], old_inp_16k_16fx[n], + &ener_fx[n], &relE_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], &vad_hover_flag[n], &attack_flag[n], + realBuffer_fx[n], imagBuffer_fx[n], &q_re_im_buf[n], old_wsp_fx[n], &q_old_wsp, pitch_fr_fx[n], voicing_fr_fx[n], &loc_harm[n], &cor_map_sum_fx[n], &vad_flag_dtx[n], enerBuffer_fx[n], &enerBuffer_fx_exp[n], + fft_buff_fx[n], &fft_buff_fx_q[n], A_fx[0], lsp_new_fx[0], currFlatness_fx[n], tdm_ratio_idx, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, q_lf_E[n], localVAD_HE_SAD, + band_energies_LR_fx, q_band_energies_LR, 0, front_vad_flag, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate, &Q_new[n] ); -#ifndef FIX_2344_ALIGN_PREPROC - IF( error != IVAS_ERR_OK ) - { - return error; - } -#endif e_old_wsp[n] = sub( Q15, q_old_wsp ); move16(); } @@ -1141,11 +1097,7 @@ ivas_error ivas_cpe_enc_fx( IF( ( NE_16( hCPE->element_mode, IVAS_CPE_DFT ) && NE_16( hCPE->element_mode, IVAS_CPE_TD ) ) || n == 0 ) /* modify coder_type of primary channel */ { /* limit coder_type depending on the bitrate */ -#ifndef FIX_2334_HARM_CODER_MODIF - coder_type_modif_ivas_fx( sts[n], relE_fx[n] ); -#else coder_type_modif_fx( sts[n], relE_fx[n] ); -#endif } } diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 7a2823b7a7487516c835d9c37db769f18748005a..16934822576d785bb3402878939bafc2b3400403 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -1574,17 +1574,9 @@ void computeDiffuseness_mdft_fx( set_zero_fx( intensity_slow, i_mult( DIRAC_NUM_DIMS, MASA_FREQUENCY_BANDS ) ); set16_fx( intensity_slow_e, 0, i_mult( DIRAC_NUM_DIMS, MASA_FREQUENCY_BANDS ) ); set_zero_fx( intensity_slow_abs, MASA_FREQUENCY_BANDS ); -#ifdef FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT set16_fx( intensity_slow_abs_e, 0, MASA_FREQUENCY_BANDS ); -#else - set16_fx( intensity_slow_abs_e, 0, no_col_avg_diff ); -#endif set_zero_fx( energy_slow, MASA_FREQUENCY_BANDS ); -#ifdef FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT set16_fx( energy_slow_e, 0, MASA_FREQUENCY_BANDS ); -#else - set16_fx( energy_slow_e, 0, no_col_avg_diff ); -#endif FOR( i = 0; i < no_col_avg_diff; ++i ) { diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 40f683925285942b8a23d87b066c23d35a838a37..94548ad2f9bfa812196d7d9890ac0cd3febd0396 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -244,19 +244,10 @@ ivas_error ivas_ism_enc_fx( move16(); Word16 q_fr_bands[2]; -#ifndef FIX_2344_ALIGN_PREPROC - error = -#endif - pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], - &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], - realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], - fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] ); -#ifndef FIX_2344_ALIGN_PREPROC - IF( error != IVAS_ERR_OK ) - { - return error; - } -#endif + pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata[sce_id], input_frame, 0, old_inp_12k8_fx[sce_id][0], old_inp_16k_fx[sce_id][0], + &ener_fx[sce_id][0], &relE_fx[sce_id][0], A_fx[sce_id][0], Aw_fx[sce_id][0], epsP_fx[sce_id][0], &epsP_fx_q[sce_id][0], lsp_new_fx[sce_id][0], lsp_mid_fx[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], + realBuffer_fx[sce_id][0], imagBuffer_fx[sce_id][0], &q_re_im_buf[sce_id], old_wsp_fx[sce_id][0], &q_old_wsp, pitch_fr_fx[sce_id][0], voicing_fr_fx[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum_fx[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer_fx[sce_id][0], &enerBuffer_fx_exp[sce_id][0], + fft_buff_fx[sce_id][0], &fft_buff_fx_q[sce_id][0], A_fx[sce_id][0], lsp_new_fx[sce_id][0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, 0, 0, 0, 0, ISM_FORMAT, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[sce_id][0] ); e_old_wsp[sce_id][0] = sub( Q15, q_old_wsp ); move16(); @@ -447,11 +438,7 @@ ivas_error ivas_ism_enc_fx( } /* modify the coder_type depending on the total_brate per channel */ -#ifndef FIX_2334_HARM_CODER_MODIF - coder_type_modif_ivas_fx( st, relE_fx[sce_id][0] ); -#else coder_type_modif_fx( st, relE_fx[sce_id][0] ); -#endif /*----------------------------------------------------------------* * Encoder *----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 0cdad4d9285c5f70b8440640e2b541504e0709e3..6bfea1f19540db98ecc8ea5190a0d3f2ba23bd60 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -1800,10 +1800,8 @@ void ivas_masa_combine_directions_fx( } } -#ifdef FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA IF( GT_16( hMasa->config.numTwoDirBands, 0 ) ) { -#endif /* Estimate the importance of having two directions instead of one */ /* Reduced precision of importance_fx intentionally to Q13 to maintatin 0.0001f resolution */ FOR( i = 0; i < numCodingBands; i++ ) @@ -1831,10 +1829,8 @@ void ivas_masa_combine_directions_fx( /* Determine bands where to use two directions */ find_n_largest_fx( importance_fx, exp_importance, indicesOfLargest, numCodingBands, hMasa->config.numTwoDirBands ); -#ifdef FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA } -#endif FOR( i = 0; i < numCodingBands; i++ ) { diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 4d611915abdf3ef68ef2e41727178bcdd37c057c..2507d6a0dbd6e1502235a206b44e499180448a4f 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -1021,14 +1021,12 @@ void ivas_mcmasa_param_est_enc_fx( move32(); hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = 0; move32(); -#ifdef FIX_BASOP_2324_MISSING_SET_TO_ZERO hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx] = 0; move16(); hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx] = 0; move16(); hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx] = 0; move16(); -#endif } /* Reset variable */ diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index f4889bf5f0b2b983e6de9dfcd068cf4b54dccf4b..560cd81bd4b542e53725da58e0a8d9c5ecb556d0 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -2445,11 +2445,7 @@ void ivas_mdct_core_whitening_enc_fx( } } -#ifdef HARM_COREDECODER_FUNCTIONS encode_lpc_avq_fx( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode ); -#else - encode_lpc_avq_ivas_fx( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode ); -#endif st->side_bits_frame_channel = add( st->side_bits_frame_channel, sub( hBstr->nb_bits_tot, nbits_start_sns ) ); move16(); diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 4d639c961ca13c7ce256ecd3481d68b59c778e90..ec539b738321d0cedd7b19d0d0ae80c5347b74ba 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -251,7 +251,6 @@ ivas_error ivas_sce_enc_fx( move16(); Word16 q_fr_bands[2]; -#ifdef FIX_2344_ALIGN_PREPROC Word16 front_vad_flag, force_front_vad, front_vad_dtx_flag; IF( st_ivas->hSpar != NULL ) { @@ -274,17 +273,6 @@ ivas_error ivas_sce_enc_fx( realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc, front_vad_flag, force_front_vad, front_vad_dtx_flag, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] ); -#else - error = pre_proc_front_ivas_fx( hSCE, NULL, hSCE->element_brate, nb_bits_metadata, input_frame, 0, old_inp_12k8_fx[0], old_inp_16k_fx[0], - &ener_fx[0], &relE_fx[0], A_fx[0], Aw_fx[0], epsP_fx[0], &epsP_fx_q[0], lsp_new_fx[0], lsp_mid_fx[0], &vad_hover_flag[0], &attack_flag[0], - realBuffer_fx[0], imagBuffer_fx[0], &q_re_im_buf, old_wsp_fx[0], &q_old_wsp, pitch_fr_fx[0], voicing_fr_fx[0], &loc_harm[0], &cor_map_sum_fx[0], &vad_flag_dtx[0], enerBuffer_fx[0], &enerBuffer_fx_exp[0], - fft_buff_fx[0], &fft_buff_fx_q[0], A_fx[0], lsp_new_fx[0], currFlatness_fx[0], 0, fr_bands_fx, q_fr_bands, Etot_LR_fx, lf_E_fx, 31, localVAD_HE_SAD, NULL, 31, flag_16k_smc, - st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, ivas_format, 0, st_ivas->hEncoderConfig->last_ivas_total_brate, st_ivas->hEncoderConfig->ivas_total_brate, &Q_new[0] ); - IF( NE_32( error, IVAS_ERR_OK ) ) - { - return error; - } -#endif e_old_wsp[0] = sub( Q15, q_old_wsp ); move16(); @@ -364,11 +352,7 @@ ivas_error ivas_sce_enc_fx( move16(); /* modify the coder_type depending on the total_brate per channel */ -#ifndef FIX_2334_HARM_CODER_MODIF - coder_type_modif_ivas_fx( st, relE_fx[0] ); -#else coder_type_modif_fx( st, relE_fx[0] ); -#endif /*----------------------------------------------------------------* * Encoder *----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 6bd3aca8cf73508e86923b64c57a3a91ff1d0a60..709e17ef716a3ea4c82c7824624b342d35933d24 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -629,27 +629,15 @@ void stereo_tcx_core_enc( E_LPC_a_lsp_conversion( A_fx, lsptmp_fx, lsp_new_fx, M ); Residu3_fx( A_fx, buf_fx + L_LP - L_FRAME, res_fx, L_FRAME, 0 ); -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsptmp_fx, res_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, Q_r, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#else - cng_params_upd_ivas_fx( lsptmp_fx, res_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, - st->hTdCngEnc->ho_lsp_circ_fx, Q_r, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, - st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#endif Q_exc = Q_r; move16(); } ELSE { -#ifdef HARM_NON_LINEARITY cng_params_upd_fx( lsp_new_fx, st->hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, st->hLPDmem->q_lpd_old_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#else - cng_params_upd_ivas_fx( lsp_new_fx, st->hLPDmem->old_exc + L_EXC_MEM - st->L_frame, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, - st->hTdCngEnc->ho_lsp_circ_fx, st->hLPDmem->q_lpd_old_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, - st->hFdCngEnc->hFdCngCom->CngBandwidth ); -#endif } IF( EQ_16( st->L_frame, L_FRAME ) ) diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index b423a7ae6da29d1e3d3af5e580dcce29f0a2419a..bc1f4cb3a979d6ec7b864bbe8a8505f500d48877 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -653,24 +653,11 @@ void lsf_end_enc_fx( IF( st->bwidth == NB ) { -#ifdef FIX_2302_LSF_CDBK_THRESHOLD abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); -#else - abs_threshold = L_add( SFNETLOWLIMIT_NB, 0 ); -#endif } ELSE { -#ifdef FIX_2302_LSF_CDBK_THRESHOLD abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 ); -#else - abs_threshold = SFNETLOWLIMIT_WB / 2; - move32(); - if ( flag_1bit_gran == 0 ) - { - abs_threshold = L_add( SFNETLOWLIMIT_WB, 0 ); - } -#endif } /* Calculate LSF weighting coefficients */ diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index bf2b1a7047e116664be6f322c778e6f63300f2e3..2f9f2b7c7a87fe1557a842fd5001e1c9eda70836 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1512,45 +1512,6 @@ Word16 lsf_msvq_ma_encprm_fx( return nbits_lpc; } -#ifndef HARM_COREDECODER_FUNCTIONS -Word16 lsf_msvq_ma_encprm_ivas_fx( - BSTR_ENC_HANDLE hBstr, - const Word16 *param_lpc, // Q0 - const Word16 core, - const Word16 acelp_mode, - const Word16 acelp_midLpc, - const Word16 *bits_param_lpc, - const Word16 no_indices ) -{ - Word16 i, nbits_lpc; - Word16 bits_midlpc; - - bits_midlpc = MIDLSF_NBITS; - move16(); - nbits_lpc = 0; - move16(); - - FOR( i = 0; i < no_indices; i++ ) - { - - push_next_indice( hBstr, *param_lpc, bits_param_lpc[i] ); - param_lpc++; - nbits_lpc = add( nbits_lpc, bits_param_lpc[i] ); - } - IF( NE_16( acelp_mode, VOICED ) ) - { - test(); - IF( ( core == ACELP_CORE ) && acelp_midLpc ) - { - - push_next_indice( hBstr, *param_lpc, bits_midlpc ); - nbits_lpc = add( nbits_lpc, bits_midlpc ); - } - } - - return nbits_lpc; -} -#endif /*--------------------------------------------------------------------------* * midlsf_enc_fx() @@ -1992,41 +1953,6 @@ Word16 enc_lsf_tcxlpc_fx( return NumBits; } -#ifndef HARM_COREDECODER_FUNCTIONS -Word16 enc_lsf_tcxlpc_ivas_fx( - const Word16 **indices, /* i : Ptr to VQ indices */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -) -{ - Word16 i, NumBits; - - Word16 flag; - - /* Read flag */ - flag = ( *indices )[0]; - move16(); - ++*indices; - - NumBits = TCXLPC_NUMBITS; - move16(); - FOR( i = 0; i < TCXLPC_NUMSTAGES; ++i ) - { - push_next_indice( hBstr, **indices, lsf_numbits[i] ); - ++*indices; - } - - IF( flag ) - { - NumBits = add( NumBits, TCXLPC_IND_NUMBITS ); - FOR( i = 0; i < TCXLPC_IND_NUMSTAGES; ++i ) - { - push_next_indice( hBstr, **indices, lsf_ind_numbits[i] ); - ++*indices; - } - } - return NumBits; -} -#endif /*--------------------------------------------------------------------------* * lsf_bctcvq_encprm_fx() @@ -2053,26 +1979,3 @@ Word16 lsf_bctcvq_encprm_fx( return nbits_lpc; } -#ifndef HARM_COREDECODER_FUNCTIONS - -Word16 lsf_bctcvq_encprm_ivas_fx( - BSTR_ENC_HANDLE hBstr, - const Word16 *param_lpc, // Q0 - const Word16 *bits_param_lpc, - const Word16 no_indices ) -{ - Word16 i, nbits_lpc; - - nbits_lpc = 0; - move16(); - - FOR( i = 0; i < no_indices; i++ ) - { - push_next_indice( hBstr, *param_lpc, bits_param_lpc[i] ); - param_lpc++; - nbits_lpc = add( nbits_lpc, bits_param_lpc[i] ); - } - - return nbits_lpc; -} -#endif diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 3e7207d0732f7cffc8e37d2569f6288ce8b250ec..479df45be311e0db91427d4ad915e0145753dda6 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -507,13 +507,8 @@ void pre_proc_fx( find_tilt_fx( fr_bands, hNoiseEst->bckr_fx, ee, st->pitch, st->voicing_fx, lf_E, corr_shift, st->input_bwidth, st->max_band, hp_E, st->codec_mode, *Q_new, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); -#ifdef FIX_2349_HARM_FIND_UV st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, 0L, corr_shift, relE, *Etot, hp_E, &flag_spitch, last_core_orig, NULL, *Q_new, *shift, 31 ); // Q0 -#else - st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, - corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig ); -#endif /*-----------------------------------------------------------------* * channel aware mode configuration * diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index fc5fa2eeb774f76c76812d27ef665ab0063f66f0..30aa1498bb144407acfe4bd83a371e21aa19831f 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -217,13 +217,8 @@ void find_tilt_fx( Word16 Opt_vbr_mode /* Q0 */ ); -#ifndef FIX_2349_HARM_FIND_UV -/* o : coding type */ -Word16 find_uv_ivas_fx( -#else /*! r: coder type */ Word16 find_uv_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ @@ -238,29 +233,9 @@ Word16 find_uv_fx( const Word16 last_core_orig, /* i : original last core Q0*/ STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ const Word16 Q_new, -#ifdef FIX_2349_HARM_FIND_UV const Word16 shift, -#endif const Word16 q_hp_E ); -#ifndef FIX_2349_HARM_FIND_UV -/* o : coding type */ -Word16 find_uv_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ - const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ - const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/ - const Word16 Q_new, - Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ - const Word16 shift, - const Word16 last_core_orig /* i : original last core Q0*/ -); -#endif void fine_gain_quant_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *ord, /* i : Indices for energy order */ @@ -615,13 +590,6 @@ void swb_CNG_enc_fx( const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz */ ); -#ifndef HARM_NON_LINEARITY -void swb_CNG_enc_ivas_fx( - Encoder_State *st, /* i/o: State structure */ - const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ - const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz Q0 */ -); -#endif void swb_pre_proc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *input_fx, /* i : original i signal */ @@ -1159,12 +1127,6 @@ void coder_type_modif_fx( const Word16 relE /* i : frame relative E to the long term average */ ); -#ifndef FIX_2334_HARM_CODER_MODIF -void coder_type_modif_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 relE /* i : frame relative E to the long term average */ -); -#endif void speech_music_clas_init_fx( SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ ); @@ -1709,21 +1671,6 @@ void reset_rf_indices_fx( ); void CNG_enc_fx( -#ifndef HARM_NON_LINEARITY - Encoder_State *st_fx, /* i/o: State structure */ - Word16 Aq[], /* o : LP coefficients Q12 */ - const Word16 *speech, /* i : pointer to current frame i speech buffer Q_new */ - Word32 L_enr, /* i : residual energy from Levinson-Durbin Q6 */ - const Word16 *lsp_mid, /* i : mid frame LSPs Q15 */ - Word16 *lsp_new, /* i/o: current frame ISPs Q15 */ - Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */ - Word16 *allow_cn_step, /* o : allow CN step Q0 */ - Word16 Q_new, /* i : Q value of speech */ - Word32 *q_env, - Word16 *sid_bw ); - -void CNG_enc_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: State structure */ Word16 Aq[], /* o : LP coefficients Q12 */ const Word16 *speech, /* i : pointer to current frame i speech buffer Q_new */ @@ -2714,13 +2661,6 @@ Word16 enc_lsf_tcxlpc_fx( BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ ); -#ifndef HARM_COREDECODER_FUNCTIONS -/* Returns: number of bits written */ -Word16 enc_lsf_tcxlpc_ivas_fx( - const Word16 **indices, /* i : Ptr to VQ indices */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -); -#endif Word16 encode_lpc_avq_fx( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 numlpc, /* i : Number of sets of lpc Q0*/ @@ -2729,28 +2669,12 @@ Word16 encode_lpc_avq_fx( const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/ ); -#ifndef HARM_COREDECODER_FUNCTIONS -Word16 encode_lpc_avq_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 numlpc, /* i : Number of sets of lpc Q0*/ - const Word16 *param_lpc, /* i : lpc parameters Q0*/ - const Word16 core, /* i : core Q0*/ - const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/ -); -#endif Word16 lsf_bctcvq_encprm_fx( BSTR_ENC_HANDLE hBstr, const Word16 *param_lpc, const Word16 *bits_param_lpc, const Word16 no_indices ); -#ifndef HARM_COREDECODER_FUNCTIONS -Word16 lsf_bctcvq_encprm_ivas_fx( - BSTR_ENC_HANDLE hBstr, - const Word16 *param_lpc, - const Word16 *bits_param_lpc, - const Word16 no_indices ); -#endif Word16 lsf_msvq_ma_encprm_fx( BSTR_ENC_HANDLE hBstr, const Word16 *param_lpc, @@ -2760,16 +2684,6 @@ Word16 lsf_msvq_ma_encprm_fx( const Word16 *bits_param_lpc, const Word16 no_indices ); -#ifndef HARM_COREDECODER_FUNCTIONS -Word16 lsf_msvq_ma_encprm_ivas_fx( - BSTR_ENC_HANDLE hBstr, - const Word16 *param_lpc, - const Word16 core, - const Word16 acelp_mode, - const Word16 acelp_midLpc, - const Word16 *bits_param_lpc, - const Word16 no_indices ); -#endif /* o: number of bits written per frame */ Word16 IGFEncWriteBitstream_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ @@ -3639,22 +3553,6 @@ void gain_enc_tc_fx( const Word16 Q_xn /* i : xn and y1 scaling */ ); -#ifndef HARM_COREDECODER_FUNCTIONS -void gain_enc_tc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 xn_fx[], /* i : target vector Q_xn*/ - const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : innovation gain Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/ - const Word16 Q_xn /* i : xn and y1 scaling */ -); -#endif Word16 gaus_encode_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subframe index Q0*/ @@ -3675,27 +3573,6 @@ Word16 gaus_encode_fx( Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ ); -#ifndef HARM_COREDECODER_FUNCTIONS -Word16 gaus_encode_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *h1, /* i : weighted filter input response Q14*/ - const Word16 *xn, /* i : target vector Q12*/ - Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ - Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ - Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word32 *gain_code, /* o : Code gain. Q16*/ - Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ - Word16 *gain_inov, /* o : innovation gain Q12*/ - Word16 *voice_fac, /* o : voicing factor Q15*/ - Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ - const Word16 Q_new, /* i : scaling factor */ - const Word16 shift, /* i : scaling factor */ - Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ -); -#endif void pre_proc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 input_frame, /* i : frame length */ diff --git a/lib_enc/qlpc_avq_fx.c b/lib_enc/qlpc_avq_fx.c index 0b28d1b77fc8632a5ce580a5649fee295cc80fbb..5d4d93fdfaf6d1aa6859cb40eb5f9a3835058d7c 100644 --- a/lib_enc/qlpc_avq_fx.c +++ b/lib_enc/qlpc_avq_fx.c @@ -130,38 +130,9 @@ void qlpc_avq_fx( * *--------------------------------------------------------------------*/ -#ifdef HARM_COREDECODER_FUNCTIONS static Word16 unary_code_fx( -#else -static Word16 unary_code( -#endif Word16 ind, /* Q0 */ BSTR_ENC_HANDLE hBstr ) -#ifndef HARM_COREDECODER_FUNCTIONS -{ - Word16 nb_bits; - - move16(); - nb_bits = 1; - - /* Index bits */ - ind = sub( ind, 1 ); - - FOR( ; ind > 0; ind-- ) - { - push_next_indice( hBstr, 1, 1 ); - nb_bits = add( nb_bits, 1 ); // Q0 - } - - /* Stop bit */ - push_next_indice( hBstr, 0, 1 ); - - return ( nb_bits ); -} -static Word16 unary_code_ivas_fx( - Word16 ind, /* Q0 */ - BSTR_ENC_HANDLE hBstr ) -#endif { Word16 nb_bits; @@ -195,11 +166,7 @@ static Word16 unary_code_ivas_fx( * *--------------------------------------------------------------------*/ -#ifdef HARM_COREDECODER_FUNCTIONS static Word16 unpack4bits_fx( -#else -static Word16 unpack4bits( -#endif Word16 nbits, /* Q0 */ const Word16 *prm, /* Q0 */ BSTR_ENC_HANDLE hBstr ) @@ -228,37 +195,6 @@ static Word16 unpack4bits( return ( i ); } -#ifndef HARM_COREDECODER_FUNCTIONS -static Word16 unpack4bits_ivas_fx( - Word16 nbits, /* Q0 */ - const Word16 *prm, /* Q0 */ - BSTR_ENC_HANDLE hBstr ) -{ - Word16 i; - - IF( nbits == 0 ) - { - push_next_indice( hBstr, 0, 0 ); - i = 1; - move16(); - } - ELSE - { - move16(); - i = 0; - - FOR( ; nbits > 4; nbits -= 4 ) - { - push_next_indice( hBstr, prm[i], 4 ); - i = add( i, 1 ); - } - push_next_indice( hBstr, prm[i], nbits ); - i = add( i, 1 ); - } - - return ( i ); -} -#endif /*-------------------------------------------------------------------* * encode_lpc_avq_fx() * @@ -266,215 +202,6 @@ static Word16 unpack4bits_ivas_fx( *--------------------------------------------------------------------*/ Word16 encode_lpc_avq_fx( -#ifndef HARM_COREDECODER_FUNCTIONS - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 numlpc, /* i : Number of sets of lpc Q0*/ - const Word16 *param_lpc, /* i : lpc parameters Q0*/ - const Word16 core, /* i : core Q0*/ - const Word16 element_mode /* i : element mode - decides between SNS and LPC coding Q0*/ -) -{ - Word16 k, j; - Word16 q_type, nb_ind; - Word16 i, qn1, qn2, nb, avqBits, st1; - Word16 nb_bits; - Word16 stereo_mode, bits_for_abs_quant; - - stereo_mode = 0; - move16(); - bits_for_abs_quant = LPC_ABS_QUANT_BITS; - move16(); - if ( EQ_16( element_mode, IVAS_CPE_MDCT ) ) - { - bits_for_abs_quant = SNS_ABS_QUANT_BITS; - move16(); - } - - move16(); - move16(); - move16(); - st1 = 0; - j = 0; - nb_bits = 0; - - FOR( k = 0; k < numlpc; k++ ) - { - /* Retrieve quantizer type */ - - - move16(); - q_type = 0; - if ( k != 0 ) - { - move16(); - q_type = param_lpc[j]; // Q0 - j = add( j, 1 ); - } - test(); - if ( EQ_16( element_mode, IVAS_CPE_MDCT ) && k == 0 ) - { - stereo_mode = param_lpc[j]; // Q0 - move16(); - j = add( j, 1 ); - } - /* Determine number of AVQ indices */ - move16(); - nb_ind = 0; - - if ( q_type == 0 ) - { - move16(); - st1 = param_lpc[j++]; // Q0 - } - move16(); - move16(); - qn1 = param_lpc[j++]; // Q0 - qn2 = param_lpc[j++]; // Q0 - IF( EQ_16( qn1, SNS_LOW_BR_MODE ) ) - { - nb_ind = add( qn1, qn2 ); - } - - test(); - test(); - IF( k == 0 || ( EQ_16( k, 1 ) && NE_16( core, TCX_20_CORE ) ) ) - { - /* Encode quantizer type */ - move16(); - nb = 0; - IF( k != 0 ) - { - nb = 1; - move16(); - push_next_indice( hBstr, q_type, nb ); - } - nb_bits = add( nb_bits, nb ); // Q0 - - /* Encode quantizer data */ - test(); - test(); - test(); - test(); - IF( ( ( q_type == 0 ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) || ( ( q_type == 0 ) && ( GE_16( st1, 0 ) ) && EQ_16( element_mode, IVAS_CPE_MDCT ) ) ) - { - /* Absolute quantizer with 1st stage stochastic codebook */ - push_next_indice( hBstr, st1, bits_for_abs_quant ); - nb_bits = add( nb_bits, bits_for_abs_quant ); // Q0 - } - - test(); - test(); - IF( EQ_16( element_mode, IVAS_CPE_MDCT ) && EQ_16( stereo_mode, 3 ) && st1 < 0 ) - { - push_next_indice( hBstr, add( st1, 2 ), 1 ); - nb_bits = add( nb_bits, 1 ); // Q0 - } - - test(); - test(); - IF( NE_16( element_mode, IVAS_CPE_MDCT ) || ( NE_16( st1, -2 ) && NE_16( qn1, SNS_LOW_BR_MODE ) ) ) - { - - /* 2 bits to specify Q2,Q3,Q4,ext */ - nb_bits = add( nb_bits, 4 ); // Q0 - i = sub( qn1, 2 ); - - if ( s_or( i < 0, (Word16) GT_16( i, 3 ) ) ) - { - move16(); - i = 3; - } - push_next_indice( hBstr, i, 2 ); - - i = sub( qn2, 2 ); - - if ( s_or( i < 0, (Word16) GT_16( i, 3 ) ) ) - { - move16(); - i = 3; - } - push_next_indice( hBstr, i, 2 ); - - /* Unary code for abs and rel LPC0/LPC2 */ - /* Q5 = 0, Q6=10, Q0=110, Q7=1110, ... */ - move16(); - nb = qn1; - - IF( GT_16( nb, 6 ) ) - { - nb = sub( nb, 3 ); - } - ELSE IF( GT_16( nb, 4 ) ) - { - nb = sub( nb, 4 ); - } - ELSE IF( nb == 0 ) - { - move16(); - nb = 3; - } - ELSE - { - move16(); - nb = 0; - } - - IF( nb > 0 ) - { - unary_code( nb, hBstr ); - } - nb_bits = add( nb_bits, nb ); // Q0 - - move16(); - nb = qn2; - - IF( GT_16( nb, 6 ) ) - { - nb = sub( nb, 3 ); // Q0 - } - ELSE IF( GT_16( nb, 4 ) ) - { - nb = sub( nb, 4 ); // Q0 - } - ELSE IF( nb == 0 ) - { - move16(); - nb = 3; - } - ELSE - { - move16(); - nb = 0; - } - - IF( nb > 0 ) - { - unary_code( nb, hBstr ); - } - nb_bits = add( nb_bits, nb ); // Q0 - - avqBits = shl( qn1, 2 ); - unpack4bits( avqBits, ¶m_lpc[j], hBstr ); - j = add( j, qn1 ); - nb_bits = add( nb_bits, avqBits ); // Q0 - - avqBits = shl( qn2, 2 ); - unpack4bits( avqBits, ¶m_lpc[j], hBstr ); - j = add( j, qn2 ); - nb_bits = add( nb_bits, avqBits ); // Q0 - } - } - ELSE - { - j = add( j, nb_ind ); - } - } - - return ( nb_bits ); -} - -Word16 encode_lpc_avq_ivas_fx( -#endif BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 numlpc, /* i : Number of sets of lpc Q0*/ const Word16 *param_lpc, /* i : lpc parameters Q0*/ @@ -631,11 +358,7 @@ Word16 encode_lpc_avq_ivas_fx( IF( nb > 0 ) { -#ifdef HARM_COREDECODER_FUNCTIONS unary_code_fx( nb, hBstr ); -#else - unary_code_ivas_fx( nb, hBstr ); -#endif } nb_bits = add( nb_bits, nb ); @@ -663,29 +386,17 @@ Word16 encode_lpc_avq_ivas_fx( IF( nb > 0 ) { -#ifdef HARM_COREDECODER_FUNCTIONS unary_code_fx( nb, hBstr ); -#else - unary_code_ivas_fx( nb, hBstr ); -#endif } nb_bits = add( nb_bits, nb ); avqBits = shl( qn1, 2 ); -#ifdef HARM_COREDECODER_FUNCTIONS unpack4bits_fx( avqBits, ¶m_lpc[j], hBstr ); -#else - unpack4bits_ivas_fx( avqBits, ¶m_lpc[j], hBstr ); -#endif j = add( j, qn1 ); nb_bits = add( nb_bits, avqBits ); // Q0 avqBits = shl( qn2, 2 ); -#ifdef HARM_COREDECODER_FUNCTIONS unpack4bits_fx( avqBits, ¶m_lpc[j], hBstr ); -#else - unpack4bits_ivas_fx( avqBits, ¶m_lpc[j], hBstr ); -#endif j = add( j, qn2 ); nb_bits = add( nb_bits, avqBits ); // Q0 } diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index b4d41c4055d402db5abd52c86c0f671b37f13c7d..ccc1e38e918d12836208aaf80b8bed6869d526cc 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -545,151 +545,7 @@ void select_TC_fx( * * Coder type modification *-------------------------------------------------------------------*/ -#ifndef FIX_2334_HARM_CODER_MODIF void coder_type_modif_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 relE /* i : frame relative E to the long term average Q8*/ -) -{ - Word16 unmod_coder_type, vbr_generic_ho; - - SC_VBR_ENC_HANDLE hSC_VBR = st->hSC_VBR; - - - IF( st->Opt_SC_VBR ) - { - vbr_generic_ho = hSC_VBR->vbr_generic_ho; - move16(); - } - ELSE - { - vbr_generic_ho = -1; - move16(); - } - - IF( EQ_16( st->codec_mode, MODE1 ) ) - { - /*---------------------------------------------------------------------* - * Coder type modification - * - * Prevent UC coder type in certain conditions - * Prevent VC coder type in certain conditions - * Select TC coder type in appropriate frames - *---------------------------------------------------------------------*/ - - /* At higher rates, use GC coding instead of UC coding to improve quality */ - test(); - test(); - test(); - test(); - test(); - if ( ( st->element_mode == 0 && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) || - ( st->element_mode > 0 && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) ) - { - st->coder_type = GENERIC; - move16(); - } - - /* Prevent UC coding on mixed content at 9.6 kb/s */ - test(); - test(); - if ( GE_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) && st->audio_frame_cnt != 0 ) - { - st->coder_type = GENERIC; - move16(); - } - - unmod_coder_type = st->coder_type; - move16(); - - /* Enforce GC coder type on inactive signal (this can be later overwritten to INACTIVE) */ - test(); - test(); - test(); - test(); - test(); - test(); - test(); - if ( st->localVAD == 0 && ( ( - EQ_16( st->coder_type, UNVOICED ) && ( ( st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->Opt_SC_VBR, 1 ) ) && vbr_generic_ho == 0 && GT_16( st->last_coder_type, UNVOICED ) ) ) ) || - EQ_16( st->coder_type, TRANSITION ) || EQ_16( st->coder_type, VOICED ) ) - - ) - { - st->coder_type = GENERIC; - move16(); - } - - test(); - test(); - IF( EQ_16( st->Opt_SC_VBR, 1 ) ) - { - test(); - if ( EQ_16( st->coder_type, GENERIC ) && EQ_16( unmod_coder_type, UNVOICED ) ) - { - hSC_VBR->vbr_generic_ho = 1; - move16(); - } - - if ( GT_16( st->coder_type, UNVOICED ) ) - { - hSC_VBR->vbr_generic_ho = 0; - move16(); - } - } - hSC_VBR->last_7k2_coder_type = st->coder_type; - move16(); - test(); - if ( st->localVAD == 0 && EQ_16( st->coder_type, UNVOICED ) ) - { - hSC_VBR->last_7k2_coder_type = GENERIC; - move16(); - } - - IF( st->element_mode == 0 ) - { - /* At higher rates and with 16kHz core, allow only GC and TC coder type */ - test(); - test(); - // test(); - if ( GT_32( st->total_brate, ACELP_16k40 ) && NE_16( st->coder_type, GENERIC ) && NE_16( st->coder_type, TRANSITION ) ) - { - /* onset/transition frame is always coded using GC mode */ - st->coder_type = GENERIC; - move16(); - } - } - ELSE /*IVAS*/ - { - /* At higher bitrates, disable UC and VC coder type; note that IC coder type is classified later */ - test(); - test(); - test(); - if ( ( GT_32( st->total_brate, MAX_VOICED_BRATE ) && EQ_16( st->coder_type, VOICED ) ) || - ( GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) ) - { - st->coder_type = GENERIC; - move16(); - } - } - - /* Patch for certain low-level signals for which the gain quantizer sometimes goes out of its dynamic range */ - test(); - test(); - test(); - if ( EQ_16( st->coder_type, VOICED ) && st->input_bwidth == 0 && LT_16( relE, -2560 ) && LE_32( st->total_brate, ACELP_8k00 ) ) - { - st->coder_type = GENERIC; - move16(); - } - } - - return; -} -void coder_type_modif_ivas_fx( -#else -void coder_type_modif_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ const Word16 relE /* i : frame relative E to the long term average */ ) @@ -777,7 +633,6 @@ void coder_type_modif_fx( hSC_VBR->vbr_generic_ho = 0; move16(); } -#ifdef FIX_2334_HARM_CODER_MODIF IF( NE_16( st->element_mode, EVS_MONO ) ) { hSC_VBR->last_7k2_coder_type = st->coder_type; @@ -789,9 +644,7 @@ void coder_type_modif_fx( move16(); } } -#endif } -#ifdef FIX_2334_HARM_CODER_MODIF IF( EQ_16( st->element_mode, EVS_MONO ) ) { hSC_VBR->last_7k2_coder_type = st->coder_type; @@ -803,7 +656,6 @@ void coder_type_modif_fx( move16(); } } -#endif IF( st->element_mode == 0 ) { diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index 08f3e5033ba2333499269cfd77117fff3cc79345..30def3e2ef7f2e707de6626f9913ed4d92b69d89 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -791,48 +791,28 @@ Word16 WriteTnsData_ivas_fx( STnsConfig const *pTnsConfig, Word16 const *stream, { IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) { -#ifdef HARM_COREDECODER_FUNCTIONS WriteToBitstream_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#else - WriteToBitstream_ivas_fx( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#endif } ELSE { -#ifdef HARM_COREDECODER_FUNCTIONS WriteToBitstream_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#else - WriteToBitstream_ivas_fx( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#endif } } ELSE { IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) { -#ifdef HARM_COREDECODER_FUNCTIONS WriteToBitstream_fx( &tnsEnabledSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#else - WriteToBitstream_ivas_fx( &tnsEnabledSWBTCX10BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#endif } ELSE { -#ifdef HARM_COREDECODER_FUNCTIONS WriteToBitstream_fx( &tnsEnabledSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#else - WriteToBitstream_ivas_fx( &tnsEnabledSWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#endif } } } ELSE { -#ifdef HARM_COREDECODER_FUNCTIONS WriteToBitstream_fx( &tnsEnabledWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#else - WriteToBitstream_ivas_fx( &tnsEnabledWBTCX20BitMap, 1, &stream, pnSize, hBstr, pnBits ); -#endif } return TNS_NO_ERROR; diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 5f1356def9e5285ced59d606e810b9163f037786..7c541478058975c0b623e303c7d9a8833b7e8a7f 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -562,11 +562,7 @@ Word16 wb_vad_fx( st_fx->max_band = 19; move16(); } -#ifdef FIX_2334_HARM_CODER_MODIF IF( st_fx->Opt_SC_VBR || ( !st_fx->Opt_SC_VBR && st_fx->element_mode == EVS_MONO ) ) /* this keep 26.444 BE */ -#else - IF( 1 ) // st_fx->Opt_SC_VBR ) /* this keep 26.444 BE */ -#endif { last_7k2_coder_type = st_fx->hSC_VBR->last_7k2_coder_type; move16(); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 7121cbe2c300d2120eded6de3e72be89f069dd69..f2a225de365080d75c07b2260cb0691022d492ae 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -211,11 +211,7 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } -#ifdef FIX_BASOP_2328_MSAN_WRONG_ASSIGNMENT dirac_output_synthesis_state->cy_auto_diff_smooth_prev_len = imult1616( dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ); -#else - dirac_output_synthesis_state->cy_auto_dir_smooth_prev_len = imult1616( dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ); -#endif move16(); } ELSE diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index e7df45b6cfb4128d2b3c9c2ba6744c8b2bf3af56..e242c9c085ccae575979946a8b7a8b7f579d49fe 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -860,11 +860,9 @@ ivas_error ivas_dirac_alloc_mem_fx( /* Prototypes */ hDirAC_mem->proto_direct_buffer_f_fx = NULL; hDirAC_mem->proto_diffuse_buffer_f_fx = NULL; -#ifdef FIX_BASOP_2329_UNINIT_VALUE hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len = 0; hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len = 0; hDirAC_mem->proto_diffuse_buffer_f_len = 0; -#endif test(); test(); IF( NE_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) && NE_32( renderer_type, RENDERER_STEREO_PARAMETRIC ) ) diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 05d65ececfc1cc090502bed5171f531498167a70..8f4149171fceb11c6109c2bbcc73f506ec4c8a65 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -425,7 +425,6 @@ void ivas_mcmasa_ana_close( free( ( *hMcMasa )->direction_vector_m_fx[i] ); ( *hMcMasa )->direction_vector_m_fx[i] = NULL; -#ifdef FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { @@ -435,7 +434,6 @@ void ivas_mcmasa_ana_close( free( ( *hMcMasa )->direction_vector_e[i] ); ( *hMcMasa )->direction_vector_e[i] = NULL; -#endif FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index edffafe45d63ebb773e261997bb2f09e81dce270..02af0f7fdb41a0beae11f7b2f41b25d0452c8cb2 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -719,11 +719,7 @@ static void ivas_omasa_dmx_fx( } max_e = in_e[0]; move16(); -#ifdef FIX_BASOP_2327_WRONG_LOOP_END FOR( l = 1; l < input_frame; l++ ) -#else - FOR( l = 1; l < L_FRAME48k; l++ ) -#endif { IF( LT_16( max_e, in_e[l] ) ) { @@ -732,11 +728,7 @@ static void ivas_omasa_dmx_fx( } } -#ifdef FIX_BASOP_2327_WRONG_LOOP_END FOR( l = 0; l < input_frame; l++ ) -#else - FOR( l = 0; l < L_FRAME48k; l++ ) -#endif { data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e ) move32(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index b497bceb7c2faf7bad8cac9602d2a46014ef1020..527a1b56486ba2d598ec29f77bacffb57bb8a965 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6487,17 +6487,9 @@ static ivas_error renderIsmToBinaural( ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) ); copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpTDRendBuffer ); -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpTDRendBuffer[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ -#else - Scale_sig32( tmpTDRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ -#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, @@ -6507,17 +6499,9 @@ static ivas_error renderIsmToBinaural( return error; } -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < outAudio.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpTDRendBuffer[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#else - Scale_sig32( tmpTDRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#endif } IF( ismInput->hReverb != NULL ) @@ -6780,17 +6764,9 @@ static ivas_error renderIsmToBinauralReverb( ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) ); copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpRendBuffer_fx ); -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer_fx[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ -#else - Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ -#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer_fx, &exp ) ), IVAS_ERR_OK ) ) @@ -6798,17 +6774,9 @@ static ivas_error renderIsmToBinauralReverb( return error; } -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < outAudio.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer_fx[i], outAudio.config.numSamplesPerChannel, negate( sub( 11, exp ) ) ); /* Q(exp) */ -#else - Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, negate( sub( 11, exp ) ) ); /* Q(exp) */ -#endif } IF( ismInput->hReverb != NULL ) @@ -6960,9 +6928,7 @@ static ivas_error renderIsmToSba( error = IVAS_ERR_OK; move32(); -#ifdef FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE set32_fx( currentPanGains_fx, 0, MAX_OUTPUT_CHANNELS ); -#endif ismInput->currentPos.azimuth_fx = L_shl( L_shr( L_add( ismInput->currentPos.azimuth_fx, ONE_IN_Q21 ), Q22 ), Q22 ); ismInput->currentPos.elevation_fx = L_shl( L_shr( L_add( ismInput->currentPos.elevation_fx, ONE_IN_Q21 ), Q22 ), Q22 ); @@ -7111,17 +7077,9 @@ static ivas_error renderIsmToSplitBinaural( } -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_NUM_OBJECTS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpProcessing[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ -#else - Scale_sig32( tmpProcessing[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ -#endif } /* Render */ @@ -7133,11 +7091,7 @@ static ivas_error renderIsmToSplitBinaural( FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpProcessing[i], output_frame, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#else - Scale_sig32( tmpProcessing[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#endif } IF( ismInput->hReverb != NULL ) @@ -7540,17 +7494,9 @@ static ivas_error renderMcToBinaural( { copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer_fx ); -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer_fx[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ -#else - Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ -#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb, 0, *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer_fx, &exp ) ), @@ -7559,17 +7505,9 @@ static ivas_error renderMcToBinaural( return error; } -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < outAudio.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer_fx[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#else - Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#endif } } ELSE @@ -7679,17 +7617,9 @@ static ivas_error renderMcToBinauralRoom( { copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer ); -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ -#else - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ -#endif } IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb, @@ -7699,17 +7629,9 @@ static ivas_error renderMcToBinauralRoom( return error; } -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < outAudio.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#else - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#endif } } ELSE @@ -8052,17 +7974,9 @@ static ivas_error renderMcToSplitBinaural( /* perform rotation in source format to tmpRotBuffer */ pCombinedOrientationDataLocal = &combinedOrientationDataLocal; -#ifdef FIX_BASOP_2351_EXTREND_SCALE FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i ) -#else - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) -#endif { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */ -#else - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */ -#endif } /* Render */ IF( ( error = ivas_td_binaural_renderer_ext_fx( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer, &exp ) ) != IVAS_ERR_OK ) @@ -8071,11 +7985,7 @@ static ivas_error renderMcToSplitBinaural( } FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { -#ifdef FIX_BASOP_2351_EXTREND_SCALE Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#else - Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */ -#endif } /* Copy rendered audio to tmp storage buffer. Copying directly to output would @@ -9175,15 +9085,10 @@ static ivas_error renderInputMasa( } copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); -#ifdef FIX_BASOP_2326_WRONG_SIG_LENGTH FOR( ch = 0; ch < inAudio.config.numChannels; ch++ ) { Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ } -#else - Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ - Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ -#endif // scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); ivas_masa_ext_rend_parambin_render_fx( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer_fx, num_subframes, masaInput->base.ctx.pSplitRendWrapper, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); @@ -9207,17 +9112,10 @@ static ivas_error renderInputMasa( masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state = Q11; move16(); } -#ifdef FIX_BASOP_2326_WRONG_SIG_LENGTH FOR( ch = 0; ch < inAudio.config.numChannels; ch++ ) { Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ } -#else - FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) - { - Scale_sig32( tmpBuffer_buff_fx[ch], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ - } -#endif scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ @@ -9241,15 +9139,10 @@ static ivas_error renderInputMasa( copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin ); -#ifdef FIX_BASOP_2326_WRONG_SIG_LENGTH FOR( ch = 0; ch < inAudio.config.numChannels; ch++ ) { Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ } -#else - Scale_sig32( tmpBuffer_buff_fx[0], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ - Scale_sig32( tmpBuffer_buff_fx[1], L_FRAME48k, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */ -#endif scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); @@ -11216,33 +11109,15 @@ static void intermidiate_ext_dirac_render( IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx ) { -#ifdef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len ); -#else - Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, imult1616( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ) ); -#endif scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len, shift ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth + shift) */ hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, shift ); move16(); } -#ifndef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND - Word16 num_channels_dir = hDirACRend->num_outputs_dir; - move16(); - - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) ) - { - num_channels_dir = hDirACRend->hOutSetup.nchan_out_woLFE; - move16(); - } -#endif IF( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx ) { -#ifdef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND tmp = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len ); -#else - tmp = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); -#endif scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len, tmp ); /* Q(h_dirac_output_synthesis_state->q_cy_auto_diff_smooth + tmp) */ h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, tmp ); move16(); @@ -11264,11 +11139,7 @@ static void intermidiate_ext_dirac_render( move16(); IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx ) { -#ifdef FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len ); -#else - Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); -#endif scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len, shift ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev + shift) */ hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, shift ); move16(); @@ -11282,11 +11153,7 @@ static void intermidiate_ext_dirac_render( move16(); } -#ifdef FIX_BASOP_2329_UNINIT_VALUE IF( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx ) -#else - IF( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len > 0 ) -#endif { Word16 shift, norm1, norm2; Word32 tmp1, tmp2; @@ -11331,10 +11198,6 @@ static void intermidiate_ext_dirac_render( move16(); } } -#ifndef FIX_2330_CLANG_18_WARNINGS_REND - hDirACRend->proto_frame_dec_f_q = sub( 31, hDirACRend->proto_frame_dec_f_q ); - move16(); -#endif IF( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx ) {