Loading apps/renderer.c +50 −0 Original line number Diff line number Diff line Loading @@ -662,6 +662,10 @@ int main( lfeRoutingConfigs[i] = NULL; } #ifdef FIX_DISCLAIMER IVAS_REND_PrintDisclaimer(); #endif CmdlnArgs args = parseCmdlnArgs( argc, argv ); if ( args.nonDiegeticPan && !( ( args.inConfig.numAudioObjects == 0 && args.inConfig.multiChannelBuses[0].audioConfig == IVAS_AUDIO_CONFIG_MONO ) || Loading Loading @@ -829,6 +833,52 @@ int main( exit( -1 ); } #ifdef FIX_DISCLAIMER fprintf( stdout, "Input audio file: %s\n", args.inputFilePath ); fprintf( stdout, "Output audio file: %s\n\n", args.outputFilePath ); if ( args.inConfig.numAudioObjects > 0 ) { if ( args.inConfig.numAudioObjects == 1 ) { IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM1 ); } else if ( args.inConfig.numAudioObjects == 2 ) { IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM2 ); } else if ( args.inConfig.numAudioObjects == 3 ) { IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM3 ); } else if ( args.inConfig.numAudioObjects == 4 ) { IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM4 ); } } for ( i = 0; i < args.inConfig.numMultiChannelBuses; i++ ) { IVAS_REND_PrintInputConfig( args.inConfig.multiChannelBuses[i].audioConfig ); } for ( i = 0; i < args.inConfig.numMasaBuses; i++ ) { IVAS_REND_PrintInputConfig( args.inConfig.masaBuses[i].audioConfig ); } for ( i = 0; i < args.inConfig.numAmbisonicsBuses; i++ ) { IVAS_REND_PrintInputConfig( args.inConfig.ambisonicsBuses[i].audioConfig ); } if ( ( error = IVAS_REND_PrintConfig( hIvasRend ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\n IVAS_REND_PrintConfig failed: %s\n\n", ivas_error_to_string( error ) ); // goto cleanup; exit( -1 ); } #endif #ifdef FIX_POINT_HRTF_FILE_FORMAT if ( !isEmptyString( args.customHrtfFilePath ) ) { Loading lib_com/disclaimer.c +4 −0 Original line number Diff line number Diff line Loading @@ -44,7 +44,11 @@ int16_t print_disclaimer( FILE *fPtr ) { fprintf( fPtr, "\n==================================================================================================\n" ); #ifdef FIX_DISCLAIMER fprintf( fPtr, " IVAS Codec BASOP Baseline\n" ); #else fprintf( fPtr, " IVAS Codec Baseline\n" ); #endif fprintf( fPtr, " \n" ); fprintf( fPtr, " Based on EVS Codec (Floating Point) 3GPP TS26.443 Nov 04, 2021,\n" ); fprintf( fPtr, " Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0\n" ); Loading lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -123,4 +123,5 @@ #define FIX_ISSUE_1157 /* Ittiam: Fix for Issue 1157: Encoder crash for Stereo at 48/64kbps DTX on/off in kernel_switch_trafo_fx() */ #define FIX_ISSUE_1152 /* Ittiam: Fix for issue 1152: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from find_tilt_fx function*/ #define FIX_ISSUE_1156 /* Ittiam: Fix for Issue 1156: Encoder crash for Stereo at 32kbps in SWB_BWE_encoding_ivas_fx() */ #define FIX_DISCLAIMER /* VA: Add disclaimer for external renderer + Add info about IVAS reference version (FLP issue 1225) */ #endif lib_com/prot_fx.h +17 −0 Original line number Diff line number Diff line Loading @@ -2914,6 +2914,23 @@ void GenShapedWBExcitation_fx( const Word16 signal_type, const Word16 igf_flag ); void GenShapedWBExcitation_ivas_enc_fx( Word16 *excSHB, /* o : synthesized shaped shb exctiation */ const Word16 *lpc_shb, /* i : lpc coefficients */ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation */ Word32 *mem_csfilt, /* i/o : memory */ Word16 *mem_genSHBexc_filt_down1, /* i/o : memory */ Word16 *mem_genSHBexc_filt_down2, /* i/o : memory */ Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ Word16 *state_lpc_syn, /* i/o : memory */ const Word16 coder_type, /* i : coding type */ const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ const Word16 Q_bwe_exc, Word16 bwe_seed[], /* i/o : random number generator seed */ const Word16 voice_factors[], /* i : voicing factor */ const Word16 signal_type, const Word16 igf_flag ); void GenWBSynth_fx( const Word16 *input_synspeech, /* i : i synthesized speech */ Word16 *shb_syn_speech_16k, /* o : output highband compnent */ Loading lib_com/swb_tbe_com_fx.c +301 −0 Original line number Diff line number Diff line Loading @@ -1951,6 +1951,307 @@ void GenShapedWBExcitation_fx( } void GenShapedWBExcitation_ivas_enc_fx( Word16 *excSHB, /* o : synthesized shaped shb exctiation Q(Q_bwe_exc) */ const Word16 *lpc_shb, /* i : lpc coefficients Q12 */ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q(Q_bwe_exc) */ Word32 *mem_csfilt, /* i/o : memory Q(Q_bwe_exc+16) */ Word16 *mem_genSHBexc_filt_down1, /* i/o : memory Q(Q_bwe_exc) */ Word16 *mem_genSHBexc_filt_down2, /* i/o : memory Q(Q_bwe_exc) */ Word16 *mem_genSHBexc_filt_down3, /* i/o : memory Q(Q_bwe_exc) */ Word16 *state_lpc_syn, /* i/o : memory Q(Q_bwe_exc) */ const Word16 coder_type, /* i : coding type */ const Word16 *bwe_exc_extended, /* i : bwidth extended exciatation Q(Q_bwe_exc) */ const Word16 Q_bwe_exc, /* i : Q for memories */ Word16 bwe_seed[], /* i/o : random number generator seed */ const Word16 voice_factors[], /* i : voicing factor Q15 */ const Word16 uv_flag, /* i : unvoiced flag */ const Word16 igf_flag ) { Word16 i, j, k; Word16 wht_fil_mem[LPC_WHTN_ORDER_WB]; Word16 lpc_whtn[LPC_WHTN_ORDER_WB + 1]; Word16 R_h[LPC_WHTN_ORDER_WB + 2], R_l[LPC_WHTN_ORDER_WB + 2]; Word16 Q_R; Word16 excTmp[L_FRAME16k]; Word16 excTmp2[L_FRAME16k / 4]; Word16 excTmp2_frac[L_FRAME16k / 4]; Word16 exc4k[L_FRAME16k / 4]; Word16 exc4k_frac[L_FRAME16k / 4]; Word32 exc4k_32[L_FRAME16k / 4]; Word32 pow1, pow22; Word16 scale; Word32 excNoisyEnv[L_FRAME16k / 4]; Word16 csfilt_num2[1] = { 1638 }; /* Q15*/ Word16 neg_csfilt_den2[2] = { -32768, 31457 }; /* Q15 */ Word32 L_tmp, Ltemp1, Ltemp2; Word16 temp1, temp2, exp; Word32 Lmax; Word16 max_val, n1, n2, sc; Word32 LepsP[LPC_WHTN_ORDER_WB + 1]; Word16 tmp_vfac; Word16 avg_voice_fac; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif move16(); move16(); move16(); /*0.25f*sum_f(voice_factors, NB_SUBFR)*/ L_tmp = L_mult( voice_factors[0], 8192 /*0.25 in Q15 */ ); FOR( i = 1; i < NB_SUBFR; i++ ) { L_tmp = L_mac( L_tmp, voice_factors[i], 8192 /*0.25 in Q15 */ ); } avg_voice_fac = round_fx( L_tmp ); test(); test(); test(); test(); IF( igf_flag != 0 && ( EQ_16( coder_type, VOICED ) || GT_16( avg_voice_fac, 11469 /* 0.35 in Q15 */ ) ) ) /*Q15 -> 0.35f*/ { csfilt_num2[0] = 6554; move16(); /*Q15 -> 0.2f*/ neg_csfilt_den2[1] = 26214; move16(); /*Q15 -> 0.8f*/ } ELSE IF( igf_flag != 0 && ( EQ_16( coder_type, UNVOICED ) || LT_16( avg_voice_fac, 6654 /* 0.2 in Q15 */ ) ) ) /*Q15 -> 0.2f*/ { csfilt_num2[0] = 328; move16(); /*Q15 -> 0.01f*/ neg_csfilt_den2[1] = 32440; move16(); /*Q15 -> 0.99f*/ } set16_fx( wht_fil_mem, 0, LPC_WHTN_ORDER_WB ); Decimate_allpass_steep_fx( bwe_exc_extended, mem_genSHBexc_filt_down1, L_FRAME32k, excTmp ); flip_spectrum_and_decimby4_fx( excTmp, exc4k, L_FRAME16k, mem_genSHBexc_filt_down2, mem_genSHBexc_filt_down3, 0 ); IF( uv_flag ) { create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed ); IF( LT_16( Q_bwe_exc, 5 ) ) { FOR( i = 0; i < L_FRAME16k / 4; i++ ) { exc4kWhtnd[i] = shl_r( exc4kWhtnd[i], sub( Q_bwe_exc, 5 ) ); /*Q(Q_bwe_exc)/Q5(if Q_bwe_exc > 5) */ move16(); } } } ELSE { autocorr_fx( exc4k, LPC_WHTN_ORDER_WB + 1, R_h, R_l, &Q_R, L_FRAME16k / 4, win_flatten_4k_fx, 0, 1 ); /* Ensure R[0] isn't zero when entering Levinson Durbin */ R_l[0] = s_max( R_l[0], 1 ); move16(); FOR( i = 1; i <= LPC_WHTN_ORDER_WB; i++ ) { L_tmp = Mpy_32( R_h[i], R_l[i], wac_h[i - 1], wac_l[i - 1] ); L_Extract( L_tmp, &R_h[i], &R_l[i] ); } E_LPC_lev_dur( R_h, R_l, lpc_whtn, LepsP, LPC_WHTN_ORDER_WB, NULL ); Copy_Scale_sig( lpc_whtn, lpc_whtn, LPC_WHTN_ORDER_WB + 1, sub( norm_s( lpc_whtn[0] ), 2 ) ); fir_fx( exc4k, lpc_whtn, exc4kWhtnd, wht_fil_mem, L_FRAME16k / 4, LPC_WHTN_ORDER_WB, 0, 3 ); /* Ensure pow1 is greater than zero when computing normalization */ max_val = 0; move16(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { excTmp2[i] = abs_s( exc4kWhtnd[i] ); move16(); /* Q_bwe_exc */ max_val = s_max( max_val, excTmp2[i] ); move16(); } IF( max_val == 0 ) { pow1 = 1; move16(); n1 = 0; move16(); } ELSE { n1 = norm_s( max_val ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB excTmp2_frac[i] = shl_o( excTmp2[i], n1, &Overflow ); #else excTmp2_frac[i] = shl( excTmp2[i], n1 ); #endif move16(); /* Q14 */ } n1 = sub( sub( 14, n1 ), Q_bwe_exc ); pow1 = 1; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB L_tmp = L_mult_o( excTmp2_frac[i], excTmp2_frac[i], &Overflow ); /* Q29 */ pow1 = L_add_o( pow1, L_shr( L_tmp, 7 ), &Overflow ); /* Q22 */ #else L_tmp = L_mult( excTmp2_frac[i], excTmp2_frac[i] ); /* Q29 */ pow1 = L_add( pow1, L_shr( L_tmp, 7 ) ); /* Q22 */ #endif } } FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB excNoisyEnv[i] = L_add_o( *mem_csfilt, L_mult_o( csfilt_num2[0], excTmp2[i], &Overflow ), &Overflow ); #else excNoisyEnv[i] = L_add( *mem_csfilt, L_mult( csfilt_num2[0], excTmp2[i] ) ); #endif move32(); /* Q_bwe_exc+16 */ *mem_csfilt = Mpy_32_16_1( excNoisyEnv[i], neg_csfilt_den2[1] ); move32(); /* Q_bwe_exc+16 */ } create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed ); /* Ensure pow22 is greater than zero when computing normalization */ Lmax = 0; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { exc4k_32[i] = Mpy_32_16_1( excNoisyEnv[i], exc4k[i] ); move32(); /* Q_bwe_exc+6 */ Lmax = L_max( Lmax, L_abs( exc4k_32[i] ) ); } IF( Lmax == 0 ) { pow22 = 1; move16(); n2 = 0; move16(); set16_fx( exc4k_frac, 0, L_FRAME16k / 4 ); } ELSE { n2 = norm_l( Lmax ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB exc4k_frac[i] = extract_h( L_shl_o( exc4k_32[i], n2, &Overflow ) ); /* Q(14-n2) */ #else exc4k_frac[i] = extract_h( L_shl( exc4k_32[i], n2 ) ); /* Q(14-n2) */ #endif move16(); } n2 = sub( sub( 30, n2 ), add( Q_bwe_exc, 6 ) ); pow22 = 1; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB L_tmp = L_mult_o( exc4k_frac[i], exc4k_frac[i], &Overflow ); /* Q29 */ pow22 = L_add_o( pow22, L_shr( L_tmp, 7 ), &Overflow ); /* Q22 */ #else L_tmp = L_mult( exc4k_frac[i], exc4k_frac[i] ); /* Q29 */ pow22 = L_add( pow22, L_shr( L_tmp, 7 ) ); /* Q22 */ #endif } } test(); test(); IF( EQ_16( coder_type, UNVOICED ) || ( igf_flag != 0 && LT_16( avg_voice_fac, 6654 /*0.2 in Q15 */ ) ) ) { L_tmp = root_a_over_b_fx( pow1, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); #ifdef BASOP_NOGLOB scale = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ #else scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ #endif sc = sub( add( n2, Q_bwe_exc ), 14 ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB exc4kWhtnd[i] = round_fx_o( L_shl_o( L_mult_o( exc4k_frac[i], scale, &Overflow ), sc, &Overflow ), &Overflow ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ #else exc4kWhtnd[i] = round_fx( L_shl( L_mult( exc4k_frac[i], scale ), sc ) ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ #endif move16(); } } ELSE { sc = sub( add( n2, Q_bwe_exc ), 14 ); /* Q_bwe_exc+n2-14*/ k = 0; move16(); FOR( i = 0; i < 4; i++ ) { test(); IF( igf_flag != 0 && EQ_16( coder_type, VOICED ) ) { /*tmp_vfac = 2*voice_factors[i]; tmp_vfac = min(1, tmp_vfac);*/ #ifdef BASOP_NOGLOB tmp_vfac = shl_o( voice_factors[i], 1, &Overflow ); #else BASOP_SATURATE_WARNING_OFF_EVS tmp_vfac = shl( voice_factors[i], 1 ); BASOP_SATURATE_WARNING_ON_EVS #endif } ELSE { tmp_vfac = voice_factors[i]; move16(); } Ltemp1 = root_a_fx( L_deposit_h( tmp_vfac ), 31, &exp ); #ifdef BASOP_NOGLOB temp1 = round_fx_o( L_shl_o( Ltemp1, exp, &Overflow ), &Overflow ); /* Q15 */ #else temp1 = round_fx( L_shl( Ltemp1, exp ) ); /* Q15 */ #endif L_tmp = Mpy_32_16_1( pow1, sub( 32767, tmp_vfac ) ); /* Q22*/ Ltemp2 = root_a_over_b_fx( L_tmp, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); #ifdef BASOP_NOGLOB temp2 = round_fx_o( L_shl_o( Ltemp2, exp, &Overflow ), &Overflow ); /* Q15 */ #else temp2 = round_fx( L_shl( Ltemp2, exp ) ); /* Q15 */ #endif FOR( j = 0; j < L_FRAME16k / 16; j++ ) { #ifdef BASOP_NOGLOB L_tmp = L_mult_o( temp1, exc4kWhtnd[k], &Overflow ); /* Q(16+Q_bwe_exc) */ L_tmp = L_add_o( L_tmp, L_shl_o( L_mult_o( temp2, exc4k_frac[k], &Overflow ), sc, &Overflow ), &Overflow ); /* Q(16+Q_bwe_exc) */ exc4kWhtnd[k] = round_fx_o( L_tmp, &Overflow ); /* Q_bwe_exc */ #else L_tmp = L_mult( temp1, exc4kWhtnd[k] ); /* Q(16+Q_bwe_exc) */ L_tmp = L_add( L_tmp, L_shl( L_mult( temp2, exc4k_frac[k] ), sc ) ); /* Q(16+Q_bwe_exc) */ exc4kWhtnd[k] = round_fx( L_tmp ); /* Q_bwe_exc */ #endif move16(); k = add( k, 1 ); } } } } syn_filt_fx( 0, lpc_shb, LPC_SHB_ORDER_WB, exc4kWhtnd, excSHB, L_FRAME16k / 4, state_lpc_syn, 1 ); return; } /*-------------------------------------------------------------------* * GenWBSynth() * Loading Loading
apps/renderer.c +50 −0 Original line number Diff line number Diff line Loading @@ -662,6 +662,10 @@ int main( lfeRoutingConfigs[i] = NULL; } #ifdef FIX_DISCLAIMER IVAS_REND_PrintDisclaimer(); #endif CmdlnArgs args = parseCmdlnArgs( argc, argv ); if ( args.nonDiegeticPan && !( ( args.inConfig.numAudioObjects == 0 && args.inConfig.multiChannelBuses[0].audioConfig == IVAS_AUDIO_CONFIG_MONO ) || Loading Loading @@ -829,6 +833,52 @@ int main( exit( -1 ); } #ifdef FIX_DISCLAIMER fprintf( stdout, "Input audio file: %s\n", args.inputFilePath ); fprintf( stdout, "Output audio file: %s\n\n", args.outputFilePath ); if ( args.inConfig.numAudioObjects > 0 ) { if ( args.inConfig.numAudioObjects == 1 ) { IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM1 ); } else if ( args.inConfig.numAudioObjects == 2 ) { IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM2 ); } else if ( args.inConfig.numAudioObjects == 3 ) { IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM3 ); } else if ( args.inConfig.numAudioObjects == 4 ) { IVAS_REND_PrintInputConfig( IVAS_AUDIO_CONFIG_ISM4 ); } } for ( i = 0; i < args.inConfig.numMultiChannelBuses; i++ ) { IVAS_REND_PrintInputConfig( args.inConfig.multiChannelBuses[i].audioConfig ); } for ( i = 0; i < args.inConfig.numMasaBuses; i++ ) { IVAS_REND_PrintInputConfig( args.inConfig.masaBuses[i].audioConfig ); } for ( i = 0; i < args.inConfig.numAmbisonicsBuses; i++ ) { IVAS_REND_PrintInputConfig( args.inConfig.ambisonicsBuses[i].audioConfig ); } if ( ( error = IVAS_REND_PrintConfig( hIvasRend ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\n IVAS_REND_PrintConfig failed: %s\n\n", ivas_error_to_string( error ) ); // goto cleanup; exit( -1 ); } #endif #ifdef FIX_POINT_HRTF_FILE_FORMAT if ( !isEmptyString( args.customHrtfFilePath ) ) { Loading
lib_com/disclaimer.c +4 −0 Original line number Diff line number Diff line Loading @@ -44,7 +44,11 @@ int16_t print_disclaimer( FILE *fPtr ) { fprintf( fPtr, "\n==================================================================================================\n" ); #ifdef FIX_DISCLAIMER fprintf( fPtr, " IVAS Codec BASOP Baseline\n" ); #else fprintf( fPtr, " IVAS Codec Baseline\n" ); #endif fprintf( fPtr, " \n" ); fprintf( fPtr, " Based on EVS Codec (Floating Point) 3GPP TS26.443 Nov 04, 2021,\n" ); fprintf( fPtr, " Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0\n" ); Loading
lib_com/options.h +1 −0 Original line number Diff line number Diff line Loading @@ -123,4 +123,5 @@ #define FIX_ISSUE_1157 /* Ittiam: Fix for Issue 1157: Encoder crash for Stereo at 48/64kbps DTX on/off in kernel_switch_trafo_fx() */ #define FIX_ISSUE_1152 /* Ittiam: Fix for issue 1152: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from find_tilt_fx function*/ #define FIX_ISSUE_1156 /* Ittiam: Fix for Issue 1156: Encoder crash for Stereo at 32kbps in SWB_BWE_encoding_ivas_fx() */ #define FIX_DISCLAIMER /* VA: Add disclaimer for external renderer + Add info about IVAS reference version (FLP issue 1225) */ #endif
lib_com/prot_fx.h +17 −0 Original line number Diff line number Diff line Loading @@ -2914,6 +2914,23 @@ void GenShapedWBExcitation_fx( const Word16 signal_type, const Word16 igf_flag ); void GenShapedWBExcitation_ivas_enc_fx( Word16 *excSHB, /* o : synthesized shaped shb exctiation */ const Word16 *lpc_shb, /* i : lpc coefficients */ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation */ Word32 *mem_csfilt, /* i/o : memory */ Word16 *mem_genSHBexc_filt_down1, /* i/o : memory */ Word16 *mem_genSHBexc_filt_down2, /* i/o : memory */ Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ Word16 *state_lpc_syn, /* i/o : memory */ const Word16 coder_type, /* i : coding type */ const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ const Word16 Q_bwe_exc, Word16 bwe_seed[], /* i/o : random number generator seed */ const Word16 voice_factors[], /* i : voicing factor */ const Word16 signal_type, const Word16 igf_flag ); void GenWBSynth_fx( const Word16 *input_synspeech, /* i : i synthesized speech */ Word16 *shb_syn_speech_16k, /* o : output highband compnent */ Loading
lib_com/swb_tbe_com_fx.c +301 −0 Original line number Diff line number Diff line Loading @@ -1951,6 +1951,307 @@ void GenShapedWBExcitation_fx( } void GenShapedWBExcitation_ivas_enc_fx( Word16 *excSHB, /* o : synthesized shaped shb exctiation Q(Q_bwe_exc) */ const Word16 *lpc_shb, /* i : lpc coefficients Q12 */ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q(Q_bwe_exc) */ Word32 *mem_csfilt, /* i/o : memory Q(Q_bwe_exc+16) */ Word16 *mem_genSHBexc_filt_down1, /* i/o : memory Q(Q_bwe_exc) */ Word16 *mem_genSHBexc_filt_down2, /* i/o : memory Q(Q_bwe_exc) */ Word16 *mem_genSHBexc_filt_down3, /* i/o : memory Q(Q_bwe_exc) */ Word16 *state_lpc_syn, /* i/o : memory Q(Q_bwe_exc) */ const Word16 coder_type, /* i : coding type */ const Word16 *bwe_exc_extended, /* i : bwidth extended exciatation Q(Q_bwe_exc) */ const Word16 Q_bwe_exc, /* i : Q for memories */ Word16 bwe_seed[], /* i/o : random number generator seed */ const Word16 voice_factors[], /* i : voicing factor Q15 */ const Word16 uv_flag, /* i : unvoiced flag */ const Word16 igf_flag ) { Word16 i, j, k; Word16 wht_fil_mem[LPC_WHTN_ORDER_WB]; Word16 lpc_whtn[LPC_WHTN_ORDER_WB + 1]; Word16 R_h[LPC_WHTN_ORDER_WB + 2], R_l[LPC_WHTN_ORDER_WB + 2]; Word16 Q_R; Word16 excTmp[L_FRAME16k]; Word16 excTmp2[L_FRAME16k / 4]; Word16 excTmp2_frac[L_FRAME16k / 4]; Word16 exc4k[L_FRAME16k / 4]; Word16 exc4k_frac[L_FRAME16k / 4]; Word32 exc4k_32[L_FRAME16k / 4]; Word32 pow1, pow22; Word16 scale; Word32 excNoisyEnv[L_FRAME16k / 4]; Word16 csfilt_num2[1] = { 1638 }; /* Q15*/ Word16 neg_csfilt_den2[2] = { -32768, 31457 }; /* Q15 */ Word32 L_tmp, Ltemp1, Ltemp2; Word16 temp1, temp2, exp; Word32 Lmax; Word16 max_val, n1, n2, sc; Word32 LepsP[LPC_WHTN_ORDER_WB + 1]; Word16 tmp_vfac; Word16 avg_voice_fac; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif move16(); move16(); move16(); /*0.25f*sum_f(voice_factors, NB_SUBFR)*/ L_tmp = L_mult( voice_factors[0], 8192 /*0.25 in Q15 */ ); FOR( i = 1; i < NB_SUBFR; i++ ) { L_tmp = L_mac( L_tmp, voice_factors[i], 8192 /*0.25 in Q15 */ ); } avg_voice_fac = round_fx( L_tmp ); test(); test(); test(); test(); IF( igf_flag != 0 && ( EQ_16( coder_type, VOICED ) || GT_16( avg_voice_fac, 11469 /* 0.35 in Q15 */ ) ) ) /*Q15 -> 0.35f*/ { csfilt_num2[0] = 6554; move16(); /*Q15 -> 0.2f*/ neg_csfilt_den2[1] = 26214; move16(); /*Q15 -> 0.8f*/ } ELSE IF( igf_flag != 0 && ( EQ_16( coder_type, UNVOICED ) || LT_16( avg_voice_fac, 6654 /* 0.2 in Q15 */ ) ) ) /*Q15 -> 0.2f*/ { csfilt_num2[0] = 328; move16(); /*Q15 -> 0.01f*/ neg_csfilt_den2[1] = 32440; move16(); /*Q15 -> 0.99f*/ } set16_fx( wht_fil_mem, 0, LPC_WHTN_ORDER_WB ); Decimate_allpass_steep_fx( bwe_exc_extended, mem_genSHBexc_filt_down1, L_FRAME32k, excTmp ); flip_spectrum_and_decimby4_fx( excTmp, exc4k, L_FRAME16k, mem_genSHBexc_filt_down2, mem_genSHBexc_filt_down3, 0 ); IF( uv_flag ) { create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed ); IF( LT_16( Q_bwe_exc, 5 ) ) { FOR( i = 0; i < L_FRAME16k / 4; i++ ) { exc4kWhtnd[i] = shl_r( exc4kWhtnd[i], sub( Q_bwe_exc, 5 ) ); /*Q(Q_bwe_exc)/Q5(if Q_bwe_exc > 5) */ move16(); } } } ELSE { autocorr_fx( exc4k, LPC_WHTN_ORDER_WB + 1, R_h, R_l, &Q_R, L_FRAME16k / 4, win_flatten_4k_fx, 0, 1 ); /* Ensure R[0] isn't zero when entering Levinson Durbin */ R_l[0] = s_max( R_l[0], 1 ); move16(); FOR( i = 1; i <= LPC_WHTN_ORDER_WB; i++ ) { L_tmp = Mpy_32( R_h[i], R_l[i], wac_h[i - 1], wac_l[i - 1] ); L_Extract( L_tmp, &R_h[i], &R_l[i] ); } E_LPC_lev_dur( R_h, R_l, lpc_whtn, LepsP, LPC_WHTN_ORDER_WB, NULL ); Copy_Scale_sig( lpc_whtn, lpc_whtn, LPC_WHTN_ORDER_WB + 1, sub( norm_s( lpc_whtn[0] ), 2 ) ); fir_fx( exc4k, lpc_whtn, exc4kWhtnd, wht_fil_mem, L_FRAME16k / 4, LPC_WHTN_ORDER_WB, 0, 3 ); /* Ensure pow1 is greater than zero when computing normalization */ max_val = 0; move16(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { excTmp2[i] = abs_s( exc4kWhtnd[i] ); move16(); /* Q_bwe_exc */ max_val = s_max( max_val, excTmp2[i] ); move16(); } IF( max_val == 0 ) { pow1 = 1; move16(); n1 = 0; move16(); } ELSE { n1 = norm_s( max_val ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB excTmp2_frac[i] = shl_o( excTmp2[i], n1, &Overflow ); #else excTmp2_frac[i] = shl( excTmp2[i], n1 ); #endif move16(); /* Q14 */ } n1 = sub( sub( 14, n1 ), Q_bwe_exc ); pow1 = 1; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB L_tmp = L_mult_o( excTmp2_frac[i], excTmp2_frac[i], &Overflow ); /* Q29 */ pow1 = L_add_o( pow1, L_shr( L_tmp, 7 ), &Overflow ); /* Q22 */ #else L_tmp = L_mult( excTmp2_frac[i], excTmp2_frac[i] ); /* Q29 */ pow1 = L_add( pow1, L_shr( L_tmp, 7 ) ); /* Q22 */ #endif } } FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB excNoisyEnv[i] = L_add_o( *mem_csfilt, L_mult_o( csfilt_num2[0], excTmp2[i], &Overflow ), &Overflow ); #else excNoisyEnv[i] = L_add( *mem_csfilt, L_mult( csfilt_num2[0], excTmp2[i] ) ); #endif move32(); /* Q_bwe_exc+16 */ *mem_csfilt = Mpy_32_16_1( excNoisyEnv[i], neg_csfilt_den2[1] ); move32(); /* Q_bwe_exc+16 */ } create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed ); /* Ensure pow22 is greater than zero when computing normalization */ Lmax = 0; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { exc4k_32[i] = Mpy_32_16_1( excNoisyEnv[i], exc4k[i] ); move32(); /* Q_bwe_exc+6 */ Lmax = L_max( Lmax, L_abs( exc4k_32[i] ) ); } IF( Lmax == 0 ) { pow22 = 1; move16(); n2 = 0; move16(); set16_fx( exc4k_frac, 0, L_FRAME16k / 4 ); } ELSE { n2 = norm_l( Lmax ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB exc4k_frac[i] = extract_h( L_shl_o( exc4k_32[i], n2, &Overflow ) ); /* Q(14-n2) */ #else exc4k_frac[i] = extract_h( L_shl( exc4k_32[i], n2 ) ); /* Q(14-n2) */ #endif move16(); } n2 = sub( sub( 30, n2 ), add( Q_bwe_exc, 6 ) ); pow22 = 1; move32(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB L_tmp = L_mult_o( exc4k_frac[i], exc4k_frac[i], &Overflow ); /* Q29 */ pow22 = L_add_o( pow22, L_shr( L_tmp, 7 ), &Overflow ); /* Q22 */ #else L_tmp = L_mult( exc4k_frac[i], exc4k_frac[i] ); /* Q29 */ pow22 = L_add( pow22, L_shr( L_tmp, 7 ) ); /* Q22 */ #endif } } test(); test(); IF( EQ_16( coder_type, UNVOICED ) || ( igf_flag != 0 && LT_16( avg_voice_fac, 6654 /*0.2 in Q15 */ ) ) ) { L_tmp = root_a_over_b_fx( pow1, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); #ifdef BASOP_NOGLOB scale = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ #else scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */ #endif sc = sub( add( n2, Q_bwe_exc ), 14 ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) { #ifdef BASOP_NOGLOB exc4kWhtnd[i] = round_fx_o( L_shl_o( L_mult_o( exc4k_frac[i], scale, &Overflow ), sc, &Overflow ), &Overflow ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ #else exc4kWhtnd[i] = round_fx( L_shl( L_mult( exc4k_frac[i], scale ), sc ) ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ #endif move16(); } } ELSE { sc = sub( add( n2, Q_bwe_exc ), 14 ); /* Q_bwe_exc+n2-14*/ k = 0; move16(); FOR( i = 0; i < 4; i++ ) { test(); IF( igf_flag != 0 && EQ_16( coder_type, VOICED ) ) { /*tmp_vfac = 2*voice_factors[i]; tmp_vfac = min(1, tmp_vfac);*/ #ifdef BASOP_NOGLOB tmp_vfac = shl_o( voice_factors[i], 1, &Overflow ); #else BASOP_SATURATE_WARNING_OFF_EVS tmp_vfac = shl( voice_factors[i], 1 ); BASOP_SATURATE_WARNING_ON_EVS #endif } ELSE { tmp_vfac = voice_factors[i]; move16(); } Ltemp1 = root_a_fx( L_deposit_h( tmp_vfac ), 31, &exp ); #ifdef BASOP_NOGLOB temp1 = round_fx_o( L_shl_o( Ltemp1, exp, &Overflow ), &Overflow ); /* Q15 */ #else temp1 = round_fx( L_shl( Ltemp1, exp ) ); /* Q15 */ #endif L_tmp = Mpy_32_16_1( pow1, sub( 32767, tmp_vfac ) ); /* Q22*/ Ltemp2 = root_a_over_b_fx( L_tmp, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); #ifdef BASOP_NOGLOB temp2 = round_fx_o( L_shl_o( Ltemp2, exp, &Overflow ), &Overflow ); /* Q15 */ #else temp2 = round_fx( L_shl( Ltemp2, exp ) ); /* Q15 */ #endif FOR( j = 0; j < L_FRAME16k / 16; j++ ) { #ifdef BASOP_NOGLOB L_tmp = L_mult_o( temp1, exc4kWhtnd[k], &Overflow ); /* Q(16+Q_bwe_exc) */ L_tmp = L_add_o( L_tmp, L_shl_o( L_mult_o( temp2, exc4k_frac[k], &Overflow ), sc, &Overflow ), &Overflow ); /* Q(16+Q_bwe_exc) */ exc4kWhtnd[k] = round_fx_o( L_tmp, &Overflow ); /* Q_bwe_exc */ #else L_tmp = L_mult( temp1, exc4kWhtnd[k] ); /* Q(16+Q_bwe_exc) */ L_tmp = L_add( L_tmp, L_shl( L_mult( temp2, exc4k_frac[k] ), sc ) ); /* Q(16+Q_bwe_exc) */ exc4kWhtnd[k] = round_fx( L_tmp ); /* Q_bwe_exc */ #endif move16(); k = add( k, 1 ); } } } } syn_filt_fx( 0, lpc_shb, LPC_SHB_ORDER_WB, exc4kWhtnd, excSHB, L_FRAME16k / 4, state_lpc_syn, 1 ); return; } /*-------------------------------------------------------------------* * GenWBSynth() * Loading