Loading lib_com/cldfb_evs_fx.c +10 −0 Original line number Diff line number Diff line Loading @@ -1598,17 +1598,27 @@ ivas_error cldfb_save_memory( } hs->memory_length = cldfb_get_memory_length( hs ); move16(); #ifdef FIX_2431_AVOID_CALLOC hs->memory = (Word16 *) malloc( ( hs->memory_length + CLDFB_MEM_EXPONENTS + 1 ) * sizeof( Word16 ) ); IF( hs->memory == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" ); } #else hs->memory = (Word16 *) calloc( hs->memory_length + CLDFB_MEM_EXPONENTS + 1, sizeof( Word16 ) ); #endif /* save the memory */ Copy( hs->FilterStates, hs->memory, hs->memory_length ); Copy( hs->FilterStates_e, hs->memory + hs->memory_length, CLDFB_MEM_EXPONENTS ); hs->memory[hs->memory_length + CLDFB_MEM_EXPONENTS] = hs->FilterStates_eg; move16(); #ifndef FIX_2431_AVOID_CALLOC IF( hs->memory == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" ); } #endif return IVAS_ERR_OK; } Loading lib_com/cng_exc_fx.c +0 −8 Original line number Diff line number Diff line Loading @@ -306,11 +306,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) IF( EQ_16( L_frame, L_FRAME16k ) ) { #ifndef FIX_2410_HARM_MODIF_FS modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0 ); #else modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0, NULL, NULL ); #endif } /* fft_rel(fft_io, L_FFT, LOG2_L_FFT); */ Loading Loading @@ -423,11 +419,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) IF( EQ_16( L_frame, L_FRAME16k ) ) { #ifndef FIX_2410_HARM_MODIF_FS modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0 ); #else modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0, NULL, NULL ); #endif } /* enr1 = dotp( fft_io, fft_io, L_frame ) / L_frame; */ Loading lib_com/core_com_config_fx.c +70 −0 Original line number Diff line number Diff line Loading @@ -169,7 +169,74 @@ Word16 get_codec_mode( return codec_mode; /*Q0*/ } #ifdef FIX_2385_GETTCXONLY /*-------------------------------------------------------------------* * getTcxonly() * * *-------------------------------------------------------------------*/ Word16 getTcxonly_fx( const Word16 element_mode, /* i : IVAS element mode Q0*/ const Word32 total_brate, /* i : total bitrate Q0*/ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ const Word16 is_ism_format /* i : flag indicating ISM format Q0*/ ) { Word16 tcxonly = 0; move16(); Word32 temp_flag; SWITCH( element_mode ) { case EVS_MONO: if ( GT_32( total_brate, ACELP_32k ) ) { tcxonly = 1; move16(); } BREAK; case IVAS_SCE: temp_flag = MAX_ACELP_BRATE; move32(); if ( is_ism_format ) { temp_flag = MAX_ACELP_BRATE_ISM; move32(); } if ( GT_32( total_brate, temp_flag ) ) { tcxonly = 1; move16(); } BREAK; case IVAS_CPE_DFT: case IVAS_CPE_TD: if ( GT_32( total_brate, MAX_ACELP_BRATE ) ) { tcxonly = 1; move16(); } BREAK; case IVAS_CPE_MDCT: temp_flag = IVAS_48k; move32(); if ( MCT_flag ) { temp_flag = IVAS_32k; move32(); } if ( GE_32( total_brate, temp_flag ) ) { tcxonly = 1; move16(); } BREAK; } return tcxonly; /*Q0*/ } #else /*-------------------------------------------------------------------* * getTcxonly_ivas() * Loading Loading @@ -244,6 +311,8 @@ Word16 getTcxonly_ivas_fx( return tcxonly; /*Q0*/ } #endif /* FIX_2385_GETTCXONLY */ #ifndef FIX_2385_GETTCXONLY Word16 getTcxonly( const Word32 total_brate /* i : total bitrate */ Loading Loading @@ -331,6 +400,7 @@ Word16 getTcxonly_fx( return tcxonly; /*Q0*/ } #endif /* FIX_2385_GETTCXONLY */ /*-------------------------------------------------------------------* * getCtxHm() Loading lib_com/ivas_prot_fx.h +14 −7 Original line number Diff line number Diff line Loading @@ -1890,9 +1890,11 @@ void TonalMDCTConceal_Detect_ivas_fx( Word16 element_mode ); #ifndef HARMONIZE_2427_GETPLC Word16 GetPLCModeDecision_ivas_fx( Decoder_State *st /* i/o: decoder memory state pointer */ ); #endif // !HARMONIZE_2427_GETPLC void ivas_DetectTonalComponents_fx( Word16 indexOfTonalPeak[], Loading Loading @@ -2954,15 +2956,8 @@ void acelp_fast_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 cdk_index, /* i : codebook index */ const Word16 dn_orig[L_SUBFR], /* i : corr. between target and h[]. Q_dn */ #ifdef OPT_2416_ACELP_FAST const Word16 Q_dncn, /* i : scaling factor of dn and cn */ #else Word16 Q_dn, #endif const Word16 cn[L_SUBFR], /* i : residual after long term prediction q_cn*/ #ifndef OPT_2416_ACELP_FAST const Word16 q_cn, #endif const Word16 H[L_SUBFR], /* i : impulse response of weighted synthesis filter e(norm_s(H[0])+1) */ Word16 code[L_SUBFR], /* o : algebraic (fixed) codebook excitation */ Word16 y[], /* o : filtered fixed codebook excitation */ Loading Loading @@ -3798,10 +3793,16 @@ ivas_error ivas_osba_render_sf_fx( void ivas_osba_stereo_add_channels_fx( Word32 *tc_fx[], /* i : transport channels */ Word32 *output_fx[], /* i/o: output channels */ #ifdef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT const Word32 gain, /* i : gain bed value Q11 */ #else const Word32 gain_bed_fx, /* i : gain bed value Q11 */ #endif const Word16 nchan_out, /* i : number of output channels */ const Word16 nchan_ism, /* i : number of ISM channels */ #ifndef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT const Word16 ism_mode, /* i : ISM mode */ #endif const UWord16 n_samples_to_render /* i : output frame length per channel */ ); Loading Loading @@ -4127,11 +4128,17 @@ ivas_error ivas_param_ism_dec_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #ifdef FIX_FLOAT_1526_DIRAC_MEM_LEAK void ivas_param_ism_dec_close_fx( PARAM_ISM_DEC_HANDLE *hParamIsmDec /* i/o: decoder ParamISM handle */ ); #else void ivas_param_ism_dec_close_fx( PARAM_ISM_DEC_HANDLE *hParamIsmDec, /* i/o: decoder ParamISM handle */ SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data */ const AUDIO_CONFIG output_config /* i : output audio configuration */ ); #endif void ivas_ism_dec_digest_tc_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ Loading lib_com/lpc_tools_fx.c +0 −199 Original line number Diff line number Diff line Loading @@ -448,9 +448,7 @@ static Word32 Div_32_opt( Word32 L_num /*Q31*/, Word16 denom_hi /*Qx -16*/, Word */ static Word16 E_LPC_lev_dur_stab( #ifdef HARM_LEV_DURBIN const Word16 element_mode, #endif const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /*QR -1*/, Word16 A[] /*Qx*/, Loading Loading @@ -615,7 +613,6 @@ static Word16 E_LPC_lev_dur_stab( t1 = L_max( t1, L_abs( t0 ) ); } #ifdef HARM_LEV_DURBIN IF( element_mode == EVS_MONO ) { k = s_min( norm_l( t1 ), 3 ); Loading @@ -624,9 +621,6 @@ static Word16 E_LPC_lev_dur_stab( { k = s_min( sub( norm_l( t1 ), 1 ), 3 ); } #else k = s_min( norm_l( t1 ), 3 ); #endif A[0] = shl( 2048, k ); move16(); FOR( i = 1; i <= order; i++ ) Loading Loading @@ -655,205 +649,12 @@ static Word16 E_LPC_lev_dur_stab( Word16 E_LPC_lev_dur_fx( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /*QR -1*/, Word16 A[] /*Qx*/, Word32 epsP[] /*QR*/, const Word16 order, Word16 *mem /*Qx*/ ) { #ifdef HARM_LEV_DURBIN return ( E_LPC_lev_dur_stab( EVS_MONO, Rh, Rl, A, epsP, order, mem, 32750 ) ); /* 0.99945 in Q15 */ #else return ( E_LPC_lev_dur_stab( Rh, Rl, A, epsP, order, mem, 32750 ) ); /* 0.99945 in Q15 */ #endif } #ifndef HARM_LEV_DURBIN static Word16 E_LPC_lev_dur_stab_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 A[], Word32 epsP[], const Word16 order, Word16 *mem, Word16 k_max ) { Word16 i, j, k; Word16 hi, lo; Word16 Kh, Kl; /* reflection coefficient; hi and lo */ Word16 alp_h, alp_l, alp_exp; /* Prediction gain; hi lo and exponent */ Word32 t0, t1, t2; /* temporary variables */ Word16 flag; Word16 Ah[TCXLTP_LTP_ORDER + 1], Al[TCXLTP_LTP_ORDER + 1]; /* LPC coef. in double prec. */ BASOP_SATURATE_WARNING_OFF_EVS if ( epsP != NULL ) { epsP[0] = L_Comp( Rh[0], Rl[0] ); move32(); } flag = 0; move16(); /* K = A[1] = -R[1] / R[0] */ t1 = L_Comp( Rh[1], Rl[1] ); /* R[1] in Q31 */ t2 = L_abs( t1 ); /* abs R[1] */ t0 = L_deposit_l( 0 ); IF( Rh[0] != 0 ) { t0 = Div_32_opt( t2, Rh[0], Rl[0] ); /* R[1]/R[0] in Q31 */ /* Cause a difference in MODE1 due to different implementation of div32*/ } if ( t1 > 0 ) { t0 = L_negate( t0 ); /* -R[1]/R[0] */ } Kl = L_Extract_lc( t0, &Kh ); /* K in DPF */ t0 = L_shr( t0, 4 ); /* A[1] in Q27 */ L_Extract( t0, &Ah[1], &Al[1] ); /* A[1] in DPF */ /* Alpha = R[0] * (1-K**2) */ t0 = Sqr_32( Kh, Kl ); /* K*K in Q31 */ t0 = L_abs( t0 ); /* Some case <0 !! */ t0 = L_sub( (Word32) 0x7fffffffL, t0 ); /* 1 - K*K in Q31 */ lo = L_Extract_lc( t0, &hi ); /* DPF format */ t0 = Mpy_32( Rh[0], Rl[0], hi, lo ); /* Alpha in Q31 */ if ( epsP != NULL ) { epsP[1] = t0; move32(); } /* Normalize Alpha */ alp_exp = norm_l( t0 ); t0 = L_shl( t0, alp_exp ); alp_l = L_Extract_lc( t0, &alp_h ); /* DPF format */ /*--------------------------------------* * ITERATIONS I=2 to m *--------------------------------------*/ FOR( i = 2; i <= order; i++ ) { /* t0 = SUM(R[j]*A[i-j], j=1, i-1) + R[i] */ t0 = L_deposit_l( 0 ); FOR( j = 1; j < i; j++ ) { t0 = Mac_32( t0, Rh[j], Rl[j], Ah[i - j], Al[i - j] ); } t0 = L_shl_sat( t0, 4 ); /* result in Q27 -> convert to Q31 */ /* No overflow possible */ /* Compose and add R[i] in Q3 */ t0 = L_mac_sat( t0, Rl[i], 1 ); t0 = L_msu_sat( t0, Rh[i], -32768 ); /* K = -t0 / Alpha */ t1 = L_abs( t0 ); t2 = L_deposit_l( 0 ); IF( alp_h != 0 ) { t2 = Div_32_opt( t1, alp_h, alp_l ); /* abs(t0)/Alpha */ /* Cause a difference in MODE1 due to different implementation of div32*/ } if ( t0 > 0 ) { t2 = L_negate( t2 ); /* K =-t0/Alpha */ } t2 = L_shl_sat( t2, alp_exp ); /* denormalize; compare to Alpha */ test(); if ( ( mem != NULL ) && ( ( GT_16( abs_s( extract_h( t2 ) ), k_max ) ) ) ) { flag = 1; move16(); /* Test for unstable filter. If unstable keep old A(z) */ } test(); if ( ( mem != NULL ) && ( ( LT_32( L_abs( t2 ), 5 ) ) ) ) { flag = 1; move16(); /*R matrix not reliable (R saturated for many coeff), keep old A(z) */ } Kl = L_Extract_lc( t2, &Kh ); /* K in DPF */ /*------------------------------------------* * Compute new LPC coeff. -> An[i] * An[j]= A[j] + K*A[i-j], j=1 to i-1 * An[i]= K *------------------------------------------*/ k = mult_r( i, 16384 ); FOR( j = 1; j < k; j++ ) { /* Do two Iterations Together to Allow Direct Update of Ah & Al */ t0 = Mac_32( L_Comp( Ah[j], Al[j] ), Kh, Kl, Ah[i - j], Al[i - j] ); t1 = Mac_32( L_Comp( Ah[i - j], Al[i - j] ), Kh, Kl, Ah[j], Al[j] ); L_Extract( t0, &Ah[j], &Al[j] ); L_Extract( t1, &Ah[i - j], &Al[i - j] ); } IF( s_and( i, 1 ) == 0 ) { t0 = Mac_32( L_Comp( Ah[j], Al[j] ), Kh, Kl, Ah[i - j], Al[i - j] ); L_Extract( t0, &Ah[j], &Al[j] ); } t2 = L_shr( t2, 4 ); /* t2 = K in Q31 ->convert to Q27 */ L_Extract( t2, &Ah[i], &Al[i] ); /* An[i] in Q27 */ /* Alpha = Alpha * (1-K**2) */ t1 = L_mult_sat( Kh, Kh ); /* K*K in Q31 */ t0 = L_mac( t1, mult( Kh, Kl ), 2 ); t0 = L_abs( t0 ); /* Some case <0 !! */ t0 = L_sub( (Word32) 0x7fffffffL, t0 ); /* 1 - K*K in Q31 */ lo = L_Extract_lc( t0, &hi ); /* DPF format */ t0 = Mpy_32( alp_h, alp_l, hi, lo ); /* Alpha in Q31 */ /* store denormalized alpha in epsP */ t1 = L_shr( t0, alp_exp ); if ( epsP != NULL ) { epsP[i] = t1; move32(); } /* Normalize Alpha */ j = norm_l( t0 ); t0 = L_shl( t0, j ); alp_l = L_Extract_lc( t0, &alp_h ); /* DPF format */ alp_exp = add( alp_exp, j ); /* Add normalization to alp_exp */ } /* Adaptive scaling */ t1 = L_deposit_l( 0 ); FOR( i = 1; i <= order; i++ ) { t0 = L_Comp( Ah[i], Al[i] ); t1 = L_max( t1, L_abs( t0 ) ); } k = s_min( sub( norm_l( t1 ), 1 ), 3 ); A[0] = shl( 2048, k ); move16(); FOR( i = 1; i <= order; i++ ) { t0 = L_Comp( Ah[i], Al[i] ); A[i] = round_fx_sat( L_shl_sat( t0, k ) ); move16(); } BASOP_SATURATE_WARNING_ON_EVS IF( mem != NULL ) { /* Enforce stable LPC filter - parcorr[0] and parcorr[1] are not LPC coeffiecients */ IF( flag ) { Copy( mem, A, add( order, 1 ) ); } ELSE /* If stable LPC filter, store into memories */ { Copy( A, mem, add( order, 1 ) ); } } return ( flag ); } #endif Word16 E_LPC_lev_dur_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 A[], Word32 epsP[], const Word16 order, Word16 *mem ) { #ifdef HARM_LEV_DURBIN return ( E_LPC_lev_dur_stab( IVAS_SCE /* just to differentiate from EVS_MONO */, Rh, Rl, A, epsP, order, mem, 32750 ) ); /* 0.99945 in Q15 */ #else return ( E_LPC_lev_dur_stab_ivas_fx( Rh, Rl, A, epsP, order, mem, 32750 ) ); /* 0.99945 in Q15 */ #endif } Loading Loading
lib_com/cldfb_evs_fx.c +10 −0 Original line number Diff line number Diff line Loading @@ -1598,17 +1598,27 @@ ivas_error cldfb_save_memory( } hs->memory_length = cldfb_get_memory_length( hs ); move16(); #ifdef FIX_2431_AVOID_CALLOC hs->memory = (Word16 *) malloc( ( hs->memory_length + CLDFB_MEM_EXPONENTS + 1 ) * sizeof( Word16 ) ); IF( hs->memory == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" ); } #else hs->memory = (Word16 *) calloc( hs->memory_length + CLDFB_MEM_EXPONENTS + 1, sizeof( Word16 ) ); #endif /* save the memory */ Copy( hs->FilterStates, hs->memory, hs->memory_length ); Copy( hs->FilterStates_e, hs->memory + hs->memory_length, CLDFB_MEM_EXPONENTS ); hs->memory[hs->memory_length + CLDFB_MEM_EXPONENTS] = hs->FilterStates_eg; move16(); #ifndef FIX_2431_AVOID_CALLOC IF( hs->memory == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" ); } #endif return IVAS_ERR_OK; } Loading
lib_com/cng_exc_fx.c +0 −8 Original line number Diff line number Diff line Loading @@ -306,11 +306,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) IF( EQ_16( L_frame, L_FRAME16k ) ) { #ifndef FIX_2410_HARM_MODIF_FS modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0 ); #else modify_Fs_fx( fft_io, L_FRAME16k, 16000, fft_io, 12800, exc_mem1, 0, NULL, NULL ); #endif } /* fft_rel(fft_io, L_FFT, LOG2_L_FFT); */ Loading Loading @@ -423,11 +419,7 @@ IF( NE_16( Opt_AMR_WB, 1 ) ) IF( EQ_16( L_frame, L_FRAME16k ) ) { #ifndef FIX_2410_HARM_MODIF_FS modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0 ); #else modify_Fs_fx( fft_io, L_FFT, 12800, fft_io, 16000, exc_mem, 0, NULL, NULL ); #endif } /* enr1 = dotp( fft_io, fft_io, L_frame ) / L_frame; */ Loading
lib_com/core_com_config_fx.c +70 −0 Original line number Diff line number Diff line Loading @@ -169,7 +169,74 @@ Word16 get_codec_mode( return codec_mode; /*Q0*/ } #ifdef FIX_2385_GETTCXONLY /*-------------------------------------------------------------------* * getTcxonly() * * *-------------------------------------------------------------------*/ Word16 getTcxonly_fx( const Word16 element_mode, /* i : IVAS element mode Q0*/ const Word32 total_brate, /* i : total bitrate Q0*/ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ const Word16 is_ism_format /* i : flag indicating ISM format Q0*/ ) { Word16 tcxonly = 0; move16(); Word32 temp_flag; SWITCH( element_mode ) { case EVS_MONO: if ( GT_32( total_brate, ACELP_32k ) ) { tcxonly = 1; move16(); } BREAK; case IVAS_SCE: temp_flag = MAX_ACELP_BRATE; move32(); if ( is_ism_format ) { temp_flag = MAX_ACELP_BRATE_ISM; move32(); } if ( GT_32( total_brate, temp_flag ) ) { tcxonly = 1; move16(); } BREAK; case IVAS_CPE_DFT: case IVAS_CPE_TD: if ( GT_32( total_brate, MAX_ACELP_BRATE ) ) { tcxonly = 1; move16(); } BREAK; case IVAS_CPE_MDCT: temp_flag = IVAS_48k; move32(); if ( MCT_flag ) { temp_flag = IVAS_32k; move32(); } if ( GE_32( total_brate, temp_flag ) ) { tcxonly = 1; move16(); } BREAK; } return tcxonly; /*Q0*/ } #else /*-------------------------------------------------------------------* * getTcxonly_ivas() * Loading Loading @@ -244,6 +311,8 @@ Word16 getTcxonly_ivas_fx( return tcxonly; /*Q0*/ } #endif /* FIX_2385_GETTCXONLY */ #ifndef FIX_2385_GETTCXONLY Word16 getTcxonly( const Word32 total_brate /* i : total bitrate */ Loading Loading @@ -331,6 +400,7 @@ Word16 getTcxonly_fx( return tcxonly; /*Q0*/ } #endif /* FIX_2385_GETTCXONLY */ /*-------------------------------------------------------------------* * getCtxHm() Loading
lib_com/ivas_prot_fx.h +14 −7 Original line number Diff line number Diff line Loading @@ -1890,9 +1890,11 @@ void TonalMDCTConceal_Detect_ivas_fx( Word16 element_mode ); #ifndef HARMONIZE_2427_GETPLC Word16 GetPLCModeDecision_ivas_fx( Decoder_State *st /* i/o: decoder memory state pointer */ ); #endif // !HARMONIZE_2427_GETPLC void ivas_DetectTonalComponents_fx( Word16 indexOfTonalPeak[], Loading Loading @@ -2954,15 +2956,8 @@ void acelp_fast_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 cdk_index, /* i : codebook index */ const Word16 dn_orig[L_SUBFR], /* i : corr. between target and h[]. Q_dn */ #ifdef OPT_2416_ACELP_FAST const Word16 Q_dncn, /* i : scaling factor of dn and cn */ #else Word16 Q_dn, #endif const Word16 cn[L_SUBFR], /* i : residual after long term prediction q_cn*/ #ifndef OPT_2416_ACELP_FAST const Word16 q_cn, #endif const Word16 H[L_SUBFR], /* i : impulse response of weighted synthesis filter e(norm_s(H[0])+1) */ Word16 code[L_SUBFR], /* o : algebraic (fixed) codebook excitation */ Word16 y[], /* o : filtered fixed codebook excitation */ Loading Loading @@ -3798,10 +3793,16 @@ ivas_error ivas_osba_render_sf_fx( void ivas_osba_stereo_add_channels_fx( Word32 *tc_fx[], /* i : transport channels */ Word32 *output_fx[], /* i/o: output channels */ #ifdef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT const Word32 gain, /* i : gain bed value Q11 */ #else const Word32 gain_bed_fx, /* i : gain bed value Q11 */ #endif const Word16 nchan_out, /* i : number of output channels */ const Word16 nchan_ism, /* i : number of ISM channels */ #ifndef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT const Word16 ism_mode, /* i : ISM mode */ #endif const UWord16 n_samples_to_render /* i : output frame length per channel */ ); Loading Loading @@ -4127,11 +4128,17 @@ ivas_error ivas_param_ism_dec_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #ifdef FIX_FLOAT_1526_DIRAC_MEM_LEAK void ivas_param_ism_dec_close_fx( PARAM_ISM_DEC_HANDLE *hParamIsmDec /* i/o: decoder ParamISM handle */ ); #else void ivas_param_ism_dec_close_fx( PARAM_ISM_DEC_HANDLE *hParamIsmDec, /* i/o: decoder ParamISM handle */ SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data */ const AUDIO_CONFIG output_config /* i : output audio configuration */ ); #endif void ivas_ism_dec_digest_tc_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ Loading
lib_com/lpc_tools_fx.c +0 −199 Original line number Diff line number Diff line Loading @@ -448,9 +448,7 @@ static Word32 Div_32_opt( Word32 L_num /*Q31*/, Word16 denom_hi /*Qx -16*/, Word */ static Word16 E_LPC_lev_dur_stab( #ifdef HARM_LEV_DURBIN const Word16 element_mode, #endif const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /*QR -1*/, Word16 A[] /*Qx*/, Loading Loading @@ -615,7 +613,6 @@ static Word16 E_LPC_lev_dur_stab( t1 = L_max( t1, L_abs( t0 ) ); } #ifdef HARM_LEV_DURBIN IF( element_mode == EVS_MONO ) { k = s_min( norm_l( t1 ), 3 ); Loading @@ -624,9 +621,6 @@ static Word16 E_LPC_lev_dur_stab( { k = s_min( sub( norm_l( t1 ), 1 ), 3 ); } #else k = s_min( norm_l( t1 ), 3 ); #endif A[0] = shl( 2048, k ); move16(); FOR( i = 1; i <= order; i++ ) Loading Loading @@ -655,205 +649,12 @@ static Word16 E_LPC_lev_dur_stab( Word16 E_LPC_lev_dur_fx( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /*QR -1*/, Word16 A[] /*Qx*/, Word32 epsP[] /*QR*/, const Word16 order, Word16 *mem /*Qx*/ ) { #ifdef HARM_LEV_DURBIN return ( E_LPC_lev_dur_stab( EVS_MONO, Rh, Rl, A, epsP, order, mem, 32750 ) ); /* 0.99945 in Q15 */ #else return ( E_LPC_lev_dur_stab( Rh, Rl, A, epsP, order, mem, 32750 ) ); /* 0.99945 in Q15 */ #endif } #ifndef HARM_LEV_DURBIN static Word16 E_LPC_lev_dur_stab_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 A[], Word32 epsP[], const Word16 order, Word16 *mem, Word16 k_max ) { Word16 i, j, k; Word16 hi, lo; Word16 Kh, Kl; /* reflection coefficient; hi and lo */ Word16 alp_h, alp_l, alp_exp; /* Prediction gain; hi lo and exponent */ Word32 t0, t1, t2; /* temporary variables */ Word16 flag; Word16 Ah[TCXLTP_LTP_ORDER + 1], Al[TCXLTP_LTP_ORDER + 1]; /* LPC coef. in double prec. */ BASOP_SATURATE_WARNING_OFF_EVS if ( epsP != NULL ) { epsP[0] = L_Comp( Rh[0], Rl[0] ); move32(); } flag = 0; move16(); /* K = A[1] = -R[1] / R[0] */ t1 = L_Comp( Rh[1], Rl[1] ); /* R[1] in Q31 */ t2 = L_abs( t1 ); /* abs R[1] */ t0 = L_deposit_l( 0 ); IF( Rh[0] != 0 ) { t0 = Div_32_opt( t2, Rh[0], Rl[0] ); /* R[1]/R[0] in Q31 */ /* Cause a difference in MODE1 due to different implementation of div32*/ } if ( t1 > 0 ) { t0 = L_negate( t0 ); /* -R[1]/R[0] */ } Kl = L_Extract_lc( t0, &Kh ); /* K in DPF */ t0 = L_shr( t0, 4 ); /* A[1] in Q27 */ L_Extract( t0, &Ah[1], &Al[1] ); /* A[1] in DPF */ /* Alpha = R[0] * (1-K**2) */ t0 = Sqr_32( Kh, Kl ); /* K*K in Q31 */ t0 = L_abs( t0 ); /* Some case <0 !! */ t0 = L_sub( (Word32) 0x7fffffffL, t0 ); /* 1 - K*K in Q31 */ lo = L_Extract_lc( t0, &hi ); /* DPF format */ t0 = Mpy_32( Rh[0], Rl[0], hi, lo ); /* Alpha in Q31 */ if ( epsP != NULL ) { epsP[1] = t0; move32(); } /* Normalize Alpha */ alp_exp = norm_l( t0 ); t0 = L_shl( t0, alp_exp ); alp_l = L_Extract_lc( t0, &alp_h ); /* DPF format */ /*--------------------------------------* * ITERATIONS I=2 to m *--------------------------------------*/ FOR( i = 2; i <= order; i++ ) { /* t0 = SUM(R[j]*A[i-j], j=1, i-1) + R[i] */ t0 = L_deposit_l( 0 ); FOR( j = 1; j < i; j++ ) { t0 = Mac_32( t0, Rh[j], Rl[j], Ah[i - j], Al[i - j] ); } t0 = L_shl_sat( t0, 4 ); /* result in Q27 -> convert to Q31 */ /* No overflow possible */ /* Compose and add R[i] in Q3 */ t0 = L_mac_sat( t0, Rl[i], 1 ); t0 = L_msu_sat( t0, Rh[i], -32768 ); /* K = -t0 / Alpha */ t1 = L_abs( t0 ); t2 = L_deposit_l( 0 ); IF( alp_h != 0 ) { t2 = Div_32_opt( t1, alp_h, alp_l ); /* abs(t0)/Alpha */ /* Cause a difference in MODE1 due to different implementation of div32*/ } if ( t0 > 0 ) { t2 = L_negate( t2 ); /* K =-t0/Alpha */ } t2 = L_shl_sat( t2, alp_exp ); /* denormalize; compare to Alpha */ test(); if ( ( mem != NULL ) && ( ( GT_16( abs_s( extract_h( t2 ) ), k_max ) ) ) ) { flag = 1; move16(); /* Test for unstable filter. If unstable keep old A(z) */ } test(); if ( ( mem != NULL ) && ( ( LT_32( L_abs( t2 ), 5 ) ) ) ) { flag = 1; move16(); /*R matrix not reliable (R saturated for many coeff), keep old A(z) */ } Kl = L_Extract_lc( t2, &Kh ); /* K in DPF */ /*------------------------------------------* * Compute new LPC coeff. -> An[i] * An[j]= A[j] + K*A[i-j], j=1 to i-1 * An[i]= K *------------------------------------------*/ k = mult_r( i, 16384 ); FOR( j = 1; j < k; j++ ) { /* Do two Iterations Together to Allow Direct Update of Ah & Al */ t0 = Mac_32( L_Comp( Ah[j], Al[j] ), Kh, Kl, Ah[i - j], Al[i - j] ); t1 = Mac_32( L_Comp( Ah[i - j], Al[i - j] ), Kh, Kl, Ah[j], Al[j] ); L_Extract( t0, &Ah[j], &Al[j] ); L_Extract( t1, &Ah[i - j], &Al[i - j] ); } IF( s_and( i, 1 ) == 0 ) { t0 = Mac_32( L_Comp( Ah[j], Al[j] ), Kh, Kl, Ah[i - j], Al[i - j] ); L_Extract( t0, &Ah[j], &Al[j] ); } t2 = L_shr( t2, 4 ); /* t2 = K in Q31 ->convert to Q27 */ L_Extract( t2, &Ah[i], &Al[i] ); /* An[i] in Q27 */ /* Alpha = Alpha * (1-K**2) */ t1 = L_mult_sat( Kh, Kh ); /* K*K in Q31 */ t0 = L_mac( t1, mult( Kh, Kl ), 2 ); t0 = L_abs( t0 ); /* Some case <0 !! */ t0 = L_sub( (Word32) 0x7fffffffL, t0 ); /* 1 - K*K in Q31 */ lo = L_Extract_lc( t0, &hi ); /* DPF format */ t0 = Mpy_32( alp_h, alp_l, hi, lo ); /* Alpha in Q31 */ /* store denormalized alpha in epsP */ t1 = L_shr( t0, alp_exp ); if ( epsP != NULL ) { epsP[i] = t1; move32(); } /* Normalize Alpha */ j = norm_l( t0 ); t0 = L_shl( t0, j ); alp_l = L_Extract_lc( t0, &alp_h ); /* DPF format */ alp_exp = add( alp_exp, j ); /* Add normalization to alp_exp */ } /* Adaptive scaling */ t1 = L_deposit_l( 0 ); FOR( i = 1; i <= order; i++ ) { t0 = L_Comp( Ah[i], Al[i] ); t1 = L_max( t1, L_abs( t0 ) ); } k = s_min( sub( norm_l( t1 ), 1 ), 3 ); A[0] = shl( 2048, k ); move16(); FOR( i = 1; i <= order; i++ ) { t0 = L_Comp( Ah[i], Al[i] ); A[i] = round_fx_sat( L_shl_sat( t0, k ) ); move16(); } BASOP_SATURATE_WARNING_ON_EVS IF( mem != NULL ) { /* Enforce stable LPC filter - parcorr[0] and parcorr[1] are not LPC coeffiecients */ IF( flag ) { Copy( mem, A, add( order, 1 ) ); } ELSE /* If stable LPC filter, store into memories */ { Copy( A, mem, add( order, 1 ) ); } } return ( flag ); } #endif Word16 E_LPC_lev_dur_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 A[], Word32 epsP[], const Word16 order, Word16 *mem ) { #ifdef HARM_LEV_DURBIN return ( E_LPC_lev_dur_stab( IVAS_SCE /* just to differentiate from EVS_MONO */, Rh, Rl, A, epsP, order, mem, 32750 ) ); /* 0.99945 in Q15 */ #else return ( E_LPC_lev_dur_stab_ivas_fx( Rh, Rl, A, epsP, order, mem, 32750 ) ); /* 0.99945 in Q15 */ #endif } Loading