From e9efb892b162fba6f6460c736a62c84c0efb8697 Mon Sep 17 00:00:00 2001 From: det Date: Mon, 13 Jan 2025 12:00:06 +0100 Subject: [PATCH 01/97] patched MR1266 into basop. --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index a914c8e66..ecfe2d6ab 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,6 +86,7 @@ #define FIX_QMETADATA_PENALTY /* Nokia: transform penalty calculation in qmetadata into integer operations */ #define FIX_1013_CRASH_HQ_CORE_DEC /* Ittiam: Saturation added on the lines of EVS */ #define NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS /* DLB: adjust prerendering and mixing gain in OSBA encoder. This is fix to float codes*/ +#define NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA /* FhG: issue 926: crash in OSBA decoding with planar FOA */ #define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */ #define FIX_ISSUE_1062_AND_1068_TON_ENE_EST_FX #define FIX_ISSUE_987 diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d69fa8525..d4ac66dcf 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -3259,7 +3259,11 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( test(); test(); +#ifdef NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA + if ( EQ_16( num_tc, 3 ) ) +#else if ( ( st_ivas->sba_planar && GE_16( num_tc, 3 ) ) || EQ_16( num_tc, 3 ) ) +#endif { num_tc = add( num_tc, 1 ); } -- GitLab From 388defeea77b1a6b83415d30b027fd742b0856ca Mon Sep 17 00:00:00 2001 From: det Date: Mon, 13 Jan 2025 15:41:26 +0100 Subject: [PATCH 02/97] merged MR1251 into basop. --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a914c8e66..5d8f7fbee 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,5 +101,6 @@ #define FIX_1109_OPTIM_MCT_STEREO_IGF_DEC /* FhG: optimize mctStereoIGF_dec_fx() */ #define FIX_1110_OPTIM_DIRAC_DECORR_PROC /* FhG: optimize ivas_dirac_dec_decorr_process() */ #define FIX_1100_REMOVE_LPC_RESCALING /* VA: Remove the rescaling of LPC coefficient to Q12 as residu and syn-filt are already taking care of it*/ +#define NONBE_FIX_855_JBM_FLUSH_OFFSET /* FhG: issue #855: add missing switch here for the code in JBM flushing */ #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d69fa8525..70b4c2699 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2669,7 +2669,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( hTcBuffer->n_samples_buffered = add( hTcBuffer->n_samples_granularity, n_samples_still_available ); hTcBuffer->n_samples_available = 0; hTcBuffer->n_samples_flushed = n_samples_to_render; -#ifdef CR_FIX_JBM_FLUSH_OFFSET +#ifdef NONBE_FIX_855_JBM_FLUSH_OFFSET hTcBuffer->n_samples_rendered = 0; #else hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; @@ -2855,7 +2855,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" ); } -#ifdef CR_FIX_JBM_FLUSH_OFFSET +#ifdef NONBE_FIX_855_JBM_FLUSH_OFFSET hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; #endif } -- GitLab From c505de6706176e7f40f9255239ff43a620ac5f6b Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 21 Feb 2025 16:15:20 +0200 Subject: [PATCH 03/97] Port MR 1273 from float repo to BASOP. --- apps/renderer.c | 4 ++++ lib_com/options.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/apps/renderer.c b/apps/renderer.c index f5c0a8847..4b74f0078 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -288,7 +288,11 @@ static const CmdLnParser_Option cliOptions[] = { .description = "LFE panning matrix. File (CSV table) containing a matrix of dimensions [ num_input_lfe x num_output_channels ] with elements specifying linear routing gain (like --gain, -g). \nIf specified, overrides the output LFE position option and the default behavior which attempts to map input to output LFE channel(s)" }, { .id = CmdLnOptionId_noDelayCmp, +#ifdef FIX_929_RENDERER_CMDL + .match = "no_delay_compensation", +#else .match = "no_delay_comparison", +#endif .matchShort = "no_delay_cmp", .description = "[flag] Turn off delay compensation", }, diff --git a/lib_com/options.h b/lib_com/options.h index 0c8105d8c..269ce610a 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,4 +164,6 @@ #define FIX_ISSUE_1247 #define NONBE_FIX_1087_OOB_SBA_DTX_RS /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */ #define FIX_1285_DECODER_CRASH +#define FIX_929_RENDERER_CMDL /* Nokia: issue #929: renderer command line option */ + #endif -- GitLab From df4ab5e6d98ccf2250ef0b6daa10b9b7c1f0ec91 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Tue, 25 Feb 2025 15:39:37 +0100 Subject: [PATCH 04/97] replaced the costly basop_util_mant2exp() function with a 64 bit addtion. there is a potential overflow which needs to be adressed first. --- lib_com/ivas_prot_fx.h | 6 +++++ lib_com/ivas_tools.c | 39 +++++++++++++++++++++++++++++++ lib_enc/speech_music_classif_fx.c | 23 ++++++------------ 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 1682c255b..1b6e7be85 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4714,6 +4714,12 @@ Word32 dot_product_cholesky_fixed( const Word16 exp_A, Word16 *exp_sum ); +Word64 dot_product_cholesky_fixed64( + const Word32 *x, /* i : vector x */ + const Word32 *A, /* i : Cholesky matrix A */ + const Word16 N /* i : vector & matrix size */ +); + void v_mult_mat_fx( Word32 *y_fx, /* o : the product x*A */ Word16 *y_q_fx, diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index d6210dfc7..9f1a42f29 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -642,6 +642,45 @@ Word32 dot_product_cholesky_fixed( return suma; } +/*---------------------------------------------------------------------* + * dot_product_cholesky() + * + * Calculates dot product of type x'*A*A'*x, where x is column vector of size m, + * and A is a Cholesky decomposition of some Hermitian matrix S whose size is m*m. + * Therefore, S=A*A' where A is upper triangular matrix of size (m*m+m)/2 (zeros ommitted, column-wise) + *---------------------------------------------------------------------*/ + +/*! r: the dot product x'*A*A'*x */ +Word64 dot_product_cholesky_fixed64( + const Word32 *x, /* i : vector x Q31 - exp_x*/ + const Word32 *A, /* i : Cholesky matrix A Q31 - exp_A*/ + const Word16 N /* i : vector & matrix size Q0*/ +) +{ + Word16 i, j; + Word64 suma, tmp_sum; + Word32 mul; + const Word32 *pt_x, *pt_A; + pt_A = A; + suma = 0; + move32(); + FOR( i = 0; i < N; i++ ) + { + tmp_sum = 0; + move32(); + pt_x = x; + + FOR( j = 0; j <= i; j++ ) + { + mul = Mpy_32_32( *pt_x++, *pt_A++ ); + tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) ); + } + + suma = W_mac_32_32( suma, tmp_sum, tmp_sum ); // TODO: make sure that this does not overflow. + } + + return suma; +} void v_mult_mat_fixed( Word32 *y, /* o : the product x*A Qx - guardbits*/ const Word32 *x, /* i : vector x Qx*/ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 295cff8a1..34744131f 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1683,10 +1683,8 @@ Word16 ivas_smc_gmm_fx( Word16 flag_odv; Word32 lps_fx, lpm_fx, lpn_fx; Word32 ps_fx[N_SMC_MIXTURES], pm_fx[N_SMC_MIXTURES], pn_fx[N_SMC_MIXTURES]; - Word32 lprob_fx; - Word16 lprob_exp = 0; + Word64 wprob_fx; Word32 fvm_fx[N_PCA_COEF]; - Word16 fvm_exp = 0; Word32 sum_PS_fx, ps_diff_fx, ps_sta_fx; Word32 dlp_fx, wrelE_fx, wdrop_fx, wght_fx; Word32 wrise_fx; @@ -2273,23 +2271,16 @@ Word16 ivas_smc_gmm_fx( FOR( m = 0; m < N_SMC_MIXTURES; m++ ) { v_sub32_fx( FV_fx, &means_speech_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - fvm_exp = sub( 31, Qfact_FV ); - lprob_exp = 0; - move16(); - lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); - ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); + ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_shr( wprob_fx, Q18 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - lprob_exp = 0; - move16(); - lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); - pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); + pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_shr( wprob_fx, Q18 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - lprob_exp = 0; - move16(); - lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); - pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); + pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_shr( wprob_fx, Q18 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); } -- GitLab From e86a8b5fe7ce3094bf769099ef03cc506dcc800f Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Wed, 26 Feb 2025 11:03:31 +0100 Subject: [PATCH 05/97] the cholesky_fixed64 function returns Q10 instead of Q18 now. --- lib_com/ivas_tools.c | 9 +++++---- lib_enc/speech_music_classif_fx.c | 12 ++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 9f1a42f29..6cb13740a 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -660,10 +660,11 @@ Word64 dot_product_cholesky_fixed64( Word16 i, j; Word64 suma, tmp_sum; Word32 mul; + Word32 tmp; const Word32 *pt_x, *pt_A; pt_A = A; suma = 0; - move32(); + move64(); FOR( i = 0; i < N; i++ ) { tmp_sum = 0; @@ -675,10 +676,10 @@ Word64 dot_product_cholesky_fixed64( mul = Mpy_32_32( *pt_x++, *pt_A++ ); tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) ); } - - suma = W_mac_32_32( suma, tmp_sum, tmp_sum ); // TODO: make sure that this does not overflow. + tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow + tmp = W_extract_l( tmp_sum ); + suma = W_mac_32_32( suma, tmp, tmp ); } - return suma; } void v_mult_mat_fixed( diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 34744131f..da93127bf 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2271,16 +2271,16 @@ Word16 ivas_smc_gmm_fx( FOR( m = 0; m < N_SMC_MIXTURES; m++ ) { v_sub32_fx( FV_fx, &means_speech_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); - ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_shr( wprob_fx, Q18 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); - pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_shr( wprob_fx, Q18 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); - pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_shr( wprob_fx, Q18 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); } -- GitLab From d3d63a8b48f4661a64f9dfc3307c043fd090ed9b Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Wed, 26 Feb 2025 14:37:27 +0100 Subject: [PATCH 06/97] applied the clang patch. --- lib_com/ivas_tools.c | 4 ++-- lib_enc/speech_music_classif_fx.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 6cb13740a..2b62a0e5a 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -654,7 +654,7 @@ Word32 dot_product_cholesky_fixed( Word64 dot_product_cholesky_fixed64( const Word32 *x, /* i : vector x Q31 - exp_x*/ const Word32 *A, /* i : Cholesky matrix A Q31 - exp_A*/ - const Word16 N /* i : vector & matrix size Q0*/ + const Word16 N /* i : vector & matrix size Q0*/ ) { Word16 i, j; @@ -676,7 +676,7 @@ Word64 dot_product_cholesky_fixed64( mul = Mpy_32_32( *pt_x++, *pt_A++ ); tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) ); } - tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow + tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow tmp = W_extract_l( tmp_sum ); suma = W_mac_32_32( suma, tmp, tmp ); } diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index da93127bf..fe6647a6c 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2271,15 +2271,15 @@ Word16 ivas_smc_gmm_fx( FOR( m = 0; m < N_SMC_MIXTURES; m++ ) { v_sub32_fx( FV_fx, &means_speech_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 move32(); } -- GitLab From 9778e0b4fb9e4c9a420b1ce19416ed22a35618b1 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 28 Feb 2025 09:30:06 +0100 Subject: [PATCH 07/97] whitespace --- lib_com/ivas_tools.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index e0a971951..dc45e3f0e 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -642,6 +642,7 @@ Word32 dot_product_cholesky_fixed( return suma; } + /*---------------------------------------------------------------------* * dot_product_cholesky() * @@ -665,6 +666,7 @@ Word64 dot_product_cholesky_fixed64( pt_A = A; suma = 0; move64(); + FOR( i = 0; i < N; i++ ) { tmp_sum = 0; @@ -676,12 +678,15 @@ Word64 dot_product_cholesky_fixed64( mul = Mpy_32_32( *pt_x++, *pt_A++ ); tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) ); } + tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow tmp = W_extract_l( tmp_sum ); suma = W_mac_32_32( suma, tmp, tmp ); } + return suma; } + void v_mult_mat_fixed( Word32 *y, /* o : the product x*A Qx - guardbits*/ const Word32 *x, /* i : vector x Qx*/ -- GitLab From 3a1f5fa87f739f3cb38d61146d2817d6118471f6 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 28 Feb 2025 19:20:51 +0530 Subject: [PATCH 08/97] Fix for 3GPP issue 1311: BASOP encoder for 80kbps Stereo does not trigger dtx when it should Link #1311 --- lib_enc/dtx_fx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index a1478d3f8..be4368f69 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -35,7 +35,7 @@ #endif #define MAX_BRATE_DTX_EVS ACELP_24k40 /* maximum bitrate to which the default DTX is applied in EVS; otherwise DTX is applied only in silence */ -#define MAX_BRATE_DTX_IVAS IVAS_64k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ +#define MAX_BRATE_DTX_IVAS IVAS_80k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ /*-------------------------------------------------------------------* * Local function prototypes @@ -107,7 +107,7 @@ void dtx_ivas_fx( test(); test(); test(); - last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, ACELP_32k ) ); + last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) ); test(); test(); @@ -118,7 +118,7 @@ void dtx_ivas_fx( ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ); #else - last_br_flag = LE_32( st_fx->last_total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, ACELP_32k ) ); + last_br_flag = LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_IVAS ) ); br_dtx_flag = 0; move16(); #endif @@ -135,7 +135,7 @@ void dtx_ivas_fx( test(); test(); test(); - if ( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && EQ_16( st_fx->element_mode, IVAS_SCE ) && EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + if ( ( EQ_16( st_fx->codec_mode, MODE1 ) || st_fx->Opt_AMR_WB ) && NE_16( st_fx->element_mode, IVAS_SCE ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { st_fx->cng_type = LP_CNG; move16(); @@ -254,8 +254,6 @@ void dtx_ivas_fx( { st_fx->last_total_brate_cng = -1; move16(); - st_fx->last_rf_mode_cng = st_fx->rf_mode; - move16(); } ELSE { @@ -265,6 +263,8 @@ void dtx_ivas_fx( move16(); st_fx->last_codec_mode_cng = st_fx->codec_mode; move16(); + st_fx->last_rf_mode_cng = st_fx->rf_mode; + move16(); } IF( hDtxEnc->cnt_SID == 0 ) @@ -321,7 +321,7 @@ void dtx_ivas_fx( test(); test(); test(); - IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, ACELP_24k40 ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( st_fx->total_brate, ACELP_32k ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */ + IF( ( EQ_16( st_fx->cng_type, FD_CNG ) && ( LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) ) /* at highest bitrates, use exclusively LP_CNG */ { test(); test(); -- GitLab From 7edb193c68a1c0c4ce8f9da3c5846c2d171e66fc Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Mar 2025 22:40:28 +0530 Subject: [PATCH 09/97] Fix for 3GPP issue 1256: Usage of NS2SA()-macro on variables Link #1256 --- lib_com/core_com_config.c | 4 +-- lib_com/ivas_fb_mixer.c | 6 ++-- lib_com/tcx_ltp_fx.c | 2 +- lib_com/window_ola_fx.c | 6 ++-- lib_dec/FEC_HQ_phase_ecu_fx.c | 30 +++++++++--------- lib_dec/acelp_core_dec_ivas_fx.c | 2 +- lib_dec/acelp_core_switch_dec_fx.c | 2 +- lib_dec/core_switching_dec.c | 8 ++--- lib_dec/core_switching_dec_fx.c | 4 +-- lib_dec/evs_dec_fx.c | 16 +++++----- lib_dec/fd_cng_dec_fx.c | 8 ++--- lib_dec/init_dec_fx.c | 4 +-- lib_dec/ivas_core_dec.c | 8 ++--- lib_dec/ivas_dirac_dec.c | 2 +- lib_dec/ivas_init_dec.c | 4 +-- lib_dec/ivas_ism_param_dec.c | 1 - lib_dec/ivas_jbm_dec.c | 26 +++++++-------- lib_dec/ivas_masa_dec.c | 2 +- lib_dec/ivas_mc_param_dec.c | 8 ++--- lib_dec/ivas_mc_paramupmix_dec.c | 2 +- lib_dec/ivas_mct_dec.c | 10 +++--- lib_dec/ivas_mdct_core_dec.c | 4 +-- lib_dec/ivas_post_proc.c | 24 +++++++------- lib_dec/ivas_sba_dec.c | 2 +- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 2 +- lib_dec/ivas_stereo_dft_dec.c | 2 +- lib_dec/ivas_stereo_dft_dec_dmx.c | 4 +-- lib_dec/ivas_stereo_dft_dec_fx.c | 4 +-- lib_dec/ivas_stereo_ica_dec.c | 12 +++---- lib_dec/ivas_stereo_icbwe_dec.c | 28 ++++++++-------- lib_dec/ivas_stereo_mdct_stereo_dec.c | 4 +-- lib_dec/ivas_stereo_switching_dec.c | 12 +++---- lib_dec/ivas_stereo_td_dec.c | 8 ++--- lib_dec/swb_bwe_dec.c | 2 +- lib_dec/swb_bwe_dec_fx.c | 2 +- lib_enc/amr_wb_enc_fx.c | 2 +- lib_enc/core_enc_init_fx.c | 2 +- lib_enc/core_switching_enc_fx.c | 4 +-- lib_enc/fd_cng_enc_fx.c | 4 +-- lib_enc/hq_core_enc.c | 2 +- lib_enc/init_enc.c | 2 +- lib_enc/init_enc_fx.c | 2 +- lib_enc/ivas_core_pre_proc.c | 24 +++++++------- lib_enc/ivas_core_pre_proc_front.c | 8 ++--- lib_enc/ivas_corecoder_enc_reconfig.c | 2 +- lib_enc/ivas_cpe_enc.c | 6 ++-- lib_enc/ivas_front_vad.c | 2 +- lib_enc/ivas_lfe_enc.c | 4 +-- lib_enc/ivas_mc_paramupmix_enc.c | 4 +-- lib_enc/ivas_mcmasa_enc.c | 16 +++++----- lib_enc/ivas_osba_enc.c | 4 +-- lib_enc/ivas_stereo_ica_enc.c | 10 +++--- lib_enc/ivas_stereo_switching_enc.c | 6 ++-- lib_enc/lib_enc.c | 2 +- lib_enc/swb_bwe_enc_fx.c | 28 ++++++++-------- lib_enc/swb_pre_proc_fx.c | 44 +++++++++++++------------- lib_enc/swb_tbe_enc_fx.c | 8 ++--- 57 files changed, 225 insertions(+), 226 deletions(-) diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index 8d360c6a3..fdf935461 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -1235,8 +1235,8 @@ void init_tcx_window_cfg_fx( } /*Mid-OLA*/ /*compute minimum length for "half" window: lookahead - 5ms. It must be also multiple of 2*/ - hTcxCfg->tcx_mdct_window_half_length = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA_FX2( 12800, 5000000L ), sr2fscale( sr_core ) ), LD_FSCALE_DENOM ) ); /*Q0*/ - hTcxCfg->tcx_mdct_window_half_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA_FX2( 12800, 5000000L ), sr2fscale( input_Fs ) ), LD_FSCALE_DENOM ) ); /*Q0*/ + hTcxCfg->tcx_mdct_window_half_length = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA( 12800, 5000000L ), sr2fscale( sr_core ) ), LD_FSCALE_DENOM ) ); /*Q0*/ + hTcxCfg->tcx_mdct_window_half_lengthFB = extract_l( L_shr( L_mult0( L_LOOK_12k8 - NS2SA( 12800, 5000000L ), sr2fscale( input_Fs ) ), LD_FSCALE_DENOM ) ); /*Q0*/ move16(); move16(); assert( GT_16( hTcxCfg->tcx_mdct_window_half_length, 16 ) && "Half window can not be large enough!" ); diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 498de0188..43f468fb0 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -1289,7 +1289,7 @@ static ivas_error ivas_filterbank_setup_fx( ivas_get_active_bins_fx( &pAll_bins_per_band, &pAll_bins_per_band_abs, &pAll_bins_start_offset, &pAll_bins_start_offset_abs, sampling_rate ); - IF( EQ_16( pCfg->fb_latency, NS2SA( sampling_rate, DELAY_FB_1_NS ) ) ) + IF( EQ_16( pCfg->fb_latency, NS2SA_FX2( sampling_rate, DELAY_FB_1_NS ) ) ) { pAll_fb_fr_fx[0] = ivas_fb_fr_12band_1ms_re_fx; // Q30 move32(); @@ -1478,7 +1478,7 @@ static ivas_error ivas_fb_mixer_get_window_fx( error = IVAS_ERR_OK; move32(); - IF( EQ_16( fade_len, NS2SA( sampling_rate, DELAY_FB_4_NS ) ) ) + IF( EQ_16( fade_len, NS2SA_FX2( sampling_rate, DELAY_FB_4_NS ) ) ) { SWITCH( sampling_rate ) { @@ -1495,7 +1495,7 @@ static ivas_error ivas_fb_mixer_get_window_fx( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unsupported Sampling frequency!" ); } } - ELSE IF( EQ_16( fade_len, NS2SA( sampling_rate, DELAY_FB_1_NS ) ) ) + ELSE IF( EQ_16( fade_len, NS2SA_FX2( sampling_rate, DELAY_FB_1_NS ) ) ) { SWITCH( sampling_rate ) { diff --git a/lib_com/tcx_ltp_fx.c b/lib_com/tcx_ltp_fx.c index 55228e0b3..9d7cb9254 100644 --- a/lib_com/tcx_ltp_fx.c +++ b/lib_com/tcx_ltp_fx.c @@ -1282,7 +1282,7 @@ void tcx_ltp_post( filtIdx = 0; /* just to avoid comilation warnings */ move16(); - tcx_buf_len = NS2SA( st->output_Fs, TCXLTP_DELAY_NS ); /* Q0 */ + tcx_buf_len = NS2SA_FX2( st->output_Fs, TCXLTP_DELAY_NS ); /* Q0 */ SideInfoOnly = 0; move16(); if ( GE_32( total_brate, HQ_96k ) ) diff --git a/lib_com/window_ola_fx.c b/lib_com/window_ola_fx.c index 19725735a..2948e725e 100644 --- a/lib_com/window_ola_fx.c +++ b/lib_com/window_ola_fx.c @@ -833,13 +833,13 @@ void core_switching_OLA_fx( IF( ( output_frame - L_FRAME16k ) == 0 ) /* no resampling */ { - Copy( mem_over_hp + 2, tmp_buf_switch + i_mult2( SWITCH_GAP_LENGTH_8k, delta ), NS2SA( output_Fs, DELAY_CLDFB_NS ) ); + Copy( mem_over_hp + 2, tmp_buf_switch + i_mult2( SWITCH_GAP_LENGTH_8k, delta ), NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ) ); } ELSE { IF( ( output_frame - L_FRAME8k ) == 0 ) /* not done yet */ { - Copy( synth_subfr_out + SWITCH_GAP_LENGTH_8k, tmp_buf_switch + SWITCH_GAP_LENGTH_8k, NS2SA( output_Fs, DELAY_CLDFB_NS ) ); /* copy subframe to tmp buffer */ + Copy( synth_subfr_out + SWITCH_GAP_LENGTH_8k, tmp_buf_switch + SWITCH_GAP_LENGTH_8k, NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ) ); /* copy subframe to tmp buffer */ } ELSE { @@ -950,7 +950,7 @@ void core_switching_OLA_fx( pt = synth; pt2 = tmp_buf_switch; - tmp = NS2SA( output_Fs, DELAY_CLDFB_NS ); + tmp = NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ); move16(); pt3 = synth_subfr_bwe; diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 708fc39e6..dd63b6508 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -2156,7 +2156,7 @@ static void ivas_subst_spec_fx( ELSE { // tmp = NS2SA(output_frame*50,PH_ECU_ALDO_OLP2_NS-PH_ECU_LOOKAHEAD_NS); - tmp = NS2SA_FX2( output_frame * 50, PH_ECU_ALDO_OLP2_NS ); + tmp = NS2SA_FX2( L_mult0( output_frame, 50 ), PH_ECU_ALDO_OLP2_NS ); move16(); tmp = sub( tmp, ph_ecu_lookahead ); tmp = add( tmp, sub( Lecu, shr( sub( Lecu, Lprot ), 1 ) ) ); @@ -2559,7 +2559,7 @@ static void subst_spec_fx( } ELSE { - tmp = NS2SA( output_frame * 50, PH_ECU_ALDO_OLP2_NS - PH_ECU_LOOKAHEAD_NS ); + tmp = NS2SA_FX2( L_mult0( output_frame, 50 ), PH_ECU_ALDO_OLP2_NS - PH_ECU_LOOKAHEAD_NS ); move16(); tmp = add( tmp, sub( Lecu, shr( sub( Lecu, Lprot ), 1 ) ) ); tmp = sub( tmp, shr( output_frame, 1 ) ); @@ -2920,9 +2920,9 @@ static void ivas_rec_wtda_fx( Word16 copy_len; Word16 ola_len; - copy_len = NS2SA( output_frame * FRAMES_PER_SEC, ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* prototype fill on each side of xsubst to fill MDCT Frame */ + copy_len = NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* prototype fill on each side of xsubst to fill MDCT Frame */ move16(); - ola_len = NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS - ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* remaining lengt of LA_ZEROS to overlap add decoded with xsubst */ + ola_len = NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS - ( 2 * FRAME_SIZE_NS - L_PROT_NS ) / 2 ); /* remaining lengt of LA_ZEROS to overlap add decoded with xsubst */ move16(); xf_len = 26; @@ -2980,7 +2980,7 @@ static void ivas_rec_wtda_fx( } /* extract reconstructed frame with aldo window */ - timesh = sub( NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ), shr( sub( shl( output_frame, 1 ), Lprot ), 1 ) ); + timesh = sub( NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ), shr( sub( shl( output_frame, 1 ), Lprot ), 1 ) ); set16_fx( xsubst_, 0, add( sub( shl( output_frame, 1 ), Lprot ), timesh ) ); Copy( X, xsubst_ + add( sub( shl( output_frame, 1 ), Lprot ), timesh ), sub( Lprot, timesh ) ); @@ -2988,9 +2988,9 @@ static void ivas_rec_wtda_fx( /* Copy and OLA look ahead zero part of MDCT window from decoded signal */ IF( element_mode != EVS_MONO ) { - Copy( old_dec, xsubst_ + NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ), copy_len ); /* also need to scale to Q0 ?? */ + Copy( old_dec, xsubst_ + NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ), copy_len ); /* also need to scale to Q0 ?? */ pOld = old_dec + copy_len; - pNew = xsubst_ + add( copy_len, NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ) ); + pNew = xsubst_ + add( copy_len, NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ) ); tmp = div_s( 1, shl( ola_len, 1 ) ); // Q15 tmp = round_fx( L_shl( L_mult( tmp, EVS_PI_FX ), 2 ) ); // Q15 sinq_fx( tmp, 0, ola_len, xfwin ); @@ -4583,7 +4583,7 @@ static void ivas_fec_noise_filling_fx( } ELSE { - kk = NS2SA( L * FRAMES_PER_SEC, N_ZERO_MDCT_NS ); + kk = NS2SA_FX2( L_mult0( L, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ); p_mdct_ola = old_out + kk; } @@ -4939,7 +4939,7 @@ static void ivas_hq_phase_ecu_fx( IF( element_mode == EVS_MONO ) { - ph_ecu_lookahead = NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS ); + ph_ecu_lookahead = NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), PH_ECU_LOOKAHEAD_NS ); move16(); } ELSE @@ -5018,7 +5018,7 @@ static void ivas_hq_phase_ecu_fx( alpha, beta, *beta_mute, Xavg, element_mode, ph_ecu_lookahead, noise_fac ); /* reconstructed frame in tda domain */ - old_dec = prevsynth + sub( shl( output_frame, 1 ), NS2SA( output_frame * FRAMES_PER_SEC, N_ZERO_MDCT_NS ) ); + old_dec = prevsynth + sub( shl( output_frame, 1 ), NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), N_ZERO_MDCT_NS ) ); ivas_rec_frame_fx( X, ecu_rec, output_frame, *Q_spec, old_dec, element_mode, num_p, plocs ); *last_fec = 0; @@ -5223,11 +5223,11 @@ void ivas_hq_ecu_fx( move16(); IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { - fec_alg_input = prevsynth + NS2SA( output_frame * FRAMES_PER_SEC, ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ); + fec_alg_input = prevsynth + NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ); } ELSE { - fec_alg_input = prevsynth - NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS ); + fec_alg_input = prevsynth - NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), PH_ECU_LOOKAHEAD_NS ); } /* init (values ar changed after) */ @@ -5286,7 +5286,7 @@ void ivas_hq_ecu_fx( } ELSE { - ivas_hq_phase_ecu_fx( prevsynth - NS2SA( output_frame * FRAMES_PER_SEC, PH_ECU_LOOKAHEAD_NS ), ecu_rec, time_offs, X_sav, Q_spec, num_p, plocs, plocsi, + ivas_hq_phase_ecu_fx( prevsynth - NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), PH_ECU_LOOKAHEAD_NS ), ecu_rec, time_offs, X_sav, Q_spec, num_p, plocs, plocsi, env_stab, last_fec, ph_ecu_active, prev_bfi, old_is_transient, mag_chg_1st, Xavg, beta_mute, st_fx->bwidth, output_frame, corr, st_fx->element_mode ); @@ -5354,7 +5354,7 @@ void hq_ecu_fx( #ifdef IVAS_FEC_ECU_TO_COMPLETE fec_ecu_pitch_fx( fec_alg_input, prevsynth_LP, output_frame, &N, &corr, &decimatefactor, ph_ecu_HqVoicing ); #else - fec_ecu_pitch_fx( prevsynth + NS2SA( output_frame * 50, ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, output_frame, &N, &corr, &decimatefactor, ph_ecu_HqVoicing ); + fec_ecu_pitch_fx( prevsynth + NS2SA_FX2( L_mult0( output_frame, 50 ), ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, output_frame, &N, &corr, &decimatefactor, ph_ecu_HqVoicing ); #endif } ELSE @@ -5409,7 +5409,7 @@ void hq_ecu_fx( ( LT_32( st_fx->total_brate, 48000 ) && ( ( ph_ecu_HqVoicing || GT_16( corr, 27853 ) ) && !prev_bfi && ( !old_is_transient[0] || old_is_transient[1] ) ) ) ) { - fec_alg_fx( prevsynth + NS2SA( output_frame * 50, ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, &st_fx->hHQ_core->ni_seed_forfec, ecu_rec, output_frame, N, decimatefactor, ph_ecu_HqVoicing, gapsynth ); + fec_alg_fx( prevsynth + NS2SA_FX2( L_mult0( output_frame, 50 ), ACELP_LOOK_NS / 2 - PH_ECU_LOOKAHEAD_NS ), prevsynth_LP, &st_fx->hHQ_core->ni_seed_forfec, ecu_rec, output_frame, N, decimatefactor, ph_ecu_HqVoicing, gapsynth ); *last_fec = 1; move16(); *ph_ecu_active = 0; diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 42e4e36ef..6e56bc154 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -2101,7 +2101,7 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 ); #endif - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn ); + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn ); #ifdef MSAN_FIX Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 387533957..f1772b9a7 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -242,7 +242,7 @@ ivas_error acelp_core_switch_dec_fx( *Q_syn = 0; move16(); - Copy_Scale_sig( synth_intFreq + sub( NS2SA( i_mult( L_frame_for_cs, 50 ), ( SWITCH_GAP_LENGTH_NS - DELAY_CLDFB_NS ) ), 2 ), mem_synth, add( NS2SA( i_mult( L_frame_for_cs, 50 ), DELAY_CLDFB_NS ), 2 ), negate( st_fx->Q_syn ) ); /* Copy mem with Q0 */ + Copy_Scale_sig( synth_intFreq + sub( NS2SA_FX2( i_mult( L_frame_for_cs, 50 ), ( SWITCH_GAP_LENGTH_NS - DELAY_CLDFB_NS ) ), 2 ), mem_synth, add( NS2SA_FX2( i_mult( L_frame_for_cs, 50 ), DELAY_CLDFB_NS ), 2 ), negate( st_fx->Q_syn ) ); /* Copy mem with Q0 */ /*----------------------------------------------------------------* * BWE decoding diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index 4c48a6fa8..aa04a70cb 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -110,11 +110,11 @@ ivas_error core_switching_pre_dec_ivas_fx( /* reset old HB synthesis buffer */ IF( EQ_16( st->last_L_frame, L_FRAME ) ) { - st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); + st->old_bwe_delay = NS2SA_FX2( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); } ELSE { - st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); + st->old_bwe_delay = NS2SA_FX2( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); } move16(); set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); @@ -189,7 +189,7 @@ ivas_error core_switching_pre_dec_ivas_fx( st->last_core = HQ_CORE; move16(); - Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); // Copy_Scale_sig_32_16( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0 } @@ -221,7 +221,7 @@ ivas_error core_switching_pre_dec_ivas_fx( move16(); } - delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); + delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); /*TODO To be tested:control not entering the block*/ test(); test(); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 17df8b5ca..d654b3af4 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1765,7 +1765,7 @@ ivas_error core_switching_post_dec_ivas_fx( Copy_Scale_sig( st_fx->previoussynth_fx, synth, delay_comp, *Qsynth ); /* Qsynth */ /* Overlap between TCX-LB and TCX-FB*/ - Word16 tmpDelta = NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ); + Word16 tmpDelta = NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ); Word32 L_tmp2; FOR( i = 0; i < tmpDelta; i++ ) { @@ -1924,7 +1924,7 @@ ivas_error core_switching_post_dec_ivas_fx( } IF( output_mem_fx != NULL ) { - Scale_sig( output_mem_fx, NS2SA( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ + Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ } *Qsynth = Qtmp; move16(); diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index de6448433..945e149f2 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -919,7 +919,7 @@ ivas_error evs_dec_fx( IF( ( EQ_16( st_fx->bwidth, SWB ) || EQ_16( st_fx->bwidth, FB ) ) && ( ( EQ_16( st_fx->last_extl, SWB_TBE ) || EQ_16( st_fx->last_extl, FB_TBE ) ) && EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) { - GenTransition_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->old_tbe_synth_fx, 2 * NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), hb_synth_fx, + GenTransition_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->old_tbe_synth_fx, shl( NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), 1 ), hb_synth_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->mem_resamp_HB_32k_fx, &( hBWE_TD->syn_dm_phase ), st_fx->output_Fs, hBWE_TD->int_3_over_2_tbemem_dec_fx, st_fx->rf_flag, st_fx->total_brate ); @@ -929,7 +929,7 @@ ivas_error evs_dec_fx( } ELSE IF( EQ_16( st_fx->bwidth, WB ) && EQ_16( st_fx->last_extl, WB_TBE ) ) { - GenTransition_WB_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->old_tbe_synth_fx, st_fx->prev_Qx, 2 * NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), hb_synth_fx, + GenTransition_WB_fx( hBWE_TD->syn_overlap_fx, hBWE_TD->old_tbe_synth_fx, st_fx->prev_Qx, shl( NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ), 1 ), hb_synth_fx, hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx, st_fx->output_Fs, hBWE_TD->mem_resamp_HB_fx ); hb_synth_fx_exp = st_fx->prev_Qx; @@ -1327,12 +1327,12 @@ ivas_error evs_dec_fx( { IF( EQ_32( st_fx->output_Fs, 8000 ) ) { - Copy( hTcxDec->FBTCXdelayBuf, st_fx->delay_buf_out_fx, NS2SA( st_fx->output_Fs, DELAY_CLDFB_NS ) ); /*st_fx->q_prev_synth_buffer_fx*/ + Copy( hTcxDec->FBTCXdelayBuf, st_fx->delay_buf_out_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ) ); /*st_fx->q_prev_synth_buffer_fx*/ } ELSE { - Copy( hTcxDec->FBTCXdelayBuf, st_fx->prev_synth_buffer_fx, NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /*st_fx->Qprev_synth_buffer_fx*/ - Copy( hTcxDec->FBTCXdelayBuf + NS2SA( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), st_fx->delay_buf_out_fx, NS2SA( st_fx->output_Fs, DELAY_CLDFB_NS ) ); /*Q0*/ + Copy( hTcxDec->FBTCXdelayBuf, st_fx->prev_synth_buffer_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); /*st_fx->Qprev_synth_buffer_fx*/ + Copy( hTcxDec->FBTCXdelayBuf + NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), st_fx->delay_buf_out_fx, NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ) ); /*Q0*/ } } } @@ -1362,7 +1362,7 @@ ivas_error evs_dec_fx( Scale_sig( output_sp, output_frame, timeIn_e ); /*timeIn_e*/ - tcx_ltp_post( st_fx, hTcxLtpDec, st_fx->core, output_frame /*hTcxDec->L_frameTCX*/, NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS ) + tmps, + tcx_ltp_post( st_fx, hTcxLtpDec, st_fx->core, output_frame /*hTcxDec->L_frameTCX*/, add( NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS ), tmps ), output_sp, hTcxDec->FBTCXdelayBuf ); Copy( output_sp, synth_fx, output_frame ); /*timeIn_e*/ @@ -1397,8 +1397,8 @@ ivas_error evs_dec_fx( ELSE { - Copy_Scale_sig( synth_fx + output_frame, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) ); /*Q0*/ - Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_FX2( st_fx->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + shl( output_frame, 1 ) - NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( hHQ_core->Q_old_wtda ) ); /*Q0*/ + Copy_Scale_sig( synth_fx + output_frame, hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st_fx->output_Fs, DELAY_CLDFB_NS ), negate( Qpostd ) ); /*Q0*/ + Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA_FX2( st_fx->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st_fx->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ), negate( hHQ_core->Q_old_wtda ) ); /*Q0*/ } } } diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index fa7e602a5..8a902448f 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -3621,9 +3621,9 @@ void generate_comfort_noise_dec_fx( IF( st->hTcxCfg->last_aldo != 0 ) { - FOR( i = 0; i < sub( hFdCngCom->frameSize, NS2SA( st->sr_core, N_ZERO_MDCT_NS ) ); i++ ) + FOR( i = 0; i < hFdCngCom->frameSize - NS2SA( st->sr_core, N_ZERO_MDCT_NS ); i++ ) { - timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); /*st->q_old_outLB_fx*/ + timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); /*st->q_old_outLB_fx*/ move16(); } } @@ -4160,9 +4160,9 @@ void generate_comfort_noise_dec_ivas_fx( IF( st->hTcxCfg->last_aldo != 0 ) { - FOR( i = 0; i < sub( hFdCngCom->frameSize, NS2SA( st->sr_core, N_ZERO_MDCT_NS ) ); i++ ) + FOR( i = 0; i < hFdCngCom->frameSize - NS2SA( st->sr_core, N_ZERO_MDCT_NS ); i++ ) { - timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); /*st->q_old_outLB_fx*/ + timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( st->hHQ_core->old_out_LB_fx[i + NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS )], st->hHQ_core->Q_old_wtda_LB ) ); /*st->q_old_outLB_fx*/ move16(); } } diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index d709ff5fc..a96774113 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -493,8 +493,8 @@ ivas_error init_decoder_fx( set16_fx( st_fx->hTcxDec->FBTCXdelayBuf, 0, 111 ); - st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA( st_fx->output_Fs, PH_ECU_MEM_NS ); - st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ); + st_fx->hTcxDec->old_synthFB_fx = st_fx->hTcxDec->synth_history_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_MEM_NS ); + st_fx->hTcxDec->prev_good_synth_fx = st_fx->hTcxDec->old_synthFB_fx + NS2SA_FX2( st_fx->output_Fs, PH_ECU_LOOKAHEAD_NS ); } ELSE { diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 92b43092b..261a3c74e 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -1639,15 +1639,15 @@ ivas_error ivas_core_dec_fx( move16(); move16(); - Copy_Scale_sig32_16( st->prev_synth_buffer32_fx, st->prev_synth_buffer_fx, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -( Q11 ) ); // Q0 + Copy_Scale_sig32_16( st->prev_synth_buffer32_fx, st->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -( Q11 ) ); // Q0 st->q_prev_synth_buffer_fx = 0; move16(); exp_ouput = Find_Max_Norm32( output_32_fx[n], output_frame ); exp_ouput = add( exp_ouput, Q11 ); - exp_prev_synth_buffer = Find_Max_Norm16( st->prev_synth_buffer_fx, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + exp_prev_synth_buffer = Find_Max_Norm16( st->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); exp_prev_synth_buffer = add( exp_prev_synth_buffer, st->q_prev_synth_buffer_fx ); - exp_old_out = Find_Max_Norm16( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), sub( add( NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ), NS2SA( st->output_Fs, N_ZERO_MDCT_NS ) ) ); + exp_old_out = Find_Max_Norm16( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), sub( add( NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ), NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ) ) ); exp_delay_buf_out = Find_Max_Norm16( st->delay_buf_out_fx, NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); exp_synth_history = Find_Max_Norm16( st->hTcxDec->synth_history_fx + output_frame, sub( add( sub( imult1616( 2, output_frame ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ), output_frame ) ); exp_max = s_min( exp_synth_history, exp_ouput ); @@ -1660,7 +1660,7 @@ ivas_error ivas_core_dec_fx( Scale_sig32( output_fx_loc, output_frame, sub( exp_max, Q11 ) ); // Q(31-exp_max) Scale_sig( st->delay_buf_out_fx, NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ), exp_max ); // exp_max Scale_sig( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), sub( NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ), NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ) ), exp_max ); // Q(31-exp_max) - Scale_sig( st->prev_synth_buffer_fx, NS2SA_FX2( 48000, L_sub( DELAY_BWE_TOTAL_NS, DELAY_CLDFB_NS ) ), sub( exp_max, st->q_prev_synth_buffer_fx ) ); // Q(exp_max - prev_synth_buffer_fx) + Scale_sig( st->prev_synth_buffer_fx, NS2SA_FX2( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), sub( exp_max, st->q_prev_synth_buffer_fx ) ); // Q(exp_max - prev_synth_buffer_fx) Scale_sig( st->hTcxDec->synth_history_fx + output_frame, sub( add( sub( imult1616( 2, output_frame ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ), output_frame ), sub( exp_max, 0 ) ); // Q(31-exp_max) st->q_prev_synth_buffer_fx = sub( exp_max, st->q_prev_synth_buffer_fx ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 7d2f7be4f..9849647ea 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2093,7 +2093,7 @@ void ivas_dirac_dec_render_fx( output_f_local_fx[ch] = output_f_local_buff_fx[ch]; set_zero_fx( output_f_local_fx[ch], nSamplesAsked ); } - slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); // cL + slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); // cL /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 73e2b5d01..037ef4eb9 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2034,7 +2034,7 @@ ivas_error ivas_init_decoder_fx( } } - granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); @@ -2333,7 +2333,7 @@ ivas_error ivas_init_decoder_fx( /* no module has yet open the TC buffer, open a default one */ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 1f7af935d..424e6fb86 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -797,7 +797,6 @@ ivas_error ivas_param_ism_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { - move16(); // NS2SA IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, nchan_full, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 5317e803e..3b66d3107 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -431,8 +431,8 @@ ivas_error ivas_jbm_dec_tc_fx( scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft FOR( i = 0; i < CPE_CHANNELS; ++i ) { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft } IF( hCPE->hCoreCoder[0] != NULL ) { @@ -522,7 +522,7 @@ ivas_error ivas_jbm_dec_tc_fx( #ifdef MSAN_FIX FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { - Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), hCPE->q_prev_synth_fx - 11 ); // q_prev_synth_fx + Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx } #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), hCPE->q_prev_synth_fx - 11 ); @@ -537,7 +537,7 @@ ivas_error ivas_jbm_dec_tc_fx( #ifdef MSAN_FIX FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) { - Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); // Q11 + Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 } #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); @@ -968,8 +968,8 @@ ivas_error ivas_jbm_dec_tc_fx( scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft } IF( hCPE->hCoreCoder[0] != NULL ) { @@ -1008,7 +1008,7 @@ ivas_error ivas_jbm_dec_tc_fx( } #ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, 11 ) ); // q_prev_synth_fx + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), hCPE->q_prev_synth_fx - 11 ); #endif @@ -1028,8 +1028,8 @@ ivas_error ivas_jbm_dec_tc_fx( scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 FOR( i = 0; i < CPE_CHANNELS; ++i ) { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 } IF( hCPE->hCoreCoder[0] != NULL ) @@ -1427,8 +1427,8 @@ ivas_error ivas_jbm_dec_tc_fx( scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft } IF( hCPE->hCoreCoder[0] != NULL ) @@ -1473,7 +1473,7 @@ ivas_error ivas_jbm_dec_tc_fx( } #ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, 11 ) ); // q_prev_synth_fx + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), hCPE->q_prev_synth_fx - 11 ); #endif @@ -1484,7 +1484,7 @@ ivas_error ivas_jbm_dec_tc_fx( } #ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); // Q11 + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); #endif // MSAN_FIX diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index aa42f4f91..4ca5c05b0 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -836,7 +836,7 @@ ivas_error ivas_masa_dec_open_fx( nchan_to_allocate = add( nchan_to_allocate, 1 ); } - IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_transport, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 50d03b577..459dcc4d4 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -534,7 +534,7 @@ ivas_error ivas_param_mc_dec_open_fx( IF( st_ivas->hTcBuffer == NULL ) { - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { return error; } @@ -1941,10 +1941,10 @@ void ivas_param_mc_dec_render_fx( /*slots_to_render = min(sub(hParamMC->num_slots, hParamMC->slots_rendered), nSamplesAsked / NS2SA(output_Fs, CLDFB_SLOT_NS)); *nSamplesRendered = slots_to_render * NS2SA(output_Fs, CLDFB_SLOT_NS);*/ Word16 temp_e; - Word16 temp = BASOP_Util_Divide1616_Scale( nSamplesAsked, NS2SA( output_Fs, CLDFB_SLOT_NS ), &temp_e ); + Word16 temp = BASOP_Util_Divide1616_Scale( nSamplesAsked, NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ), &temp_e ); temp = shr( temp, sub( 15, temp_e ) ); slots_to_render = s_min( sub( hParamMC->num_slots, hParamMC->slots_rendered ), temp ); - *nSamplesRendered = imult1616( slots_to_render, NS2SA( output_Fs, CLDFB_SLOT_NS ) ); + *nSamplesRendered = imult1616( slots_to_render, NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ) ); move16(); Word16 j, k; first_sf = hParamMC->subframes_rendered; @@ -2272,7 +2272,7 @@ void ivas_param_mc_dec_render_fx( hParamMC->subframes_rendered = last_sf; move16(); - *nSamplesAvailableNext = imult1616( sub( hParamMC->num_slots, hParamMC->slots_rendered ), NS2SA( output_Fs, CLDFB_SLOT_NS ) ); + *nSamplesAvailableNext = imult1616( sub( hParamMC->num_slots, hParamMC->slots_rendered ), NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ) ); move16(); FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index b12236746..be53d79c8 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -418,7 +418,7 @@ ivas_error ivas_mc_paramupmix_dec_open( move16(); } - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index a92f21f6d..c95a5285a 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -430,11 +430,11 @@ ivas_error ivas_mct_dec_fx( Word16 output_mem_fx[L_FRAME48k]; IF( hCPE->output_mem_fx[1] != NULL ) { - Copy_Scale_sig_32_16( hCPE->output_mem_fx[1], output_mem_fx, NS2SA( sts[n]->output_Fs, 3125000 ), -Q11 ); + Copy_Scale_sig_32_16( hCPE->output_mem_fx[1], output_mem_fx, NS2SA_FX2( sts[n]->output_Fs, 3125000 ), -Q11 ); } ELSE { - set16_fx( output_mem_fx, 0, NS2SA( sts[n]->output_Fs, 3125000 ) ); + set16_fx( output_mem_fx, 0, NS2SA_FX2( sts[n]->output_Fs, 3125000 ) ); } Word16 Q_synth = sub( 15, e_sig[n] ); @@ -461,9 +461,9 @@ ivas_error ivas_mct_dec_fx( #endif /* Save synthesis for HQ FEC */ Word32 output_fx_[L_FRAME48k]; - Copy32( output_fx[( cpe_id * CPE_CHANNELS ) + n], output_fx_, L_FRAME48k ); // Q11 - Scale_sig32( output_fx_, L_FRAME48k, Q16 - Q11 ); // Q11 -> Q16 - Copy_Scale_sig32_16( sts[n]->prev_synth_buffer32_fx, sts[n]->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); // Q11 -> Q0 + Copy32( output_fx[( cpe_id * CPE_CHANNELS ) + n], output_fx_, L_FRAME48k ); // Q11 + Scale_sig32( output_fx_, L_FRAME48k, Q16 - Q11 ); // Q11 -> Q16 + Copy_Scale_sig32_16( sts[n]->prev_synth_buffer32_fx, sts[n]->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -Q11 ); // Q11 -> Q0 sts[n]->q_prev_synth_buffer_fx = 0; move16(); diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 2158dec1c..190cc6b14 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1361,7 +1361,7 @@ void ivas_mdct_core_reconstruct_fx( /* Update */ Copy( synth_buf_fx + st->L_frame, st->hTcxDec->old_synth, st->hTcxDec->old_synth_len ); - Copy( st->hTcxDec->old_synthFB_fx + st->hTcxDec->L_frameTCX - NS2SA( st->output_Fs, PH_ECU_MEM_NS ), st->hTcxDec->synth_history_fx, NS2SA( st->output_Fs, PH_ECU_MEM_NS ) ); + Copy( st->hTcxDec->old_synthFB_fx + st->hTcxDec->L_frameTCX - NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ), st->hTcxDec->synth_history_fx, NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ); Copy( synth_bufFB_fx + st->hTcxDec->L_frameTCX, st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB ); st->hTcxDec->q_old_synth = q_syn; st->hTcxDec->q_synth_history_fx = st->hTcxDec->q_old_synth; @@ -1371,7 +1371,7 @@ void ivas_mdct_core_reconstruct_fx( IF( st->hHQ_core != NULL ) { - Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + st->hTcxDec->old_synth_lenFB, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + st->hTcxDec->old_synth_lenFB, NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); } Copy( st->lsp_q_cng, st->old_lsp_q_cng, M ); diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index dc4a1b01b..853aa365f 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -159,7 +159,7 @@ void ivas_post_proc_fx( ELSE { /*Use channel 0 side info.*/ - tcx_ltp_post32( sts[0], hTcxLtpDec, TCX_20_CORE, output_frame, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ), output[k], hCPE->output_mem_fx[k], output_q ); + tcx_ltp_post32( sts[0], hTcxLtpDec, TCX_20_CORE, output_frame, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ), output[k], hCPE->output_mem_fx[k], output_q ); } } } @@ -268,7 +268,7 @@ void stereo_dft_dec_core_switching_fx( IF( ( ( ( st->last_core != ACELP_CORE ) || ( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( sba_dirac_stereo_dtx_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ { /* In case of a TCX to ACELP switch next frame */ - Copy32( &output_fx[st->L_frame - NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*q*/ + Copy32( &output_fx[st->L_frame - NS2SA( ( st->L_frame * FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*q*/ /* BPF */ test(); @@ -315,8 +315,8 @@ void stereo_dft_dec_core_switching_fx( /* Update FB input buff with hb synth FOR last delay_tdbwe sampled */ FOR( i = 0; i < delay_tdbwe; i++ ) { - hCPE->input_mem_fx[0][( ( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_tdbwe ) + i )] = - L_add( hCPE->input_mem_fx[0][NS2SA_FX2( L_add( L_sub( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_tdbwe ), i )], hb_synth_fx[i] ); /*Q11*/ + hCPE->input_mem_fx[0][( ( NS2SA( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe ) + i )] = + L_add( hCPE->input_mem_fx[0][NS2SA( ( ( L_frameTCX * FRAMES_PER_SEC ) - STEREO_DFT32MS_OVL_NS ) + delay_tdbwe, i )], hb_synth_fx[i] ); /*Q11*/ move32(); } } @@ -325,7 +325,7 @@ void stereo_dft_dec_core_switching_fx( /* Update FB input buff with hb synth FOR last delay_tdbwe sampled */ FOR( i = 0; i < delay_tdbwe; i++ ) { - hCPE->input_mem_fx[0][( ( NS2SA_FX2( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_tdbwe ) + i )] = hb_synth_fx[i]; /*Q11*/ + hCPE->input_mem_fx[0][( ( NS2SA_FX2( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe ) + i )] = hb_synth_fx[i]; /*Q11*/ move32(); } } @@ -368,7 +368,7 @@ void stereo_dft_dec_core_switching_fx( /* In case of TCX frames, output LB TCX is zeroed out until the end but in case of an TCX->ACELP switch, this memory is needed, hence it is backed up */ /* Unlike the case when DFT32MS is disabled, there is only 1 DFT analysis window, hence in the TCX frame we don't want to do a DFT analysis FOR LB TCX but in a potential ACELP frame, we want the memories of the LB TCX FOR the last OLA samples so that HB analysis can be skipped */ - Copy32( &output_fx[st->L_frame - NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*q*/ + Copy32( &output_fx[st->L_frame - NS2SA_FX2( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*q*/ /*zero the rest FOR avoiding adding contribution except the last samples which are not considered in DFT analysis (potentially used in next ACELP frame)*/ IF( GT_32( st->last_core_brate, SID_2k40 ) ) @@ -418,8 +418,8 @@ void stereo_dft_dec_core_switching_fx( delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); /*Q0*/ move16(); - Copy32( &st->hHQ_core->oldOut_fx[( nZeros - ( delay_comp + NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ) )], hCPE->input_mem_fx[0], NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*Q11*/ - Copy32( synth_fx, synth_tmp_fx, output_frame ); /*q*/ + Copy32( &st->hHQ_core->oldOut_fx[nZeros - ( delay_comp + NS2SA( output_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) )], hCPE->input_mem_fx[0], NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*Q11*/ + Copy32( synth_fx, synth_tmp_fx, output_frame ); /*q*/ Word16 mem_len; mem_len = NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); /*Q0*/ @@ -462,11 +462,11 @@ void stereo_dft_dec_core_switching_fx( Word32 delay_dft_dec_lb_inv = (Word32) ( calc_inv / delay_dft_dec_lb ); FOR( i = 0; i < delay_dft_dec_lb; i++ ) { - hCPE->input_mem_LB_fx[0][( ( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )] = - Mpy_32_32( hCPE->input_mem_LB_fx[0][( ( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )], L_shl( i, qdelay_dft_dec_lb ) ); /*Q11 + qdelay_dft_dec_lb -31*/ + hCPE->input_mem_LB_fx[0][( ( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )] = + Mpy_32_32( hCPE->input_mem_LB_fx[0][( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i], L_shl( i, qdelay_dft_dec_lb ) ); /*Q11 + qdelay_dft_dec_lb -31*/ move32(); - hCPE->input_mem_LB_fx[0][( ( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )] = - L_shl( Mpy_32_32( hCPE->input_mem_LB_fx[0][( ( NS2SA_FX2( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )], delay_dft_dec_lb_inv ), sub( Q31, qdelay_dft_dec_lb ) ); /*Q11*/ + hCPE->input_mem_LB_fx[0][( ( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )] = + L_shl( Mpy_32_32( hCPE->input_mem_LB_fx[0][( ( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ) + i )], delay_dft_dec_lb_inv ), sub( Q31, qdelay_dft_dec_lb ) ); /*Q11*/ move32(); } stereo_dft_dec_analyze_fx( hCPE, output_fx, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0, q, q_DFT ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 94f1affde..417079541 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -223,7 +223,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( } /* determine new granularity */ - granularity_new = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /*Q0*/ + granularity_new = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /*Q0*/ move16(); /* this will change anyway only with binaural */ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 12a34e170..573a9c17f 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1293,7 +1293,7 @@ void ivas_sba_dirac_stereo_dec_fx( sba_mono_flag = (Word16) EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ); move16(); - memOffset = NS2SA( L_mult0( output_frame, FRAMES_PER_SEC ), IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); + memOffset = NS2SA_FX2( L_mult0( output_frame, FRAMES_PER_SEC ), IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); move16(); ivas_sba_dirac_stereo_config( hStereoDft->hConfig ); diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 5449521d6..b0100063a 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -289,7 +289,7 @@ void stereo_dft_dec_analyze_fx( move16(); /* Offset FOR the time buffers */ - assert( ( delay >= -NS2SA_FX2( ( input_frame * FRAMES_PER_SEC ), STEREO_DFT_DELAY_DEC_BWE_NS + STEREO_DFT_OVL_NS / 2 ) ) && ( delay <= NS2SA_FX2( ( input_frame * FRAMES_PER_SEC ), STEREO_DFT_OVL_NS ) ) ); + assert( ( delay >= -NS2SA( input_frame * FRAMES_PER_SEC, STEREO_DFT_DELAY_DEC_BWE_NS + STEREO_DFT_OVL_NS / 2 ) ) && ( delay <= NS2SA( input_frame * FRAMES_PER_SEC, STEREO_DFT_OVL_NS ) ) ); mem_size = add( delay_dec, delay ); /* Update buffers */ diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx.c index 99cea064b..0db9ab09f 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx.c @@ -61,8 +61,8 @@ void stereo_dft_dmx_out_reset_fx( hStereoDftDmx->prevTargetGain_fx = ONE_IN_Q29; /* Q29 */ move32(); - set32_fx( hStereoDftDmx->memOutHB_fx, 0, NS2SA_FX2( 48000, STEREO_DFT32MS_OVL_NS ) ); - set32_fx( hStereoDftDmx->memTransitionHB_fx, 0, NS2SA_FX2( 48000, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoDftDmx->memOutHB_fx, 0, NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoDftDmx->memTransitionHB_fx, 0, NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) ); return; } diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index b76bddbbc..ca4cfdb69 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -99,7 +99,7 @@ void stereo_dft_dec_reset_fx( Word16 i; Word16 j, b; #ifdef MSAN_FIX - set_zero_fx( hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( 16000, STEREO_DFT32MS_OVL_NS ) ); + set_zero_fx( hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); #endif /*Configuration*/ @@ -1360,7 +1360,7 @@ void stereo_dft_dec_res_fx( set32_fx( hCPE->hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k ); hCPE->hStereoDft->q_res_cod_mem_fx = Q16; move16(); - set32_fx( hCPE->input_mem_fx[1], 0, NS2SA_FX2( 8000, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hCPE->input_mem_fx[1], 0, NS2SA( 8000, STEREO_DFT32MS_OVL_NS ) ); set16_fx( hCPE->hStereoDft->hBpf->pst_old_syn_fx, 0, STEREO_DFT_NBPSF_PIT_MAX_8k ); hCPE->hStereoDft->hBpf->pst_mem_deemp_err_fx = 0; move16(); diff --git a/lib_dec/ivas_stereo_ica_dec.c b/lib_dec/ivas_stereo_ica_dec.c index b72e66c5f..08ac60ffc 100644 --- a/lib_dec/ivas_stereo_ica_dec.c +++ b/lib_dec/ivas_stereo_ica_dec.c @@ -126,7 +126,7 @@ void stereo_tca_dec_fx( dsFactor = BASOP_Util_Divide3232_Scale( output_Fs, 8000, &exp_ds ); dsFactor = shr( dsFactor, sub( 15, exp_ds ) ); /* Q0 */ - tempMax = NS2SA( output_Fs, L_NCSHIFT_NS ); /* Q0 */ + tempMax = NS2SA_FX2( output_Fs, L_NCSHIFT_NS ); /* Q0 */ hStereoTCA->corrLagStats = s_min( hStereoTCA->indx_ica_NCShift * dsFactor, tempMax ); /* Q0 */ bothChannelShift = 0; @@ -343,14 +343,14 @@ void stereo_tca_scale_R_channel_fx( return; } /* Scale the Right channel with the gain */ - l_ica_ovl = NS2SA( output_Fs, STEREO_L_TCA_OVLP_NS ); /* Q0 */ + l_ica_ovl = NS2SA_FX2( output_Fs, STEREO_L_TCA_OVLP_NS ); /* Q0 */ move16(); test(); IF( EQ_16( hCPE->nchan_out, 1 ) ) { /* in mono DMX, the scaling is done before synchro_synthesis() */ - flat_old = NS2SA( output_Fs, ACELP_LOOK_NS + IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); /* Q0 */ + flat_old = NS2SA_FX2( output_Fs, ACELP_LOOK_NS + IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); /* Q0 */ move16(); test(); @@ -365,18 +365,18 @@ void stereo_tca_scale_R_channel_fx( hCPE->hStereoDftDmx->targetGain_fx = ONE_IN_Q29; /* Q29 */ move32(); - flat_old = NS2SA( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ + flat_old = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ move16(); } } ELSE IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_TD ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { - flat_old = NS2SA( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ + flat_old = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ move16(); } ELSE { - flat_old = NS2SA( output_Fs, ACELP_LOOK_NS + IVAS_DEC_DELAY_NS ); /* Q0 */ + flat_old = NS2SA_FX2( output_Fs, ACELP_LOOK_NS + IVAS_DEC_DELAY_NS ); /* Q0 */ move16(); } diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c index 6bba90feb..b634d4557 100644 --- a/lib_dec/ivas_stereo_icbwe_dec.c +++ b/lib_dec/ivas_stereo_icbwe_dec.c @@ -339,7 +339,7 @@ void stereo_icBWE_dec_fx( move32(); alpha_fx = add_sat( alpha_fx, winSlope_fx ); /* Q15 */ } - FOR( ; i < NS2SA( st->output_Fs, FRAME_SIZE_NS ); i++ ) + FOR( ; i < NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ); i++ ) { synthRef_fx[i] = Mpy_32_16_1( synthRef_fx[i], icbweM2Ref_fx ); // Qsyth - 1 move32(); @@ -766,7 +766,7 @@ void stereo_icBWE_dec_fx( alpha_fx = add( alpha_fx, winSlope_fx ); /* Q15 */ } } - FOR( ; i < NS2SA( st->output_Fs, FRAME_SIZE_NS ); i++ ) + FOR( ; i < NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ); i++ ) { synthRef_fx[i] = Mpy_32_16_1( synthRef_fx[i], icbweM2Ref_fx ); /* Qsyn - 1 */ move32(); @@ -933,7 +933,7 @@ void stereo_icBWE_dec_fx( } } - FOR( ; i < NS2SA( st->output_Fs, FRAME_SIZE_NS ); i++ ) + FOR( ; i < NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ); i++ ) { synthRef_fx[i] = Mpy_32_16_1( synthRef_fx[i], icbweM2Ref_fx ); /* Qsyn - 1 */ move32(); @@ -1015,7 +1015,7 @@ void stereo_icBWE_decproc_fx( output_Fs = hCPE->hCoreCoder[0]->output_Fs; /* Q0 */ move32(); - memOffset = NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); /* Q0 */ + memOffset = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); /* Q0 */ /* LRTD stereo mode - 2xBWEs used */ test(); @@ -1070,8 +1070,8 @@ void stereo_icBWE_decproc_fx( set32_fx( hStereoICBWE->memOutHB_fx[0], 0, memOffset ); set32_fx( hStereoICBWE->memOutHB_fx[1], 0, memOffset ); - set32_fx( hStereoICBWE->memTransitionHB_fx[0], 0, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); - set32_fx( hStereoICBWE->memTransitionHB_fx[1], 0, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoICBWE->memTransitionHB_fx[0], 0, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoICBWE->memTransitionHB_fx[1], 0, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); } test(); @@ -1123,13 +1123,13 @@ void stereo_icBWE_decproc_fx( Copy32( outputHB[refChanIndx_bwe], temp0_fx + memOffset, sub( output_frame, memOffset ) ); /* Q11 */ Copy32( outputHB[!refChanIndx_bwe], temp1_fx + memOffset, sub( output_frame, memOffset ) ); /* Q11 */ - decoderDelay = NS2SA( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ + decoderDelay = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ test(); IF( last_core != ACELP_CORE && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { /* hb_synth of mid band is faded out in the 1.25 ms prior to DFT analysis and the icbwe is faded in time domain */ - icbweOLASize = NS2SA( output_Fs, STEREO_DFT_DELAY_DEC_BWE_NS ); /* Q0 */ + icbweOLASize = NS2SA_FX2( output_Fs, STEREO_DFT_DELAY_DEC_BWE_NS ); /* Q0 */ FOR( i = 0; i < decoderDelay; i++ ) { @@ -1286,15 +1286,15 @@ void stereo_icBWE_decproc_fx( ELSE { /* This is generated in the ACELP frame and windowed. This process is akin to GenTransition for IC-BWE */ - v_add_32( output[0], hStereoICBWE->memTransitionHB_fx[hStereoICBWE->prev_refChanIndx_bwe], output[0], NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); - v_add_32( output[1], hStereoICBWE->memTransitionHB_fx[!hStereoICBWE->prev_refChanIndx_bwe], output[1], NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + v_add_32( output[0], hStereoICBWE->memTransitionHB_fx[hStereoICBWE->prev_refChanIndx_bwe], output[0], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + v_add_32( output[1], hStereoICBWE->memTransitionHB_fx[!hStereoICBWE->prev_refChanIndx_bwe], output[1], NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); } set32_fx( hStereoICBWE->memOutHB_fx[0], 0, memOffset ); set32_fx( hStereoICBWE->memOutHB_fx[1], 0, memOffset ); - set32_fx( hStereoICBWE->memTransitionHB_fx[0], 0, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); - set32_fx( hStereoICBWE->memTransitionHB_fx[1], 0, NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoICBWE->memTransitionHB_fx[0], 0, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hStereoICBWE->memTransitionHB_fx[1], 0, NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) ); } } } @@ -1304,13 +1304,13 @@ void stereo_icBWE_decproc_fx( } ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && EQ_16( last_core, ACELP_CORE ) ) { - Word16 delay_tdbwe = NS2SA( output_Fs, DELAY_BWE_TOTAL_NS ); + Word16 delay_tdbwe = NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ); FOR( n = 0; n < hCPE->nchan_out; n++ ) { FOR( i = 0; i < delay_tdbwe; i++ ) { - output[n][NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe + i] = L_add_sat( output[n][NS2SA( output_Fs, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe + i], outputHB[0][i] ); + output[n][NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe + i] = L_add_sat( output[n][NS2SA_FX2( output_Fs, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe + i], outputHB[0][i] ); move32(); } } diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 4a788be83..20fa578f8 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -947,7 +947,7 @@ void applyDmxMdctStereo_fx( test(); IF( LE_32( hCPE->last_element_brate, IVAS_SID_5k2 ) ) { - crossfade_len = NS2SA( hCPE->hCoreCoder[0]->output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); + crossfade_len = NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); move16(); SWITCH( hCPE->hCoreCoder[0]->output_Fs ) { @@ -994,7 +994,7 @@ void applyDmxMdctStereo_fx( } ELSE IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && LE_32( hCPE->last_element_brate, IVAS_32k ) ) { - crossfade_len = NS2SA( hCPE->hCoreCoder[0]->output_Fs, DELAY_CLDFB_NS ); /* Q0 */ + crossfade_len = NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, DELAY_CLDFB_NS ); /* Q0 */ move16(); SWITCH( hCPE->hCoreCoder[0]->output_Fs ) { diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index a8b74c447..c6466183b 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -415,7 +415,7 @@ ivas_error stereo_memory_dec_fx( IF( hCPE->hCoreCoder[0]->last_core != ACELP_CORE ) { - Copy32( hCPE->hStereoDft->buff_LBTCX_mem_fx, hCPE->input_mem_LB_fx[0], NS2SA( i_mult( hCPE->hCoreCoder[0]->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /* Q11 */ + Copy32( hCPE->hStereoDft->buff_LBTCX_mem_fx, hCPE->input_mem_LB_fx[0], NS2SA_FX2( i_mult( hCPE->hCoreCoder[0]->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /* Q11 */ } } @@ -470,7 +470,7 @@ ivas_error stereo_memory_dec_fx( } /* memory update - needed in TD stereo, TCX/HQ frame -> DFT stereo, ACELP frame switching */ - Copy32( hCPE->input_mem_LB_fx[0], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( s_min( i_mult( hCPE->hCoreCoder[0]->last_L_frame, FRAMES_PER_SEC ), 16000 ), STEREO_DFT32MS_OVL_NS ) ); /* Q11 */ + Copy32( hCPE->input_mem_LB_fx[0], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( s_min( i_mult( hCPE->hCoreCoder[0]->last_L_frame, FRAMES_PER_SEC ), 16000 ), STEREO_DFT32MS_OVL_NS ) ); /* Q11 */ /* allocate ICBWE structure */ IF( hCPE->hStereoICBWE == NULL ) @@ -1034,11 +1034,11 @@ ivas_error stereo_memory_dec_fx( IF( hCPE->prev_synth_chs_fx[1] == NULL ) { st = hCPE->hCoreCoder[1]; - IF( ( hCPE->prev_synth_chs_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * NS2SA( st->output_Fs, FRAME_SIZE_NS ) ) ) == NULL ) + IF( ( hCPE->prev_synth_chs_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT stereo memory\n" ) ); } - set32_fx( hCPE->prev_synth_chs_fx[1], 0, NS2SA( st->output_Fs, FRAME_SIZE_NS ) ); + set32_fx( hCPE->prev_synth_chs_fx[1], 0, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ) ); } IF( hCPE->hStereoICBWE == NULL && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) @@ -2143,7 +2143,7 @@ void stereo_td2dft_update_fx( /* TCX synthesis (it was already delayed in TD stereo in core_switching_post_dec()) */ IF( sts[n]->hTcxDec != NULL ) { - ovl_TCX = NS2SA_FX2( sts[n]->hTcxDec->L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ); /* Q0 */ + ovl_TCX = NS2SA_FX2( L_mult0( sts[n]->hTcxDec->L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); /* Q0 */ move16(); Copy32( synth_fx + sts[n]->hTcxDec->L_frameTCX + hq_delay_comp - ovl_TCX, hCPE->input_mem_fx[n], sub( ovl_TCX, hq_delay_comp ) ); /* Q11 */ Copy32( sts[n]->delay_buf_out32_fx, hCPE->input_mem_fx[n] + ovl_TCX - hq_delay_comp, hq_delay_comp ); /* Q11 */ @@ -2161,7 +2161,7 @@ void stereo_td2dft_update_fx( /* TCX synthesis (it was already delayed in TD stereo in core_switching_post_dec()) */ IF( sts[n]->hTcxDec != NULL ) { - ovl_TCX = NS2SA_FX2( sts[n]->hTcxDec->L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ); /* Q0 */ + ovl_TCX = NS2SA_FX2( L_mult0( sts[n]->hTcxDec->L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); /* Q0 */ move16(); Copy32( synth_fx + add( sts[n]->hTcxDec->L_frameTCX, sub( hq_delay_comp, ovl_TCX ) ), hCPE->input_mem_fx[n], sub( ovl_TCX, hq_delay_comp ) ); /* Q11 */ Copy32( sts[n]->delay_buf_out32_fx, hCPE->input_mem_fx[n] + sub( ovl_TCX, hq_delay_comp ), hq_delay_comp ); /* Q11 */ diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index d296e3f33..c975da8d6 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -680,17 +680,17 @@ void stereo_tdm_combine_fx( output_Fs = hCPE->hCoreCoder[0]->output_Fs; /* Q0 */ move32(); - tdm_n_OVA = NS2SA( output_Fs, TDM_L_NOVA_NS ); /* Q0 */ + tdm_n_OVA = NS2SA_FX2( output_Fs, TDM_L_NOVA_NS ); /* Q0 */ move16(); IF( flag_HB ) { - upmixing_delay = NS2SA( output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ); /* Q0 */ + upmixing_delay = NS2SA_FX2( output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ); /* Q0 */ move16(); } ELSE { - upmixing_delay = NS2SA( output_Fs, ACELP_LOOK_NS + DELAY_CLDFB_NS ); /* Q0 */ + upmixing_delay = NS2SA_FX2( output_Fs, ACELP_LOOK_NS + DELAY_CLDFB_NS ); /* Q0 */ move16(); } @@ -845,7 +845,7 @@ void stereo_tdm_combine_fx( } incr_fx = Mpy_32_32( L_sub( ONE_IN_Q29, fac_fx ), step ); /* Q29 */ - FOR( i = 0; i < NS2SA( output_Fs, ACELP_LOOK_NS ); i++ ) + FOR( i = 0; i < NS2SA_FX2( output_Fs, ACELP_LOOK_NS ); i++ ) { PCh_2_L_fx[i] = L_shl_sat( Mpy_32_32( PCh_2_L_fx[i], fac_fx ), 2 ); /* Qx */ move32(); diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c index 68272a79f..6b80108a8 100644 --- a/lib_dec/swb_bwe_dec.c +++ b/lib_dec/swb_bwe_dec.c @@ -654,7 +654,7 @@ void fd_bwe_dec_init_fx( ) { set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, L_FRAME48k ); - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); hBWE_FD->prev_mode = NORMAL; move16(); hBWE_FD->prev_Energy_fx = 0; diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 7a6abb790..9552bbf2f 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -1223,7 +1223,7 @@ void fd_bwe_dec_init( { hBWE_FD->old_wtda_wb_fx_exp = 0; move16(); - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, L_FRAME48k ); hBWE_FD->old_wtda_swb_fx_exp = 0; move16(); diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index d5bbfab29..d7dd47256 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -455,7 +455,7 @@ void amr_wb_enc_fx( IF( EQ_32( st->input_Fs, 16000 ) ) { /* no resampling needed, only delay adjustement to account for the FIR resampling delay */ - tmps = NS2SA_FX2( 16000, DELAY_FIR_RESAMPL_NS ); + tmps = NS2SA( 16000, DELAY_FIR_RESAMPL_NS ); Copy_Scale_sig( &st->mem_decim16k_fx[tmps], new_inp_16k, tmps, -1 ); /* Input in Q0 -> Output in Q-1 to mimic the resampling filter */ Copy_Scale_sig( st->input_fx, new_inp_16k + tmps, sub( input_frame, tmps ), -1 ); /* Input in Q0 -> Output in Q-1 to mimic the resampling filter */ Copy( st->input_fx + input_frame - shl( tmps, 1 ), st->mem_decim16k_fx, shl( tmps, 1 ) ); /* memory still in Q0 */ diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index f6b5b5984..1f5b0df1e 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -526,7 +526,7 @@ void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Wor st->new_speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc + st->encoderLookahead_enc; st->new_speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc + st->encoderLookahead_enc; hTcxEnc->new_speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc + st->encoderLookahead_enc; - hTcxEnc->new_speech_TCX = st->input_buff_fx + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) - NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ); + hTcxEnc->new_speech_TCX = st->input_buff_fx + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) - NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ); st->speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc; st->speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc; diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 07468363f..da1139d15 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -430,8 +430,8 @@ void core_switching_post_enc_fx( test(); IF( ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) && EQ_16( st_fx->element_mode, EVS_MONO ) ) /* core switching ==> CELP subframe encoding */ { - acelp_core_switch_enc_fx( st_fx, old_inp_12k8 + L_INP_MEM - NS2SA_FX2( INT_FS_FX, ACELP_LOOK_NS ), - old_inp_16k + L_INP_MEM - NS2SA_FX2( INT_FS_16k, ACELP_LOOK_NS ), A, Qshift, Q_new ); + acelp_core_switch_enc_fx( st_fx, old_inp_12k8 + L_INP_MEM - NS2SA( INT_FS_FX, ACELP_LOOK_NS ), + old_inp_16k + L_INP_MEM - NS2SA( INT_FS_16k, ACELP_LOOK_NS ), A, Qshift, Q_new ); } hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index d5be64f77..93a954ae8 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -1531,7 +1531,7 @@ void generate_comfort_noise_enc_fx( Encoder_State *stcod, { FOR( i = 0; i < st->frameSize; i++ ) { - timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( hTcxEnc->old_out_fx[i + NS2SA( stcod->sr_core, N_ZERO_MDCT_NS )], hTcxEnc->Q_old_out ) ); + timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( hTcxEnc->old_out_fx[i + NS2SA_FX2( stcod->sr_core, N_ZERO_MDCT_NS )], hTcxEnc->Q_old_out ) ); move16(); } } @@ -1917,7 +1917,7 @@ void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod, { FOR( i = 0; i < st->frameSize; i++ ) { - timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( hTcxEnc->old_out_fx[i + NS2SA( stcod->sr_core, N_ZERO_MDCT_NS )], hTcxEnc->Q_old_out ) ); + timeDomainOutput[i] = add( timeDomainOutput[i], shr_r( hTcxEnc->old_out_fx[i + NS2SA_FX2( stcod->sr_core, N_ZERO_MDCT_NS )], hTcxEnc->Q_old_out ) ); move16(); } } diff --git a/lib_enc/hq_core_enc.c b/lib_enc/hq_core_enc.c index a3a75cc95..24579e74e 100644 --- a/lib_enc/hq_core_enc.c +++ b/lib_enc/hq_core_enc.c @@ -323,7 +323,7 @@ void hq_core_enc_ivas_fx( overlap = st->hTcxCfg->tcx_mdct_window_length; /* Q0 */ move16(); - nz = NS2SA( st->sr_core, N_ZERO_MDCT_NS ); + nz = NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS ); move16(); L_frame = sub( st->L_frame + st->hTcxCfg->tcx_offset, st->hTcxCfg->lfacNext ); tcx_offset = st->hTcxCfg->lfacNext; diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 8448843dc..1d4964ab8 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -429,7 +429,7 @@ ivas_error init_encoder_ivas_fx( IF( st->element_mode == EVS_MONO ) { st->input32_fx = st->input_buff32_fx + st->input_Fs / FRAMES_PER_SEC + NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ); - st->input_fx = st->input_buff_fx + add( frame_length, (Word16) NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); + st->input_fx = st->input_buff_fx + add( frame_length, (Word16) NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); } ELSE { diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 89bbdc898..58706279e 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -71,7 +71,7 @@ ivas_error init_encoder_fx( st_fx->old_input_signal_fx = st_fx->input_buff_fx; IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { - st_fx->input_fx = st_fx->input_buff_fx + st_fx->input_Fs / FRAMES_PER_SEC + NS2SA( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ); + st_fx->input_fx = st_fx->input_buff_fx + st_fx->input_Fs / FRAMES_PER_SEC + NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ); } ELSE { diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 96a3e110f..718a09026 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -533,7 +533,7 @@ ivas_error pre_proc_ivas_fx( sr_core_tmp = L_max( INT_FS_16k, st->sr_core ); } - L_look = NS2SA( sr_core_tmp, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) Q0*/ + L_look = NS2SA_FX2( sr_core_tmp, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) Q0*/ move16(); inp_16k_fx = old_inp_16k_fx + L_INP_MEM - L_look; @@ -747,7 +747,7 @@ ivas_error ivas_compute_core_buffers_fx( { lMemRecalc_16k = NS2SA( INT_FS_16k, L_MEM_RECALC_NS ); move16(); - lMemRecalc = NS2SA( input_Fs, L_MEM_RECALC_NS ); + lMemRecalc = NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ); move16(); } @@ -765,7 +765,7 @@ ivas_error ivas_compute_core_buffers_fx( L_frame_tmp = s_max( L_FRAME16k, st->L_frame ); } - L_look = NS2SA( sr_core, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) */ + L_look = NS2SA_FX2( sr_core, ACELP_LOOK_NS ); /* lookahead at other sampling rate (16kHz, 25.6kHz, 32kHz) */ move16(); new_inp_16k_fx = old_inp_16k_fx + L_INP_MEM; /* pointer to new samples of the input signal in 16kHz core */ @@ -775,7 +775,7 @@ ivas_error ivas_compute_core_buffers_fx( test(); IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_SCE ) ) { - new_inp_16k_fx -= NS2SA( sr_core, DELAY_FIR_RESAMPL_NS ); + new_inp_16k_fx -= NS2SA_FX2( sr_core, DELAY_FIR_RESAMPL_NS ); } IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) @@ -814,8 +814,8 @@ ivas_error ivas_compute_core_buffers_fx( Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX ); /* Q(-1) */ set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); - size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ - Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ + size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), 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 ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ } } ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) ) @@ -840,7 +840,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 length_16k = NS2SA_FX2( INT_FS_16k, L_MEM_RECALC_SCH_NS - DELAY_FIR_RESAMPL_NS ); move16(); - Copy( signal_in_fx - lMemRecalc - length_inp - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */ + Copy( signal_in_fx - lMemRecalc - length_inp - 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */ size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_16k_fx - lMemRecalc_16k - length_16k, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ Scale_sig( new_inp_16k_fx - lMemRecalc_16k - length_16k, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ } @@ -851,19 +851,19 @@ ivas_error ivas_compute_core_buffers_fx( IF( lMemRecalc > 0 ) { - size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ - Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ + 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 */ + Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ } set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); - size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ - Scale_sig( new_inp_16k_fx + NS2SA( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ + size_modified = modify_Fs_ivas_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), 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 ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ } } ELSE IF( st->idchan == 0 ) { /* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */ - Copy( signal_in_fx + input_frame - NS2SA( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */ + Copy( signal_in_fx + input_frame - NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ) - 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), st->mem_decim16k_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* st->q_inp */ } /*------------------------------------------------* diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index b7a10a4f3..7bb67cbbd 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -432,7 +432,7 @@ ivas_error pre_proc_front_ivas_fx( IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_MDCT ) ) { lMemRecalc = NS2SA_FX2( st->input_Fs, L_MEM_RECALC_NS ); - lMemRecalc_12k8 = NS2SA_FX2( INT_FS_12k8, L_MEM_RECALC_NS ); + lMemRecalc_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_NS ); } input_Fs = st->input_Fs; /* Q0 */ @@ -575,7 +575,7 @@ ivas_error pre_proc_front_ivas_fx( IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && EQ_16( st->idchan, 1 ) ) { Word16 length_inp = NS2SA_FX2( input_Fs, L_MEM_RECALC_SCH_NS ); - Word16 length_12k8 = NS2SA_FX2( INT_FS_12k8, L_MEM_RECALC_SCH_NS ); + Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS ); new_inp_out_size = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc - length_inp, length_inp, input_Fs, new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, INT_FS_12k8, st->mem_decim_fx, 0, &Q_new_inp, &mem_decim_size ); /* Q0 */ Scale_sig( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to Q_to_be_looked_into*/ @@ -597,7 +597,7 @@ ivas_error pre_proc_front_ivas_fx( ELSE /* DFT stereo */ { /* update the FIR resampling filter memory, needed for switching to time-domain (FIR) resampling */ - Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* hSCE->hCoreCoder[n]->q_inp */ + Copy( signal_in_fx + sub( input_frame, add( NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ), 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ) ), st->mem_decim_fx, 2 * NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ) ); /* hSCE->hCoreCoder[n]->q_inp */ } Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( -1, sub( 15, st->exp_buf_speech_enc ) ) ); /* Q(-1) */ @@ -678,7 +678,7 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && EQ_16( st->idchan, 1 ) ) { - Word16 length_12k8 = NS2SA_FX2( INT_FS_12k8, L_MEM_RECALC_SCH_NS ); + Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS ); move16(); // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx ); PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, sig_out, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx ); diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index b1d819f5c..1b4d5da4a 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -86,7 +86,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); IF( EQ_16( hEncoderConfig->ivas_format, SBA_FORMAT ) ) { - len_inp_memory = add( len_inp_memory, NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ); /* Q0 */ + len_inp_memory = add( len_inp_memory, NS2SA_FX2( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ) ); /* Q0 */ } nchan_transport_old_real = nchan_transport_old; /* Q0 */ diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 3635ab04a..8f9a0edf6 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -873,7 +873,7 @@ ivas_error ivas_cpe_enc_fx( Word16 input_norm, q_inp32, common_q, fir_delay_len; input_norm = L_norm_arr( sts[0]->input32_fx + out_start_ind, sub( out_end_ind, out_start_ind ) ); q_inp32 = add( Q15, input_norm ); - fir_delay_len = NS2SA( sts[0]->input_Fs, DELAY_FIR_RESAMPL_NS ); + fir_delay_len = NS2SA_FX2( sts[0]->input_Fs, DELAY_FIR_RESAMPL_NS ); move16(); // Find common Q-factor between { q_inp, q_old_inp and q_inp32-16 } @@ -1408,12 +1408,12 @@ ivas_error create_cpe_enc_fx( test(); IF( EQ_16( ivas_format, STEREO_FORMAT ) || EQ_16( ivas_format, MASA_FORMAT ) || ( EQ_16( ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) { - IF( ( hCPE->input_mem_fx[n] = (Word16 *) malloc( sizeof( Word16 ) * NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ) ) == NULL ) + IF( ( hCPE->input_mem_fx[n] = (Word16 *) malloc( sizeof( Word16 ) * NS2SA_FX2( input_Fs, STEREO_DFT_OVL_NS ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT stereo memory\n" ) ); } - set16_zero_fx( hCPE->input_mem_fx[n], NS2SA( input_Fs, STEREO_DFT_OVL_NS ) ); + set16_zero_fx( hCPE->input_mem_fx[n], NS2SA_FX2( input_Fs, STEREO_DFT_OVL_NS ) ); } ELSE { diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 5460ccb12..3844598c6 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -417,7 +417,7 @@ ivas_error front_vad_create_fx( move16(); /* allocate delay buffer to compensate for filterbank delay */ - hFrontVad->delay_samples = NS2SA( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); + hFrontVad->delay_samples = NS2SA_FX2( hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); move16(); hFrontVad->delay_buf_fx = NULL; IF( GT_16( hFrontVad->delay_samples, 0 ) ) diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc.c index 8ccb59c9c..fee34abd8 100644 --- a/lib_enc/ivas_lfe_enc.c +++ b/lib_enc/ivas_lfe_enc.c @@ -538,12 +538,12 @@ ivas_error ivas_create_lfe_enc_fx( * Input memory buffer: allocate and initialize *-----------------------------------------------------------------*/ - IF( ( hLFE->old_wtda_audio_fx = (Word32 *) malloc( sizeof( hLFE->old_wtda_audio_fx[0] ) * NS2SA( input_Fs, IVAS_LFE_FADE_NS ) ) ) == NULL ) + IF( ( hLFE->old_wtda_audio_fx = (Word32 *) malloc( sizeof( hLFE->old_wtda_audio_fx[0] ) * NS2SA_FX2( input_Fs, IVAS_LFE_FADE_NS ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LFE memory\n" ) ); } - set32_fx( hLFE->old_wtda_audio_fx, 0, NS2SA( input_Fs, IVAS_LFE_FADE_NS ) ); + set32_fx( hLFE->old_wtda_audio_fx, 0, NS2SA_FX2( input_Fs, IVAS_LFE_FADE_NS ) ); hLFE->q_old_wtda_audio = 31; move16(); diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index c94946b2d..392f1d9ab 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -201,8 +201,8 @@ ivas_error ivas_mc_paramupmix_enc_open_fx( /* assuming parameters are calculated at end of frame, compensate for MCT delay and half of decoder fb */ /* still 1.5ms off, since MCT delay is not large enough */ /* param at end of frame */ - fb_cfg->prior_input_length = (int16_t) ( NS2SA( input_Fs, 12000000L ) + NS2SA( input_Fs, DELAY_FB_4_NS / 2 ) - input_frame / 2 - NS2SA( input_Fs, DELAY_FB_1_NS / 2 ) ); - fb_cfg->prior_input_length = (int16_t) max( fb_cfg->prior_input_length, input_frame / MAX_PARAM_SPATIAL_SUBFRAMES ); + fb_cfg->prior_input_length = (Word16) ( NS2SA_FX2( input_Fs, 12000000L ) + NS2SA_FX2( input_Fs, DELAY_FB_4_NS / 2 ) - input_frame / 2 - NS2SA_FX2( input_Fs, DELAY_FB_1_NS / 2 ) ); + fb_cfg->prior_input_length = (Word16) max( fb_cfg->prior_input_length, input_frame / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Allocate and initialize FB mixer handle */ IF( NE_32( ( error = ivas_FB_mixer_open_fx( &( hMCParamUpmix->hFbMixer ), input_Fs, fb_cfg, 0 ) ), IVAS_ERR_OK ) ) diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 3687df381..b3f99e27c 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -200,22 +200,22 @@ ivas_error ivas_mcmasa_enc_open_fx( } /* initialize delay compensation */ - hMcMasa->num_samples_delay_comp = NS2SA( input_Fs, DELAY_DIRAC_ENC_CMP_NS ); + hMcMasa->num_samples_delay_comp = NS2SA_FX2( input_Fs, DELAY_DIRAC_ENC_CMP_NS ); move16(); #ifdef DISABLE_DIRAC_DELAY_COMP hMcMasa->num_samples_delay_comp = 0; /* disable delay compensation by setting to 0 */ #endif - tmp_f = idiv1616( hMcMasa->num_samples_delay_comp, ( NS2SA( input_Fs, DIRAC_SLOT_ENC_NS ) ) ); + tmp_f = idiv1616( hMcMasa->num_samples_delay_comp, ( NS2SA_FX2( input_Fs, DIRAC_SLOT_ENC_NS ) ) ); hMcMasa->num_slots_delay_comp = tmp_f; move16(); - IF( GT_16( hMcMasa->num_samples_delay_comp, ( NS2SA( input_Fs, DIRAC_SLOT_ENC_NS ) ) ) ) + IF( GT_16( hMcMasa->num_samples_delay_comp, ( NS2SA_FX2( input_Fs, DIRAC_SLOT_ENC_NS ) ) ) ) { hMcMasa->num_slots_delay_comp = add( hMcMasa->num_slots_delay_comp, 1 ); move16(); hMcMasa->offset_comp = negate( hMcMasa->num_samples_delay_comp ); move16(); - hMcMasa->num_samples_delay_comp = i_mult( hMcMasa->num_slots_delay_comp, NS2SA( input_Fs, DIRAC_SLOT_ENC_NS ) ); + hMcMasa->num_samples_delay_comp = i_mult( hMcMasa->num_slots_delay_comp, NS2SA_FX2( input_Fs, DIRAC_SLOT_ENC_NS ) ); move16(); hMcMasa->offset_comp = add( hMcMasa->offset_comp, hMcMasa->num_samples_delay_comp ); move16(); @@ -241,17 +241,17 @@ ivas_error ivas_mcmasa_enc_open_fx( IF( hMcMasa->separateChannelEnabled ) { /* TD Energy calculation with LP */ - IF( ( hMcMasa->delay_buffer_lfe[0] = (Word32 *) malloc( NS2SA( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) * sizeof( Word32 ) ) ) == NULL ) + IF( ( hMcMasa->delay_buffer_lfe[0] = (Word32 *) malloc( NS2SA_FX2( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); } - set_zero_fx( hMcMasa->delay_buffer_lfe[0], NS2SA( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) ); + set_zero_fx( hMcMasa->delay_buffer_lfe[0], NS2SA_FX2( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) ); - IF( ( hMcMasa->delay_buffer_lfe[1] = (Word32 *) malloc( NS2SA( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) * sizeof( Word32 ) ) ) == NULL ) + IF( ( hMcMasa->delay_buffer_lfe[1] = (Word32 *) malloc( NS2SA_FX2( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); } - set_zero_fx( hMcMasa->delay_buffer_lfe[1], NS2SA( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) ); + set_zero_fx( hMcMasa->delay_buffer_lfe[1], NS2SA_FX2( input_Fs, DELAY_DIRAC_ENC_CMP_NS + DIRAC_SLOT_ENC_NS ) ); hMcMasa->hFbMixerLfe = NULL; } ELSE diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index ab8252854..5eee0975a 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -114,7 +114,7 @@ ivas_error ivas_osba_enc_open_fx( { set_val_Word32( hOSba->prev_object_dm_gains_fx[i], INV_SQRT_2_Q30, MAX_INPUT_CHANNELS ); } - len = NS2SA( st_ivas->hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); + len = NS2SA_FX2( st_ivas->hEncoderConfig->input_Fs, IVAS_FB_ENC_DELAY_NS ); move16(); FOR( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) { @@ -421,7 +421,7 @@ void ivas_osba_enc_fx( Word16 Q_out = *q_data; move16(); Word16 n, delay_s; - delay_s = NS2SA( input_Fs, IVAS_FB_ENC_DELAY_NS ); + delay_s = NS2SA_FX2( input_Fs, IVAS_FB_ENC_DELAY_NS ); IF( ism_mode == ISM_MODE_NONE ) { /*keep the delay buffer up to date*/ diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c index 72876ae35..e0a8a8ed4 100644 --- a/lib_enc/ivas_stereo_ica_enc.c +++ b/lib_enc/ivas_stereo_ica_enc.c @@ -112,7 +112,7 @@ static void tcaTargetCh_LA_fx( target = ptrChanL; } - tempS = NS2SA( L_mult0( input_frame, FRAMES_PER_SEC ), L_SAMPLES_LA_NS ); + tempS = NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_SAMPLES_LA_NS ); tempF1 = 0; move32(); tempF1_exp = 0; @@ -1512,7 +1512,7 @@ static void icaMemUpdate_fx( IF( hCPE->hStereoICBWE != NULL ) { assert( L_MEM_RECALC_TBE_NS <= L_MEM_RECALC_NS ); - i = NS2SA( sts[0]->input_Fs, L_MEM_RECALC_TBE_NS ); + i = NS2SA_FX2( sts[0]->input_Fs, L_MEM_RECALC_TBE_NS ); Copy_Scale_sig_32_16( bufChanL + sub( add( lMemRecalc, lMemRecalc_SCh ), i ), hCPE->hStereoICBWE->icbwe_inp_mem_fx[0], i, -Q16 ); /* q_com-16 */ Copy_Scale_sig_32_16( bufChanR + sub( add( lMemRecalc, lMemRecalc_SCh ), i ), hCPE->hStereoICBWE->icbwe_inp_mem_fx[1], i, -Q16 ); /* q_com-16 */ hCPE->hStereoICBWE->q_dataChan_fx = sub( q_com, Q16 ); @@ -1580,9 +1580,9 @@ void stereo_tca_enc_fx( q_com = sts[0]->q_inp32; move16(); - lMemRecalc = NS2SA( input_Fs, L_MEM_RECALC_NS ); + lMemRecalc = NS2SA_FX2( input_Fs, L_MEM_RECALC_NS ); move16(); - lMemRecalc_SCh = NS2SA( input_Fs, L_MEM_RECALC_SCH_NS ); + lMemRecalc_SCh = NS2SA_FX2( input_Fs, L_MEM_RECALC_SCH_NS ); move16(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) @@ -2081,7 +2081,7 @@ void stereo_tca_enc_fx( { /* Scale the Right channel with the gain */ Word16 j; - Word16 l_ica_ovl = NS2SA( input_Fs, STEREO_L_TCA_OVLP_NS ); + Word16 l_ica_ovl = NS2SA_FX2( input_Fs, STEREO_L_TCA_OVLP_NS ); Word16 winSlope = div_s( 1, l_ica_ovl ); // Q15 diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 786c45cb3..190adbf1c 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -822,7 +822,7 @@ void stereo_switching_enc_fx( offset = sub( sts[0]->cldfbAnaEnc->p_filter_length, sts[0]->cldfbAnaEnc->no_channels ); /* Q0 */ FOR( i = 0; i < offset; i++ ) { - sts[0]->cldfbAnaEnc->cldfb_state_fx[i] = L_deposit_h( old_input_signal_pri[input_frame - offset - NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) + i] ); /* Q16+q_inp */ + sts[0]->cldfbAnaEnc->cldfb_state_fx[i] = L_deposit_h( old_input_signal_pri[input_frame - offset - NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) + i] ); /* Q16+q_inp */ move32(); } sts[0]->cldfbAnaEnc->Q_cldfb_state = add( Q16, q_inp ); @@ -844,7 +844,7 @@ void stereo_switching_enc_fx( test(); IF( hCPE->hStereoTD != NULL && EQ_16( hCPE->hStereoTD->tdm_last_ratio_idx, LRTD_STEREO_LEFT_IS_PRIM ) ) { - v_multc_fixed_32_16( hCPE->hCoreCoder[1]->old_input_signal_fx + sub( input_frame, add( offset, NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) ) ), -MAX_32, sts[1]->cldfbAnaEnc->cldfb_state_fx, offset ); /* Q16+q_inp */ + v_multc_fixed_32_16( hCPE->hCoreCoder[1]->old_input_signal_fx + sub( input_frame, add( offset, NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) ) ), -MAX_32, sts[1]->cldfbAnaEnc->cldfb_state_fx, offset ); /* Q16+q_inp */ sts[1]->cldfbAnaEnc->Q_cldfb_state = add( Q16, q_inp ); move16(); } @@ -852,7 +852,7 @@ void stereo_switching_enc_fx( { FOR( i = 0; i < offset; i++ ) { - sts[1]->cldfbAnaEnc->cldfb_state_fx[i] = L_shr( L_deposit_h( hCPE->hCoreCoder[1]->old_input_signal_fx[input_frame - offset - NS2SA( input_frame * FRAMES_PER_SEC, L_MEM_RECALC_TBE_NS ) + i] ), 5 ); /* Q11+q_inp */ + sts[1]->cldfbAnaEnc->cldfb_state_fx[i] = L_shr( L_deposit_h( hCPE->hCoreCoder[1]->old_input_signal_fx[input_frame - offset - NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) + i] ), 5 ); /* Q11+q_inp */ move32(); } sts[1]->cldfbAnaEnc->Q_cldfb_state = add( Q16 - 5, q_inp ); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 6035687ed..b4ca63bac 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1451,7 +1451,7 @@ ivas_error IVAS_ENC_GetDelay( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - *delay = NS2SA( hEncoderConfig->input_Fs, get_delay_fx( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL ) ); + *delay = NS2SA_FX2( hEncoderConfig->input_Fs, get_delay_fx( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL ) ); move16(); *delay = imult1616( *delay, hEncoderConfig->nchan_inp ); diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index c7d99cc69..01ac8383f 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -225,8 +225,8 @@ void wb_bwe_enc_ivas_fx( /*---------------------------------------------------------------------* * Delay the original input signal to be synchronized with ACELP core synthesis *---------------------------------------------------------------------*/ - set16_fx( old_input_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k ); - Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + set16_fx( old_input_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k ); + Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); move16(); new_input_fx = old_input_fx + Sample_Delay_WB_BWE; @@ -351,21 +351,21 @@ void swb_bwe_enc_ivas_fx( move32(); } - set16_fx( old_input_fx, 0, add( NS2SA( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ), inner_frame ) ); + set16_fx( old_input_fx, 0, add( NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ), inner_frame ) ); IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); - Sample_Delay_HP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - Sample_Delay_HP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); } - Sample_Delay_LP = NS2SA_FX2( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); IF( st_fx->element_mode > EVS_MONO ) { - Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); + Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA_FX2( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) @@ -381,15 +381,15 @@ void swb_bwe_enc_ivas_fx( ELSE { Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); - Sample_Delay_HP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - Sample_Delay_HP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); } - Sample_Delay_LP = NS2SA_FX2( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); + Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); IF( st_fx->element_mode > EVS_MONO ) { - Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); + Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA_FX2( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) @@ -677,11 +677,11 @@ void swb_bwe_enc_fx( move32(); } - set16_fx( old_input_fx, 0, add( NS2SA( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ), inner_frame ) ); + set16_fx( old_input_fx, 0, add( NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ), inner_frame ) ); IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { - Sample_Delay_SWB_BWE = NS2SA( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); @@ -689,7 +689,7 @@ void swb_bwe_enc_fx( } ELSE { - Sample_Delay_SWB_BWE = NS2SA( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 3e9c07c23..3bad5fa7f 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -81,7 +81,7 @@ void wb_pre_proc_fx( move16(); } - set16_fx( old_input, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k ); + set16_fx( old_input, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k ); max_wb = 1; move16(); @@ -161,7 +161,7 @@ void wb_pre_proc_fx( test(); IF( ( NE_16( st_fx->extl, WB_BWE ) || ( EQ_16( st_fx->extl, WB_BWE ) && LE_32( st_fx->total_brate, ACELP_8k00 ) ) ) && !hSC_VBR->ppp_mode ) { - Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); Copy( new_inp_resamp16k, &old_input[Sample_Delay_WB_BWE], L_FRAME16k ); Copy( hBWE_FD->old_input_wb_fx, old_input, Sample_Delay_WB_BWE ); @@ -257,7 +257,7 @@ void wb_pre_proc_ivas_fx( move16(); } - set16_fx( old_input, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + STEREO_DFT_OVL_16k + L_FRAME16k ); + set16_fx( old_input, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + STEREO_DFT_OVL_16k + L_FRAME16k ); max_wb = 1; move16(); @@ -311,7 +311,7 @@ void wb_pre_proc_ivas_fx( hb_speech and the two decimator memories are in Q_wb_sp */ IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) { - Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); IF( EQ_16( last_element_mode, IVAS_CPE_TD ) ) { @@ -347,7 +347,7 @@ void wb_pre_proc_ivas_fx( move16(); Word16 l_recalc_4k = ( L_MEM_RECALC_16K + L_FILT16k + 1 ) / 4; move16(); - Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); IF( EQ_16( last_element_mode, IVAS_CPE_DFT ) ) { @@ -391,7 +391,7 @@ void wb_pre_proc_ivas_fx( Word16 l_recalc_16k = L_FILT16k + 1; /* Note: "+1" is used because L_FILT16k is not divisible by 4 */ Word16 l_recalc_4k = ( L_FILT16k + 1 ) / 4; - Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); /*Get past signal*/ Copy_Scale_sig( hBWE_FD->L_old_wtda_swb_fx + L_FRAME16k - l_recalc_16k, old_input, l_recalc_16k, Q_wb_sp ); @@ -454,7 +454,7 @@ void wb_pre_proc_ivas_fx( test(); IF( ( NE_16( st_fx->extl, WB_BWE ) || ( EQ_16( st_fx->extl, WB_BWE ) && EQ_32( st_fx->total_brate, 0 ) ) ) && !ppp_mode ) { - Sample_Delay_WB_BWE = NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); Copy( new_inp_resamp16k, &old_input[Sample_Delay_WB_BWE], L_FRAME16k ); Copy( hBWE_FD->old_input_wb_fx, old_input, Sample_Delay_WB_BWE ); @@ -540,7 +540,7 @@ void swb_pre_proc_fx( imagBufferFlipped[j] = imagBufferTmp[j]; } - set16_fx( old_input_fx, 0, NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k ); + set16_fx( old_input_fx, 0, NS2SA( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k ); IF( EQ_32( st_fx->input_Fs, 32000 ) ) { @@ -549,7 +549,7 @@ void swb_pre_proc_fx( test(); IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) && NE_16( st_fx->extl, SWB_BWE_HIGHRATE ) ) { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_SWB_BWE = NS2SA( 32000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); Copy( hBWE_FD->old_fdbwe_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], L_FRAME32k ); set16_fx( old_input_fx, 0, Sample_Delay_SWB_BWE ); Copy( hBWE_FD->old_fdbwe_speech_fx + L_FRAME32k - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); @@ -756,9 +756,9 @@ void swb_pre_proc_fx( /* Reset CLDFB synthesis buffer */ set16_fx( st_fx->cldfbSynTd->FilterStates, 0, st_fx->cldfbSynTd->p_filter_length + st_fx->cldfbSynTd->no_channels * st_fx->cldfbSynTd->no_col ); } - IF( st_fx->last_extl == -1 ) + IF( EQ_16( st_fx->last_extl, -1 ) ) { - delay = NS2SA( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ); + delay = NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ); FOR( i = 0; i < delay; i++ ) { shb_speech_fx[i] = mult_r( mult_r( i, 983 /*0.03f Q15*/ ), shb_speech_fx[2 * delay - 1 - i] ); @@ -813,7 +813,7 @@ void swb_pre_proc_ivas_fx( Word16 Sample_Delay_SWB_BWE32k, lMemRecalc32k, dft_ovl32k; Word32 one_by_50_Q31 = 42949673; - lMemRecalc32k = NS2SA_FX2( 32000, L_MEM_RECALC_NS ); + lMemRecalc32k = NS2SA( 32000, L_MEM_RECALC_NS ); move16(); // exp_lbEner move16(); // lMemRecalc32k move32(); // one_by_50_Q31 @@ -831,16 +831,16 @@ void swb_pre_proc_ivas_fx( imagBufferFlipped[j] = imagBufferTmp[j]; } - set16_fx( old_input_fx, 0, NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k ); + set16_fx( old_input_fx, 0, NS2SA( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k ); IF( EQ_32( st->input_Fs, 32000 ) ) { IF( st->element_mode > EVS_MONO ) { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_SWB_BWE = NS2SA( 32000, DELAY_FD_BWE_ENC_12k8_NS ); IF( EQ_16( st->L_frame, L_FRAME16k ) ) { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_16k_NS ); + Sample_Delay_SWB_BWE = NS2SA( 32000, DELAY_FD_BWE_ENC_16k_NS ); } Copy( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); @@ -864,15 +864,15 @@ void swb_pre_proc_ivas_fx( test(); IF( NE_16( st->last_extl, SWB_BWE ) && NE_16( st->last_extl, FB_BWE ) && NE_16( st->extl, SWB_BWE_HIGHRATE ) ) { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_SWB_BWE = NS2SA( 32000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); test(); IF( st->element_mode > EVS_MONO && EQ_16( st->L_frame, L_FRAME16k ) ) { - Sample_Delay_SWB_BWE = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_SWB_BWE = NS2SA( 32000, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); } IF( st->element_mode > EVS_MONO ) { - Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA_FX2( 32000, DELAY_FIR_RESAMPL_NS ) ); + Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA( 32000, DELAY_FIR_RESAMPL_NS ) ); } Copy( hBWE_FD->old_fdbwe_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], L_FRAME32k ); @@ -894,15 +894,15 @@ void swb_pre_proc_ivas_fx( ELSE /* 48 kHz */ { - Sample_Delay_SWB_BWE32k = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_SWB_BWE32k = NS2SA( 32000, DELAY_FD_BWE_ENC_12k8_NS ); move16(); - Sample_Delay_SWB_BWE = NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_12k8_NS ); + Sample_Delay_SWB_BWE = NS2SA( 48000, DELAY_FD_BWE_ENC_12k8_NS ); move16(); IF( EQ_16( st->L_frame, L_FRAME16k ) ) { - Sample_Delay_SWB_BWE32k = NS2SA_FX2( 32000, DELAY_FD_BWE_ENC_16k_NS ); + Sample_Delay_SWB_BWE32k = NS2SA( 32000, DELAY_FD_BWE_ENC_16k_NS ); move16(); - Sample_Delay_SWB_BWE = NS2SA_FX2( 48000, DELAY_FD_BWE_ENC_16k_NS ); + Sample_Delay_SWB_BWE = NS2SA( 48000, DELAY_FD_BWE_ENC_16k_NS ); move16(); } diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 7422a5a15..a5e4e902b 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -7332,7 +7332,7 @@ void fb_tbe_enc_fx( Copy_Scale_sig( new_input, input_fhb, L_FRAME48k, exp_temp ); elliptic_bpf_48k_generic_fx( input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); - Sample_Delay_HP = NS2SA_FX2( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; + Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; IF( NE_16( st->last_extl, FB_TBE ) ) { @@ -7468,16 +7468,16 @@ void fb_tbe_enc_ivas_fx( IF( EQ_16( st->L_frame, L_FRAME ) ) { - Sample_Delay_HP = NS2SA_FX2( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ) - L_FRAME48k / 2; + Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ) - L_FRAME48k / 2; } ELSE { - Sample_Delay_HP = NS2SA_FX2( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ) - L_FRAME48k / 2; + Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ) - L_FRAME48k / 2; } } ELSE { - Sample_Delay_HP = NS2SA_FX2( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; + Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; } IF( NE_16( st->last_extl, FB_TBE ) ) -- GitLab From f8098d80f2d9eb69dfb23381d4aec58ab747d4d7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 4 Mar 2025 10:40:10 +0530 Subject: [PATCH 10/97] Files cleanup in lib_enc --- Workspace_msvc/lib_enc.vcxproj | 66 -- Workspace_msvc/lib_enc.vcxproj.filters | 198 ---- lib_enc/ari_enc.c | 316 ------ lib_enc/ari_enc_fx.c | 223 +++++ lib_enc/ari_hm_enc.c | 53 -- lib_enc/arith_coder_enc.c | 51 - lib_enc/avq_cod.c | 42 - lib_enc/bass_psfilter_enc.c | 42 - lib_enc/bw_detect.c | 64 -- lib_enc/cng_enc.c | 429 --------- lib_enc/cng_enc_fx.c | 374 ++++++++ lib_enc/cod2t32.c | 41 - lib_enc/cod4t64.c | 48 - lib_enc/cod_ace.c | 42 - lib_enc/cod_tcx.c | 869 ----------------- lib_enc/cod_tcx_fx.c | 721 ++++++++++++++ lib_enc/cod_uv.c | 40 - lib_enc/comvad_decision.c | 41 - lib_enc/cor_shif.c | 41 - lib_enc/core_enc_2div.c | 42 - lib_enc/core_enc_init.c | 1055 -------------------- lib_enc/core_enc_init_fx.c | 1004 ++++++++++++++++++++ lib_enc/core_enc_ol.c | 46 - lib_enc/core_enc_reconf.c | 346 ------- lib_enc/core_enc_reconf_fx.c | 304 ++++++ lib_enc/core_enc_switch.c | 302 ------ lib_enc/core_enc_switch_fx.c | 259 +++++ lib_enc/core_enc_updt.c | 117 --- lib_enc/core_enc_updt_fx.c | 74 ++ lib_enc/core_switching_enc.c | 603 ------------ lib_enc/core_switching_enc_fx.c | 561 ++++++++++- lib_enc/corr_xh.c | 41 - lib_enc/decision_matrix_enc.c | 45 - lib_enc/detect_transient.c | 42 - lib_enc/diffcod.c | 149 --- lib_enc/dtx.c | 45 - lib_enc/enc_acelp.c | 91 -- lib_enc/enc_acelp_tcx_main.c | 41 - lib_enc/enc_acelpx.c | 42 - lib_enc/enc_amr_wb.c | 42 - lib_enc/enc_gain.c | 43 - lib_enc/enc_gen_voic.c | 42 - lib_enc/enc_prm.c | 231 ----- lib_enc/enc_prm_fx.c | 189 +++- lib_enc/fd_cng_enc.c | 1172 ----------------------- lib_enc/fd_cng_enc_fx.c | 1100 +++++++++++++++++++++ lib_enc/find_tilt.c | 303 ------ lib_enc/find_tilt_fx.c | 252 +++++ lib_enc/find_uv.c | 660 ------------- lib_enc/find_uv_fx.c | 539 +++++++++++ lib_enc/find_wsp.c | 98 -- lib_enc/find_wsp_fx.c | 59 +- lib_enc/frame_spec_dif_cor_rate.c | 47 - lib_enc/gain_enc.c | 55 -- lib_enc/gs_enc.c | 56 -- lib_enc/guided_plc_enc.c | 42 - lib_enc/hf_cod_amrwb.c | 43 - lib_enc/hq_classifier_enc.c | 52 - lib_enc/hq_core_enc.c | 410 -------- lib_enc/hq_core_enc_fx.c | 359 +++++++ lib_enc/hq_env_enc.c | 42 - lib_enc/hq_hr_enc.c | 280 ------ lib_enc/hq_hr_enc_fx.c | 236 ++++- lib_enc/hq_lr_enc.c | 46 - lib_enc/hvq_enc.c | 44 - lib_enc/init_enc.c | 1215 ------------------------ lib_enc/init_enc_fx.c | 1170 +++++++++++++++++++++++ lib_enc/inov_enc.c | 49 - lib_enc/isf_enc_amr_wb.c | 43 - lib_enc/ivas_entropy_coder.c | 3 +- lib_enc/lead_indexing.c | 208 ---- lib_enc/long_enr.c | 47 - lib_enc/lp_exc_e.c | 42 - lib_enc/lsf_enc.c | 49 - lib_enc/ltd_stable.c | 41 - lib_enc/mdct_classifier.c | 43 - lib_enc/mdct_selector.c | 44 - lib_enc/mslvq_enc.c | 308 ------ lib_enc/mslvq_enc_fx.c | 177 ++++ lib_enc/multi_harm.c | 42 - lib_enc/nelp_enc.c | 43 - lib_enc/pit_enc.c | 45 - lib_enc/pitch_ol.c | 48 - lib_enc/pitch_ol2.c | 274 ------ lib_enc/pitch_ol2_fx.c | 224 +++++ lib_enc/plc_enc_ext.c | 43 - lib_enc/setmodeindex.c | 97 -- lib_enc/setmodeindex_fx.c | 45 + 88 files changed, 7865 insertions(+), 11787 deletions(-) delete mode 100644 lib_enc/ari_enc.c delete mode 100644 lib_enc/ari_hm_enc.c delete mode 100644 lib_enc/arith_coder_enc.c delete mode 100644 lib_enc/avq_cod.c delete mode 100644 lib_enc/bass_psfilter_enc.c delete mode 100644 lib_enc/bw_detect.c delete mode 100644 lib_enc/cng_enc.c delete mode 100644 lib_enc/cod2t32.c delete mode 100644 lib_enc/cod4t64.c delete mode 100644 lib_enc/cod_ace.c delete mode 100644 lib_enc/cod_tcx.c delete mode 100644 lib_enc/cod_uv.c delete mode 100644 lib_enc/comvad_decision.c delete mode 100644 lib_enc/cor_shif.c delete mode 100644 lib_enc/core_enc_2div.c delete mode 100644 lib_enc/core_enc_init.c delete mode 100644 lib_enc/core_enc_ol.c delete mode 100644 lib_enc/core_enc_reconf.c delete mode 100644 lib_enc/core_enc_switch.c delete mode 100644 lib_enc/core_enc_updt.c delete mode 100644 lib_enc/core_switching_enc.c delete mode 100644 lib_enc/corr_xh.c delete mode 100644 lib_enc/decision_matrix_enc.c delete mode 100644 lib_enc/detect_transient.c delete mode 100644 lib_enc/diffcod.c delete mode 100644 lib_enc/dtx.c delete mode 100644 lib_enc/enc_acelp.c delete mode 100644 lib_enc/enc_acelp_tcx_main.c delete mode 100644 lib_enc/enc_acelpx.c delete mode 100644 lib_enc/enc_amr_wb.c delete mode 100644 lib_enc/enc_gain.c delete mode 100644 lib_enc/enc_gen_voic.c delete mode 100644 lib_enc/enc_prm.c delete mode 100644 lib_enc/fd_cng_enc.c delete mode 100644 lib_enc/find_tilt.c delete mode 100644 lib_enc/find_uv.c delete mode 100644 lib_enc/find_wsp.c delete mode 100644 lib_enc/frame_spec_dif_cor_rate.c delete mode 100644 lib_enc/gain_enc.c delete mode 100644 lib_enc/gs_enc.c delete mode 100644 lib_enc/guided_plc_enc.c delete mode 100644 lib_enc/hf_cod_amrwb.c delete mode 100644 lib_enc/hq_classifier_enc.c delete mode 100644 lib_enc/hq_core_enc.c delete mode 100644 lib_enc/hq_env_enc.c delete mode 100644 lib_enc/hq_hr_enc.c delete mode 100644 lib_enc/hq_lr_enc.c delete mode 100644 lib_enc/hvq_enc.c delete mode 100644 lib_enc/init_enc.c delete mode 100644 lib_enc/inov_enc.c delete mode 100644 lib_enc/isf_enc_amr_wb.c delete mode 100644 lib_enc/lead_indexing.c delete mode 100644 lib_enc/long_enr.c delete mode 100644 lib_enc/lp_exc_e.c delete mode 100644 lib_enc/lsf_enc.c delete mode 100644 lib_enc/ltd_stable.c delete mode 100644 lib_enc/mdct_classifier.c delete mode 100644 lib_enc/mdct_selector.c delete mode 100644 lib_enc/mslvq_enc.c delete mode 100644 lib_enc/multi_harm.c delete mode 100644 lib_enc/nelp_enc.c delete mode 100644 lib_enc/pit_enc.c delete mode 100644 lib_enc/pitch_ol.c delete mode 100644 lib_enc/pitch_ol2.c delete mode 100644 lib_enc/plc_enc_ext.c delete mode 100644 lib_enc/setmodeindex.c diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 75831970e..86e56d42a 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -239,60 +239,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -324,18 +273,13 @@ - - - - - @@ -373,18 +317,8 @@ - - - - - - - - - - diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters index 0c3220178..406c01b86 100644 --- a/Workspace_msvc/lib_enc.vcxproj.filters +++ b/Workspace_msvc/lib_enc.vcxproj.filters @@ -8,75 +8,39 @@ encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c @@ -92,54 +56,33 @@ encoder_evs_c - - encoder_evs_c - encoder_evs_c encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c - - encoder_evs_c - encoder_evs_c encoder_evs_c - - encoder_evs_c - encoder_evs_c encoder_evs_c - - encoder_evs_c - encoder_evs_c @@ -347,135 +290,72 @@ encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c encoder_all_c - - encoder_all_c - encoder_all_c @@ -494,9 +374,6 @@ encoder_all_c - - encoder_all_c - encoder_all_c @@ -506,27 +383,15 @@ encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c @@ -536,45 +401,24 @@ encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c @@ -590,39 +434,21 @@ encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c @@ -632,27 +458,15 @@ encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c @@ -668,21 +482,12 @@ encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c - - encoder_all_c - encoder_all_c @@ -719,9 +524,6 @@ encoder_all_c - - encoder_all_c - encoder_all_c diff --git a/lib_enc/ari_enc.c b/lib_enc/ari_enc.c deleted file mode 100644 index da4d1486b..000000000 --- a/lib_enc/ari_enc.c +++ /dev/null @@ -1,316 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "stat_com.h" -#include "basop_util.h" -#include "wmc_auto.h" -#include "prot_fx_enc.h" - - -/*--------------------------------------------------------------- - * ari_copy_states() - * - * Copy state - *-------------------------------------------------------------*/ - -void ari_copy_states( - Tastat *source, - Tastat *dest ) -{ - dest->low = source->low; - dest->high = source->high; - dest->bits_to_follow = source->bits_to_follow; - - return; -} - -/*--------------------------------------------------------------- - Ari encoder 14 bits routines - -------------------------------------------------------------*/ - -/*--------------------------------------------------------------- - * ari_start_encoding_14bits() - * - * Start ArCo encoding - *-------------------------------------------------------------*/ - -void ari_start_encoding_14bits( - Tastat *s ) -{ - /* : addressing is made with walking pointer s */ - s->low = 0; - s->high = ari_q4new; - s->bits_to_follow = 0; - move32(); - move32(); - move32(); - - return; -} -void ari_start_encoding_14bits_ivas_fx( - Tastat *s ) -{ - /* : addressing is made with walking pointer s */ - s->low = 0; - s->high = ari_q4new; - s->bits_to_follow = 0; - move32(); - move32(); - move32(); - - return; -} - -/*--------------------------------------------------------------- - * ari_done_encoding_14bits_ivas_fx() - * - * Finish ArCo encoding - *-------------------------------------------------------------*/ - -Word16 ari_done_encoding_14bits_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Tastat *s ) -{ - Word16 bit; - - bit = 0; - move16(); - IF( GE_32( s->low, ari_q1new ) ) - { - bit = s_xor( bit, 1 ); - } - return ari_put_bit_plus_follow( ptr, bp, add( extract_l( s->bits_to_follow ), 1 ), bit ); -} - - -/*--------------------------------------------------------------- - * ari_encode_14bits_ext_ivas_fx() - * - * encode function for extended proba tables: less branches needed for coding - * - *-------------------------------------------------------------*/ -Word16 ari_encode_14bits_ext_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Tastat *s, - Word32 symbol, /* Q0 */ - UWord16 const *cum_freq /* Q0 */ -) -{ - Word32 low; - Word32 high; - Word32 range; - Word16 bits_to_follow; - Word16 i; - UWord16 temp; - Word32 L_temp1, L_temp2; - - high = L_add( s->high, 0 ); - low = L_add( s->low, 0 ); - range = L_add( L_sub( high, low ), 1 ); /* Q0 */ - - L_temp1 = L_shl( range, 15 - stat_bitsnew /*both are constants*/ ); - Mpy_32_16_ss( L_temp1, cum_freq[symbol + 1], &L_temp2, &temp ); - IF( symbol != 0 ) /* when symbol is 0, range remains unchanged */ - { - Mpy_32_16_ss( L_temp1, cum_freq[symbol], &range, &temp ); - } - high = L_sub( L_add( low, range ), 1 ); /* Q0 */ - low = L_add( low, L_temp2 ); /* Q0 */ - - assert( s->bits_to_follow <= MAX_16 ); - bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */ - - FOR( i = 0; i < 0x7FFF; i++ ) - { - IF( LT_32( high, ari_q2new ) ) - { - bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */ - bits_to_follow = 0; - move16(); - } - ELSE IF( GE_32( low, ari_q2new ) ) - { - bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */ - bits_to_follow = 0; - move16(); - low = L_sub( low, ari_q2new ); - high = L_sub( high, ari_q2new ); /* Subtract offset to top. */ - } - ELSE - { - test(); - IF( GE_32( low, ari_q1new ) && LT_32( high, ari_q3new ) ) - { - /* Output an opposite bit */ - /* later if in middle half. */ - bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */ - low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/ - high = L_sub( high, ari_q1new ); - } - ELSE - { - BREAK; /* Otherwise exit loop. */ - } - } - low = L_add( low, low ); /* Q0 */ - high = L_add( L_add( high, high ), 1 ); /* Scale up code range. Q0*/ - } - - s->low = low; /* Q0 */ - move32(); - s->high = high; /* Q0 */ - move32(); - s->bits_to_follow = bits_to_follow; /* Q0 */ - move32(); - - return bp; -} - - -/*------------------------------------------------------------------------ - * Function: ari_encode_14bits_high_low_fx() - * - *-------------------------------------------------------------------------*/ - -static Word16 ari_encode_14bits_high_low_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Word16 bits, /* Q0 */ - Tastat *s, - Word32 high, /* Q0 */ - Word32 low /* Q0 */ -) -{ - Word16 bits_to_follow, tmp; - - bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */ - move16(); - - /* while there are more than 16 bits left */ - tmp = sub( 16, bits ); /* Q0 */ - WHILE( add( add( bp, bits_to_follow ), tmp ) < 0 ) - { - IF( LE_32( high, ari_q2new ) ) - { - bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */ - bits_to_follow = 0; - move16(); - } - ELSE IF( GE_32( low, ari_q2new ) ) - { - bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */ - bits_to_follow = 0; - move16(); - low = L_sub( low, ari_q2new ); /* Q0 */ - high = L_sub( high, ari_q2new ); /* Subtract offset to top. Q0*/ - } - ELSE - { - test(); - IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) - { - /* Output an opposite bit */ - /* later if in middle half. */ - bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */ - low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/ - high = L_sub( high, ari_q1new ); /* Q0 */ - } - ELSE - { - BREAK; /* Otherwise exit loop. */ - } - } - - low = L_add( low, low ); - high = L_add( high, high ); /* Scale up code range. */ - } - - s->low = low; /* Q0 */ - move32(); - s->high = L_sub( high, 1 ); /* Q0 */ - move32(); - s->bits_to_follow = bits_to_follow; /* Q0 */ - move16(); - - return bp; -} - -/*------------------------------------------------------------------------ - * Function: ari_encode_14bits_sign_ivas_fx() - * - * Encode a sign with equal probabilities. - *-------------------------------------------------------------------------*/ -Word16 ari_encode_14bits_sign_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Word32 bits, /* Q0 */ - Tastat *s, - Word16 sign /* Q0 */ -) -{ - Word32 low, high, range; - Word32 L_tmp; - - high = L_add( s->high, 1 ); - low = L_add( s->low, 0 ); - range = L_sub( high, low ); /* Q0 */ - - L_tmp = L_shr( range, 1 ); - if ( sign != 0 ) - { - high = L_add( low, L_tmp ); /* Q0 */ - } - if ( sign == 0 ) - { - low = L_add( low, L_tmp ); /* Q0 */ - } - - return ari_encode_14bits_high_low_fx( ptr, bp, extract_l( bits ), s, high, low ); -} - -/*------------------------------------------------------------------------ - * Function: ari_done_cbr_encoding_14bits() - * - * Finish up encoding in CBR mode. - *-------------------------------------------------------------------------*/ diff --git a/lib_enc/ari_enc_fx.c b/lib_enc/ari_enc_fx.c index 0ef053edd..29ddd838c 100644 --- a/lib_enc/ari_enc_fx.c +++ b/lib_enc/ari_enc_fx.c @@ -364,3 +364,226 @@ Word16 ari_done_cbr_encoding_14bits_fx( return bp; } + +void ari_start_encoding_14bits_ivas_fx( + Tastat *s ) +{ + /* : addressing is made with walking pointer s */ + s->low = 0; + s->high = ari_q4new; + s->bits_to_follow = 0; + move32(); + move32(); + move32(); + + return; +} + +/*--------------------------------------------------------------- + * ari_done_encoding_14bits_ivas_fx() + * + * Finish ArCo encoding + *-------------------------------------------------------------*/ + +Word16 ari_done_encoding_14bits_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Tastat *s ) +{ + Word16 bit; + + bit = 0; + move16(); + IF( GE_32( s->low, ari_q1new ) ) + { + bit = s_xor( bit, 1 ); + } + return ari_put_bit_plus_follow( ptr, bp, add( extract_l( s->bits_to_follow ), 1 ), bit ); +} + + +/*--------------------------------------------------------------- + * ari_encode_14bits_ext_ivas_fx() + * + * encode function for extended proba tables: less branches needed for coding + * + *-------------------------------------------------------------*/ +Word16 ari_encode_14bits_ext_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Tastat *s, + Word32 symbol, /* Q0 */ + UWord16 const *cum_freq /* Q0 */ +) +{ + Word32 low; + Word32 high; + Word32 range; + Word16 bits_to_follow; + Word16 i; + UWord16 temp; + Word32 L_temp1, L_temp2; + + high = L_add( s->high, 0 ); + low = L_add( s->low, 0 ); + range = L_add( L_sub( high, low ), 1 ); /* Q0 */ + + L_temp1 = L_shl( range, 15 - stat_bitsnew /*both are constants*/ ); + Mpy_32_16_ss( L_temp1, cum_freq[symbol + 1], &L_temp2, &temp ); + IF( symbol != 0 ) /* when symbol is 0, range remains unchanged */ + { + Mpy_32_16_ss( L_temp1, cum_freq[symbol], &range, &temp ); + } + high = L_sub( L_add( low, range ), 1 ); /* Q0 */ + low = L_add( low, L_temp2 ); /* Q0 */ + + assert( s->bits_to_follow <= MAX_16 ); + bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */ + + FOR( i = 0; i < 0x7FFF; i++ ) + { + IF( LT_32( high, ari_q2new ) ) + { + bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */ + bits_to_follow = 0; + move16(); + } + ELSE IF( GE_32( low, ari_q2new ) ) + { + bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */ + bits_to_follow = 0; + move16(); + low = L_sub( low, ari_q2new ); + high = L_sub( high, ari_q2new ); /* Subtract offset to top. */ + } + ELSE + { + test(); + IF( GE_32( low, ari_q1new ) && LT_32( high, ari_q3new ) ) + { + /* Output an opposite bit */ + /* later if in middle half. */ + bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */ + low = L_sub( low, ari_q1new ); /* Subtract offset to middle*/ + high = L_sub( high, ari_q1new ); + } + ELSE + { + BREAK; /* Otherwise exit loop. */ + } + } + low = L_add( low, low ); /* Q0 */ + high = L_add( L_add( high, high ), 1 ); /* Scale up code range. Q0*/ + } + + s->low = low; /* Q0 */ + move32(); + s->high = high; /* Q0 */ + move32(); + s->bits_to_follow = bits_to_follow; /* Q0 */ + move32(); + + return bp; +} + + +/*------------------------------------------------------------------------ + * Function: ari_encode_14bits_high_low_fx() + * + *-------------------------------------------------------------------------*/ + +static Word16 ari_encode_14bits_high_low_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Word16 bits, /* Q0 */ + Tastat *s, + Word32 high, /* Q0 */ + Word32 low /* Q0 */ +) +{ + Word16 bits_to_follow, tmp; + + bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */ + move16(); + + /* while there are more than 16 bits left */ + tmp = sub( 16, bits ); /* Q0 */ + WHILE( add( add( bp, bits_to_follow ), tmp ) < 0 ) + { + IF( LE_32( high, ari_q2new ) ) + { + bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */ + bits_to_follow = 0; + move16(); + } + ELSE IF( GE_32( low, ari_q2new ) ) + { + bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */ + bits_to_follow = 0; + move16(); + low = L_sub( low, ari_q2new ); /* Q0 */ + high = L_sub( high, ari_q2new ); /* Subtract offset to top. Q0*/ + } + ELSE + { + test(); + IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) + { + /* Output an opposite bit */ + /* later if in middle half. */ + bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */ + low = L_sub( low, ari_q1new ); /* Subtract offset to middle Q0*/ + high = L_sub( high, ari_q1new ); /* Q0 */ + } + ELSE + { + BREAK; /* Otherwise exit loop. */ + } + } + + low = L_add( low, low ); + high = L_add( high, high ); /* Scale up code range. */ + } + + s->low = low; /* Q0 */ + move32(); + s->high = L_sub( high, 1 ); /* Q0 */ + move32(); + s->bits_to_follow = bits_to_follow; /* Q0 */ + move16(); + + return bp; +} + +/*------------------------------------------------------------------------ + * Function: ari_encode_14bits_sign_ivas_fx() + * + * Encode a sign with equal probabilities. + *-------------------------------------------------------------------------*/ +Word16 ari_encode_14bits_sign_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Word32 bits, /* Q0 */ + Tastat *s, + Word16 sign /* Q0 */ +) +{ + Word32 low, high, range; + Word32 L_tmp; + + high = L_add( s->high, 1 ); + low = L_add( s->low, 0 ); + range = L_sub( high, low ); /* Q0 */ + + L_tmp = L_shr( range, 1 ); + if ( sign != 0 ) + { + high = L_add( low, L_tmp ); /* Q0 */ + } + if ( sign == 0 ) + { + low = L_add( low, L_tmp ); /* Q0 */ + } + + return ari_encode_14bits_high_low_ivas_fx( ptr, bp, extract_l( bits ), s, high, low ); +} diff --git a/lib_enc/ari_hm_enc.c b/lib_enc/ari_hm_enc.c deleted file mode 100644 index c6e11a3f0..000000000 --- a/lib_enc/ari_hm_enc.c +++ /dev/null @@ -1,53 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "stl.h" -#include "basop_util.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * EncodeIndex() - * - * - *-------------------------------------------------------------------*/ diff --git a/lib_enc/arith_coder_enc.c b/lib_enc/arith_coder_enc.c deleted file mode 100644 index 5625b6cf4..000000000 --- a/lib_enc/arith_coder_enc.c +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "basop_util.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ diff --git a/lib_enc/avq_cod.c b/lib_enc/avq_cod.c deleted file mode 100644 index 9228e2f5d..000000000 --- a/lib_enc/avq_cod.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/bass_psfilter_enc.c b/lib_enc/bass_psfilter_enc.c deleted file mode 100644 index 9228e2f5d..000000000 --- a/lib_enc/bass_psfilter_enc.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c deleted file mode 100644 index d86351ae8..000000000 --- a/lib_enc/bw_detect.c +++ /dev/null @@ -1,64 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "ivas_prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -#define BWD_MIN_BRATE_WIDER_BW_MDCT IVAS_48k -#define BWD_MIN_BRATE_WIDER_BW_ISM IVAS_32k -#define BWD_MAX_BRATE_WIDER_BW_MDCT IVAS_80k -#define BWD_MAX_BRATE_WIDER_BW_ISM IVAS_64k - -#define ALPHA_BWD 0.75f -#define BWD_LT_THRESH 0.6f - -#define BWD_COUNT_MAX 100 -#define BWD_COUNT_WIDER_BW 10 -#define BWD_COUNT_WIDER_BW_MDCT 0 - -#define CLDFB_ENER_OFFSET 1.6f diff --git a/lib_enc/cng_enc.c b/lib_enc/cng_enc.c deleted file mode 100644 index 192a71f92..000000000 --- a/lib_enc/cng_enc.c +++ /dev/null @@ -1,429 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -#include "prot_fx_enc.h" -#include "prot_fx.h" -#include "ivas_rom_com_fx.h" - -/*---------------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------------*/ - -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 ); - - -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 */ -) -{ - Word16 shb_SID_updt; - - test(); - IF( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA ) - { - IF( st->cng_type == LP_CNG ) - { - test(); - IF( GE_32( st->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) ) - { - /* decide if SHB SID encoding or not */ - shb_SID_updt = shb_DTX_ivas_fx( st, shb_speech_fx, syn_12k8_16k_fx ); - - /* SHB CNG encoding */ - shb_CNG_encod_ivas_fx( st, shb_SID_updt ); - } - ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_32( st->core_brate, SID_2k40 ) ) - { - /* LF-boost not used in DFT-stereo, instead the bandwidth is transmitted */ - delete_indice( st->hBstr, IND_CNG_ENV1 ); - push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); - push_indice( st->hBstr, IND_UNUSED, 0, 4 ); - push_indice( st->hBstr, IND_SID_BW, 1, 1 ); - } - } - st->hTdCngEnc->last_vad = 0; - move16(); - } - ELSE - { - st->hTdCngEnc->last_vad = 1; - move16(); - } - - return; -} - - -/*---------------------------------------------------------------------* - * shb_CNG_encod() - * - * SID parameters encoding for SHB signal - *---------------------------------------------------------------------*/ - -static void shb_CNG_encod_ivas_fx( - Encoder_State *st, /* i/o: State structure */ - const Word16 update /* i : SID update flag */ -) -{ - Word16 idx_ener = 0; - move16(); - BSTR_ENC_HANDLE hBstr = st->hBstr; - - Word16 ener_mid_dec_thr_fx; - - IF( EQ_16( update, 1 ) ) - { - IF( st->element_mode == EVS_MONO ) - { - /* 6.0 in Q8 -> 1510 */ - /* 0.9 in Q15 29491 */ - /* ( 1 / log10(2.0) ) * 0.1 in Q15 ->10886 */ - idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 29491 ), 8 ); /* Q0 */ - } - ELSE - { - /*idx_ener = (int16_t)(0.7f * (0.1f * st->hTdCngEnc->mov_shb_cng_ener / (float)log10(2.0f) + 6.0f) + 0.5f);*/ - // PMT("shb_CNG_encod_fx quantization in missing") - /* 6.0 in Q8 -> 1510 */ - /* 0.7 in Q15 22938 */ - /* ( 1 / log10(2.0) ) * 0.1 in Q15 -> 10886 */ - idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 22938 ), 8 ); /* Q0 */ - } - - - if ( LT_16( st->bwidth, SWB ) ) - { - idx_ener = 0; - move16(); - } - - IF( GT_16( idx_ener, 15 ) ) - { - idx_ener = 15; - move16(); - } - ELSE IF( idx_ener < 0 ) - { - idx_ener = 0; - move16(); - } - - /* prevent toggling of idx_ener by adding small dead-zone interval around decision thresholds */ - IF( st->element_mode != EVS_MONO ) - { - IF( EQ_16( abs_s( sub( idx_ener, st->hTdCngEnc->last_idx_ener ) ), 1 ) ) - { - - Word16 tmp, tmp1, tmp2, scale, exp1, exp2, ener_mid_dec_thr_e; - tmp = BASOP_Util_Divide1616_Scale( st->hTdCngEnc->last_idx_ener, 22938, &scale ); // 0.7 in Q15 ->exp 0 - scale = add( scale, ( 15 - 0 ) ); - tmp = sub( tmp, shl( 6, sub( Q15, scale ) ) ); - tmp1 = BASOP_Util_Divide1616_Scale( tmp, 3277, &exp1 ); - exp1 = add( exp1, ( scale - 0 ) ); - - ener_mid_dec_thr_fx = shr( mult( tmp1, 9864 ), 1 ); // exp = exp - - tmp = BASOP_Util_Divide1616_Scale( idx_ener, 22938, &scale ); // 0.7 in Q15 ->exp 0 - scale = add( scale, ( 15 - 0 ) ); - tmp = sub( tmp, shl( 6, sub( Q15, scale ) ) ); - tmp1 = BASOP_Util_Divide1616_Scale( tmp, 3277, &exp2 ); - exp2 = add( exp2, ( scale - 0 ) ); - - tmp2 = shr( mult( tmp1, 9864 ), 1 ); // exp = exp - - ener_mid_dec_thr_e = BASOP_Util_Add_MantExp( tmp2, exp2, ener_mid_dec_thr_fx, exp1, &ener_mid_dec_thr_fx ); - - - scale = BASOP_Util_Add_MantExp( st->hTdCngEnc->mov_shb_cng_ener_fx, 7, negate( ener_mid_dec_thr_fx ), ener_mid_dec_thr_e, &tmp ); - tmp1 = BASOP_Util_Divide1616_Scale( tmp, ener_mid_dec_thr_fx, &exp1 ); - exp1 = add( exp1, sub( scale, ener_mid_dec_thr_e ) ); - IF( LT_16( abs_s( tmp1 ), shr( 328, sub( 15, exp1 ) ) ) ) - { - idx_ener = st->hTdCngEnc->last_idx_ener; - move16(); - } - } - } - - st->hTdCngEnc->last_idx_ener = idx_ener; - move16(); - - push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener, 4 ); - push_indice( hBstr, IND_SID_BW, 1, 1 ); - delete_indice( hBstr, IND_CNG_ENV1 ); - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); - } - ELSE - { - push_indice( hBstr, IND_UNUSED, 0, 2 ); - } - st->hTdCngEnc->ho_sid_bw = L_shl( L_and( st->hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); - st->hTdCngEnc->ho_sid_bw = L_or( st->hTdCngEnc->ho_sid_bw, 0x1L ); - move32(); - move32(); - } - ELSE IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - st->hTdCngEnc->ho_sid_bw = L_shl( L_and( st->hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); - move32(); - push_indice( hBstr, IND_SID_BW, 0, 1 ); - } - - return; -} - -/*---------------------------------------------------------------------* - * shb_DTX() - * - * Decide if encoding SHB SID or not - *---------------------------------------------------------------------*/ - -static Word16 shb_DTX_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 */ -) -{ - Word16 i; - Word16 update; - - Word16 allow_cn_step = 0; - move16(); - 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_fx; /*Q8*/ - - TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc; - TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; - - -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move16(); -#endif - - 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 ); // old_speech_shb_fx -> Q0 - Copy( shb_speech_fx, shb_new_speech_fx, L_FRAME16k ); // Q0 - Copy( shb_old_speech_fx + L_FRAME16k, hBWE_TD->old_speech_shb_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 ); // Q0 - - 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] ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac - } - - shb_ener_fx = L_add( Mpy_32_16_1( shb_ener_fx, 102 ), 1 ); /* ( 1 / L_FRAME16K ) -> 102 in Q15, shb_ener_fx in Q1 */ - - wb_ener_fx = L_deposit_l( 0 ); - FOR( i = 0; i < st->L_frame; i++ ) - { - wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k_fx[i], syn_12k8_16k_fx[i], &Overflow ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac - } - - 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_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* 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->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - Word32 att_fx32 = 0; - move32(); - Word16 index; - - apply_scale_ivas_fx( &att_fx32, st->hFdCngEnc->hFdCngCom->CngBandwidth, st->hFdCngEnc->hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO, &index ); // Q23; - - att_fx = extract_l( L_shr( att_fx32, 15 ) ); // Q8 - } - ELSE - { - att_fx = -1664; // Q8 - move16(); - } - - - log_shb_ener_fx = sub_o( round_fx_o( L_shl_o( shb_ener_fx, 10, &Overflow ), &Overflow ), att_fx, &Overflow ); /* log_shb_ener_fx in Q8 */ - - IF( st->hDtxEnc->first_CNG == 0 ) - { - - - hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; // Q8 - hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; // Q8 - hTdCngEnc->last_wb_cng_ener_fx = log_wb_ener_fx; // Q8 - hTdCngEnc->last_shb_cng_ener_fx = log_shb_ener_fx; // Q8 - move16(); - move16(); - move16(); - move16(); - } - IF( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12 in Q8*/ ) ) - { - allow_cn_step = 1; - move16(); - } - - /* Also allow step if shb energy has dropped 12 dB */ - test(); - test(); - IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GT_16( sub( hTdCngEnc->mov_shb_cng_ener_fx, log_shb_ener_fx ), 3072 /*12 in Q8*/ ) ) - { - allow_cn_step = 1; - move16(); - } - - IF( EQ_16( allow_cn_step, 1 ) ) - { - hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; - hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; - move16(); - 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 ); - update = 0; - - move16(); - move16(); - - IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - test(); - test(); - test(); - IF( st->hDtxEnc->first_CNG == 0 ) - { - update = 1; - move16(); - } - ELSE IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) - { - hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); - update = 1; - move16(); - move16(); - } - ELSE IF( EQ_16( hTdCngEnc->last_vad, 1 ) ) - { - update = 1; - move16(); - } - ELSE IF( GE_16( hTdCngEnc->shb_NO_DATA_cnt, 100 ) ) - { - update = 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 ) ) - { - update = 1; - move16(); - } - ELSE IF( ( GE_16( st->bwidth, SWB ) && LT_16( hTdCngEnc->last_SID_bwidth, SWB ) ) || ( LT_16( st->bwidth, SWB ) && GE_16( hTdCngEnc->last_SID_bwidth, SWB ) ) ) - { - update = 1; - move16(); - } - - hTdCngEnc->last_SID_bwidth = st->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->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_32( st->core_brate, SID_2k40 ) ) - { - update = 1; - move16(); - } - - IF( EQ_16( update, 1 ) ) - { - hTdCngEnc->last_wb_cng_ener_fx = hTdCngEnc->mov_wb_cng_ener_fx; - hTdCngEnc->last_shb_cng_ener_fx = hTdCngEnc->mov_shb_cng_ener_fx; - hTdCngEnc->shb_NO_DATA_cnt = 0; - move16(); - move16(); - move16(); - } - - return ( update ); -} diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 4cfc193ec..7188bcbad 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -27,6 +27,8 @@ *---------------------------------------------------------------------*/ 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 ); +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 ); /*---------------------------------------------------------------------* * CNG_enc() * @@ -2839,3 +2841,375 @@ void calculate_hangover_attenuation_gain_ivas_fx( return; } + +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 */ +) +{ + Word16 shb_SID_updt; + + test(); + IF( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA ) + { + IF( st->cng_type == LP_CNG ) + { + test(); + IF( GE_32( st->input_Fs, L_FRAME32k * FRAMES_PER_SEC ) ) + { + /* decide if SHB SID encoding or not */ + shb_SID_updt = shb_DTX_ivas_fx( st, shb_speech_fx, syn_12k8_16k_fx ); + + /* SHB CNG encoding */ + shb_CNG_encod_ivas_fx( st, shb_SID_updt ); + } + ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_32( st->core_brate, SID_2k40 ) ) + { + /* LF-boost not used in DFT-stereo, instead the bandwidth is transmitted */ + delete_indice( st->hBstr, IND_CNG_ENV1 ); + push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); + push_indice( st->hBstr, IND_UNUSED, 0, 4 ); + push_indice( st->hBstr, IND_SID_BW, 1, 1 ); + } + } + st->hTdCngEnc->last_vad = 0; + move16(); + } + ELSE + { + st->hTdCngEnc->last_vad = 1; + move16(); + } + + return; +} + + +/*---------------------------------------------------------------------* + * shb_CNG_encod() + * + * SID parameters encoding for SHB signal + *---------------------------------------------------------------------*/ + +static void shb_CNG_encod_ivas_fx( + Encoder_State *st, /* i/o: State structure */ + const Word16 update /* i : SID update flag */ +) +{ + Word16 idx_ener = 0; + move16(); + BSTR_ENC_HANDLE hBstr = st->hBstr; + + Word16 ener_mid_dec_thr_fx; + + IF( EQ_16( update, 1 ) ) + { + IF( st->element_mode == EVS_MONO ) + { + /* 6.0 in Q8 -> 1510 */ + /* 0.9 in Q15 29491 */ + /* ( 1 / log10(2.0) ) * 0.1 in Q15 ->10886 */ + idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 29491 ), 8 ); /* Q0 */ + } + ELSE + { + /*idx_ener = (int16_t)(0.7f * (0.1f * st->hTdCngEnc->mov_shb_cng_ener / (float)log10(2.0f) + 6.0f) + 0.5f);*/ + // PMT("shb_CNG_encod_fx quantization in missing") + /* 6.0 in Q8 -> 1510 */ + /* 0.7 in Q15 22938 */ + /* ( 1 / log10(2.0) ) * 0.1 in Q15 -> 10886 */ + idx_ener = shr( mult( add( mult( st->hTdCngEnc->mov_shb_cng_ener_fx, 10886 ), 1510 ), 22938 ), 8 ); /* Q0 */ + } + + + if ( LT_16( st->bwidth, SWB ) ) + { + idx_ener = 0; + move16(); + } + + IF( GT_16( idx_ener, 15 ) ) + { + idx_ener = 15; + move16(); + } + ELSE IF( idx_ener < 0 ) + { + idx_ener = 0; + move16(); + } + + /* prevent toggling of idx_ener by adding small dead-zone interval around decision thresholds */ + IF( st->element_mode != EVS_MONO ) + { + IF( EQ_16( abs_s( sub( idx_ener, st->hTdCngEnc->last_idx_ener ) ), 1 ) ) + { + + Word16 tmp, tmp1, tmp2, scale, exp1, exp2, ener_mid_dec_thr_e; + tmp = BASOP_Util_Divide1616_Scale( st->hTdCngEnc->last_idx_ener, 22938, &scale ); // 0.7 in Q15 ->exp 0 + scale = add( scale, ( 15 - 0 ) ); + tmp = sub( tmp, shl( 6, sub( Q15, scale ) ) ); + tmp1 = BASOP_Util_Divide1616_Scale( tmp, 3277, &exp1 ); + exp1 = add( exp1, ( scale - 0 ) ); + + ener_mid_dec_thr_fx = shr( mult( tmp1, 9864 ), 1 ); // exp = exp + + tmp = BASOP_Util_Divide1616_Scale( idx_ener, 22938, &scale ); // 0.7 in Q15 ->exp 0 + scale = add( scale, ( 15 - 0 ) ); + tmp = sub( tmp, shl( 6, sub( Q15, scale ) ) ); + tmp1 = BASOP_Util_Divide1616_Scale( tmp, 3277, &exp2 ); + exp2 = add( exp2, ( scale - 0 ) ); + + tmp2 = shr( mult( tmp1, 9864 ), 1 ); // exp = exp + + ener_mid_dec_thr_e = BASOP_Util_Add_MantExp( tmp2, exp2, ener_mid_dec_thr_fx, exp1, &ener_mid_dec_thr_fx ); + + + scale = BASOP_Util_Add_MantExp( st->hTdCngEnc->mov_shb_cng_ener_fx, 7, negate( ener_mid_dec_thr_fx ), ener_mid_dec_thr_e, &tmp ); + tmp1 = BASOP_Util_Divide1616_Scale( tmp, ener_mid_dec_thr_fx, &exp1 ); + exp1 = add( exp1, sub( scale, ener_mid_dec_thr_e ) ); + IF( LT_16( abs_s( tmp1 ), shr( 328, sub( 15, exp1 ) ) ) ) + { + idx_ener = st->hTdCngEnc->last_idx_ener; + move16(); + } + } + } + + st->hTdCngEnc->last_idx_ener = idx_ener; + move16(); + + push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener, 4 ); + push_indice( hBstr, IND_SID_BW, 1, 1 ); + delete_indice( hBstr, IND_CNG_ENV1 ); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) + { + push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); + } + ELSE + { + push_indice( hBstr, IND_UNUSED, 0, 2 ); + } + st->hTdCngEnc->ho_sid_bw = L_shl( L_and( st->hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); + st->hTdCngEnc->ho_sid_bw = L_or( st->hTdCngEnc->ho_sid_bw, 0x1L ); + move32(); + move32(); + } + ELSE IF( EQ_32( st->core_brate, SID_2k40 ) ) + { + st->hTdCngEnc->ho_sid_bw = L_shl( L_and( st->hTdCngEnc->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); + move32(); + push_indice( hBstr, IND_SID_BW, 0, 1 ); + } + + return; +} + +/*---------------------------------------------------------------------* + * shb_DTX() + * + * Decide if encoding SHB SID or not + *---------------------------------------------------------------------*/ + +static Word16 shb_DTX_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 */ +) +{ + Word16 i; + Word16 update; + + Word16 allow_cn_step = 0; + move16(); + 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_fx; /*Q8*/ + + TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc; + TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; + + +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move16(); +#endif + + 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 ); // old_speech_shb_fx -> Q0 + Copy( shb_speech_fx, shb_new_speech_fx, L_FRAME16k ); // Q0 + Copy( shb_old_speech_fx + L_FRAME16k, hBWE_TD->old_speech_shb_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 ); // Q0 + + 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] ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac + } + + shb_ener_fx = L_add( Mpy_32_16_1( shb_ener_fx, 102 ), 1 ); /* ( 1 / L_FRAME16K ) -> 102 in Q15, shb_ener_fx in Q1 */ + + wb_ener_fx = L_deposit_l( 0 ); + FOR( i = 0; i < st->L_frame; i++ ) + { + wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k_fx[i], syn_12k8_16k_fx[i], &Overflow ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac + } + + 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_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* 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->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) + { + Word32 att_fx32 = 0; + move32(); + Word16 index; + + apply_scale_ivas_fx( &att_fx32, st->hFdCngEnc->hFdCngCom->CngBandwidth, st->hFdCngEnc->hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO, &index ); // Q23; + + att_fx = extract_l( L_shr( att_fx32, 15 ) ); // Q8 + } + ELSE + { + att_fx = -1664; // Q8 + move16(); + } + + + log_shb_ener_fx = sub_o( round_fx_o( L_shl_o( shb_ener_fx, 10, &Overflow ), &Overflow ), att_fx, &Overflow ); /* log_shb_ener_fx in Q8 */ + + IF( st->hDtxEnc->first_CNG == 0 ) + { + + + hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; // Q8 + hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; // Q8 + hTdCngEnc->last_wb_cng_ener_fx = log_wb_ener_fx; // Q8 + hTdCngEnc->last_shb_cng_ener_fx = log_shb_ener_fx; // Q8 + move16(); + move16(); + move16(); + move16(); + } + IF( GT_16( abs_s( sub( log_wb_ener_fx, hTdCngEnc->mov_wb_cng_ener_fx ) ), 3072 /*12 in Q8*/ ) ) + { + allow_cn_step = 1; + move16(); + } + + /* Also allow step if shb energy has dropped 12 dB */ + test(); + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GT_16( sub( hTdCngEnc->mov_shb_cng_ener_fx, log_shb_ener_fx ), 3072 /*12 in Q8*/ ) ) + { + allow_cn_step = 1; + move16(); + } + + IF( EQ_16( allow_cn_step, 1 ) ) + { + hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; + hTdCngEnc->mov_shb_cng_ener_fx = log_shb_ener_fx; + move16(); + 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 ); + update = 0; + + move16(); + move16(); + + IF( EQ_32( st->core_brate, SID_2k40 ) ) + { + test(); + test(); + test(); + IF( st->hDtxEnc->first_CNG == 0 ) + { + update = 1; + move16(); + } + ELSE IF( hTdCngEnc->shb_cng_ini_cnt > 0 ) + { + hTdCngEnc->shb_cng_ini_cnt = sub( hTdCngEnc->shb_cng_ini_cnt, 1 ); + update = 1; + move16(); + move16(); + } + ELSE IF( EQ_16( hTdCngEnc->last_vad, 1 ) ) + { + update = 1; + move16(); + } + ELSE IF( GE_16( hTdCngEnc->shb_NO_DATA_cnt, 100 ) ) + { + update = 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 ) ) + { + update = 1; + move16(); + } + ELSE IF( ( GE_16( st->bwidth, SWB ) && LT_16( hTdCngEnc->last_SID_bwidth, SWB ) ) || ( LT_16( st->bwidth, SWB ) && GE_16( hTdCngEnc->last_SID_bwidth, SWB ) ) ) + { + update = 1; + move16(); + } + + hTdCngEnc->last_SID_bwidth = st->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->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_32( st->core_brate, SID_2k40 ) ) + { + update = 1; + move16(); + } + + IF( EQ_16( update, 1 ) ) + { + hTdCngEnc->last_wb_cng_ener_fx = hTdCngEnc->mov_wb_cng_ener_fx; + hTdCngEnc->last_shb_cng_ener_fx = hTdCngEnc->mov_shb_cng_ener_fx; + hTdCngEnc->shb_NO_DATA_cnt = 0; + move16(); + move16(); + move16(); + } + + return ( update ); +} diff --git a/lib_enc/cod2t32.c b/lib_enc/cod2t32.c deleted file mode 100644 index 167c70dbf..000000000 --- a/lib_enc/cod2t32.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/cod4t64.c b/lib_enc/cod4t64.c deleted file mode 100644 index 9be976783..000000000 --- a/lib_enc/cod4t64.c +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------------*/ diff --git a/lib_enc/cod_ace.c b/lib_enc/cod_ace.c deleted file mode 100644 index 46d7a42d1..000000000 --- a/lib_enc/cod_ace.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "prot.h" -#include -#include "options.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c deleted file mode 100644 index 88e028c86..000000000 --- a/lib_enc/cod_tcx.c +++ /dev/null @@ -1,869 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" -#include "ivas_prot.h" -#include "ivas_rom_com.h" -#include "ivas_rom_com_fx.h" -#include "prot_fx_enc.h" -#include "prot_fx.h" -#include "ivas_prot_fx.h" - - -/*-------------------------------------------------------------------* - * TNSAnalysisStereo() - * - * - *-------------------------------------------------------------------*/ - -#define SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ( 1311 ) -#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q7 ( 384 ) -#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ( 25165824 ) -void TNSAnalysisStereo_fx( - Encoder_State **sts, /* i : encoder state handle */ - Word32 *mdst_spectrum_fx[CPE_CHANNELS][NB_DIV], /* o : MDST spectrum Qx*/ - const Word16 bWhitenedDomain, /* i : whitened domain flag Q0*/ - Word16 tnsSize[CPE_CHANNELS][NB_DIV], /* i : number of tns parameters put into prm Q0*/ - Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* i : number of tns bits in the frame Q0*/ - Word16 param_core[][NB_DIV * NPRM_DIV], /* o : TNS parameters Q0*/ - const Word16 mct_on /* i : flag mct block (1) or stereo (0) Q0*/ -) -{ - Word16 ch, k, L_spec, L_frame, nSubframes, iFilter; - Word32 *spectrum_fx; - Encoder_State *st = NULL; - TCX_ENC_HANDLE hTcxEnc = NULL; - Word16 individual_decision[NB_DIV]; - Word32 maxPredictionGain_fx = 0, meanPredictionGain_fx; - move32(); - Word16 maxPredictionGain_e = Q31, meanPredictionGain_e; - move16(); - Word16 sum_e = 0; - move16(); - individual_decision[0] = 0; - move16(); - individual_decision[1] = 0; - move16(); - L_spec = -1; - move16(); - L_frame = -1; - move16(); - - /* TNS filter analysis, loop over channels */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = sts[ch]; - IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) - { - continue; - } - - hTcxEnc = st->hTcxEnc; - - IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) ) - { - nSubframes = 1; - } - ELSE - { - nSubframes = NB_DIV; - } - move16(); - - FOR( k = 0; k < nSubframes; k++ ) - { - /* reset tns on whitened domain flag */ - IF( !bWhitenedDomain ) - { - hTcxEnc->bTnsOnWhithenedSpectra[k] = 0; - move16(); - hTcxEnc->fUseTns[k] = 0; - move16(); - } - test(); - test(); - IF( st->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) - { - spectrum_fx = hTcxEnc->spectrum_fx[k]; - - L_frame = hTcxEnc->L_frameTCX; - move16(); - st->hTcxCfg->pCurrentTnsConfig = &st->hTcxCfg->tnsConfig[hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( st->last_core == ACELP_CORE )]; - L_spec = st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0]; - move16(); - /*-----------------------------------------------------------* - * Temporal Noise Shaping analysis * - *-----------------------------------------------------------*/ - - IF( EQ_16( hTcxEnc->transform_type[k], TCX_5 ) ) - { - /* rearrange LF sub-window lines prior to TNS analysis & filtering */ - tcx5TnsGrouping_fx( shr( L_frame, 2 ), shr( L_spec, 1 ), spectrum_fx ); - } - - /* WMOPS: All initializations are either for safety or static (tables) and thus not to be counted */ - - ResetTnsData( &hTcxEnc->tnsData[k] ); - IF( st->hTcxCfg->pCurrentTnsConfig->maxOrder <= 0 ) - { - BREAK; - } - - CalculateTnsFilt_fx( st->hTcxCfg->pCurrentTnsConfig, spectrum_fx, hTcxEnc->spectrum_e[k], &hTcxEnc->tnsData[k] ); - } - } - } - - IF( !mct_on ) - { - /* TNS decision */ - /* if framing differs between channels, keep the filter decision per channel */ - test(); - test(); - IF( ( NE_16( sts[0]->hTcxEnc->transform_type[0], sts[1]->hTcxEnc->transform_type[0] ) && - NE_16( sts[0]->hTcxEnc->transform_type[1], sts[1]->hTcxEnc->transform_type[1] ) ) || - NE_16( sts[0]->hTcxCfg->fIsTNSAllowed, sts[1]->hTcxCfg->fIsTNSAllowed ) ) - { - individual_decision[0] = individual_decision[1] = 1; - move16(); - move16(); - } - ELSE IF( bWhitenedDomain ) - { - IF( EQ_16( sts[0]->hTcxEnc->tcxMode, TCX_20 ) ) - { - nSubframes = 1; - } - ELSE - { - nSubframes = NB_DIV; - } - move16(); - FOR( k = 0; k < nSubframes; k++ ) - { - IF( NE_16( sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k], sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) - { - individual_decision[k] = 1; - move16(); - } - } - } - - /* framing equal, check for similar filters, if very similar (also indicator for and M signal), - * use at least the same decision, maybe use the same filter - */ - { - Word8 isTCX10; - - IF( EQ_16( sts[0]->hTcxEnc->tcxMode, TCX_20 ) ) - { - nSubframes = 1; - isTCX10 = 0; - } - ELSE - { - nSubframes = NB_DIV; - isTCX10 = 1; - } - move16(); - move16(); - FOR( k = 0; k < nSubframes; k++ ) - { - test(); - test(); - test(); - IF( sts[0]->hTcxCfg->fIsTNSAllowed && NE_16( individual_decision[k], 1 ) && ( !bWhitenedDomain || sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) - { - Word32 maxPredGain_fx = -ONE_IN_Q31; - move32(); - Word16 maxPredGain_e = 0; - move16(); - sts[0]->hTcxCfg->pCurrentTnsConfig = &sts[0]->hTcxCfg->tnsConfig[sts[0]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[0]->last_core == ACELP_CORE )]; - sts[1]->hTcxCfg->pCurrentTnsConfig = &sts[1]->hTcxCfg->tnsConfig[sts[1]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[1]->last_core == ACELP_CORE )]; - - FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - STnsFilter *pFilter[2]; - struct TnsParameters const *pTnsParameters[2]; - pFilter[0] = sts[0]->hTcxEnc->tnsData[k].filter + iFilter; - pTnsParameters[0] = sts[0]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; - pFilter[1] = sts[1]->hTcxEnc->tnsData[k].filter + iFilter; - pTnsParameters[1] = sts[1]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; - - /* if prediction gain and avgSqrCoef are both close we are pretty sure the filters are quite similar, use the avg of - * both filters for the decision - */ - - meanPredictionGain_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[0]->predictionGain_e, Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[1]->predictionGain_e, &meanPredictionGain_e ); // meanPredictionGain_e - Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, meanPredictionGain_fx, meanPredictionGain_e ); - IF( flag < 0 ) - { - maxPredictionGain_fx = meanPredictionGain_fx; - maxPredictionGain_e = meanPredictionGain_e; - move32(); - move16(); - } - flag = BASOP_Util_Cmp_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - Word16 flag_1 = BASOP_Util_Cmp_Mant32Exp( pFilter[1]->predictionGain32, pFilter[1]->predictionGain_e, L_deposit_h( pTnsParameters[1]->minPredictionGain ), PRED_GAIN_E ); - if ( flag_1 < 0 ) - { - flag_1 = 0; - move16(); - } - test(); - test(); - test(); - IF( flag && LT_32( sts[0]->element_brate, IVAS_80k ) && - flag_1 && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) - { - pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ - move32(); - move32(); - pFilter[0]->predictionGain_e = pFilter[1]->predictionGain_e = meanPredictionGain_e; /* more TNS filter sync at 48kbps */ - move16(); - move16(); - pFilter[0]->predictionGain = pFilter[1]->predictionGain = shl_sat( extract_h( meanPredictionGain_fx ), sub( meanPredictionGain_e, PRED_GAIN_E ) ); /* Q7 */ - move16(); - move16(); - } - flag = BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ), meanPredictionGain_e, L_abs( BASOP_Util_Add_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_negate( pFilter[1]->predictionGain32 ), pFilter[1]->predictionGain_e, &sum_e ) ), sum_e ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - test(); - IF( flag && - ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) ) - { - - Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15 - Word16 meanLtpGain_fx = add( shr( sts[0]->hTcxEnc->tcxltp_gain, 1 ), shr( sts[1]->hTcxEnc->tcxltp_gain, 1 ) ); - // maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); - flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, meanPredictionGain_fx, meanPredictionGain_e ); - IF( flag < 0 ) - { - maxPredGain_fx = meanPredictionGain_fx; - maxPredGain_e = meanPredictionGain_e; - move32(); - move16(); - } - flag = BASOP_Util_Cmp_Mant32Exp( meanPredictionGain_fx, meanPredictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - test(); - test(); - IF( flag || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) - { - test(); - test(); - test(); - IF( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 || sts[1]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( meanLtpGain_fx, 19660 /* 0.6 in Q15*/ ) ) - { - - sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, - this may result in crash later. Changing the filter type here so the order is taken here in further section */ - IF( pFilter[0]->order != 0 ) - { - pFilter[0]->filterType = TNS_FILTER_ON; - move16(); - } - ELSE - { - pFilter[0]->filterType = TNS_FILTER_ON_ZERO; - move16(); - } - sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - IF( pFilter[1]->order != 0 ) - { - pFilter[1]->filterType = TNS_FILTER_ON; - move16(); - } - ELSE - { - pFilter[1]->filterType = TNS_FILTER_ON_ZERO; - move16(); - } - } - ELSE - { - Word16 maxEnergyChange_fx; - maxEnergyChange_fx = mac_r( L_mult( GetTCXMaxenergyChange_ivas_fx( sts[0]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ), GetTCXMaxenergyChange_ivas_fx( sts[1]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ); - - IF( GE_16( maxEnergyChange_fx, shl( pTnsParameters[0]->minEnergyChange, Q3 - Q7 ) ) ) - { - sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, - this may result in crash later. Changing the filter type here so the order is taken here in further section */ - IF( pFilter[0]->order != 0 ) - { - pFilter[0]->filterType = TNS_FILTER_ON; - move16(); - } - ELSE - { - pFilter[0]->filterType = TNS_FILTER_ON_ZERO; - move16(); - } - sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - IF( pFilter[1]->order != 0 ) - { - pFilter[1]->filterType = TNS_FILTER_ON; - move16(); - } - ELSE - { - pFilter[1]->filterType = TNS_FILTER_ON_ZERO; - move16(); - } - } - ELSE - { - pFilter[0]->filterType = TNS_FILTER_OFF; - move16(); - pFilter[1]->filterType = TNS_FILTER_OFF; - move16(); - } - } - } - ELSE IF( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 && sts[1]->hTcxEnc->tnsData[k].nFilters > 0 ) /* If a previous filter is turned on */ - { - pFilter[0]->filterType = TNS_FILTER_ON_ZERO; - pFilter[1]->filterType = TNS_FILTER_ON_ZERO; - move16(); - move16(); - sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - } - ELSE IF( NE_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) /* sanity check */ - { - assert( 0 ); - } - ELSE - { - pFilter[0]->filterType = TNS_FILTER_OFF; - move16(); - pFilter[1]->filterType = TNS_FILTER_OFF; - move16(); - } - - test(); - test(); - IF( EQ_16( pFilter[0]->filterType, TNS_FILTER_ON ) && EQ_16( pFilter[1]->filterType, TNS_FILTER_ON ) && LT_32( sts[0]->element_brate, IVAS_80k ) ) - { - Word16 tmpIntValue = 0; - move16(); - Word16 tmpCoeff[TNS_MAX_FILTER_ORDER]; - Word16 i, maxOrder = s_max( pFilter[0]->order, pFilter[1]->order ); - - set16_fx( tmpCoeff, 0, TNS_MAX_FILTER_ORDER ); - FOR( i = 0; i < maxOrder; i++ ) - { - tmpIntValue = s_max( tmpIntValue, abs_s( sub( pFilter[0]->coefIndex[i], pFilter[1]->coefIndex[i] ) ) ); - } - - IF( EQ_16( tmpIntValue, 1 ) ) /* the TNS coefficients are sufficiently similar to equalize the two filters */ - { - FOR( i = maxOrder - 1; i >= 0; i-- ) - { - IF( LT_16( abs_s( pFilter[0]->coefIndex[i] ), abs_s( pFilter[1]->coefIndex[i] ) ) ) - { - tmpCoeff[i] = pFilter[0]->coefIndex[i]; - } - ELSE - { - tmpCoeff[i] = pFilter[1]->coefIndex[i]; - } - move16(); - IF( ( tmpIntValue > 0 ) && ( tmpCoeff[i] == 0 ) ) - { - maxOrder = sub( maxOrder, 1 ); - } - ELSE - { - tmpIntValue = 0; - move16(); - } - } - /* make sure that maxOrder is non zero and not all coefficients are zero (could happen in rare cases) */ - IF( maxOrder > 0 ) - { - FOR( i = TNS_MAX_FILTER_ORDER - 1; i >= 0; i-- ) - { - pFilter[0]->coefIndex[i] = pFilter[1]->coefIndex[i] = tmpCoeff[i]; - move16(); - move16(); - } - - pFilter[0]->order = pFilter[1]->order = maxOrder; - move16(); - move16(); - } - } - } - } - ELSE - { - individual_decision[k] = 1; - move16(); - } - } - - IF( individual_decision[k] == 0 ) - { - IF( ( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 ) ) - { - sts[0]->hTcxEnc->fUseTns[k] = 1; - } - ELSE - { - sts[0]->hTcxEnc->fUseTns[k] = 0; - } - move16(); - - IF( ( sts[1]->hTcxEnc->tnsData[k].nFilters > 0 ) ) - { - sts[1]->hTcxEnc->fUseTns[k] = 1; - } - ELSE - { - sts[1]->hTcxEnc->fUseTns[k] = 0; - } - move16(); - } - ELSE - { - sts[0]->hTcxEnc->tnsData[k].nFilters = 0; - move16(); - sts[1]->hTcxEnc->tnsData[k].nFilters = 0; - move16(); - sts[0]->hTcxEnc->fUseTns[k] = 0; - move16(); - sts[1]->hTcxEnc->fUseTns[k] = 0; - move16(); - FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - sts[0]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF; - move16(); - sts[1]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF; - move16(); - } - } - Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - test(); - test(); - test(); - IF( !bWhitenedDomain && individual_decision[k] == 0 && flag && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) - { - sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; - move16(); - sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; - move16(); - sts[0]->hTcxEnc->tnsData[k].nFilters = 0; - move16(); - sts[1]->hTcxEnc->tnsData[k].nFilters = 0; - move16(); - sts[0]->hTcxEnc->fUseTns[k] = 0; - move16(); - sts[1]->hTcxEnc->fUseTns[k] = 0; - move16(); - FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - ClearTnsFilterCoefficients( sts[0]->hTcxEnc->tnsData[k].filter + iFilter ); - ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter ); - } - } - // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); - flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); - IF( flag < 0 ) - { - maxPredictionGain_fx = maxPredGain_fx; - maxPredictionGain_e = maxPredGain_e; - move32(); - move16(); - } - } - } - } - } - - /* individual decision for each channel */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) - { - CONTINUE; - } - - Word8 isTCX10; - - IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) - { - nSubframes = 1; - isTCX10 = 0; - } - ELSE - { - nSubframes = NB_DIV; - isTCX10 = 1; - } - move16(); - move16(); - - FOR( k = 0; k < nSubframes; k++ ) - { - test(); - test(); - test(); - test(); - IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( individual_decision[k] || mct_on ) && - ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) - { - Word32 maxPredGain_fx = -ONE_IN_Q31; // Q31 - move32(); - Word16 maxPredGain_e = 0; - move16(); - sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; - - FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - STnsFilter *pFilter; - struct TnsParameters const *pTnsParameters; - pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; - pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; - - // maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); - Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, pFilter->predictionGain32, pFilter->predictionGain_e ); - IF( flag < 0 ) - { - maxPredGain_fx = pFilter->predictionGain32; - move32(); - maxPredGain_e = pFilter->predictionGain_e; - move16(); - } - flag = BASOP_Util_Cmp_Mant32Exp( pFilter->predictionGain32, pFilter->predictionGain_e, L_deposit_h( pTnsParameters->minPredictionGain ), PRED_GAIN_E ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - test(); - IF( flag || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) - { - test(); - test(); - IF( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( sts[ch]->hTcxEnc->tcxltp_gain, 19660 /*.6f in Q15*/ ) ) - { - sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, - this may result in crash later. Changing the filter type here so the order is taken here in further section */ - IF( pFilter->order != 0 ) - { - pFilter->filterType = TNS_FILTER_ON; - move16(); - } - ELSE - { - pFilter->filterType = TNS_FILTER_ON_ZERO; - move16(); - } - } - ELSE - { - Word16 maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( sts[ch]->hTranDet, isTCX10, NSUBBLOCKS, 3 ); - - IF( GE_16( maxEnergyChange_fx, shl( pTnsParameters->minEnergyChange, Q3 - Q7 ) ) ) - { - sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, - this may result in crash later. Changing the filter type here so the order is taken here in further section */ - IF( pFilter->order != 0 ) - { - pFilter->filterType = TNS_FILTER_ON; - move16(); - } - ELSE - { - pFilter->filterType = TNS_FILTER_ON_ZERO; - move16(); - } - } - ELSE - { - pFilter->filterType = TNS_FILTER_OFF; - move16(); - } - } - } - ELSE IF( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) /* If a previous filter is turned on */ - { - pFilter->filterType = TNS_FILTER_ON_ZERO; - move16(); - sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); - move16(); - } - ELSE - { - pFilter->filterType = TNS_FILTER_OFF; - move16(); - } - } - - IF( ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) ) - { - sts[ch]->hTcxEnc->fUseTns[k] = 1; - } - ELSE - { - sts[ch]->hTcxEnc->fUseTns[k] = 0; - } - move16(); - Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - test(); - test(); - IF( !bWhitenedDomain && flag && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) - { - sts[ch]->hTcxEnc->fUseTns[k] = 0; - move16(); - sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; - move16(); - sts[ch]->hTcxEnc->tnsData[k].nFilters = 0; - move16(); - FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - ClearTnsFilterCoefficients( sts[ch]->hTcxEnc->tnsData[k].filter + iFilter ); - sts[ch]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF; - move16(); - } - } - // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); - flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); - IF( flag < 0 ) - { - maxPredictionGain_fx = maxPredGain_fx; - maxPredictionGain_e = maxPredGain_e; - move32(); - move16(); - } - } - } - } - - - /* we have the decision, set filter data accordingly */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( EQ_16( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) - { - CONTINUE; - } - - IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) - { - nSubframes = 1; - } - ELSE - { - nSubframes = NB_DIV; - } - move16(); - FOR( k = 0; k < nSubframes; k++ ) - { - test(); - test(); - IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) - { - sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; - - FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - STnsFilter *pFilter; - pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; - SWITCH( pFilter->filterType ) - { - case TNS_FILTER_OFF: - ClearTnsFilterCoefficients( sts[ch]->hTcxEnc->tnsData[k].filter + iFilter ); - BREAK; - case TNS_FILTER_ON_ZERO: - /* Since TNS filter of order 0 is not allowed we have to signal in the stream filter of order 1 with the 0th coefficient equal to 0 */ - ClearTnsFilterCoefficients( pFilter ); - pFilter->order = 1; - move16(); - BREAK; - } - } - } - } - } - - /* Apply filters, loop over channels */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = sts[ch]; - IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) - { - CONTINUE; - } - - IF( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) - { - nSubframes = 1; - } - ELSE - { - nSubframes = NB_DIV; - } - move16(); - - FOR( k = 0; k < nSubframes; k++ ) - { - test(); - test(); - test(); - test(); - test(); - IF( bWhitenedDomain && ( ch > 0 ) && /* test for identical TNS filter data in both channels */ - sts[0]->hTcxCfg->fIsTNSAllowed && sts[0]->hTcxEnc->fUseTns[k] && - sts[1]->hTcxCfg->fIsTNSAllowed && sts[1]->hTcxEnc->fUseTns[k] ) - { - Word16 equalFilterData = 0; - move16(); - test(); - test(); - if ( EQ_16( sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, sts[1]->hTcxCfg->pCurrentTnsConfig->nMaxFilters ) && - EQ_16( sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k], sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) && - EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) - { - equalFilterData = 1; - move16(); - } - - IF( equalFilterData ) - { - FOR( iFilter = st->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) - { - const Word16 *pDataCh0 = (const Word16 *) &sts[0]->hTcxEnc->tnsData[k].filter[iFilter]; - const Word16 *pDataCh1 = (const Word16 *) &sts[1]->hTcxEnc->tnsData[k].filter[iFilter]; - Word16 i = 2 + TNS_MAX_FILTER_ORDER; /* excl. informative float data. Portable? */ - - move16(); - test(); - WHILE( ( i >= 0 ) && EQ_16( pDataCh0[i], pDataCh1[i] ) ) - { - test(); - i = sub( i, 1 ); - } - IF( i >= 0 ) - { - equalFilterData = 0; - move16(); - BREAK; - } - } - IF( equalFilterData ) - { - st->hTcxEnc->tnsData[k].nFilters = i_mult( st->hTcxEnc->tnsData[k].nFilters, -1 ); /* signals common TNS */ - move16(); - } - } - } - test(); - test(); - IF( st->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || st->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) - { - L_spec = st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0]; - move16(); - spectrum_fx = st->hTcxEnc->spectrum_fx[k]; - /* If TNS should be used then get the residual after applying it inplace in the spectrum */ - IF( st->hTcxEnc->fUseTns[k] ) - { - st->hTcxCfg->pCurrentTnsConfig = &st->hTcxCfg->tnsConfig[st->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( st->last_core == ACELP_CORE )]; - - ApplyTnsFilter( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], spectrum_fx, 1 ); - } - - IF( EQ_16( st->hTcxEnc->transform_type[k], TCX_5 ) ) - { - tcx5TnsUngrouping_fx( shr( L_frame, 2 ), shr( L_spec, 1 ), st->hTcxEnc->spectrum_fx[k], ENC ); - } - - st->hTcxEnc->tnsData[k].tnsOnWhitenedSpectra = st->hTcxEnc->bTnsOnWhithenedSpectra[k]; - move16(); - EncodeTnsData_ivas_fx( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], param_core[ch] + k * NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, tnsSize[ch] + k, tnsBits[ch] + k ); - } - - IF( EQ_16( st->hTcxEnc->transform_type[k], TCX_5 ) ) - { - tcx5SpectrumInterleaving_fx( st->hTcxCfg->tcx5SizeFB, st->hTcxEnc->spectrum_fx[k] ); - tcx5SpectrumInterleaving_fx( st->hTcxCfg->tcx5SizeFB, mdst_spectrum_fx[ch][k] ); - } - } - } - return; -} diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index b2fe04ce1..bf20608b0 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -26,6 +26,9 @@ #include "debug.h" #endif +#define SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ( 1311 ) +#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q7 ( 384 ) +#define TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ( 25165824 ) /* Up to the Autocorrelation it is the same code as in GetMDCT, with the difference in the parameters in the call to tcx_windowing_analysis */ void HBAutocorrelation_fx( @@ -5363,3 +5366,721 @@ void InternalTCXDecoder_fx( return; } + + +void TNSAnalysisStereo_fx( + Encoder_State **sts, /* i : encoder state handle */ + Word32 *mdst_spectrum_fx[CPE_CHANNELS][NB_DIV], /* o : MDST spectrum Qx*/ + const Word16 bWhitenedDomain, /* i : whitened domain flag Q0*/ + Word16 tnsSize[CPE_CHANNELS][NB_DIV], /* i : number of tns parameters put into prm Q0*/ + Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* i : number of tns bits in the frame Q0*/ + Word16 param_core[][NB_DIV * NPRM_DIV], /* o : TNS parameters Q0*/ + const Word16 mct_on /* i : flag mct block (1) or stereo (0) Q0*/ +) +{ + Word16 ch, k, L_spec, L_frame, nSubframes, iFilter; + Word32 *spectrum_fx; + Encoder_State *st = NULL; + TCX_ENC_HANDLE hTcxEnc = NULL; + Word16 individual_decision[NB_DIV]; + Word32 maxPredictionGain_fx = 0, meanPredictionGain_fx; + move16(); + + individual_decision[0] = 0; + move16(); + individual_decision[1] = 0; + move16(); + L_spec = -1; + move16(); + L_frame = -1; + move16(); + + /* TNS filter analysis, loop over channels */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + st = sts[ch]; + IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + { + continue; + } + + hTcxEnc = st->hTcxEnc; + + IF( EQ_16( hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + } + ELSE + { + nSubframes = NB_DIV; + } + move16(); + + FOR( k = 0; k < nSubframes; k++ ) + { + /* reset tns on whitened domain flag */ + IF( !bWhitenedDomain ) + { + hTcxEnc->bTnsOnWhithenedSpectra[k] = 0; + move16(); + hTcxEnc->fUseTns[k] = 0; + move16(); + } + test(); + test(); + IF( st->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) + { + spectrum_fx = hTcxEnc->spectrum_fx[k]; + + L_frame = hTcxEnc->L_frameTCX; + move16(); + st->hTcxCfg->pCurrentTnsConfig = &st->hTcxCfg->tnsConfig[hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( st->last_core == ACELP_CORE )]; + L_spec = st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0]; + move16(); + /*-----------------------------------------------------------* + * Temporal Noise Shaping analysis * + *-----------------------------------------------------------*/ + + IF( EQ_16( hTcxEnc->transform_type[k], TCX_5 ) ) + { + /* rearrange LF sub-window lines prior to TNS analysis & filtering */ + tcx5TnsGrouping_fx( shr( L_frame, 2 ), shr( L_spec, 1 ), spectrum_fx ); + } + + /* WMOPS: All initializations are either for safety or static (tables) and thus not to be counted */ + + ResetTnsData( &hTcxEnc->tnsData[k] ); + IF( st->hTcxCfg->pCurrentTnsConfig->maxOrder <= 0 ) + { + BREAK; + } + + CalculateTnsFilt_fx( st->hTcxCfg->pCurrentTnsConfig, spectrum_fx, hTcxEnc->spectrum_e[k], &hTcxEnc->tnsData[k] ); + } + } + } + + IF( !mct_on ) + { + /* TNS decision */ + /* if framing differs between channels, keep the filter decision per channel */ + test(); + test(); + IF( ( NE_16( sts[0]->hTcxEnc->transform_type[0], sts[1]->hTcxEnc->transform_type[0] ) && + NE_16( sts[0]->hTcxEnc->transform_type[1], sts[1]->hTcxEnc->transform_type[1] ) ) || + NE_16( sts[0]->hTcxCfg->fIsTNSAllowed, sts[1]->hTcxCfg->fIsTNSAllowed ) ) + { + individual_decision[0] = individual_decision[1] = 1; + move16(); + move16(); + } + ELSE IF( bWhitenedDomain ) + { + IF( EQ_16( sts[0]->hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + } + ELSE + { + nSubframes = NB_DIV; + } + move16(); + FOR( k = 0; k < nSubframes; k++ ) + { + IF( NE_16( sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k], sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) + { + individual_decision[k] = 1; + move16(); + } + } + } + + /* framing equal, check for similar filters, if very similar (also indicator for and M signal), + * use at least the same decision, maybe use the same filter + */ + { + Word8 isTCX10; + + IF( EQ_16( sts[0]->hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + isTCX10 = 0; + } + ELSE + { + nSubframes = NB_DIV; + isTCX10 = 1; + } + move16(); + move16(); + FOR( k = 0; k < nSubframes; k++ ) + { + test(); + test(); + test(); + IF( sts[0]->hTcxCfg->fIsTNSAllowed && NE_16( individual_decision[k], 1 ) && ( !bWhitenedDomain || sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) + { + Word32 maxPredGain_fx = -ONE_IN_Q23; + move16(); + sts[0]->hTcxCfg->pCurrentTnsConfig = &sts[0]->hTcxCfg->tnsConfig[sts[0]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[0]->last_core == ACELP_CORE )]; + sts[1]->hTcxCfg->pCurrentTnsConfig = &sts[1]->hTcxCfg->tnsConfig[sts[1]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[1]->last_core == ACELP_CORE )]; + + FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + STnsFilter *pFilter[2]; + struct TnsParameters const *pTnsParameters[2]; + pFilter[0] = sts[0]->hTcxEnc->tnsData[k].filter + iFilter; + pTnsParameters[0] = sts[0]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; + pFilter[1] = sts[1]->hTcxEnc->tnsData[k].filter + iFilter; + pTnsParameters[1] = sts[1]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; + + /* if prediction gain and avgSqrCoef are both close we are pretty sure the filters are quite similar, use the avg of + * both filters for the decision + */ + + meanPredictionGain_fx = L_add( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ) ); // Q23 + maxPredictionGain_fx = L_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q23 + + test(); + test(); + test(); + IF( GT_32( pFilter[0]->predictionGain32, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) && + GT_32( pFilter[1]->predictionGain32, L_shl( pTnsParameters[1]->minPredictionGain, 16 ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + { + pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ + move16(); + move16(); + } + test(); + IF( LT_32( L_abs( L_sub( pFilter[0]->predictionGain32, pFilter[1]->predictionGain32 ) ), Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ) ) && + ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) ) + { + + Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15 + Word16 meanLtpGain_fx = add( shr( sts[0]->hTcxEnc->tcxltp_gain, 1 ), shr( sts[1]->hTcxEnc->tcxltp_gain, 1 ) ); + maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); + test(); + test(); + IF( GT_32( meanPredictionGain_fx, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) + { + test(); + test(); + test(); + IF( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 || sts[1]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( meanLtpGain_fx, 19660 /* 0.6 in Q15*/ ) ) + { + + sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, + this may result in crash later. Changing the filter type here so the order is taken here in further section */ + IF( pFilter[0]->order != 0 ) + { + pFilter[0]->filterType = TNS_FILTER_ON; + move16(); + } + ELSE + { + pFilter[0]->filterType = TNS_FILTER_ON_ZERO; + move16(); + } + sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + IF( pFilter[1]->order != 0 ) + { + pFilter[1]->filterType = TNS_FILTER_ON; + move16(); + } + ELSE + { + pFilter[1]->filterType = TNS_FILTER_ON_ZERO; + move16(); + } + } + ELSE + { + Word16 maxEnergyChange_fx; + maxEnergyChange_fx = mac_r( L_mult( GetTCXMaxenergyChange_ivas_fx( sts[0]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ), GetTCXMaxenergyChange_ivas_fx( sts[1]->hTranDet, isTCX10, NSUBBLOCKS, 3 ), 16384 ); + + IF( GE_16( maxEnergyChange_fx, shl( pTnsParameters[0]->minEnergyChange, Q3 - Q7 ) ) ) + { + sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, + this may result in crash later. Changing the filter type here so the order is taken here in further section */ + IF( pFilter[0]->order != 0 ) + { + pFilter[0]->filterType = TNS_FILTER_ON; + move16(); + } + ELSE + { + pFilter[0]->filterType = TNS_FILTER_ON_ZERO; + move16(); + } + sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + IF( pFilter[1]->order != 0 ) + { + pFilter[1]->filterType = TNS_FILTER_ON; + move16(); + } + ELSE + { + pFilter[1]->filterType = TNS_FILTER_ON_ZERO; + move16(); + } + } + ELSE + { + pFilter[0]->filterType = TNS_FILTER_OFF; + move16(); + pFilter[1]->filterType = TNS_FILTER_OFF; + move16(); + } + } + } + ELSE IF( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 && sts[1]->hTcxEnc->tnsData[k].nFilters > 0 ) /* If a previous filter is turned on */ + { + pFilter[0]->filterType = TNS_FILTER_ON_ZERO; + pFilter[1]->filterType = TNS_FILTER_ON_ZERO; + move16(); + move16(); + sts[0]->hTcxEnc->tnsData[k].nFilters = add( sts[0]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + sts[1]->hTcxEnc->tnsData[k].nFilters = add( sts[1]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + } + ELSE IF( NE_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) /* sanity check */ + { + assert( 0 ); + } + ELSE + { + pFilter[0]->filterType = TNS_FILTER_OFF; + move16(); + pFilter[1]->filterType = TNS_FILTER_OFF; + move16(); + } + + test(); + test(); + IF( EQ_16( pFilter[0]->filterType, TNS_FILTER_ON ) && EQ_16( pFilter[1]->filterType, TNS_FILTER_ON ) && LT_32( sts[0]->element_brate, IVAS_80k ) ) + { + Word16 tmpIntValue = 0; + move16(); + Word16 tmpCoeff[TNS_MAX_FILTER_ORDER]; + Word16 i, maxOrder = s_max( pFilter[0]->order, pFilter[1]->order ); + + set16_fx( tmpCoeff, 0, TNS_MAX_FILTER_ORDER ); + FOR( i = 0; i < maxOrder; i++ ) + { + tmpIntValue = s_max( tmpIntValue, abs_s( sub( pFilter[0]->coefIndex[i], pFilter[1]->coefIndex[i] ) ) ); + } + + IF( EQ_16( tmpIntValue, 1 ) ) /* the TNS coefficients are sufficiently similar to equalize the two filters */ + { + FOR( i = maxOrder - 1; i >= 0; i-- ) + { + IF( LT_16( abs_s( pFilter[0]->coefIndex[i] ), abs_s( pFilter[1]->coefIndex[i] ) ) ) + { + tmpCoeff[i] = pFilter[0]->coefIndex[i]; + } + ELSE + { + tmpCoeff[i] = pFilter[1]->coefIndex[i]; + } + move16(); + IF( ( tmpIntValue > 0 ) && ( tmpCoeff[i] == 0 ) ) + { + maxOrder = sub( maxOrder, 1 ); + } + ELSE + { + tmpIntValue = 0; + move16(); + } + } + /* make sure that maxOrder is non zero and not all coefficients are zero (could happen in rare cases) */ + IF( maxOrder > 0 ) + { + FOR( i = TNS_MAX_FILTER_ORDER - 1; i >= 0; i-- ) + { + pFilter[0]->coefIndex[i] = pFilter[1]->coefIndex[i] = tmpCoeff[i]; + move16(); + move16(); + } + + pFilter[0]->order = pFilter[1]->order = maxOrder; + move16(); + move16(); + } + } + } + } + ELSE + { + individual_decision[k] = 1; + move16(); + } + } + + IF( individual_decision[k] == 0 ) + { + IF( ( sts[0]->hTcxEnc->tnsData[k].nFilters > 0 ) ) + { + sts[0]->hTcxEnc->fUseTns[k] = 1; + } + ELSE + { + sts[0]->hTcxEnc->fUseTns[k] = 0; + } + move16(); + + IF( ( sts[1]->hTcxEnc->tnsData[k].nFilters > 0 ) ) + { + sts[1]->hTcxEnc->fUseTns[k] = 1; + } + ELSE + { + sts[1]->hTcxEnc->fUseTns[k] = 0; + } + move16(); + } + ELSE + { + sts[0]->hTcxEnc->tnsData[k].nFilters = 0; + move16(); + sts[1]->hTcxEnc->tnsData[k].nFilters = 0; + move16(); + sts[0]->hTcxEnc->fUseTns[k] = 0; + move16(); + sts[1]->hTcxEnc->fUseTns[k] = 0; + move16(); + FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + sts[0]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF; + move16(); + sts[1]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF; + move16(); + } + } + test(); + test(); + test(); + IF( !bWhitenedDomain && individual_decision[k] == 0 && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) + { + sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; + move16(); + sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; + move16(); + sts[0]->hTcxEnc->tnsData[k].nFilters = 0; + move16(); + sts[1]->hTcxEnc->tnsData[k].nFilters = 0; + move16(); + sts[0]->hTcxEnc->fUseTns[k] = 0; + move16(); + sts[1]->hTcxEnc->fUseTns[k] = 0; + move16(); + FOR( iFilter = sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + ClearTnsFilterCoefficients( sts[0]->hTcxEnc->tnsData[k].filter + iFilter ); + ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter ); + } + } + maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + } + } + } + } + + /* individual decision for each channel */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + { + CONTINUE; + } + + Word8 isTCX10; + + IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + isTCX10 = 0; + } + ELSE + { + nSubframes = NB_DIV; + isTCX10 = 1; + } + move16(); + move16(); + + FOR( k = 0; k < nSubframes; k++ ) + { + test(); + test(); + test(); + test(); + IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( individual_decision[k] || mct_on ) && + ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) + { + Word32 maxPredGain_fx = -ONE_IN_Q23; // Q23 + move16(); + sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; + + FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + STnsFilter *pFilter; + struct TnsParameters const *pTnsParameters; + pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; + pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; + + maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); + test(); + IF( GT_32( pFilter->predictionGain32, L_shl( pTnsParameters->minPredictionGain, 16 ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) + { + test(); + test(); + IF( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 || isTCX10 || LT_16( sts[ch]->hTcxEnc->tcxltp_gain, 19660 /*.6f in Q15*/ ) ) + { + sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, + this may result in crash later. Changing the filter type here so the order is taken here in further section */ + IF( pFilter->order != 0 ) + { + pFilter->filterType = TNS_FILTER_ON; + move16(); + } + ELSE + { + pFilter->filterType = TNS_FILTER_ON_ZERO; + move16(); + } + } + ELSE + { + Word16 maxEnergyChange_fx = GetTCXMaxenergyChange_ivas_fx( sts[ch]->hTranDet, isTCX10, NSUBBLOCKS, 3 ); + + IF( GE_16( maxEnergyChange_fx, shl( pTnsParameters->minEnergyChange, Q3 - Q7 ) ) ) + { + sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + /* When order parameter is evaluated as 0 and change in precision causes the flow to reach here, + this may result in crash later. Changing the filter type here so the order is taken here in further section */ + IF( pFilter->order != 0 ) + { + pFilter->filterType = TNS_FILTER_ON; + move16(); + } + ELSE + { + pFilter->filterType = TNS_FILTER_ON_ZERO; + move16(); + } + } + ELSE + { + pFilter->filterType = TNS_FILTER_OFF; + move16(); + } + } + } + ELSE IF( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) /* If a previous filter is turned on */ + { + pFilter->filterType = TNS_FILTER_ON_ZERO; + move16(); + sts[ch]->hTcxEnc->tnsData[k].nFilters = add( sts[ch]->hTcxEnc->tnsData[k].nFilters, 1 ); + move16(); + } + ELSE + { + pFilter->filterType = TNS_FILTER_OFF; + move16(); + } + } + + IF( ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) ) + { + sts[ch]->hTcxEnc->fUseTns[k] = 1; + } + ELSE + { + sts[ch]->hTcxEnc->fUseTns[k] = 0; + } + move16(); + test(); + test(); + IF( !bWhitenedDomain && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) + { + sts[ch]->hTcxEnc->fUseTns[k] = 0; + move16(); + sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; + move16(); + sts[ch]->hTcxEnc->tnsData[k].nFilters = 0; + move16(); + FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + ClearTnsFilterCoefficients( sts[ch]->hTcxEnc->tnsData[k].filter + iFilter ); + sts[ch]->hTcxEnc->tnsData[k].filter[iFilter].filterType = TNS_FILTER_OFF; + move16(); + } + } + maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + } + } + } + + + /* we have the decision, set filter data accordingly */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + IF( EQ_16( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + { + CONTINUE; + } + + IF( EQ_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + } + ELSE + { + nSubframes = NB_DIV; + } + move16(); + FOR( k = 0; k < nSubframes; k++ ) + { + test(); + test(); + IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) + { + sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; + + FOR( iFilter = sts[ch]->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + STnsFilter *pFilter; + pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; + SWITCH( pFilter->filterType ) + { + case TNS_FILTER_OFF: + ClearTnsFilterCoefficients( sts[ch]->hTcxEnc->tnsData[k].filter + iFilter ); + BREAK; + case TNS_FILTER_ON_ZERO: + /* Since TNS filter of order 0 is not allowed we have to signal in the stream filter of order 1 with the 0th coefficient equal to 0 */ + ClearTnsFilterCoefficients( pFilter ); + pFilter->order = 1; + move16(); + BREAK; + } + } + } + } + } + + /* Apply filters, loop over channels */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + st = sts[ch]; + IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + { + CONTINUE; + } + + IF( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) + { + nSubframes = 1; + } + ELSE + { + nSubframes = NB_DIV; + } + move16(); + + FOR( k = 0; k < nSubframes; k++ ) + { + test(); + test(); + test(); + test(); + test(); + IF( bWhitenedDomain && ( ch > 0 ) && /* test for identical TNS filter data in both channels */ + sts[0]->hTcxCfg->fIsTNSAllowed && sts[0]->hTcxEnc->fUseTns[k] && + sts[1]->hTcxCfg->fIsTNSAllowed && sts[1]->hTcxEnc->fUseTns[k] ) + { + Word16 equalFilterData = 0; + move16(); + test(); + test(); + if ( EQ_16( sts[0]->hTcxCfg->pCurrentTnsConfig->nMaxFilters, sts[1]->hTcxCfg->pCurrentTnsConfig->nMaxFilters ) && + EQ_16( sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k], sts[1]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) && + EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + { + equalFilterData = 1; + move16(); + } + + IF( equalFilterData ) + { + FOR( iFilter = st->hTcxCfg->pCurrentTnsConfig->nMaxFilters - 1; iFilter >= 0; iFilter-- ) + { + const Word16 *pDataCh0 = (const Word16 *) &sts[0]->hTcxEnc->tnsData[k].filter[iFilter]; + const Word16 *pDataCh1 = (const Word16 *) &sts[1]->hTcxEnc->tnsData[k].filter[iFilter]; + Word16 i = 2 + TNS_MAX_FILTER_ORDER; /* excl. informative float data. Portable? */ + + move16(); + test(); + WHILE( ( i >= 0 ) && EQ_16( pDataCh0[i], pDataCh1[i] ) ) + { + test(); + i = sub( i, 1 ); + } + IF( i >= 0 ) + { + equalFilterData = 0; + move16(); + BREAK; + } + } + IF( equalFilterData ) + { + st->hTcxEnc->tnsData[k].nFilters = i_mult( st->hTcxEnc->tnsData[k].nFilters, -1 ); /* signals common TNS */ + move16(); + } + } + } + test(); + test(); + IF( st->hTcxCfg->fIsTNSAllowed && ( !bWhitenedDomain || st->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) + { + L_spec = st->hTcxCfg->pCurrentTnsConfig->iFilterBorders[0]; + move16(); + spectrum_fx = st->hTcxEnc->spectrum_fx[k]; + /* If TNS should be used then get the residual after applying it inplace in the spectrum */ + IF( st->hTcxEnc->fUseTns[k] ) + { + st->hTcxCfg->pCurrentTnsConfig = &st->hTcxCfg->tnsConfig[st->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( st->last_core == ACELP_CORE )]; + + ApplyTnsFilter( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], spectrum_fx, 1 ); + } + + IF( EQ_16( st->hTcxEnc->transform_type[k], TCX_5 ) ) + { + tcx5TnsUngrouping_fx( shr( L_frame, 2 ), shr( L_spec, 1 ), st->hTcxEnc->spectrum_fx[k], ENC ); + } + + st->hTcxEnc->tnsData[k].tnsOnWhitenedSpectra = st->hTcxEnc->bTnsOnWhithenedSpectra[k]; + move16(); + EncodeTnsData_ivas_fx( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], param_core[ch] + k * NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, tnsSize[ch] + k, tnsBits[ch] + k ); + } + + IF( EQ_16( st->hTcxEnc->transform_type[k], TCX_5 ) ) + { + tcx5SpectrumInterleaving_fx( st->hTcxCfg->tcx5SizeFB, st->hTcxEnc->spectrum_fx[k] ); + tcx5SpectrumInterleaving_fx( st->hTcxCfg->tcx5SizeFB, mdst_spectrum_fx[ch][k] ); + } + } + } + return; +} diff --git a/lib_enc/cod_uv.c b/lib_enc/cod_uv.c deleted file mode 100644 index 9e7ce9558..000000000 --- a/lib_enc/cod_uv.c +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/comvad_decision.c b/lib_enc/comvad_decision.c deleted file mode 100644 index efb9c1d78..000000000 --- a/lib_enc/comvad_decision.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_enc.h" -#include "wmc_auto.h" diff --git a/lib_enc/cor_shif.c b/lib_enc/cor_shif.c deleted file mode 100644 index 0e2004abf..000000000 --- a/lib_enc/cor_shif.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/core_enc_2div.c b/lib_enc/core_enc_2div.c deleted file mode 100644 index c899b52ff..000000000 --- a/lib_enc/core_enc_2div.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c deleted file mode 100644 index b0a1c880e..000000000 --- a/lib_enc/core_enc_init.c +++ /dev/null @@ -1,1055 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "options_warnings.h" -#include "cnst.h" -#include "prot.h" -#include "ivas_prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" - -#include "prot_fx.h" - -/*-----------------------------------------------------------------------* - * Local function prototypes - *-----------------------------------------------------------------------*/ -static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag ); -static void init_core_sig_ana_ivas_fx( Encoder_State *st ); -static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate ); -static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ); -static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ); -/*-----------------------------------------------------------------------* - * init_coder_ace_plus() - * - * Initialization of state variables - *-----------------------------------------------------------------------*/ -void init_coder_ace_plus_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate */ -#ifdef FIX_920_IGF_INIT_ERROR - const Word32 igf_brate, /* i : IGF configuration bitrate */ -#endif - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -) -{ - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - Word16 L_frame_old; /*keep old frame size for switching */ - Word16 L_subfr; - - /* Bitrate */ - st->tcxonly = getTcxonly_ivas_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); - move16(); - - /* Core Sampling Rate */ - st->sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); - st->fscale = sr2fscale_fx( st->sr_core ); - move32(); - move16(); - - /* Narrowband? */ - IF( EQ_16( st->bwidth, NB ) ) - { - st->narrowBand = 1; - move16(); - } - ELSE - { - st->narrowBand = 0; - move16(); - } - - /* Core Framing */ - L_frame_old = st->last_L_frame; - move16(); - st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ - move16(); - st->L_frame_past = -1; - move16(); - - IF( hTcxEnc != NULL ) - { - hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ - move16(); - - IF( st->ini_frame == 0 ) - { - set16_fx( hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); - hTcxEnc->acelp_zir = hTcxEnc->Txnq + L_FRAME / 2; - hTcxEnc->q_Txnq = Q15; - move16(); - hTcxEnc->tcx_target_bits_fac = ONE_IN_Q14; - move16(); - } - } - - test(); - test(); - test(); - test(); - test(); - IF( ( st->element_mode == EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->element_mode > EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) ) - { - st->nb_subfr = NB_SUBFR16k; - move16(); - } - ELSE - { - st->nb_subfr = NB_SUBFR; - move16(); - } - L_subfr = idiv1616( st->L_frame, st->nb_subfr ); - - /* Core Lookahead */ - st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS ); - st->encoderLookahead_FB = NS2SA_FX2( st->input_Fs, ACELP_LOOK_NS ); - move16(); - move16(); - - IF( st->ini_frame == 0 ) - { - st->acelpFramesCount = 0; - move16(); - st->prevTempFlatness_fx = 128 /*1.0f Q7*/; - move16(); - } - - /* Initialize TBE */ - IF( st->hBWE_TD != NULL ) - { - st->hBWE_TD->prev_coder_type = GENERIC; - move16(); - set16_fx( st->hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 ); - st->hBWE_TD->prev_tilt_para_fx = 0; - move16(); - set16_fx( st->hBWE_TD->cur_sub_Aq_fx, 0, M + 1 ); - } - - st->currEnergyHF_fx = 0; - move32(); - st->currEnergyHF_e_fx = 0; - move16(); - test(); - /* Initialize LPC analysis/quantization */ - IF( LE_32( st->sr_core, INT_FS_16k ) && st->tcxonly == 0 ) - { - st->lpcQuantization = 1; - move16(); - } - ELSE - { - st->lpcQuantization = 0; - move16(); - } - - st->next_force_safety_net = 0; - move16(); - test(); - test(); - IF( ( NE_16( st->last_L_frame, st->L_frame ) ) || ( EQ_16( st->last_core, AMR_WB_CORE ) ) || ( EQ_16( st->last_core, HQ_CORE ) ) ) - { - set16_fx( st->mem_MA_fx, 0, M ); - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); - } - - /* Initialize IGF */ - if ( st->hIGFEnc != NULL ) - { - st->hIGFEnc->infoStopFrequency = -1; - move16(); - } - - test(); - IF( st->igf && st->hIGFEnc != NULL ) - { -#ifdef FIX_920_IGF_INIT_ERROR - IGFEncSetMode_ivas_fx( st->hIGFEnc, igf_brate, st->bwidth, st->element_mode, st->rf_mode ); -#else - IGFEncSetMode_ivas_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode ); -#endif - } - ELSE IF( st->hIGFEnc != NULL ) - { - st->hIGFEnc->infoTotalBitsWritten = 0; - move16(); - st->hIGFEnc->infoTotalBitsPerFrameWritten = 0; - move16(); - } - - /* Initialize Core Signal Analysis Module */ - init_core_sig_ana_ivas_fx( st ); - - - /* Initialize TCX */ - IF( hTcxEnc != NULL ) - { - init_tcx_ivas_fx( st, L_frame_old, st->total_brate, last_total_brate, MCT_flag ); - } - - /* Initialize Signal Buffers */ - init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr, last_total_brate ); - - /* Initialize ACELP */ - - init_acelp_ivas_fx( st, L_frame_old, 0, last_total_brate ); - - if ( st->ini_frame == 0 ) - { - st->tec_tfa = 0; - move16(); - } - - IF( st->hTECEnc != NULL ) - { - resetTecEnc_Fx( st->hTECEnc, st->tec_tfa ); - } - - test(); - test(); - test(); - IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) - { - st->tec_tfa = 1; - move16(); - } - ELSE - { - st->tec_tfa = 0; - move16(); - } - - st->tec_flag = 0; - move16(); - st->tfa_flag = 0; - move16(); - - test(); - test(); - test(); - IF( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) - { - st->glr = 1; - move16(); - } - ELSE - { - st->glr = 0; - move16(); - } - - st->glr_reset = 0; - move16(); - - /* Initialize ACELP/TCX Modes */ - init_modes_ivas_fx( st, last_total_brate ); - - /* Adaptive BPF */ - set32_fx( st->mem_bpf_fx1, 0, 2 * L_FILT16k ); - set32_fx( st->mem_error_bpf_fx, 0, 2 * L_FILT16k ); - - IF( st->ini_frame == 0 ) - { - st->Q_max_enc[0] = 15; - move16(); - st->Q_max_enc[1] = 15; - move16(); - } - - IF( GE_32( st->total_brate, HQ_48k ) ) - { - st->enablePlcWaveadjust = 1; - move16(); - } - ELSE - { - st->enablePlcWaveadjust = 0; - move16(); - } - - IF( st->hPlcExt ) - { - init_PLC_enc_fx( st->hPlcExt, st->sr_core ); - } - - st->glr_idx[0] = 0; - move16(); - st->glr_idx[1] = 0; - move16(); - st->mean_gc[0] = 0; - move16(); - st->mean_gc[1] = 0; - move16(); - st->prev_lsf4_mean = 0; - move16(); - st->last_stab_fac = 0; - move16(); - - return; -} - -/*-----------------------------------------------------------------------* - * init_tcx() - * - * Initialization of TCX - *-----------------------------------------------------------------------*/ - - -static void init_tcx_ivas_fx( - Encoder_State *st, - const Word16 L_frame_old, - const Word32 total_brate, - const Word32 last_total_brate, - const Word16 MCT_flag ) -{ - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - - /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ - hTcxEnc->spectrum_fx[0] = hTcxEnc->spectrum_long_fx; - hTcxEnc->spectrum_fx[1] = hTcxEnc->spectrum_long_fx + N_TCX10_MAX; - st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; - move16(); - move16(); - - init_tcx_cfg_ivas_fx( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, - st->fscale, st->preemph_fac, st->tcxonly, st->rf_mode, st->igf, - st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag ); - - /* Init TCX target bits correction factor */ - hTcxEnc->tcx_target_bits_fac = 0x4000; /*1.0f in 1Q14*/ - move16(); - hTcxEnc->measuredBwRatio = 0x4000; /*1.0f in 1Q14*/ - move16(); - hTcxEnc->noiseTiltFactor = 9216; /*0.5625f in 1Q14*/ - move16(); - hTcxEnc->noiseLevelMemory_cnt = 0; - move16(); - - set16_fx( hTcxEnc->ltpGainMemory_fx, 0, N_LTP_GAIN_MEMS ); - set8_fx( hTcxEnc->memQuantZeros, 0, L_FRAME_PLUS ); - - /* TCX-LTP */ - hTcxEnc->tcxltp = getTcxLtp( st->sr_core ); - move16(); - - test(); - test(); - test(); - test(); - IF( st->ini_frame == 0 ) - { - hTcxEnc->tcxltp_pitch_int_past = st->L_frame; - hTcxEnc->tcxltp_pitch_fr_past = 0; - hTcxEnc->tcxltp_gain_past = 0; - hTcxEnc->tcxltp_norm_corr_past = 0; - hTcxEnc->tcxltp_norm_corr_mem = 0; - hTcxEnc->kernel_switch_corr_past = 0; - hTcxEnc->kernel_symmetry_past = 0; /* MDCT_IV & 1 */ - hTcxEnc->enc_ste_pre_corr_past = 0; - hTcxEnc->tfm_mem_fx = 1610612736; /* 0.75 in Q31 */ - hTcxEnc->tcxltp_on_mem = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - } - ELSE IF( NE_16( st->L_frame, L_frame_old ) && !( ( GE_32( total_brate, ACELP_16k40 ) && LE_32( total_brate, ACELP_24k40 ) ) && - ( EQ_32( total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) - { - Word16 pitres, pitres_old; - Word16 pit, pit_old; - - pitres_old = 4; - move16(); - if ( EQ_16( 160, shr( L_frame_old, sub( 7, norm_s( L_frame_old ) ) ) ) ) /*if ( L_frame_old%160==0 )*/ - { - pitres_old = 6; - move16(); - } - - /*pit_old = (float)st->tcxltp_pitch_int_past + (float)st->tcxltp_pitch_fr_past/(float)pitres_old;*/ - pit_old = add( hTcxEnc->tcxltp_pitch_int_past, mult_r( hTcxEnc->tcxltp_pitch_fr_past, div_s( 1, pitres_old ) ) ); - - pitres = 4; - move16(); - if ( EQ_16( 160, shr( st->L_frame, sub( 7, norm_s( st->L_frame ) ) ) ) ) /*if ( st->L_frame%160==0 )*/ - { - pitres = 6; - move16(); - } - - /*pit = pit_old * (float)st->L_frame/(float)L_frame_old;*/ - pit = shl_sat( mult_r( pit_old, div_s( st->L_frame, shl( L_frame_old, 2 ) ) ), 2 ); - /* Note : the saturation here that can happens when FS == 32kHz*/ - /* assert(pit <= st->L_frame);*/ - - hTcxEnc->tcxltp_pitch_int_past = pit; - move16(); - hTcxEnc->tcxltp_pitch_fr_past = i_mult2( sub( pit, hTcxEnc->tcxltp_pitch_int_past ), pitres ); - move16(); - } - - hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode ); - move16(); - - return; -} - -/*-----------------------------------------------------------------------* - * init_sig_buffers() - * - * Initialization of signal buffers - *-----------------------------------------------------------------------*/ -/*copy of evs function since it was static */ -static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ) -{ - - LPD_state_HANDLE hLPDmem = st->hLPDmem; - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - - /* Encoder Past Samples at encoder-sampling-rate */ - st->encoderPastSamples_enc = shr( imult1616( st->L_frame, 9 ), 4 ); - move16(); - - /* Initialize Signal Buffers and Pointers at encoder-sampling-rate */ - IF( st->ini_frame == 0 ) - { - set16_fx( st->buf_speech_enc, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - st->exp_buf_speech_enc = 0; - move16(); - set16_fx( st->buf_speech_enc_pe, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - st->exp_buf_speech_enc_pe = 0; - move16(); - if ( hTcxEnc != NULL ) - { - set16_fx( hTcxEnc->buf_speech_ltp, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - hTcxEnc->exp_buf_speech_ltp = 0; - move16(); - } - set16_fx( st->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); /* increased by 320 to avoid memory overlap in ivas_find_wsp_fx() and also to accomodate for the wspeech_enc */ - st->exp_buf_wspeech_enc = 0; - move16(); - } - ELSE - { - test(); - test(); - test(); - test(); - test(); - IF( NE_16( st->L_frame, L_frame_old ) && !( ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) - { - lerp( st->buf_speech_enc, st->buf_speech_enc, st->L_frame, L_frame_old ); - test(); - IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) /* condition should be checked again */ - { - Copy( st->buf_speech_enc, hTcxEnc->buf_speech_ltp, st->L_frame ); - Scale_sig( hTcxEnc->buf_speech_ltp, st->L_frame, sub( st->exp_buf_speech_enc, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(15-max(st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp)) - Scale_sig( hTcxEnc->buf_speech_ltp + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( hTcxEnc->exp_buf_speech_ltp, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(15-max(st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp)) - hTcxEnc->exp_buf_speech_ltp = s_max( hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc ); - move16(); - } - - // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); - Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); - st->exp_buf_wspeech_enc = st->exp_old_wsp; - move16(); - - /*Resamp buffers needed only for ACELP*/ - test(); - test(); - IF( EQ_16( st->L_frame, L_FRAME ) && !st->tcxonly ) - { - // Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); - Copy( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); - /* SCaling to common exponent*/ - Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_12k8, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ); - move16(); - } - ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) && !st->tcxonly ) - { - lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); - Copy( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); - /* SCaling to common exponent*/ - Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_16k, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ); - move16(); - } - - st->mem_preemph_enc = st->buf_speech_enc[st->encoderPastSamples_enc + st->encoderLookahead_enc - 1]; - move16(); - st->exp_mem_preemph_enc = st->exp_buf_speech_enc; - move16(); - st->mem_wsp_enc = shr( st->buf_wspeech_enc[st->L_frame + L_SUBFR - 1], sub( Q16, st->exp_buf_wspeech_enc ) ); // Q-1 - move16(); - } - /*coming from TCXonly modes*/ - ELSE IF( !st->tcxonly && GE_32( last_total_brate, ACELP_32k ) ) - { - - Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); - // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); - st->exp_buf_wspeech_enc = st->exp_old_wsp; - move16(); /*Resamp buffers needed only for ACELP*/ - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); - } - hLPDmem->mem_w0 = 0; - move16(); - st->mem_wsp_enc = shr( st->buf_wspeech_enc[st->L_frame + L_SUBFR - 1], sub( Q16, st->exp_buf_wspeech_enc ) ); // Q-1 - move16(); - } - } - - st->new_speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc + st->encoderLookahead_enc; - st->new_speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc + st->encoderLookahead_enc; - if ( hTcxEnc != NULL ) - { - hTcxEnc->new_speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc + st->encoderLookahead_enc; - } - - IF( st->hTcxEnc != NULL ) - { - st->hTcxEnc->new_speech_TCX = st->input_buff_fx + Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ); - st->hTcxEnc->speech_TCX = st->hTcxEnc->new_speech_TCX - st->encoderLookahead_FB; - } - st->speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc; - st->speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc; - - if ( hTcxEnc != NULL ) - { - hTcxEnc->speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc; - } - - IF( st->element_mode > EVS_MONO ) - { - st->wspeech_enc = st->buf_wspeech_enc + st->L_frame + L_SUBFR; - } - ELSE - { - st->wspeech_enc = st->buf_wspeech_enc + st->L_frame + L_subfr; - } - - test(); - test(); - IF( st->ini_frame == 0 || NE_16( st->L_frame, L_frame_old ) || EQ_16( st->last_codec_mode, MODE1 ) ) - { - set16_fx( st->buf_synth, 0, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); - } - - st->synth = st->buf_synth + st->L_frame + L_subfr; - - - return; -} - -/*-----------------------------------------------------------------------* - * init_core_sig_ana() - * - * - *-----------------------------------------------------------------------*/ -static void init_core_sig_ana_ivas_fx( Encoder_State *st ) -{ - - /* Pre-emphasis factor and memory */ - - st->preemph_fac = PREEMPH_FAC_SWB; /*SWB*/ - move16(); - IF( LT_16( st->fscale, ( 16000 * FSCALE_DENOM ) / 12800 ) ) - { - st->preemph_fac = PREEMPH_FAC; /*WB*/ - move16(); - } - ELSE IF( LT_16( st->fscale, ( 24000 * FSCALE_DENOM ) / 12800 ) ) - { - st->preemph_fac = PREEMPH_FAC_16k; /*WB*/ - move16(); - } - - st->gamma = GAMMA1; - move16(); - st->inv_gamma = GAMMA1_INV; - move16(); - IF( EQ_32( st->sr_core, 16000 ) ) - { - st->gamma = GAMMA16k; - move16(); - st->inv_gamma = GAMMA16k_INV; - move16(); - } - - - st->min_band = 1; - move16(); - st->max_band = 16; - move16(); - - IF( st->narrowBand == 0 ) - { - st->min_band = 0; - move16(); - st->max_band = 19; - move16(); - } - - - return; -} -/*-----------------------------------------------------------------------* - * init_acelp() - * - * - *-----------------------------------------------------------------------*/ -static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ) -{ - Word16 mem_syn_r_size_old; - Word16 mem_syn_r_size_new; - LPD_state_HANDLE hLPDmem = st->hLPDmem; - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - - /* Init pitch lag */ - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - /* TCX LTP ana always runs @12.8kHz */ - st->pit_res_max = initPitchLagParameters( 12800, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); - move16(); - } - ELSE - { - st->pit_res_max = initPitchLagParameters( st->sr_core, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); - move16(); - } - - /* Init LPDmem */ - IF( st->ini_frame == 0 ) - { - IF( hLPDmem != NULL ) - { - set16_fx( hLPDmem->syn, 0, 1 + M ); - set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); - } - - IF( st->hTcxEnc != NULL ) - { - set16_fx( st->hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); - st->hTcxEnc->q_Txnq = Q15; - move16(); - st->hTcxEnc->acelp_zir = st->hTcxEnc->Txnq + shr( st->L_frame, 1 ); - } - } - ELSE /*Rate switching*/ - { - IF( st->last_core == ACELP_CORE ) - { - lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, shr( st->L_frame, 1 ), shr( L_frame_old, 1 ) ); - } - ELSE - { - lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_length_old ); - } - hTcxEnc->acelp_zir = hTcxEnc->Txnq + shr( st->L_frame, 1 ); - - /* Rate switching */ - IF( EQ_16( st->last_codec_mode, MODE1 ) && st->element_mode == EVS_MONO ) - { - IF( hLPDmem != NULL ) - { - Copy( hLPDmem->mem_syn1_fx, hLPDmem->mem_syn2, M ); - set16_fx( hLPDmem->syn, 0, M ); - hLPDmem->q_lpd_syn = Q15; - move16(); - } - IF( st->hTcxEnc != NULL ) - { - set16_fx( hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); - st->hTcxEnc->q_Txnq = Q15; - move16(); - } - } - - /*AMR-WBIO->MODE2*/ - IF( EQ_16( st->last_core, AMR_WB_CORE ) ) - { - st->next_force_safety_net = 1; - move16(); - st->last_core = ACELP_CORE; - move16(); - } - /*HQ-CORE->MODE2*/ - test(); - IF( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->last_core, HQ_CORE ) ) - { - /*Reset of ACELP memories*/ - st->next_force_safety_net = 1; - move16(); - st->rate_switching_reset = 1; - move16(); - IF( hLPDmem != NULL ) - { - hLPDmem->tilt_code = TILT_CODE; - move16(); - set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); - set16_fx( hLPDmem->syn, 0, 1 + M ); - hLPDmem->q_lpd_syn = Q15; - move16(); - hLPDmem->q_lpd_old_exc = Q15; - move16(); - hLPDmem->mem_w0 = 0; - move16(); - set16_fx( hLPDmem->mem_syn, 0, M ); - set16_fx( hLPDmem->mem_syn2, 0, M ); - hLPDmem->q_mem_syn = Q15; - move16(); - } - - /* unquantized LPC*/ - test(); - test(); - test(); - IF( !( ( GE_32( st->total_brate, ACELP_16k40 ) && LE_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) - { - Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - lsp_convert_poly_fx( st->lspold_enc_fx, st->L_frame, 0 ); - } - } - Copy( st->lspold_enc_fx, st->lsp_old_fx, M ); /*used unquantized values for mid-LSF Q*/ - IF( st->tcxonly == 0 ) - { - lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); - } - ELSE - { - E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); - } - st->last_core = TCX_20_CORE; - move16(); - - st->hTcxCfg->last_aldo = 1; /*It was previously ALDO*/ - st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; - move16(); - move16(); - /*ALDO overlap windowed past: also used in MODE1 but for other MDCT-FB*/ - set16_fx( hTcxEnc->old_out_fx, 0, st->L_frame ); - } - ELSE - { - test(); - test(); - test(); - test(); - IF( ( NE_16( st->L_frame, L_frame_old ) ) && ( LE_16( st->L_frame, L_FRAME16k ) ) && ( LE_16( L_frame_old, L_FRAME16k ) ) ) - { - /* convert quantized LSP vector */ - st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); - move16(); - IF( st->tcxonly == 0 ) - { - lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); - } - ELSE - { - E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); - } - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); - } - ELSE - { - Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); - } - - - /*Mem of deemphasis stay unchanged : hLPDmem->syn*/ - IF( hLPDmem != NULL ) - { - synth_mem_updt2( st->L_frame, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn2, hLPDmem->mem_syn, ENC ); - Word16 tmp, A[M + 1], Ap[M + 1], tmp_buf[M + 1]; - /* Update wsyn */ - /* lsp2a_stab( st->lsp_old, A, M ); */ - E_LPC_f_lsp_a_conversion( st->lsp_old_fx, A, M ); - weight_a_fx( A, Ap, GAMMA1, M ); - tmp = 0; - move16(); - tmp_buf[0] = 0; - move16(); - Copy( hLPDmem->mem_syn2, tmp_buf + 1, M ); - deemph_fx( tmp_buf + 1, st->preemph_fac, M, &tmp ); - Residu3_fx( Ap, tmp_buf + M, &tmp, 1, 1 ); - hLPDmem->mem_w0 = sub_sat( shr_sat( st->wspeech_enc[-1], shift ), tmp ); - move16(); - } - } - ELSE IF( ( NE_16( st->L_frame, L_frame_old ) ) ) - { - /*Partial reset of ACELP memories*/ - st->next_force_safety_net = 1; - move16(); - st->rate_switching_reset = 1; - move16(); - - /*reset partly some memories*/ - IF( hLPDmem != NULL ) - { - hLPDmem->tilt_code = TILT_CODE; - move16(); - set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); - move16(); - hLPDmem->q_lpd_old_exc = Q15; - move16(); - /*Resamp others memories*/ - /*Size of LPC syn memory*/ - /* 1.25/20.0 = 1.0/16.0 -> shift 4 to the right. */ - mem_syn_r_size_old = shr( L_frame_old, 4 ); - mem_syn_r_size_new = shr( st->L_frame, 4 ); - - lerp( hLPDmem->mem_syn_r + L_SYN_MEM - mem_syn_r_size_old, hLPDmem->mem_syn_r + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); - Copy( hLPDmem->mem_syn_r + L_SYN_MEM - M, hLPDmem->mem_syn, M ); - Copy( hLPDmem->mem_syn, hLPDmem->mem_syn2, M ); - - /*Untouched memories : hLPDmem->syn & hLPDmem->mem_w0*/ - hLPDmem->mem_w0 = 0; - move16(); - } - /* unquantized LPC*/ - Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - lsp_convert_poly_fx( st->lspold_enc_fx, st->L_frame, 0 ); - } - Copy( st->lspold_enc_fx, st->lsp_old_fx, M ); /*used unquantized values for mid-LSF Q*/ - IF( st->tcxonly == 0 ) - { - lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); - } - ELSE - { - E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); - } - } - ELSE IF( !st->tcxonly && EQ_16( st->L_frame, L_FRAME16k ) && GT_32( st->last_total_brate, ACELP_32k ) ) - { - lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); - } - } - } - - test(); - test(); - if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && st->ini_frame != 0 ) - { - st->rate_switching_reset = 1; - move16(); - } - - /* Post-processing */ - /*EVS specific*/ - /* hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 ); - set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); - hLPDmem->dm_fx.prev_state = 0;*/ - /*------------*/ - - if ( hLPDmem != NULL ) - { - hLPDmem->dm_fx.prev_state = 0; - move16(); /* This corresponds to st_fx->dispMem in FLP */ - hLPDmem->dm_fx.prev_gain_code = 0; - move32(); - - FOR( Word16 i = 2; i < 8; i++ ) - { - hLPDmem->dm_fx.prev_gain_pit[i - 2] = 0; - move16(); - } - hLPDmem->gc_threshold = 0; - move16(); - } - - /* Pulse Search configuration */ - st->acelp_autocorr = 1; - move16(); - - /*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/ - test(); - test(); - if ( ( LE_32( st->total_brate, ACELP_9k60 ) || EQ_16( st->rf_mode, 1 ) ) && ( EQ_32( st->sr_core, 12800 ) ) ) - { - st->acelp_autocorr = 0; - move16(); - } - - - /*BPF parameters for adjusting gain in function of background noise*/ - IF( EQ_16( st->codec_mode, MODE2 ) ) - { - st->mem_bpf_fx.lp_error_ener = L_deposit_l( 0 ); - move32(); - st->pst_lp_ener_fx = 0; - move16(); - IF( EQ_16( st->last_codec_mode, MODE1 ) ) - { - st->mem_bpf_fx.lp_error = 0; - move32(); - st->pst_mem_deemp_err_fx = 0; - move16(); - } - } - - return; -} -/*-----------------------------------------------------------------------* - * init_modes() - * - * - *-----------------------------------------------------------------------*/ - -static void init_modes_ivas_fx( - Encoder_State *st, - const Word32 last_total_brate ) -{ - Word8 n; - Word32 tmp32; - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - - /* Restrict ACE/TCX20/TCX10 mode */ - move16(); - st->restrictedMode = getRestrictedMode( st->element_mode, st->total_brate, st->Opt_AMR_WB ); - move16(); - st->acelpEnabled = 0; - move16(); - st->tcx20Enabled = 0; - move16(); - st->tcx10Enabled = 0; - - if ( EQ_16( s_and( st->restrictedMode, 1 ), 1 ) ) - { - st->acelpEnabled = 1; - move16(); - } - if ( EQ_16( s_and( st->restrictedMode, 2 ), 2 ) ) - { - st->tcx20Enabled = 1; - move16(); - } - if ( EQ_16( s_and( st->restrictedMode, 4 ), 4 ) ) - { - st->tcx10Enabled = 1; - move16(); - } - - /* TCX mode (TCX20 TCX10_10 or NO_TCX) */ - if ( st->hTcxEnc != NULL ) - { - hTcxEnc->tcxMode = NO_TCX; - move16(); - } - - /* Bits Budget */ - /*st->bits_frame_nominal = (int)( (float)st->L_frame * (float)FSCALE_DENOM * (float)st->bitrate / ( (float)st->fscale * 12800.0f ) );*/ - /*st->bits_frame_nominal = (int)( (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate/100.0f + 0.49f );*/ - /*328 = 0.010009765625 in 0Q15*/ - /* st->bits_frame_nominal = extract_h(L_add(L_mult(div_l(L_mult(shl(st->L_frame,2),st->bitrate),st->fscale),328),16056)); */ - - /* st->bits_frame_nominal = (int)( (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate/100.0f + 0.49f ); */ - tmp32 = L_shl( st->total_brate, 1 ); /* (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate */ - st->bits_frame_nominal = extract_l( L_shr( Mpy_32_16_1( tmp32, 20972 ), 6 ) ); /* 20972 = 0.01 * 64 * 32768 */ - move16(); - - IF( st->Opt_AMR_WB ) - { - st->bits_frame = st->bits_frame_nominal; - move16(); - st->bits_frame_core = st->bits_frame_nominal; - move16(); - st->frame_size_index = 0; - move16(); - } - ELSE - { - FOR( n = 0; n < FRAME_SIZE_NB; n++ ) - { - IF( LT_32( n, FRAME_SIZE_NB - 1 ) ) - { - test(); - IF( LE_32( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) && GT_32( FrameSizeConfig[n + 1].frame_bits, st->bits_frame_nominal ) ) - { - st->frame_size_index = n; - move16(); - st->bits_frame = st->bits_frame_nominal; - move16(); - st->bits_frame_core = sub( sub( sub( st->bits_frame_nominal, FrameSizeConfig[n].transmission_bits ), FrameSizeConfig[n].bandwidth_bits ), FrameSizeConfig[n].reserved_bits ); - move16(); - BREAK; - } - } - ELSE - { - IF( LE_32( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) ) - { - st->frame_size_index = n; - move16(); - st->bits_frame = st->bits_frame_nominal; - move16(); - st->bits_frame_core = sub( sub( sub( st->bits_frame_nominal, FrameSizeConfig[n].transmission_bits ), FrameSizeConfig[n].bandwidth_bits ), FrameSizeConfig[n].reserved_bits ); - move16(); - BREAK; - } - } - } - } - - /* Reconfigure core */ - core_coder_reconfig_ivas_fx( st, last_total_brate ); - - - return; -} diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 1f5b0df1e..4151725af 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -28,6 +28,11 @@ static void init_core_sig_ana_fx( Encoder_State *st ); static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 shift ); static void init_modes_fx( Encoder_State *st, const Word32 Last_total_brate ); static void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr ); +static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag ); +static void init_core_sig_ana_ivas_fx( Encoder_State *st ); +static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate ); +static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ); +static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ); /*-----------------------------------------------------------------------* * init_coder_ace_plus_fx() @@ -930,5 +935,1004 @@ static void init_modes_fx( core_coder_reconfig_fx( st, last_total_brate ); + return; +} + +/*-----------------------------------------------------------------------* + * init_coder_ace_plus() + * + * Initialization of state variables + *-----------------------------------------------------------------------*/ +void init_coder_ace_plus_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate */ +#ifdef FIX_920_IGF_INIT_ERROR + const Word32 igf_brate, /* i : IGF configuration bitrate */ +#endif + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +) +{ + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + Word16 L_frame_old; /*keep old frame size for switching */ + Word16 L_subfr; + + /* Bitrate */ + st->tcxonly = getTcxonly_ivas_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); + move16(); + + /* Core Sampling Rate */ + st->sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); + st->fscale = sr2fscale_fx( st->sr_core ); + move32(); + move16(); + + /* Narrowband? */ + IF( EQ_16( st->bwidth, NB ) ) + { + st->narrowBand = 1; + move16(); + } + ELSE + { + st->narrowBand = 0; + move16(); + } + + /* Core Framing */ + L_frame_old = st->last_L_frame; + move16(); + st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ + move16(); + st->L_frame_past = -1; + move16(); + + IF( hTcxEnc != NULL ) + { + hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ + move16(); + + IF( st->ini_frame == 0 ) + { + set16_fx( hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); + hTcxEnc->acelp_zir = hTcxEnc->Txnq + L_FRAME / 2; + hTcxEnc->q_Txnq = Q15; + move16(); + hTcxEnc->tcx_target_bits_fac = ONE_IN_Q14; + move16(); + } + } + + test(); + test(); + test(); + test(); + test(); + IF( ( st->element_mode == EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->element_mode > EVS_MONO && EQ_32( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, MAX_ACELP_BRATE ) ) ) + { + st->nb_subfr = NB_SUBFR16k; + move16(); + } + ELSE + { + st->nb_subfr = NB_SUBFR; + move16(); + } + L_subfr = idiv1616( st->L_frame, st->nb_subfr ); + + /* Core Lookahead */ + st->encoderLookahead_enc = NS2SA_FX2( st->sr_core, ACELP_LOOK_NS ); + st->encoderLookahead_FB = NS2SA_FX2( st->input_Fs, ACELP_LOOK_NS ); + move16(); + move16(); + + IF( st->ini_frame == 0 ) + { + st->acelpFramesCount = 0; + move16(); + st->prevTempFlatness_fx = 128 /*1.0f Q7*/; + move16(); + } + + /* Initialize TBE */ + IF( st->hBWE_TD != NULL ) + { + st->hBWE_TD->prev_coder_type = GENERIC; + move16(); + set16_fx( st->hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 ); + st->hBWE_TD->prev_tilt_para_fx = 0; + move16(); + set16_fx( st->hBWE_TD->cur_sub_Aq_fx, 0, M + 1 ); + } + + st->currEnergyHF_fx = 0; + move32(); + st->currEnergyHF_e_fx = 0; + move16(); + test(); + /* Initialize LPC analysis/quantization */ + IF( LE_32( st->sr_core, INT_FS_16k ) && st->tcxonly == 0 ) + { + st->lpcQuantization = 1; + move16(); + } + ELSE + { + st->lpcQuantization = 0; + move16(); + } + + st->next_force_safety_net = 0; + move16(); + test(); + test(); + IF( ( NE_16( st->last_L_frame, st->L_frame ) ) || ( EQ_16( st->last_core, AMR_WB_CORE ) ) || ( EQ_16( st->last_core, HQ_CORE ) ) ) + { + set16_fx( st->mem_MA_fx, 0, M ); + Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); + } + + /* Initialize IGF */ + if ( st->hIGFEnc != NULL ) + { + st->hIGFEnc->infoStopFrequency = -1; + move16(); + } + + test(); + IF( st->igf && st->hIGFEnc != NULL ) + { +#ifdef FIX_920_IGF_INIT_ERROR + IGFEncSetMode_ivas_fx( st->hIGFEnc, igf_brate, st->bwidth, st->element_mode, st->rf_mode ); +#else + IGFEncSetMode_ivas_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode ); +#endif + } + ELSE IF( st->hIGFEnc != NULL ) + { + st->hIGFEnc->infoTotalBitsWritten = 0; + move16(); + st->hIGFEnc->infoTotalBitsPerFrameWritten = 0; + move16(); + } + + /* Initialize Core Signal Analysis Module */ + init_core_sig_ana_ivas_fx( st ); + + + /* Initialize TCX */ + IF( hTcxEnc != NULL ) + { + init_tcx_ivas_fx( st, L_frame_old, st->total_brate, last_total_brate, MCT_flag ); + } + + /* Initialize Signal Buffers */ + init_sig_buffers_ivas_fx( st, L_frame_old, L_subfr, last_total_brate ); + + /* Initialize ACELP */ + + init_acelp_ivas_fx( st, L_frame_old, 0, last_total_brate ); + + if ( st->ini_frame == 0 ) + { + st->tec_tfa = 0; + move16(); + } + + IF( st->hTECEnc != NULL ) + { + resetTecEnc_Fx( st->hTECEnc, st->tec_tfa ); + } + + test(); + test(); + test(); + IF( EQ_16( st->bwidth, SWB ) && ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) + { + st->tec_tfa = 1; + move16(); + } + ELSE + { + st->tec_tfa = 0; + move16(); + } + + st->tec_flag = 0; + move16(); + st->tfa_flag = 0; + move16(); + + test(); + test(); + test(); + IF( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) + { + st->glr = 1; + move16(); + } + ELSE + { + st->glr = 0; + move16(); + } + + st->glr_reset = 0; + move16(); + + /* Initialize ACELP/TCX Modes */ + init_modes_ivas_fx( st, last_total_brate ); + + /* Adaptive BPF */ + set32_fx( st->mem_bpf_fx1, 0, 2 * L_FILT16k ); + set32_fx( st->mem_error_bpf_fx, 0, 2 * L_FILT16k ); + + IF( st->ini_frame == 0 ) + { + st->Q_max_enc[0] = 15; + move16(); + st->Q_max_enc[1] = 15; + move16(); + } + + IF( GE_32( st->total_brate, HQ_48k ) ) + { + st->enablePlcWaveadjust = 1; + move16(); + } + ELSE + { + st->enablePlcWaveadjust = 0; + move16(); + } + + IF( st->hPlcExt ) + { + init_PLC_enc_fx( st->hPlcExt, st->sr_core ); + } + + st->glr_idx[0] = 0; + move16(); + st->glr_idx[1] = 0; + move16(); + st->mean_gc[0] = 0; + move16(); + st->mean_gc[1] = 0; + move16(); + st->prev_lsf4_mean = 0; + move16(); + st->last_stab_fac = 0; + move16(); + + return; +} + +/*-----------------------------------------------------------------------* + * init_tcx() + * + * Initialization of TCX + *-----------------------------------------------------------------------*/ + + +static void init_tcx_ivas_fx( + Encoder_State *st, + const Word16 L_frame_old, + const Word32 total_brate, + const Word32 last_total_brate, + const Word16 MCT_flag ) +{ + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + + /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ + hTcxEnc->spectrum_fx[0] = hTcxEnc->spectrum_long_fx; + hTcxEnc->spectrum_fx[1] = hTcxEnc->spectrum_long_fx + N_TCX10_MAX; + st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; + move16(); + move16(); + + init_tcx_cfg_ivas_fx( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, + st->fscale, st->preemph_fac, st->tcxonly, st->rf_mode, st->igf, + st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag ); + + /* Init TCX target bits correction factor */ + hTcxEnc->tcx_target_bits_fac = 0x4000; /*1.0f in 1Q14*/ + move16(); + hTcxEnc->measuredBwRatio = 0x4000; /*1.0f in 1Q14*/ + move16(); + hTcxEnc->noiseTiltFactor = 9216; /*0.5625f in 1Q14*/ + move16(); + hTcxEnc->noiseLevelMemory_cnt = 0; + move16(); + + set16_fx( hTcxEnc->ltpGainMemory_fx, 0, N_LTP_GAIN_MEMS ); + set8_fx( hTcxEnc->memQuantZeros, 0, L_FRAME_PLUS ); + + /* TCX-LTP */ + hTcxEnc->tcxltp = getTcxLtp( st->sr_core ); + move16(); + + test(); + test(); + test(); + test(); + IF( st->ini_frame == 0 ) + { + hTcxEnc->tcxltp_pitch_int_past = st->L_frame; + hTcxEnc->tcxltp_pitch_fr_past = 0; + hTcxEnc->tcxltp_gain_past = 0; + hTcxEnc->tcxltp_norm_corr_past = 0; + hTcxEnc->tcxltp_norm_corr_mem = 0; + hTcxEnc->kernel_switch_corr_past = 0; + hTcxEnc->kernel_symmetry_past = 0; /* MDCT_IV & 1 */ + hTcxEnc->enc_ste_pre_corr_past = 0; + hTcxEnc->tfm_mem_fx = 1610612736; /* 0.75 in Q31 */ + hTcxEnc->tcxltp_on_mem = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + } + ELSE IF( NE_16( st->L_frame, L_frame_old ) && !( ( GE_32( total_brate, ACELP_16k40 ) && LE_32( total_brate, ACELP_24k40 ) ) && + ( EQ_32( total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) + { + Word16 pitres, pitres_old; + Word16 pit, pit_old; + + pitres_old = 4; + move16(); + if ( EQ_16( 160, shr( L_frame_old, sub( 7, norm_s( L_frame_old ) ) ) ) ) /*if ( L_frame_old%160==0 )*/ + { + pitres_old = 6; + move16(); + } + + /*pit_old = (float)st->tcxltp_pitch_int_past + (float)st->tcxltp_pitch_fr_past/(float)pitres_old;*/ + pit_old = add( hTcxEnc->tcxltp_pitch_int_past, mult_r( hTcxEnc->tcxltp_pitch_fr_past, div_s( 1, pitres_old ) ) ); + + pitres = 4; + move16(); + if ( EQ_16( 160, shr( st->L_frame, sub( 7, norm_s( st->L_frame ) ) ) ) ) /*if ( st->L_frame%160==0 )*/ + { + pitres = 6; + move16(); + } + + /*pit = pit_old * (float)st->L_frame/(float)L_frame_old;*/ + pit = shl_sat( mult_r( pit_old, div_s( st->L_frame, shl( L_frame_old, 2 ) ) ), 2 ); + /* Note : the saturation here that can happens when FS == 32kHz*/ + /* assert(pit <= st->L_frame);*/ + + hTcxEnc->tcxltp_pitch_int_past = pit; + move16(); + hTcxEnc->tcxltp_pitch_fr_past = i_mult2( sub( pit, hTcxEnc->tcxltp_pitch_int_past ), pitres ); + move16(); + } + + hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode ); + move16(); + + return; +} + +/*-----------------------------------------------------------------------* + * init_sig_buffers() + * + * Initialization of signal buffers + *-----------------------------------------------------------------------*/ +/*copy of evs function since it was static */ +static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ) +{ + + LPD_state_HANDLE hLPDmem = st->hLPDmem; + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + + /* Encoder Past Samples at encoder-sampling-rate */ + st->encoderPastSamples_enc = shr( imult1616( st->L_frame, 9 ), 4 ); + move16(); + + /* Initialize Signal Buffers and Pointers at encoder-sampling-rate */ + IF( st->ini_frame == 0 ) + { + set16_fx( st->buf_speech_enc, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + st->exp_buf_speech_enc = 0; + move16(); + set16_fx( st->buf_speech_enc_pe, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + st->exp_buf_speech_enc_pe = 0; + move16(); + if ( hTcxEnc != NULL ) + { + set16_fx( hTcxEnc->buf_speech_ltp, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + hTcxEnc->exp_buf_speech_ltp = 0; + move16(); + } + set16_fx( st->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); /* increased by 320 to avoid memory overlap in ivas_find_wsp_fx() and also to accomodate for the wspeech_enc */ + st->exp_buf_wspeech_enc = 0; + move16(); + } + ELSE + { + test(); + test(); + test(); + test(); + test(); + IF( NE_16( st->L_frame, L_frame_old ) && !( ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) + { + lerp( st->buf_speech_enc, st->buf_speech_enc, st->L_frame, L_frame_old ); + test(); + IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) /* condition should be checked again */ + { + Copy( st->buf_speech_enc, hTcxEnc->buf_speech_ltp, st->L_frame ); + Scale_sig( hTcxEnc->buf_speech_ltp, st->L_frame, sub( st->exp_buf_speech_enc, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(15-max(st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp)) + Scale_sig( hTcxEnc->buf_speech_ltp + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( hTcxEnc->exp_buf_speech_ltp, s_max( st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(15-max(st->exp_buf_speech_enc, hTcxEnc->exp_buf_speech_ltp)) + hTcxEnc->exp_buf_speech_ltp = s_max( hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc ); + move16(); + } + + // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); + Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); + st->exp_buf_wspeech_enc = st->exp_old_wsp; + move16(); + + /*Resamp buffers needed only for ACELP*/ + test(); + test(); + IF( EQ_16( st->L_frame, L_FRAME ) && !st->tcxonly ) + { + // Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); + Copy( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); + /* SCaling to common exponent*/ + Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_12k8, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) + Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) + Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) + st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ); + move16(); + } + ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) && !st->tcxonly ) + { + lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); + Copy( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); + /* SCaling to common exponent*/ + Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_16k, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); + Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); + Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); + st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ); + move16(); + } + + st->mem_preemph_enc = st->buf_speech_enc[st->encoderPastSamples_enc + st->encoderLookahead_enc - 1]; + move16(); + st->exp_mem_preemph_enc = st->exp_buf_speech_enc; + move16(); + st->mem_wsp_enc = shr( st->buf_wspeech_enc[st->L_frame + L_SUBFR - 1], sub( Q16, st->exp_buf_wspeech_enc ) ); // Q-1 + move16(); + } + /*coming from TCXonly modes*/ + ELSE IF( !st->tcxonly && GE_32( last_total_brate, ACELP_32k ) ) + { + + Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); + // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); + st->exp_buf_wspeech_enc = st->exp_old_wsp; + move16(); /*Resamp buffers needed only for ACELP*/ + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); + } + hLPDmem->mem_w0 = 0; + move16(); + st->mem_wsp_enc = shr( st->buf_wspeech_enc[st->L_frame + L_SUBFR - 1], sub( Q16, st->exp_buf_wspeech_enc ) ); // Q-1 + move16(); + } + } + + st->new_speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc + st->encoderLookahead_enc; + st->new_speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc + st->encoderLookahead_enc; + if ( hTcxEnc != NULL ) + { + hTcxEnc->new_speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc + st->encoderLookahead_enc; + } + + IF( st->hTcxEnc != NULL ) + { + st->hTcxEnc->new_speech_TCX = st->input_buff_fx + Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ); + st->hTcxEnc->speech_TCX = st->hTcxEnc->new_speech_TCX - st->encoderLookahead_FB; + } + st->speech_enc = st->buf_speech_enc + st->encoderPastSamples_enc; + st->speech_enc_pe = st->buf_speech_enc_pe + st->encoderPastSamples_enc; + + if ( hTcxEnc != NULL ) + { + hTcxEnc->speech_ltp = hTcxEnc->buf_speech_ltp + st->encoderPastSamples_enc; + } + + IF( st->element_mode > EVS_MONO ) + { + st->wspeech_enc = st->buf_wspeech_enc + st->L_frame + L_SUBFR; + } + ELSE + { + st->wspeech_enc = st->buf_wspeech_enc + st->L_frame + L_subfr; + } + + test(); + test(); + IF( st->ini_frame == 0 || NE_16( st->L_frame, L_frame_old ) || EQ_16( st->last_codec_mode, MODE1 ) ) + { + set16_fx( st->buf_synth, 0, OLD_SYNTH_SIZE_ENC + L_FRAME32k ); + } + + st->synth = st->buf_synth + st->L_frame + L_subfr; + + + return; +} + +/*-----------------------------------------------------------------------* + * init_core_sig_ana() + * + * + *-----------------------------------------------------------------------*/ +static void init_core_sig_ana_ivas_fx( Encoder_State *st ) +{ + + /* Pre-emphasis factor and memory */ + + st->preemph_fac = PREEMPH_FAC_SWB; /*SWB*/ + move16(); + IF( LT_16( st->fscale, ( 16000 * FSCALE_DENOM ) / 12800 ) ) + { + st->preemph_fac = PREEMPH_FAC; /*WB*/ + move16(); + } + ELSE IF( LT_16( st->fscale, ( 24000 * FSCALE_DENOM ) / 12800 ) ) + { + st->preemph_fac = PREEMPH_FAC_16k; /*WB*/ + move16(); + } + + st->gamma = GAMMA1; + move16(); + st->inv_gamma = GAMMA1_INV; + move16(); + IF( EQ_32( st->sr_core, 16000 ) ) + { + st->gamma = GAMMA16k; + move16(); + st->inv_gamma = GAMMA16k_INV; + move16(); + } + + + st->min_band = 1; + move16(); + st->max_band = 16; + move16(); + + IF( st->narrowBand == 0 ) + { + st->min_band = 0; + move16(); + st->max_band = 19; + move16(); + } + + + return; +} +/*-----------------------------------------------------------------------* + * init_acelp() + * + * + *-----------------------------------------------------------------------*/ +static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ) +{ + Word16 mem_syn_r_size_old; + Word16 mem_syn_r_size_new; + LPD_state_HANDLE hLPDmem = st->hLPDmem; + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + + /* Init pitch lag */ + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + /* TCX LTP ana always runs @12.8kHz */ + st->pit_res_max = initPitchLagParameters( 12800, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); + move16(); + } + ELSE + { + st->pit_res_max = initPitchLagParameters( st->sr_core, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); + move16(); + } + + /* Init LPDmem */ + IF( st->ini_frame == 0 ) + { + IF( hLPDmem != NULL ) + { + set16_fx( hLPDmem->syn, 0, 1 + M ); + set16_fx( hLPDmem->mem_syn_r, 0, L_SYN_MEM ); + } + + IF( st->hTcxEnc != NULL ) + { + set16_fx( st->hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); + st->hTcxEnc->q_Txnq = Q15; + move16(); + st->hTcxEnc->acelp_zir = st->hTcxEnc->Txnq + shr( st->L_frame, 1 ); + } + } + ELSE /*Rate switching*/ + { + IF( st->last_core == ACELP_CORE ) + { + lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, shr( st->L_frame, 1 ), shr( L_frame_old, 1 ) ); + } + ELSE + { + lerp( hTcxEnc->Txnq, hTcxEnc->Txnq, st->hTcxCfg->tcx_mdct_window_length, st->hTcxCfg->tcx_mdct_window_length_old ); + } + hTcxEnc->acelp_zir = hTcxEnc->Txnq + shr( st->L_frame, 1 ); + + /* Rate switching */ + IF( EQ_16( st->last_codec_mode, MODE1 ) && st->element_mode == EVS_MONO ) + { + IF( hLPDmem != NULL ) + { + Copy( hLPDmem->mem_syn1_fx, hLPDmem->mem_syn2, M ); + set16_fx( hLPDmem->syn, 0, M ); + hLPDmem->q_lpd_syn = Q15; + move16(); + } + IF( st->hTcxEnc != NULL ) + { + set16_fx( hTcxEnc->Txnq, 0, L_FRAME32k / 2 + 64 ); + st->hTcxEnc->q_Txnq = Q15; + move16(); + } + } + + /*AMR-WBIO->MODE2*/ + IF( EQ_16( st->last_core, AMR_WB_CORE ) ) + { + st->next_force_safety_net = 1; + move16(); + st->last_core = ACELP_CORE; + move16(); + } + /*HQ-CORE->MODE2*/ + test(); + IF( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->last_core, HQ_CORE ) ) + { + /*Reset of ACELP memories*/ + st->next_force_safety_net = 1; + move16(); + st->rate_switching_reset = 1; + move16(); + IF( hLPDmem != NULL ) + { + hLPDmem->tilt_code = TILT_CODE; + move16(); + set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); + set16_fx( hLPDmem->syn, 0, 1 + M ); + hLPDmem->q_lpd_syn = Q15; + move16(); + hLPDmem->q_lpd_old_exc = Q15; + move16(); + hLPDmem->mem_w0 = 0; + move16(); + set16_fx( hLPDmem->mem_syn, 0, M ); + set16_fx( hLPDmem->mem_syn2, 0, M ); + hLPDmem->q_mem_syn = Q15; + move16(); + } + + /* unquantized LPC*/ + test(); + test(); + test(); + IF( !( ( GE_32( st->total_brate, ACELP_16k40 ) && LE_32( st->total_brate, ACELP_24k40 ) ) && ( EQ_32( st->total_brate, last_total_brate ) ) && ( EQ_16( st->last_bwidth, st->bwidth ) ) ) ) + { + Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + lsp_convert_poly_fx( st->lspold_enc_fx, st->L_frame, 0 ); + } + } + Copy( st->lspold_enc_fx, st->lsp_old_fx, M ); /*used unquantized values for mid-LSF Q*/ + IF( st->tcxonly == 0 ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); + } + ELSE + { + E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); + } + st->last_core = TCX_20_CORE; + move16(); + + st->hTcxCfg->last_aldo = 1; /*It was previously ALDO*/ + st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; + move16(); + move16(); + /*ALDO overlap windowed past: also used in MODE1 but for other MDCT-FB*/ + set16_fx( hTcxEnc->old_out_fx, 0, st->L_frame ); + } + ELSE + { + test(); + test(); + test(); + test(); + IF( ( NE_16( st->L_frame, L_frame_old ) ) && ( LE_16( st->L_frame, L_FRAME16k ) ) && ( LE_16( L_frame_old, L_FRAME16k ) ) ) + { + /* convert quantized LSP vector */ + st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); + move16(); + IF( st->tcxonly == 0 ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); + } + ELSE + { + E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); + } + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); + } + ELSE + { + Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); + } + + + /*Mem of deemphasis stay unchanged : hLPDmem->syn*/ + IF( hLPDmem != NULL ) + { + synth_mem_updt2( st->L_frame, st->last_L_frame, hLPDmem->old_exc, hLPDmem->mem_syn_r, hLPDmem->mem_syn2, hLPDmem->mem_syn, ENC ); + Word16 tmp, A[M + 1], Ap[M + 1], tmp_buf[M + 1]; + /* Update wsyn */ + /* lsp2a_stab( st->lsp_old, A, M ); */ + E_LPC_f_lsp_a_conversion( st->lsp_old_fx, A, M ); + weight_a_fx( A, Ap, GAMMA1, M ); + tmp = 0; + move16(); + tmp_buf[0] = 0; + move16(); + Copy( hLPDmem->mem_syn2, tmp_buf + 1, M ); + deemph_fx( tmp_buf + 1, st->preemph_fac, M, &tmp ); + Residu3_fx( Ap, tmp_buf + M, &tmp, 1, 1 ); + hLPDmem->mem_w0 = sub_sat( shr_sat( st->wspeech_enc[-1], shift ), tmp ); + move16(); + } + } + ELSE IF( ( NE_16( st->L_frame, L_frame_old ) ) ) + { + /*Partial reset of ACELP memories*/ + st->next_force_safety_net = 1; + move16(); + st->rate_switching_reset = 1; + move16(); + + /*reset partly some memories*/ + IF( hLPDmem != NULL ) + { + hLPDmem->tilt_code = TILT_CODE; + move16(); + set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); + move16(); + hLPDmem->q_lpd_old_exc = Q15; + move16(); + /*Resamp others memories*/ + /*Size of LPC syn memory*/ + /* 1.25/20.0 = 1.0/16.0 -> shift 4 to the right. */ + mem_syn_r_size_old = shr( L_frame_old, 4 ); + mem_syn_r_size_new = shr( st->L_frame, 4 ); + + lerp( hLPDmem->mem_syn_r + L_SYN_MEM - mem_syn_r_size_old, hLPDmem->mem_syn_r + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + Copy( hLPDmem->mem_syn_r + L_SYN_MEM - M, hLPDmem->mem_syn, M ); + Copy( hLPDmem->mem_syn, hLPDmem->mem_syn2, M ); + + /*Untouched memories : hLPDmem->syn & hLPDmem->mem_w0*/ + hLPDmem->mem_w0 = 0; + move16(); + } + /* unquantized LPC*/ + Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); /*lsp old @12.8kHz*/ + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + lsp_convert_poly_fx( st->lspold_enc_fx, st->L_frame, 0 ); + } + Copy( st->lspold_enc_fx, st->lsp_old_fx, M ); /*used unquantized values for mid-LSF Q*/ + IF( st->tcxonly == 0 ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); + } + ELSE + { + E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); + } + } + ELSE IF( !st->tcxonly && EQ_16( st->L_frame, L_FRAME16k ) && GT_32( st->last_total_brate, ACELP_32k ) ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); + } + } + } + + test(); + test(); + if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && st->ini_frame != 0 ) + { + st->rate_switching_reset = 1; + move16(); + } + + /* Post-processing */ + /*EVS specific*/ + /* hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 ); + set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); + hLPDmem->dm_fx.prev_state = 0;*/ + /*------------*/ + + if ( hLPDmem != NULL ) + { + hLPDmem->dm_fx.prev_state = 0; + move16(); /* This corresponds to st_fx->dispMem in FLP */ + hLPDmem->dm_fx.prev_gain_code = 0; + move32(); + + FOR( Word16 i = 2; i < 8; i++ ) + { + hLPDmem->dm_fx.prev_gain_pit[i - 2] = 0; + move16(); + } + hLPDmem->gc_threshold = 0; + move16(); + } + + /* Pulse Search configuration */ + st->acelp_autocorr = 1; + move16(); + + /*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/ + test(); + test(); + if ( ( LE_32( st->total_brate, ACELP_9k60 ) || EQ_16( st->rf_mode, 1 ) ) && ( EQ_32( st->sr_core, 12800 ) ) ) + { + st->acelp_autocorr = 0; + move16(); + } + + + /*BPF parameters for adjusting gain in function of background noise*/ + IF( EQ_16( st->codec_mode, MODE2 ) ) + { + st->mem_bpf_fx.lp_error_ener = L_deposit_l( 0 ); + move32(); + st->pst_lp_ener_fx = 0; + move16(); + IF( EQ_16( st->last_codec_mode, MODE1 ) ) + { + st->mem_bpf_fx.lp_error = 0; + move32(); + st->pst_mem_deemp_err_fx = 0; + move16(); + } + } + + return; +} +/*-----------------------------------------------------------------------* + * init_modes() + * + * + *-----------------------------------------------------------------------*/ + +static void init_modes_ivas_fx( + Encoder_State *st, + const Word32 last_total_brate ) +{ + Word8 n; + Word32 tmp32; + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + + /* Restrict ACE/TCX20/TCX10 mode */ + move16(); + st->restrictedMode = getRestrictedMode( st->element_mode, st->total_brate, st->Opt_AMR_WB ); + move16(); + st->acelpEnabled = 0; + move16(); + st->tcx20Enabled = 0; + move16(); + st->tcx10Enabled = 0; + + if ( EQ_16( s_and( st->restrictedMode, 1 ), 1 ) ) + { + st->acelpEnabled = 1; + move16(); + } + if ( EQ_16( s_and( st->restrictedMode, 2 ), 2 ) ) + { + st->tcx20Enabled = 1; + move16(); + } + if ( EQ_16( s_and( st->restrictedMode, 4 ), 4 ) ) + { + st->tcx10Enabled = 1; + move16(); + } + + /* TCX mode (TCX20 TCX10_10 or NO_TCX) */ + if ( st->hTcxEnc != NULL ) + { + hTcxEnc->tcxMode = NO_TCX; + move16(); + } + + /* Bits Budget */ + /*st->bits_frame_nominal = (int)( (float)st->L_frame * (float)FSCALE_DENOM * (float)st->bitrate / ( (float)st->fscale * 12800.0f ) );*/ + /*st->bits_frame_nominal = (int)( (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate/100.0f + 0.49f );*/ + /*328 = 0.010009765625 in 0Q15*/ + /* st->bits_frame_nominal = extract_h(L_add(L_mult(div_l(L_mult(shl(st->L_frame,2),st->bitrate),st->fscale),328),16056)); */ + + /* st->bits_frame_nominal = (int)( (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate/100.0f + 0.49f ); */ + tmp32 = L_shl( st->total_brate, 1 ); /* (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate */ + st->bits_frame_nominal = extract_l( L_shr( Mpy_32_16_1( tmp32, 20972 ), 6 ) ); /* 20972 = 0.01 * 64 * 32768 */ + move16(); + + IF( st->Opt_AMR_WB ) + { + st->bits_frame = st->bits_frame_nominal; + move16(); + st->bits_frame_core = st->bits_frame_nominal; + move16(); + st->frame_size_index = 0; + move16(); + } + ELSE + { + FOR( n = 0; n < FRAME_SIZE_NB; n++ ) + { + IF( LT_32( n, FRAME_SIZE_NB - 1 ) ) + { + test(); + IF( LE_32( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) && GT_32( FrameSizeConfig[n + 1].frame_bits, st->bits_frame_nominal ) ) + { + st->frame_size_index = n; + move16(); + st->bits_frame = st->bits_frame_nominal; + move16(); + st->bits_frame_core = sub( sub( sub( st->bits_frame_nominal, FrameSizeConfig[n].transmission_bits ), FrameSizeConfig[n].bandwidth_bits ), FrameSizeConfig[n].reserved_bits ); + move16(); + BREAK; + } + } + ELSE + { + IF( LE_32( FrameSizeConfig[n].frame_bits, st->bits_frame_nominal ) ) + { + st->frame_size_index = n; + move16(); + st->bits_frame = st->bits_frame_nominal; + move16(); + st->bits_frame_core = sub( sub( sub( st->bits_frame_nominal, FrameSizeConfig[n].transmission_bits ), FrameSizeConfig[n].bandwidth_bits ), FrameSizeConfig[n].reserved_bits ); + move16(); + BREAK; + } + } + } + } + + /* Reconfigure core */ + core_coder_reconfig_ivas_fx( st, last_total_brate ); + + return; } diff --git a/lib_enc/core_enc_ol.c b/lib_enc/core_enc_ol.c deleted file mode 100644 index c282f7649..000000000 --- a/lib_enc/core_enc_ol.c +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" diff --git a/lib_enc/core_enc_reconf.c b/lib_enc/core_enc_reconf.c deleted file mode 100644 index 2bffd1728..000000000 --- a/lib_enc/core_enc_reconf.c +++ /dev/null @@ -1,346 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-----------------------------------------------------------------* - * Funtion core_coder_reconfig * - * ~~~~~~~~~~~~~~~~~~~ * - * - reconfig core coder when switching to another frame type * - *-----------------------------------------------------------------*/ - -void core_coder_reconfig_ivas_fx( - Encoder_State *st, - const int32_t last_total_brate ) -{ - Word16 i, bwidth, index; - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - /*Configuration of ACELP*/ - BITS_ALLOC_init_config_acelp( st->total_brate, st->narrowBand, st->nb_subfr, &( st->acelp_cfg ) ); - - /*Configuration of partial copy*/ - IF( st->Opt_RF_ON ) - { - st->hRF->acelp_cfg_rf.mode_index = 1; - st->hRF->acelp_cfg_rf.midLpc = 0; - st->hRF->acelp_cfg_rf.midLpc_enable = 0; - st->hRF->acelp_cfg_rf.pre_emphasis = 0; - st->hRF->acelp_cfg_rf.formant_enh = 1; - st->hRF->acelp_cfg_rf.formant_tilt = 1; - st->hRF->acelp_cfg_rf.voice_tilt = 1; - st->hRF->acelp_cfg_rf.formant_enh_num = FORMANT_SHARPENING_G1; - st->hRF->acelp_cfg_rf.formant_enh_den = FORMANT_SHARPENING_G2; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - } - - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - st->nb_bits_header_tcx = 2; /* signal class */ - move16(); - } - ELSE IF( st->tcxonly ) - { - st->nb_bits_header_tcx = 1 + 1; /*TCX20/TCX10 + last_core*/ - st->nb_bits_header_tcx = add( st->nb_bits_header_tcx, 2 ); /* Siganl class*/ - move16(); - move16(); - } - ELSE - { - st->nb_bits_header_ace = 1 + 2 + 1; /*TCX/ACELP+coder_type + last_core*/ - st->nb_bits_header_tcx = st->nb_bits_header_ace; - move16(); - move16(); - - IF( st->hTcxCfg != NULL ) - { - IF( st->hTcxCfg->lfacNext <= 0 ) - { - st->nb_bits_header_ace = sub( st->nb_bits_header_ace, 1 ); /*No last_core*/ - move16(); - } - } - } - - - /*Switch off TCX or ACELP?*/ - IF( EQ_32( st->sr_core, INT_FS_12k8 ) ) - { - st->acelpEnabled = extract_l( EQ_16( ( s_and( st->restrictedMode, 1 ) ), 1 ) ); - st->tcx20Enabled = extract_l( EQ_16( ( s_and( st->restrictedMode, 2 ) ), 2 ) ); - move16(); - move16(); - } - st->prevEnergyHF_fx = st->currEnergyHF_fx = 1073725440l /*65535.0f Q14*/; /* prevent block switch */ - st->currEnergyHF_e_fx = 17; - move32(); - move16(); - - /*Sanity check : don't need to be instrumented*/ - IF( st->tcxonly == 0 ) - { - assert( st->acelpEnabled || st->tcx20Enabled || st->frame_size_index == 0 ); - } - ELSE - { - assert( st->tcx10Enabled || st->tcx20Enabled || st->frame_size_index == 0 ); - } - - /* TCX-LTP */ - IF( st->hTcxEnc != NULL ) - { - hTcxEnc->tcxltp = getTcxLtp( st->sr_core ); - move16(); - } - - /*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/ - - st->acelp_autocorr = 1; - move16(); - - test(); - if ( ( LE_32( st->total_brate, ACELP_9k60 ) ) && ( EQ_32( st->sr_core, INT_FS_12k8 ) ) ) - { - st->acelp_autocorr = 0; - move16(); - } - - /*Get bandwidth mode*/ - IF( st->narrowBand ) - { - move16(); - bwidth = NB; - } - ELSE IF( LE_32( st->sr_core, INT_FS_16k ) ) - { - move16(); - bwidth = WB; - } - ELSE - { - move16(); - bwidth = SWB; - } - - /*Scale TCX for non-active frames to adjust loudness with ACELP*/ - IF( st->hTcxCfg != NULL ) - { - st->hTcxCfg->na_scale = 32767 /*1.0f Q15*/; - move16(); - - test(); - IF( LT_16( bwidth, 2 ) && ( st->tcxonly == 0 ) ) - { - /*const Word16 scaleTableSize = sizeof(scaleTcxTable) / sizeof(scaleTcxTable[0]);*/ - - FOR( i = 0; i < SIZE_SCALE_TABLE_TCX; i++ ) - { - - test(); - test(); - IF( EQ_16( bwidth, scaleTcxTable[i].bwmode ) && - GE_32( st->total_brate, scaleTcxTable[i].bitrateFrom ) && - LT_32( st->total_brate, scaleTcxTable[i].bitrateTo ) ) - { - if ( st->rf_mode ) - { - i = sub( i, 1 ); - } - move16(); - st->hTcxCfg->na_scale = scaleTcxTable[i].scale; - BREAK; - } - } - } - } - st->enableTcxLpc = 0; - move16(); - IF( GT_16( st->element_mode, IVAS_SCE ) ) - { - test(); - test(); - st->enableTcxLpc = ( EQ_16( st->lpcQuantization, 1 ) && ( LE_32( st->total_brate, LOWRATE_TCXLPC_MAX_BR_CPE ) || st->rf_mode ) ); - move16(); - } - ELSE - { - test(); - test(); - if ( EQ_16( st->lpcQuantization, 1 ) && ( LE_32( st->total_brate, LOWRATE_TCXLPC_MAX_BR ) || st->rf_mode != 0 ) ) - { - st->enableTcxLpc = 1; - move16(); - } - } - test(); - IF( st->ini_frame == 0 || EQ_16( st->last_codec_mode, MODE1 ) ) - { - st->envWeighted = 0; - move16(); - } - - test(); - test(); - test(); - IF( EQ_16( st->bwidth, SWB ) && - ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) - { - IF( st->tec_tfa == 0 ) - { - FOR( i = 0; i < MAX_TEC_SMOOTHING_DEG; i++ ) - { - st->hTECEnc->loBuffer[i] = 0; - move16(); - } - } - st->tec_tfa = 1; - move16(); - } - ELSE - { - st->tec_tfa = 0; - move16(); - } - - st->enablePlcWaveadjust = 0; - move16(); - if ( GE_32( st->total_brate, HQ_48k ) ) - { - st->enablePlcWaveadjust = 1; - move16(); - } - - - move16(); - st->glr = 0; - test(); - test(); - test(); - if ( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( st->element_mode == EVS_MONO ) ) - { - move16(); - st->glr = 1; - } - - IF( st->glr ) - { - move16(); - st->nb_bits_header_ace = add( st->nb_bits_header_ace, G_LPC_RECOVERY_BITS ); - } - IF( hTcxEnc != NULL ) - { - test(); - IF( EQ_16( st->bwidth, NB ) || EQ_16( st->bwidth, WB ) ) - { - IF( st->rf_mode == 0 ) - { - index = s_min( N_TCX_STARTLINE_NOISE_WB - 1, s_max( 3, st->frame_size_index ) ); - } - ELSE - { - index = s_min( N_TCX_STARTLINE_NOISE_WB - 1, s_max( 3, st->frame_size_index - 1 ) ); - } - hTcxEnc->nmStartLine = startLineWB[index]; - move16(); - } - ELSE /* (st->bwidth == SWB || st->bwidth == FB) */ - { - IF( st->rf_mode == 0 ) - { - index = s_min( N_TCX_STARTLINE_NOISE_SWB - 1, sub( s_max( 3, st->frame_size_index ), 3 ) ); - } - ELSE - { - index = s_min( N_TCX_STARTLINE_NOISE_SWB - 1, sub( s_max( 3, st->frame_size_index - 1 ), 3 ) ); - } - test(); - test(); - if ( GE_32( st->total_brate, IVAS_96k ) && LE_32( st->total_brate, IVAS_192k ) && GT_16( st->element_mode, IVAS_SCE ) ) - { - index = sub( index, 1 ); - } - hTcxEnc->nmStartLine = startLineSWB[index]; - move16(); - test(); - test(); - IF( EQ_32( st->total_brate, IVAS_48k ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LT_16( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), shl( st->L_frame, 2 ) ) ) - { - hTcxEnc->nmStartLine = shr( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), 2 ); /* low-rate stereo is more efficient than dual-mono due to stereo processing */ - move16(); - } - } - } - - IF( hTcxEnc != NULL ) - { - test(); - test(); - test(); - test(); - test(); - IF( ( LT_32( st->total_brate, ACELP_24k40 ) ) && ( ( GT_32( st->total_brate, last_total_brate ) ) || ( EQ_16( st->last_codec_mode, MODE1 ) ) ) ) - { - /* low-freq memQuantZeros_fx must be reset partially if bitrate increased */ - FOR( i = 0; i < hTcxEnc->nmStartLine; i++ ) - { - hTcxEnc->memQuantZeros[i] = 0; - move16(); - } - } - ELSE IF( ( GE_32( st->total_brate, ACELP_24k40 ) ) && ( LE_32( st->total_brate, ACELP_32k ) ) && ( GE_32( last_total_brate, ACELP_13k20 ) ) && ( LT_32( last_total_brate, ACELP_24k40 ) ) ) - { - FOR( i = 0; i < st->L_frame; i++ ) /* memQuantZeros_fx won't be updated */ - { - hTcxEnc->memQuantZeros[i] = 0; - move16(); - } - } - } -} diff --git a/lib_enc/core_enc_reconf_fx.c b/lib_enc/core_enc_reconf_fx.c index 3140422be..3637dd53f 100644 --- a/lib_enc/core_enc_reconf_fx.c +++ b/lib_enc/core_enc_reconf_fx.c @@ -334,3 +334,307 @@ void core_coder_reconfig_fx( } } } + + +/*-----------------------------------------------------------------* + * Funtion core_coder_reconfig * + * ~~~~~~~~~~~~~~~~~~~ * + * - reconfig core coder when switching to another frame type * + *-----------------------------------------------------------------*/ + +void core_coder_reconfig_ivas_fx( + Encoder_State *st, + const int32_t last_total_brate ) +{ + Word16 i, bwidth, index; + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + /*Configuration of ACELP*/ + BITS_ALLOC_init_config_acelp( st->total_brate, st->narrowBand, st->nb_subfr, &( st->acelp_cfg ) ); + + /*Configuration of partial copy*/ + IF( st->Opt_RF_ON ) + { + st->hRF->acelp_cfg_rf.mode_index = 1; + st->hRF->acelp_cfg_rf.midLpc = 0; + st->hRF->acelp_cfg_rf.midLpc_enable = 0; + st->hRF->acelp_cfg_rf.pre_emphasis = 0; + st->hRF->acelp_cfg_rf.formant_enh = 1; + st->hRF->acelp_cfg_rf.formant_tilt = 1; + st->hRF->acelp_cfg_rf.voice_tilt = 1; + st->hRF->acelp_cfg_rf.formant_enh_num = FORMANT_SHARPENING_G1; + st->hRF->acelp_cfg_rf.formant_enh_den = FORMANT_SHARPENING_G2; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + } + + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + st->nb_bits_header_tcx = 2; /* signal class */ + move16(); + } + ELSE IF( st->tcxonly ) + { + st->nb_bits_header_tcx = 1 + 1; /*TCX20/TCX10 + last_core*/ + st->nb_bits_header_tcx = add( st->nb_bits_header_tcx, 2 ); /* Siganl class*/ + move16(); + move16(); + } + ELSE + { + st->nb_bits_header_ace = 1 + 2 + 1; /*TCX/ACELP+coder_type + last_core*/ + st->nb_bits_header_tcx = st->nb_bits_header_ace; + move16(); + move16(); + + IF( st->hTcxCfg != NULL ) + { + IF( st->hTcxCfg->lfacNext <= 0 ) + { + st->nb_bits_header_ace = sub( st->nb_bits_header_ace, 1 ); /*No last_core*/ + move16(); + } + } + } + + + /*Switch off TCX or ACELP?*/ + IF( EQ_32( st->sr_core, INT_FS_12k8 ) ) + { + st->acelpEnabled = extract_l( EQ_16( ( s_and( st->restrictedMode, 1 ) ), 1 ) ); + st->tcx20Enabled = extract_l( EQ_16( ( s_and( st->restrictedMode, 2 ) ), 2 ) ); + move16(); + move16(); + } + st->prevEnergyHF_fx = st->currEnergyHF_fx = 1073725440l /*65535.0f Q14*/; /* prevent block switch */ + st->currEnergyHF_e_fx = 17; + move32(); + move16(); + + /*Sanity check : don't need to be instrumented*/ + IF( st->tcxonly == 0 ) + { + assert( st->acelpEnabled || st->tcx20Enabled || st->frame_size_index == 0 ); + } + ELSE + { + assert( st->tcx10Enabled || st->tcx20Enabled || st->frame_size_index == 0 ); + } + + /* TCX-LTP */ + IF( st->hTcxEnc != NULL ) + { + hTcxEnc->tcxltp = getTcxLtp( st->sr_core ); + move16(); + } + + /*Use for 12.8 kHz sampling rate and low bitrates, the conventional pulse search->better SNR*/ + + st->acelp_autocorr = 1; + move16(); + + test(); + if ( ( LE_32( st->total_brate, ACELP_9k60 ) ) && ( EQ_32( st->sr_core, INT_FS_12k8 ) ) ) + { + st->acelp_autocorr = 0; + move16(); + } + + /*Get bandwidth mode*/ + IF( st->narrowBand ) + { + move16(); + bwidth = NB; + } + ELSE IF( LE_32( st->sr_core, INT_FS_16k ) ) + { + move16(); + bwidth = WB; + } + ELSE + { + move16(); + bwidth = SWB; + } + + /*Scale TCX for non-active frames to adjust loudness with ACELP*/ + IF( st->hTcxCfg != NULL ) + { + st->hTcxCfg->na_scale = 32767 /*1.0f Q15*/; + move16(); + + test(); + IF( LT_16( bwidth, 2 ) && ( st->tcxonly == 0 ) ) + { + /*const Word16 scaleTableSize = sizeof(scaleTcxTable) / sizeof(scaleTcxTable[0]);*/ + + FOR( i = 0; i < SIZE_SCALE_TABLE_TCX; i++ ) + { + + test(); + test(); + IF( EQ_16( bwidth, scaleTcxTable[i].bwmode ) && + GE_32( st->total_brate, scaleTcxTable[i].bitrateFrom ) && + LT_32( st->total_brate, scaleTcxTable[i].bitrateTo ) ) + { + if ( st->rf_mode ) + { + i = sub( i, 1 ); + } + move16(); + st->hTcxCfg->na_scale = scaleTcxTable[i].scale; + BREAK; + } + } + } + } + st->enableTcxLpc = 0; + move16(); + IF( GT_16( st->element_mode, IVAS_SCE ) ) + { + test(); + test(); + st->enableTcxLpc = ( EQ_16( st->lpcQuantization, 1 ) && ( LE_32( st->total_brate, LOWRATE_TCXLPC_MAX_BR_CPE ) || st->rf_mode ) ); + move16(); + } + ELSE + { + test(); + test(); + if ( EQ_16( st->lpcQuantization, 1 ) && ( LE_32( st->total_brate, LOWRATE_TCXLPC_MAX_BR ) || st->rf_mode != 0 ) ) + { + st->enableTcxLpc = 1; + move16(); + } + } + test(); + IF( st->ini_frame == 0 || EQ_16( st->last_codec_mode, MODE1 ) ) + { + st->envWeighted = 0; + move16(); + } + + test(); + test(); + test(); + IF( EQ_16( st->bwidth, SWB ) && + ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && st->element_mode == EVS_MONO ) + { + IF( st->tec_tfa == 0 ) + { + FOR( i = 0; i < MAX_TEC_SMOOTHING_DEG; i++ ) + { + st->hTECEnc->loBuffer[i] = 0; + move16(); + } + } + st->tec_tfa = 1; + move16(); + } + ELSE + { + st->tec_tfa = 0; + move16(); + } + + st->enablePlcWaveadjust = 0; + move16(); + if ( GE_32( st->total_brate, HQ_48k ) ) + { + st->enablePlcWaveadjust = 1; + move16(); + } + + + move16(); + st->glr = 0; + test(); + test(); + test(); + if ( ( EQ_32( st->total_brate, ACELP_9k60 ) || EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && ( st->element_mode == EVS_MONO ) ) + { + move16(); + st->glr = 1; + } + + IF( st->glr ) + { + move16(); + st->nb_bits_header_ace = add( st->nb_bits_header_ace, G_LPC_RECOVERY_BITS ); + } + IF( hTcxEnc != NULL ) + { + test(); + IF( EQ_16( st->bwidth, NB ) || EQ_16( st->bwidth, WB ) ) + { + IF( st->rf_mode == 0 ) + { + index = s_min( N_TCX_STARTLINE_NOISE_WB - 1, s_max( 3, st->frame_size_index ) ); + } + ELSE + { + index = s_min( N_TCX_STARTLINE_NOISE_WB - 1, s_max( 3, st->frame_size_index - 1 ) ); + } + hTcxEnc->nmStartLine = startLineWB[index]; + move16(); + } + ELSE /* (st->bwidth == SWB || st->bwidth == FB) */ + { + IF( st->rf_mode == 0 ) + { + index = s_min( N_TCX_STARTLINE_NOISE_SWB - 1, sub( s_max( 3, st->frame_size_index ), 3 ) ); + } + ELSE + { + index = s_min( N_TCX_STARTLINE_NOISE_SWB - 1, sub( s_max( 3, st->frame_size_index - 1 ), 3 ) ); + } + test(); + test(); + if ( GE_32( st->total_brate, IVAS_96k ) && LE_32( st->total_brate, IVAS_192k ) && GT_16( st->element_mode, IVAS_SCE ) ) + { + index = sub( index, 1 ); + } + hTcxEnc->nmStartLine = startLineSWB[index]; + move16(); + test(); + test(); + IF( EQ_32( st->total_brate, IVAS_48k ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LT_16( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), shl( st->L_frame, 2 ) ) ) + { + hTcxEnc->nmStartLine = shr( add( hTcxEnc->nmStartLine, shl( hTcxEnc->nmStartLine, 2 ) ), 2 ); /* low-rate stereo is more efficient than dual-mono due to stereo processing */ + move16(); + } + } + } + + IF( hTcxEnc != NULL ) + { + test(); + test(); + test(); + test(); + test(); + IF( ( LT_32( st->total_brate, ACELP_24k40 ) ) && ( ( GT_32( st->total_brate, last_total_brate ) ) || ( EQ_16( st->last_codec_mode, MODE1 ) ) ) ) + { + /* low-freq memQuantZeros_fx must be reset partially if bitrate increased */ + FOR( i = 0; i < hTcxEnc->nmStartLine; i++ ) + { + hTcxEnc->memQuantZeros[i] = 0; + move16(); + } + } + ELSE IF( ( GE_32( st->total_brate, ACELP_24k40 ) ) && ( LE_32( st->total_brate, ACELP_32k ) ) && ( GE_32( last_total_brate, ACELP_13k20 ) ) && ( LT_32( last_total_brate, ACELP_24k40 ) ) ) + { + FOR( i = 0; i < st->L_frame; i++ ) /* memQuantZeros_fx won't be updated */ + { + hTcxEnc->memQuantZeros[i] = 0; + move16(); + } + } + } +} diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c deleted file mode 100644 index f2375fb50..000000000 --- a/lib_enc/core_enc_switch.c +++ /dev/null @@ -1,302 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" - - -/*-------------------------------------------------------------------* - * core_coder_mode_switch() - * - * - *-------------------------------------------------------------------*/ -void core_coder_mode_switch_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word32 last_total_brate, /* i : last bitrate */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ -) -{ - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - Word16 i, fscale, switchWB; - Word32 sr_core; - Word16 bSwitchFromAmrwbIO; - Word16 tcxonly_tmp, exp_res; - - switchWB = 0; - move16(); - bSwitchFromAmrwbIO = 0; - move16(); - exp_res = 0; - move16(); - - - if ( EQ_16( st->last_core, AMR_WB_CORE ) ) - { - bSwitchFromAmrwbIO = 1; - move16(); - } - - /* force active frame for the first frame when switching from high bitrates when DTX is enabled*/ - sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); - - fscale = sr2fscale_fx( sr_core ); - if ( EQ_16( st->last_codec_mode, MODE1 ) ) - { - switchWB = 1; /*force init when coming from MODE1*/ - move16(); - } - - tcxonly_tmp = getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); - - if ( NE_32( tcxonly_tmp, st->tcxonly ) ) - { - switchWB = 1; /*force init when coming from MODE1*/ - move16(); - } - - test(); - test(); - IF( EQ_32( fscale, st->fscale ) && !bSwitchFromAmrwbIO && !switchWB ) - { - st->sr_core = sr_core; - move16(); - Word16 tmp = BASOP_Util_Divide3232_Scale( sr_core, FRAMES_PER_SEC, &exp_res ); - st->L_frame = shr( tmp, sub( 15, exp_res ) ); // Q0 - move16(); - - st->tcxonly = getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); - move16(); - - Word16 exp_tmp1 = 0; - move16(); - Word16 tmp1 = BASOP_Util_Divide1616_Scale( ONE_IN_Q9, 128, &exp_tmp1 ); - - Word16 exp_tmp2 = 0; - move16(); - Word16 tmp2 = BASOP_Util_Divide3232_Scale( st->total_brate, 100, &exp_tmp2 ); - - Word16 exp_tmp3 = 0; - move16(); - Word16 tmp3 = BASOP_Util_Divide3232_Scale( st->L_frame, st->fscale, &exp_tmp3 ); - - Word32 tmp4 = L_mult0( tmp1, tmp2 ); // exp_tmp1 + exp_tmp2 - Word32 tmp5 = L_shl( Mpy_32_16_1( tmp4, tmp3 ), 1 ); // exp_tmp1 + exp_tmp2 + exp_tmp3 - st->bits_frame_nominal = extract_l( L_shr( tmp5, sub( 31, ( add( add( exp_tmp1, exp_tmp2 ), exp_tmp3 ) ) ) ) ); - move16(); - st->igf = getIgfPresent_fx( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); - move16(); - /* switch IGF configuration */ - IF( st->igf ) - { - IGFEncSetMode_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode ); - } - st->hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( st->bwidth ); - move16(); - - st->hTcxCfg->bandwidth = getTcxBandwidth( st->bwidth ); - move16(); - if ( st->tcxonly ) - { - st->hTcxCfg->tcxRateLoopOpt = 2; - move16(); - } - else - { - st->hTcxCfg->tcxRateLoopOpt = 0; - move16(); - } - if ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - st->hTcxCfg->tcxRateLoopOpt = 3; - move16(); - } - st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, st->total_brate, st->rf_mode ); - st->hTcxCfg->resq = getResq( st->total_brate ); - hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode ); - test(); - if ( st->hTcxCfg->resq && !st->tcxonly ) - { - st->hTcxCfg->tcxRateLoopOpt = 1; - move16(); - } - st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->total_brate, st->igf, st->element_mode ); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - - IF( st->hTcxCfg->fIsTNSAllowed ) - { - InitTnsConfigs_ivas_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, MCT_flag ); - - SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, st->element_mode == IVAS_CPE_MDCT ); - } - - IF( EQ_16( st->bwidth, NB ) ) - { - st->narrowBand = 1; - st->min_band = 1; - st->max_band = 16; - } - ELSE - { - st->narrowBand = 0; - st->min_band = 0; - st->max_band = 19; - } - - move16(); - move16(); - move16(); - - FOR( i = 0; i < FRAME_SIZE_NB; i++ ) - { - IF( EQ_32( FrameSizeConfig[i].frame_bits, st->bits_frame_nominal ) ) - { - st->frame_size_index = i; - st->bits_frame = FrameSizeConfig[i].frame_bits; - st->bits_frame_core = FrameSizeConfig[i].frame_net_bits; - move16(); - move16(); - move16(); - BREAK; - } - } - - st->restrictedMode = getRestrictedMode( st->element_mode, st->total_brate, 0 ); - move16(); - core_coder_reconfig_ivas_fx( st, last_total_brate ); - } - ELSE - { - st->igf = getIgfPresent_fx( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); - move16(); - IF( hTcxEnc != NULL ) - { - hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ - move16(); - } - st->currEnergyHF_fx = 0; - move32(); - st->currEnergyHF_e_fx = 0; - move16(); - Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); - Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); - st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); - move16(); - shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); - Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); - st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); - move16(); -#ifdef FIX_920_IGF_INIT_ERROR - init_coder_ace_plus_ivas_fx( st, last_total_brate, st->total_brate, MCT_flag ); -#else - init_coder_ace_plus_ivas_fx( st, last_total_brate, MCT_flag ); -#endif - if ( st->hLPDmem != NULL ) - { - st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; - move16(); - } - } - - test(); - IF( st->igf && st->hBWE_TD != NULL ) - { - /* reset TBE */ - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( st->bwidth, WB ) && NE_16( st->last_extl, WB_TBE ) ) || - ( EQ_16( st->bwidth, SWB ) && NE_16( st->last_extl, SWB_TBE ) ) || - ( EQ_16( st->bwidth, FB ) && NE_16( st->last_extl, FB_TBE ) ) ) - { - TBEreset_enc_fx( st, st->bwidth ); - } - ELSE - { - set16_fx( st->hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); - set16_fx( st->hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); - set16_fx( st->hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - st->hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; - move16(); - } - } - test(); - IF( st->envWeighted && !st->enableTcxLpc ) - { - /* Unweight the envelope */ - st->inv_gamma = BASOP_Util_Divide1616_Scale( MAX16B, st->gamma, &exp_res ); - move16(); - st->inv_gamma = shr( st->inv_gamma, sub( Q1, exp_res ) ); /* Q14 */ - move16(); - E_LPC_lsp_unweight( st->lsp_old_fx, st->lsp_old_fx, st->lsf_old_fx, st->inv_gamma, M ); - st->envWeighted = 0; - move16(); - } - - IF( GE_32( st->total_brate, HQ_48k ) ) - { - st->enablePlcWaveadjust = 1; - move16(); - } - ELSE - { - st->enablePlcWaveadjust = 0; - move16(); - } - - test(); - test(); - if ( ( GT_32( last_total_brate, HQ_32k ) || EQ_16( st->last_codec_mode, MODE1 ) ) && ( st->element_mode == EVS_MONO ) ) - { - st->glr_reset = 1; - move16(); - } - - return; -} diff --git a/lib_enc/core_enc_switch_fx.c b/lib_enc/core_enc_switch_fx.c index 1096cfb49..82bb5fca9 100644 --- a/lib_enc/core_enc_switch_fx.c +++ b/lib_enc/core_enc_switch_fx.c @@ -223,3 +223,262 @@ void core_coder_mode_switch_fx( st->glr_reset = 1; } } + + +/*-------------------------------------------------------------------* + * core_coder_mode_switch() + * + * + *-------------------------------------------------------------------*/ +void core_coder_mode_switch_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word32 last_total_brate, /* i : last bitrate */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ +) +{ + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + Word16 i, fscale, switchWB; + Word32 sr_core; + Word16 bSwitchFromAmrwbIO; + Word16 tcxonly_tmp, exp_res; + + switchWB = 0; + move16(); + bSwitchFromAmrwbIO = 0; + move16(); + exp_res = 0; + move16(); + + + if ( EQ_16( st->last_core, AMR_WB_CORE ) ) + { + bSwitchFromAmrwbIO = 1; + move16(); + } + + /* force active frame for the first frame when switching from high bitrates when DTX is enabled*/ + sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); + + fscale = sr2fscale_fx( sr_core ); + if ( EQ_16( st->last_codec_mode, MODE1 ) ) + { + switchWB = 1; /*force init when coming from MODE1*/ + move16(); + } + + tcxonly_tmp = getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); + + if ( NE_32( tcxonly_tmp, st->tcxonly ) ) + { + switchWB = 1; /*force init when coming from MODE1*/ + move16(); + } + + test(); + test(); + IF( EQ_32( fscale, st->fscale ) && !bSwitchFromAmrwbIO && !switchWB ) + { + st->sr_core = sr_core; + move16(); + Word16 tmp = BASOP_Util_Divide3232_Scale( sr_core, FRAMES_PER_SEC, &exp_res ); + st->L_frame = shr( tmp, sub( 15, exp_res ) ); // Q0 + move16(); + + st->tcxonly = getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); + move16(); + + Word16 exp_tmp1 = 0; + move16(); + Word16 tmp1 = BASOP_Util_Divide1616_Scale( ONE_IN_Q9, 128, &exp_tmp1 ); + + Word16 exp_tmp2 = 0; + move16(); + Word16 tmp2 = BASOP_Util_Divide3232_Scale( st->total_brate, 100, &exp_tmp2 ); + + Word16 exp_tmp3 = 0; + move16(); + Word16 tmp3 = BASOP_Util_Divide3232_Scale( st->L_frame, st->fscale, &exp_tmp3 ); + + Word32 tmp4 = L_mult0( tmp1, tmp2 ); // exp_tmp1 + exp_tmp2 + Word32 tmp5 = L_shl( Mpy_32_16_1( tmp4, tmp3 ), 1 ); // exp_tmp1 + exp_tmp2 + exp_tmp3 + st->bits_frame_nominal = extract_l( L_shr( tmp5, sub( 31, ( add( add( exp_tmp1, exp_tmp2 ), exp_tmp3 ) ) ) ) ); + move16(); + st->igf = getIgfPresent_fx( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); + move16(); + /* switch IGF configuration */ + IF( st->igf ) + { + IGFEncSetMode_fx( st->hIGFEnc, st->total_brate, st->bwidth, st->element_mode, st->rf_mode ); + } + st->hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( st->bwidth ); + move16(); + + st->hTcxCfg->bandwidth = getTcxBandwidth( st->bwidth ); + move16(); + if ( st->tcxonly ) + { + st->hTcxCfg->tcxRateLoopOpt = 2; + move16(); + } + else + { + st->hTcxCfg->tcxRateLoopOpt = 0; + move16(); + } + if ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + st->hTcxCfg->tcxRateLoopOpt = 3; + move16(); + } + st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, st->total_brate, st->rf_mode ); + st->hTcxCfg->resq = getResq( st->total_brate ); + hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode ); + test(); + if ( st->hTcxCfg->resq && !st->tcxonly ) + { + st->hTcxCfg->tcxRateLoopOpt = 1; + move16(); + } + st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st->total_brate, st->igf, st->element_mode ); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + + IF( st->hTcxCfg->fIsTNSAllowed ) + { + InitTnsConfigs_ivas_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, MCT_flag ); + + SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, st->element_mode == IVAS_CPE_MDCT ); + } + + IF( EQ_16( st->bwidth, NB ) ) + { + st->narrowBand = 1; + st->min_band = 1; + st->max_band = 16; + } + ELSE + { + st->narrowBand = 0; + st->min_band = 0; + st->max_band = 19; + } + + move16(); + move16(); + move16(); + + FOR( i = 0; i < FRAME_SIZE_NB; i++ ) + { + IF( EQ_32( FrameSizeConfig[i].frame_bits, st->bits_frame_nominal ) ) + { + st->frame_size_index = i; + st->bits_frame = FrameSizeConfig[i].frame_bits; + st->bits_frame_core = FrameSizeConfig[i].frame_net_bits; + move16(); + move16(); + move16(); + BREAK; + } + } + + st->restrictedMode = getRestrictedMode( st->element_mode, st->total_brate, 0 ); + move16(); + core_coder_reconfig_ivas_fx( st, last_total_brate ); + } + ELSE + { + st->igf = getIgfPresent_fx( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); + move16(); + IF( hTcxEnc != NULL ) + { + hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ + move16(); + } + st->currEnergyHF_fx = 0; + move32(); + st->currEnergyHF_e_fx = 0; + move16(); + Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); + Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); + st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); + move16(); + shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); + Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); + st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); + move16(); +#ifdef FIX_920_IGF_INIT_ERROR + init_coder_ace_plus_ivas_fx( st, last_total_brate, st->total_brate, MCT_flag ); +#else + init_coder_ace_plus_ivas_fx( st, last_total_brate, MCT_flag ); +#endif + if ( st->hLPDmem != NULL ) + { + st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; + move16(); + } + } + + test(); + IF( st->igf && st->hBWE_TD != NULL ) + { + /* reset TBE */ + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( st->bwidth, WB ) && NE_16( st->last_extl, WB_TBE ) ) || + ( EQ_16( st->bwidth, SWB ) && NE_16( st->last_extl, SWB_TBE ) ) || + ( EQ_16( st->bwidth, FB ) && NE_16( st->last_extl, FB_TBE ) ) ) + { + TBEreset_enc_fx( st, st->bwidth ); + } + ELSE + { + set16_fx( st->hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); + set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); + set16_fx( st->hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); + set16_fx( st->hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); + st->hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; + move16(); + } + } + test(); + IF( st->envWeighted && !st->enableTcxLpc ) + { + /* Unweight the envelope */ + st->inv_gamma = BASOP_Util_Divide1616_Scale( MAX16B, st->gamma, &exp_res ); + move16(); + st->inv_gamma = shr( st->inv_gamma, sub( Q1, exp_res ) ); /* Q14 */ + move16(); + E_LPC_lsp_unweight( st->lsp_old_fx, st->lsp_old_fx, st->lsf_old_fx, st->inv_gamma, M ); + st->envWeighted = 0; + move16(); + } + + IF( GE_32( st->total_brate, HQ_48k ) ) + { + st->enablePlcWaveadjust = 1; + move16(); + } + ELSE + { + st->enablePlcWaveadjust = 0; + move16(); + } + + test(); + test(); + if ( ( GT_32( last_total_brate, HQ_32k ) || EQ_16( st->last_codec_mode, MODE1 ) ) && ( st->element_mode == EVS_MONO ) ) + { + st->glr_reset = 1; + move16(); + } + + return; +} diff --git a/lib_enc/core_enc_updt.c b/lib_enc/core_enc_updt.c deleted file mode 100644 index 4533af002..000000000 --- a/lib_enc/core_enc_updt.c +++ /dev/null @@ -1,117 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "cnst.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * core_encode_update() - * - * Common updates of buffers - *-------------------------------------------------------------------*/ - -void core_encode_update_ivas_fx( - Encoder_State *st /* i/o: Encoder state structure */ -) -{ - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - Word16 n; - - /* Update Input Signal Buffers */ - n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc ); - - Copy( st->buf_speech_enc_pe + st->L_frame, st->buf_speech_enc_pe, n ); - Copy( st->buf_speech_enc + st->L_frame, st->buf_speech_enc, n ); - - IF( !st->tcxonly ) - { - n = add( st->L_frame, shr( st->L_frame, 2 ) ); - Copy( st->buf_wspeech_enc + st->L_frame, st->buf_wspeech_enc, n ); - } - - IF( hTcxEnc != NULL ) - { - test(); - test(); - test(); - IF( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) ) - { - Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc ); - Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( sub( max_e, st->hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(31-max_e) - Copy_Scale_sig( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame, negate( sub( max_e, st->exp_buf_speech_enc ) ) ); // Q(31-max_e) - st->hTcxEnc->exp_buf_speech_ltp = max_e; - move16(); - } - } - - n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc ); - Copy( st->buf_synth + st->L_frame, st->buf_synth, add( st->L_frame, L_SUBFR ) ); - IF( hTcxEnc != NULL ) - { - Copy( hTcxEnc->buf_speech_ltp + st->L_frame, hTcxEnc->buf_speech_ltp, n ); - - IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - st->hTcxEnc->kernel_switch_corr_past = 0; - st->hTcxEnc->kernel_type[0] = MDCT_IV; - st->hTcxEnc->kernel_symmetry_past = 0; - st->hTcxEnc->enc_ste_pre_corr_past = 0; - - move16(); - move16(); - move16(); - move16(); - } - } - - test(); - test(); - test(); - test(); - test(); - IF( ( st->Opt_DTX_ON && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) || ( st->tcxonly && ( EQ_16( st->codec_mode, MODE2 ) || ( st->element_mode > EVS_MONO ) ) ) ) - { - /* reset LP memories */ - set16_fx( st->mem_MA_fx, 0, M ); - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); // 2.56 scaling - } - return; -} diff --git a/lib_enc/core_enc_updt_fx.c b/lib_enc/core_enc_updt_fx.c index 125f0cd52..305c2a92f 100644 --- a/lib_enc/core_enc_updt_fx.c +++ b/lib_enc/core_enc_updt_fx.c @@ -211,3 +211,77 @@ void core_encode_update_cng_fx( return; } + +/*-------------------------------------------------------------------* + * core_encode_update() + * + * Common updates of buffers + *-------------------------------------------------------------------*/ + +void core_encode_update_ivas_fx( + Encoder_State *st /* i/o: Encoder state structure */ +) +{ + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + Word16 n; + + /* Update Input Signal Buffers */ + n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc ); + + Copy( st->buf_speech_enc_pe + st->L_frame, st->buf_speech_enc_pe, n ); + Copy( st->buf_speech_enc + st->L_frame, st->buf_speech_enc, n ); + + IF( !st->tcxonly ) + { + n = add( st->L_frame, shr( st->L_frame, 2 ) ); + Copy( st->buf_wspeech_enc + st->L_frame, st->buf_wspeech_enc, n ); + } + + IF( hTcxEnc != NULL ) + { + test(); + test(); + test(); + IF( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) || EQ_32( st->core_brate, SID_2k40 ) || ( st->core_brate == FRAME_NO_DATA ) ) + { + Word16 max_e = s_max( st->hTcxEnc->exp_buf_speech_ltp, st->exp_buf_speech_enc ); + Scale_sig( hTcxEnc->buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, negate( sub( max_e, st->hTcxEnc->exp_buf_speech_ltp ) ) ); // Q(31-max_e) + Copy_Scale_sig( st->buf_speech_enc + st->L_frame, hTcxEnc->buf_speech_ltp + st->L_frame, st->L_frame, negate( sub( max_e, st->exp_buf_speech_enc ) ) ); // Q(31-max_e) + st->hTcxEnc->exp_buf_speech_ltp = max_e; + move16(); + } + } + + n = add( st->encoderPastSamples_enc, st->encoderLookahead_enc ); + Copy( st->buf_synth + st->L_frame, st->buf_synth, add( st->L_frame, L_SUBFR ) ); + IF( hTcxEnc != NULL ) + { + Copy( hTcxEnc->buf_speech_ltp + st->L_frame, hTcxEnc->buf_speech_ltp, n ); + + IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + st->hTcxEnc->kernel_switch_corr_past = 0; + st->hTcxEnc->kernel_type[0] = MDCT_IV; + st->hTcxEnc->kernel_symmetry_past = 0; + st->hTcxEnc->enc_ste_pre_corr_past = 0; + + move16(); + move16(); + move16(); + move16(); + } + } + + test(); + test(); + test(); + test(); + test(); + IF( ( st->Opt_DTX_ON && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) || ( st->tcxonly && ( EQ_16( st->codec_mode, MODE2 ) || ( st->element_mode > EVS_MONO ) ) ) ) + { + /* reset LP memories */ + set16_fx( st->mem_MA_fx, 0, M ); + Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); // 2.56 scaling + } + return; +} diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c deleted file mode 100644 index 08789dbde..000000000 --- a/lib_enc/core_switching_enc.c +++ /dev/null @@ -1,603 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" -#include "ivas_prot_fx.h" - -void core_switching_pre_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz q_old_inp_12k8 */ - const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ - const Word16 *old_inp_16k, /* i : old input signal @16kHz q_old_inp_16k */ - const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ - const Word16 active_cnt, /* i : active frame counter */ - const Word16 last_element_mode /* i : last_element_mode */ -) -{ - Word16 Sample_Delay_HP, Sample_Delay_LP; - Word16 tmp16; - Word16 tmp; - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; - TCX_ENC_HANDLE hTcxEnc = st_fx->hTcxEnc; - FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; - - /* Mode switching */ - test(); - test(); - test(); - IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && ( st_fx->element_mode > EVS_MONO ) ) ) ) - { - IF( hLPDmem != NULL ) - { - st_fx->mem_deemph_fx = hLPDmem->syn[M]; - move16(); - Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); - } - - if ( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - st_fx->igf = 0; - move16(); - } - - IF( hBWE_TD != NULL ) - { - IF( st_fx->last_core != ACELP_CORE ) - { - /* reset BWE memories */ - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); - move32(); - } - - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - test(); - IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) - { - if ( st_fx->element_mode == EVS_MONO ) - { - st_fx->last_core = HQ_CORE; - move16(); - } - IF( hHQ_core != NULL ) - { - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - hHQ_core->mode_count = 0; - move16(); - hHQ_core->mode_count1 = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - move16(); - hHQ_core->prev_stab_hfe2 = 0; - move16(); - } - test(); - /*ALDO overlap windowed past: also used in MODE2 but for other MDCT-LB*/ - IF( ( st_fx->element_mode == EVS_MONO ) && hTcxEnc != NULL ) - { - set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); - } - } - - test(); - IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) && ( EQ_16( st_fx->last_L_frame, L_FRAME ) ) ) - { - Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M ); - - st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 ); - move16(); - } - - st_fx->use_acelp_preq = 0; - move16(); - } - - test(); - test(); - test(); - if ( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) ) - { - /* very first frame is HQ_CORE */ - st_fx->last_core = HQ_CORE; - move16(); - } - - test(); - test(); - IF( EQ_16( st_fx->core, HQ_CORE ) && ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* HQ init */ - { - set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); - hHQ_core->last_max_pos_pulse = 0; - move16(); - - hHQ_core->mode_count = 0; - move16(); - hHQ_core->mode_count1 = 0; - move16(); - - set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); - hHQ_core->prev_frm_hfe2 = 0; - move16(); - hHQ_core->prev_stab_hfe2 = 0; - move16(); - - IF( hTcxEnc != NULL ) - { - set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); - } - } - - /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores - within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ - test(); - test(); - IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) - { - IF( hSC_VBR != NULL ) - { - hSC_VBR->last_last_ppp_mode = 0; - move16(); - hSC_VBR->last_ppp_mode = 0; - move16(); - hSC_VBR->last_nelp_mode = 0; - move16(); - } - } - - test(); - test(); - test(); - IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) ) - { - st_fx->act_count = 3; - move16(); - st_fx->uv_count = 0; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) || - ( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( active_cnt, 1 ) ) ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k ); - } - ELSE - { - Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); - } - - st_fx->mem_deemph_fx = 0; - move16(); - /* Reset ACELP parameters */ - IF( hLPDmem != NULL ) - { - move16(); - hLPDmem->syn[M] = 0; - move16(); - set16_fx( hLPDmem->mem_syn2, 0, M ); - set16_fx( hLPDmem->mem_syn, 0, M ); - set16_fx( hLPDmem->mem_syn1_fx, 0, M ); - hLPDmem->q_mem_syn = Q15; - move16(); - hLPDmem->mem_w0 = 0; - move16(); - hLPDmem->tilt_code = 0; - move16(); - hLPDmem->gc_threshold = 0; - move32(); - /* set16_fx( st_fx->dispMem, 0, 8 ); */ - set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); - hLPDmem->dm_fx.prev_state = 0; - move16(); - hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 ); - } - st_fx->Nb_ACELP_frames = 0; - move16(); - - set16_fx( st_fx->mem_MA_fx, 0, M ); - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); - init_gp_clip_fx( st_fx->clip_var_fx ); - st_fx->last_coder_type = GENERIC; - move16(); - - tmp16 = add( NB_SUBFR, 1 ); - - if ( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - tmp16 = NB_SUBFR; - move16(); - } - - Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); - set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); - - /* Reset old ACELP buffers */ - test(); - IF( ( st_fx->element_mode == EVS_MONO ) && hLPDmem != NULL ) - { - set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); - } - IF( hBWE_TD != NULL ) - { - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - - /* reset BWE memories */ - hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - IF( hBWE_FD != NULL ) - { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - } - test(); - test(); - test(); - IF( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) ) - { - /* Reset the ACELP core in case of TCX->ACELP core switching */ - st_fx->Nb_ACELP_frames = 0; - move16(); - - IF( hLPDmem != NULL ) - { - hLPDmem->mem_w0 = 0; - move16(); - hLPDmem->tilt_code = 0; - move16(); - hLPDmem->gc_threshold = 0; - move32(); - init_gp_clip_fx( st_fx->clip_var_fx ); - set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); - hLPDmem->dm_fx.prev_state = 0; - move16(); - hLPDmem->dm_fx.prev_gain_code = 0; - move32(); - } - - st_fx->last_coder_type = GENERIC; - move16(); - - tmp16 = shr( st_fx->L_frame, 6 ); - Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); - set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); - - /* Reset old TD BWE buffers */ - IF( hBWE_TD != NULL ) - { - set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - - /* reset BWE memories */ - IF( hBWE_FD != NULL ) - { - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); /* TODO : this might not be needed */ - } - } - test(); - test(); - test(); - IF( GE_32( st_fx->input_Fs, 16000 ) && NE_16( st_fx->last_extl, WB_BWE ) && EQ_16( st_fx->extl, WB_BWE ) && hBWE_FD != NULL ) - { - test(); - IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) ) - { - hBWE_FD->prev_mode = NORMAL; - move16(); - hBWE_FD->modeCount = 0; - move16(); - } - - hBWE_FD->prev_L_swb_norm1 = 8; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - IF( ( GE_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->last_extl, SWB_BWE ) && EQ_16( st_fx->extl, SWB_BWE ) ) || - ( GE_32( st_fx->input_Fs, 48000 ) && NE_16( st_fx->last_extl, FB_BWE ) && EQ_16( st_fx->extl, FB_BWE ) ) ) - { - /* we are switching to SWB BWE - reset SWB BWE buffers */ - - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); - Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); - IF( ( st_fx->element_mode > EVS_MONO ) ) - { - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); - } - Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); - } - IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ) - { - Copy_Scale_sig( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_12k8 ) ); // prev_Q_input_lp - } - ELSE - { - Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_12k8 - hBWE_FD->prev_Q_input_lp = q_old_inp_12k8; - move16(); - Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); - } - } - ELSE - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); - Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); - IF( GT_16( st_fx->element_mode, EVS_MONO ) ) - { - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); - } - Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); - } - IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ) - { - Copy_Scale_sig( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_16k ) ); // prev_Q_input_lp - } - ELSE - { - Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_16k - hBWE_FD->prev_Q_input_lp = q_old_inp_16k; - move16(); - Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); - } - } - - tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP ); - Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); -#ifdef FIX_ISSUE_1230 - hBWE_FD->Q_new_input_hp = 0; - move16(); -#endif - - IF( NE_16( st_fx->last_extl, WB_BWE ) ) - { - hBWE_FD->prev_mode = NORMAL; - move16(); - hBWE_FD->modeCount = 0; - move16(); - } - hBWE_FD->EnergyLF_fx = 0; - hBWE_FD->EnergyLF_exp = 0; - move32(); - move16(); - hBWE_FD->prev_L_swb_norm1 = 8; - move16(); /*8.0 in Q0 */ - st_fx->EnergyLT_fx_exp = 30; - move16(); /* Set to a High Exponent so it is 1^-30 */ - } - /*---------------------------------------------------------------------* - * band-width switching from WB -> SWB/FB - *---------------------------------------------------------------------*/ - IF( st_fx->element_mode > EVS_MONO ) - { - IF( st_fx->bwidth_sw_cnt == 0 ) - { - test(); - IF( GE_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) ) - { - st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); - move16(); - } - } - ELSE - { - st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); - move16(); - IF( EQ_16( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ) ) - { - st_fx->bwidth_sw_cnt = 0; - move16(); - } - } - } - - return; -} - -/*---------------------------------------------------------------------* - * core_switching_post_enc() - * - * Postprocessing for ACELP/HQ core switching - *---------------------------------------------------------------------*/ - -void core_switching_post_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz Q_new-1 */ - Word16 *old_inp_16k_fx, /* i : old input signal @16kHz Q_new-1 */ - Word16 A_fx[], /* i : unquant. LP filter coefs. Q12 */ - Word16 Q_new ) -{ - IF( EQ_16( st->core, HQ_CORE ) ) - { - st->use_acelp_preq = 0; - move16(); - test(); - test(); - IF( ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) && st->element_mode == EVS_MONO ) /* core switching ==> ACELP subframe encoding */ - { - /* Memory scaling to keep everything in common q */ - Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - st->hLPDmem->mem_w0 = shl( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ - move16(); - st->hLPDmem->q_mem_syn = sub( Q_new, 1 ); - move16(); - - acelp_core_switch_enc_ivas_fx( st, old_inp_12k8_fx + L_INP_MEM - NS2SA( INT_FS_12k8, ACELP_LOOK_NS ), old_inp_16k_fx + L_INP_MEM - NS2SA( INT_FS_16k, ACELP_LOOK_NS ), A_fx, 0, sub( Q_new, 1 ) ); - } - - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - st->hBWE_FD->mem_deemph_old_syn_fx = 0; - move16(); - st->hBWE_FD->q_mem_deemph_old_syn = 0; - move16(); - } - ELSE - { - IF( st->hBWE_TD == NULL ) - { - return; - } - - test(); - /* reset SWB TBE buffers */ - IF( EQ_16( st->extl, WB_TBE ) && NE_16( st->last_extl, WB_TBE ) ) - { - wb_tbe_extras_reset_fx( st->hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, st->hBWE_TD->mem_genSHBexc_filt_down_wb3_fx ); - - IF( NE_16( st->last_extl, WB_BWE ) ) - { - set16_fx( st->hBWE_TD->decim_state1_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - set16_fx( st->hBWE_TD->decim_state2_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - } - - set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD / 4 ); - set16_fx( st->hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD ); - set32_fx( st->hBWE_TD->mem_csfilt_fx, 0, 2 ); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - - IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && - ( EQ_16( st->last_core, HQ_CORE ) || NE_16( st->L_frame, st->last_L_frame ) || ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) ) ) - { - set16_fx( st->hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - - InitSWBencBufferStates_fx( st->hBWE_TD, NULL ); - swb_tbe_reset_fx( st->hBWE_TD->mem_csfilt_fx, st->hBWE_TD->mem_genSHBexc_filt_down_shb_fx, st->hBWE_TD->state_lpc_syn_fx, st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->state_syn_shbexc_fx, &( st->hBWE_TD->tbe_demph_fx ), &( st->hBWE_TD->tbe_premph_fx ), st->hBWE_TD->mem_stp_swb_fx, &( st->hBWE_TD->gain_prec_swb_fx ) ); - - set16_fx( st->hBWE_TD->dec_2_over_3_mem_fx, 0, L_FILT_2OVER3 ); - set16_fx( st->hBWE_TD->dec_2_over_3_mem_lp_fx, 0, L_FILT_2OVER3_LP ); - } - ELSE IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && ( ( EQ_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_32( st->last_total_brate, st->total_brate ) ) || ( NE_16( st->last_bwidth, st->bwidth ) ) || ( NE_16( st->last_codec_mode, MODE1 ) ) || ( NE_16( st->rf_mode_last, st->rf_mode ) ) ) ) - { - set16_fx( st->hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); - set16_fx( st->hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); - set16_fx( st->hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - st->hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; - move16(); - } - ELSE IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) - { - TBEreset_enc_fx( st, st->bwidth ); - } - - test(); - test(); - test(); - test(); - /* Interp_3_2 CNG buffers reset */ - IF( EQ_16( st->extl, FB_TBE ) && ( ( NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) || NE_16( st->L_frame, st->last_L_frame ) ) ) - { - set16_fx( st->hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - st->hBWE_TD->fb_tbe_demph_fx = 0; - move16(); - fb_tbe_reset_enc_fx( st->hBWE_TD->elliptic_bpf_2_48k_mem_fx, &st->hBWE_TD->prev_fb_energy_fx, st->hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &st->hBWE_TD->prev_fb_energy_fx_Q ); - } - /* Fade towards init value for non HQ_CORE */ - IF( st->hHQ_core != NULL ) - { - st->hHQ_core->crest_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_THRESHOLD_FX, sub( Q28, st->hHQ_core->crest_lp_q ) ) ) ); /*crest_lp_q*/ - move32(); - st->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_MOD_THRESHOLD_FX, sub( Q29, st->hHQ_core->crest_mod_lp_q ) ) ) ); /*crest_mod_lp_q*/ - move32(); - } - } - - return; -} diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index da1139d15..6fa341a7b 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -8,8 +8,9 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ //#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ +#include "ivas_prot_fx.h" /* Function prototypes */ +#include "prot_fx_enc.h" /* Function prototypes */ /*---------------------------------------------------------------------* @@ -672,3 +673,559 @@ void core_switching_hq_prepare_enc_fx( } return; } + +void core_switching_pre_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz q_old_inp_12k8 */ + const Word16 q_old_inp_12k8, /* i : Q old input signal @12.8kHz */ + const Word16 *old_inp_16k, /* i : old input signal @16kHz q_old_inp_16k */ + const Word16 q_old_inp_16k, /* i : Q old input signal @16kHz */ + const Word16 active_cnt, /* i : active frame counter */ + const Word16 last_element_mode /* i : last_element_mode */ +) +{ + Word16 Sample_Delay_HP, Sample_Delay_LP; + Word16 tmp16; + Word16 tmp; + SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; + LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; + HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; + TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; + TCX_ENC_HANDLE hTcxEnc = st_fx->hTcxEnc; + FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; + + /* Mode switching */ + test(); + test(); + test(); + IF( EQ_16( st_fx->last_codec_mode, MODE2 ) || ( ( ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) && ( st_fx->element_mode > EVS_MONO ) ) ) ) + { + IF( hLPDmem != NULL ) + { + st_fx->mem_deemph_fx = hLPDmem->syn[M]; + move16(); + Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); + } + + if ( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + { + st_fx->igf = 0; + move16(); + } + + IF( hBWE_TD != NULL ) + { + IF( st_fx->last_core != ACELP_CORE ) + { + /* reset BWE memories */ + set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); + move32(); + } + + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + } + test(); + IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) + { + if ( st_fx->element_mode == EVS_MONO ) + { + st_fx->last_core = HQ_CORE; + move16(); + } + IF( hHQ_core != NULL ) + { + set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); + hHQ_core->last_max_pos_pulse = 0; + move16(); + + hHQ_core->mode_count = 0; + move16(); + hHQ_core->mode_count1 = 0; + move16(); + + set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); + hHQ_core->prev_frm_hfe2 = 0; + move16(); + hHQ_core->prev_stab_hfe2 = 0; + move16(); + } + test(); + /*ALDO overlap windowed past: also used in MODE2 but for other MDCT-LB*/ + IF( ( st_fx->element_mode == EVS_MONO ) && hTcxEnc != NULL ) + { + set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); + } + } + + test(); + IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) && ( EQ_16( st_fx->last_L_frame, L_FRAME ) ) ) + { + Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M ); + + st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 ); + move16(); + } + + st_fx->use_acelp_preq = 0; + move16(); + } + + test(); + test(); + test(); + if ( EQ_16( st_fx->last_core, -1 ) && ( EQ_16( st_fx->core, HQ_CORE ) || EQ_16( st_fx->core, TCX_20_CORE ) || EQ_16( st_fx->core, TCX_10_CORE ) ) ) + { + /* very first frame is HQ_CORE */ + st_fx->last_core = HQ_CORE; + move16(); + } + + test(); + test(); + IF( EQ_16( st_fx->core, HQ_CORE ) && ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) /* HQ init */ + { + set32_fx( hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( hHQ_core->last_env_fx, 0, BANDS_MAX ); + hHQ_core->last_max_pos_pulse = 0; + move16(); + + hHQ_core->mode_count = 0; + move16(); + hHQ_core->mode_count1 = 0; + move16(); + + set16_fx( hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); + hHQ_core->prev_frm_hfe2 = 0; + move16(); + hHQ_core->prev_stab_hfe2 = 0; + move16(); + + IF( hTcxEnc != NULL ) + { + set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k ); + } + } + + /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores + within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ + test(); + test(); + IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) ) + { + IF( hSC_VBR != NULL ) + { + hSC_VBR->last_last_ppp_mode = 0; + move16(); + hSC_VBR->last_ppp_mode = 0; + move16(); + hSC_VBR->last_nelp_mode = 0; + move16(); + } + } + + test(); + test(); + test(); + IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) ) + { + st_fx->act_count = 3; + move16(); + st_fx->uv_count = 0; + move16(); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) || + ( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( active_cnt, 1 ) ) ) + { + IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) + { + Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ + lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k ); + } + ELSE + { + Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */ + lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); + } + + st_fx->mem_deemph_fx = 0; + move16(); + /* Reset ACELP parameters */ + IF( hLPDmem != NULL ) + { + move16(); + hLPDmem->syn[M] = 0; + move16(); + set16_fx( hLPDmem->mem_syn2, 0, M ); + set16_fx( hLPDmem->mem_syn, 0, M ); + set16_fx( hLPDmem->mem_syn1_fx, 0, M ); + hLPDmem->q_mem_syn = Q15; + move16(); + hLPDmem->mem_w0 = 0; + move16(); + hLPDmem->tilt_code = 0; + move16(); + hLPDmem->gc_threshold = 0; + move32(); + /* set16_fx( st_fx->dispMem, 0, 8 ); */ + set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); + hLPDmem->dm_fx.prev_state = 0; + move16(); + hLPDmem->dm_fx.prev_gain_code = L_deposit_l( 0 ); + } + st_fx->Nb_ACELP_frames = 0; + move16(); + + set16_fx( st_fx->mem_MA_fx, 0, M ); + Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); + init_gp_clip_fx( st_fx->clip_var_fx ); + st_fx->last_coder_type = GENERIC; + move16(); + + tmp16 = add( NB_SUBFR, 1 ); + + if ( EQ_16( st_fx->L_frame, L_FRAME ) ) + { + tmp16 = NB_SUBFR; + move16(); + } + + Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); + set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); + + /* Reset old ACELP buffers */ + test(); + IF( ( st_fx->element_mode == EVS_MONO ) && hLPDmem != NULL ) + { + set16_fx( hLPDmem->old_exc, 0, L_EXC_MEM ); + } + IF( hBWE_TD != NULL ) + { + set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + + /* reset BWE memories */ + hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); + } + IF( hBWE_FD != NULL ) + { + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + } + } + test(); + test(); + test(); + IF( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && ( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) ) ) + { + /* Reset the ACELP core in case of TCX->ACELP core switching */ + st_fx->Nb_ACELP_frames = 0; + move16(); + + IF( hLPDmem != NULL ) + { + hLPDmem->mem_w0 = 0; + move16(); + hLPDmem->tilt_code = 0; + move16(); + hLPDmem->gc_threshold = 0; + move32(); + init_gp_clip_fx( st_fx->clip_var_fx ); + set16_fx( hLPDmem->dm_fx.prev_gain_pit, 0, 6 ); + hLPDmem->dm_fx.prev_state = 0; + move16(); + hLPDmem->dm_fx.prev_gain_code = 0; + move32(); + } + + st_fx->last_coder_type = GENERIC; + move16(); + + tmp16 = shr( st_fx->L_frame, 6 ); + Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); + set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); + + /* Reset old TD BWE buffers */ + IF( hBWE_TD != NULL ) + { + set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); + } + + /* reset BWE memories */ + IF( hBWE_FD != NULL ) + { + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); /* TODO : this might not be needed */ + } + } + test(); + test(); + test(); + IF( GE_32( st_fx->input_Fs, 16000 ) && NE_16( st_fx->last_extl, WB_BWE ) && EQ_16( st_fx->extl, WB_BWE ) && hBWE_FD != NULL ) + { + test(); + IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) ) + { + hBWE_FD->prev_mode = NORMAL; + move16(); + hBWE_FD->modeCount = 0; + move16(); + } + + hBWE_FD->prev_L_swb_norm1 = 8; + move16(); + } + + test(); + test(); + test(); + test(); + test(); + IF( ( GE_32( st_fx->input_Fs, 32000 ) && NE_16( st_fx->last_extl, SWB_BWE ) && EQ_16( st_fx->extl, SWB_BWE ) ) || + ( GE_32( st_fx->input_Fs, 48000 ) && NE_16( st_fx->last_extl, FB_BWE ) && EQ_16( st_fx->extl, FB_BWE ) ) ) + { + /* we are switching to SWB BWE - reset SWB BWE buffers */ + + IF( EQ_16( st_fx->L_frame, L_FRAME ) ) + { + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); + Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); + IF( ( st_fx->element_mode > EVS_MONO ) ) + { + IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); + } + Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); + } + IF( GT_16( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ) + { + Copy_Scale_sig( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_12k8 ) ); // prev_Q_input_lp + } + ELSE + { + Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_12k8, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_12k8 + hBWE_FD->prev_Q_input_lp = q_old_inp_12k8; + move16(); + Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); + } + } + ELSE + { + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); + Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); + IF( GT_16( st_fx->element_mode, EVS_MONO ) ) + { + IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + { + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); + } + Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); + } + IF( GT_16( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ) + { + Copy_Scale_sig( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP, sub( hBWE_FD->prev_Q_input_lp, q_old_inp_16k ) ); // prev_Q_input_lp + } + ELSE + { + Scale_sig( hBWE_FD->old_input_lp_fx, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ), sub( q_old_inp_16k, hBWE_FD->prev_Q_input_lp ) ); // q_old_inp_16k + hBWE_FD->prev_Q_input_lp = q_old_inp_16k; + move16(); + Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); + } + } + + tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP ); + Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); +#ifdef FIX_ISSUE_1230 + hBWE_FD->Q_new_input_hp = 0; + move16(); +#endif + + IF( NE_16( st_fx->last_extl, WB_BWE ) ) + { + hBWE_FD->prev_mode = NORMAL; + move16(); + hBWE_FD->modeCount = 0; + move16(); + } + hBWE_FD->EnergyLF_fx = 0; + hBWE_FD->EnergyLF_exp = 0; + move32(); + move16(); + hBWE_FD->prev_L_swb_norm1 = 8; + move16(); /*8.0 in Q0 */ + st_fx->EnergyLT_fx_exp = 30; + move16(); /* Set to a High Exponent so it is 1^-30 */ + } + /*---------------------------------------------------------------------* + * band-width switching from WB -> SWB/FB + *---------------------------------------------------------------------*/ + IF( st_fx->element_mode > EVS_MONO ) + { + IF( st_fx->bwidth_sw_cnt == 0 ) + { + test(); + IF( GE_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) ) + { + st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); + move16(); + } + } + ELSE + { + st_fx->bwidth_sw_cnt = add( st_fx->bwidth_sw_cnt, 1 ); + move16(); + IF( EQ_16( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ) ) + { + st_fx->bwidth_sw_cnt = 0; + move16(); + } + } + } + + return; +} + +/*---------------------------------------------------------------------* + * core_switching_post_enc() + * + * Postprocessing for ACELP/HQ core switching + *---------------------------------------------------------------------*/ + +void core_switching_post_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz Q_new-1 */ + Word16 *old_inp_16k_fx, /* i : old input signal @16kHz Q_new-1 */ + Word16 A_fx[], /* i : unquant. LP filter coefs. Q12 */ + Word16 Q_new ) +{ + IF( EQ_16( st->core, HQ_CORE ) ) + { + st->use_acelp_preq = 0; + move16(); + test(); + test(); + IF( ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) && st->element_mode == EVS_MONO ) /* core switching ==> ACELP subframe encoding */ + { + /* Memory scaling to keep everything in common q */ + Scale_sig( st->hLPDmem->mem_syn, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ + Scale_sig( st->hLPDmem->mem_syn1_fx, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ + Scale_sig( st->hLPDmem->mem_syn2, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ + Scale_sig( st->hLPDmem->mem_syn3, M, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ + Scale_sig( st->hLPDmem->mem_syn_r, L_SYN_MEM, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ + st->hLPDmem->mem_w0 = shl( st->hLPDmem->mem_w0, sub( sub( Q_new, 1 ), st->hLPDmem->q_mem_syn ) ); /* Q_new-1 */ + move16(); + st->hLPDmem->q_mem_syn = sub( Q_new, 1 ); + move16(); + + acelp_core_switch_enc_ivas_fx( st, old_inp_12k8_fx + L_INP_MEM - NS2SA( INT_FS_12k8, ACELP_LOOK_NS ), old_inp_16k_fx + L_INP_MEM - NS2SA( INT_FS_16k, ACELP_LOOK_NS ), A_fx, 0, sub( Q_new, 1 ) ); + } + + st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); + st->hBWE_FD->mem_deemph_old_syn_fx = 0; + move16(); + st->hBWE_FD->q_mem_deemph_old_syn = 0; + move16(); + } + ELSE + { + IF( st->hBWE_TD == NULL ) + { + return; + } + + test(); + /* reset SWB TBE buffers */ + IF( EQ_16( st->extl, WB_TBE ) && NE_16( st->last_extl, WB_TBE ) ) + { + wb_tbe_extras_reset_fx( st->hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, st->hBWE_TD->mem_genSHBexc_filt_down_wb3_fx ); + + IF( NE_16( st->last_extl, WB_BWE ) ) + { + set16_fx( st->hBWE_TD->decim_state1_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); + set16_fx( st->hBWE_TD->decim_state2_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); + } + + set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD / 4 ); + set16_fx( st->hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD ); + set32_fx( st->hBWE_TD->mem_csfilt_fx, 0, 2 ); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + + IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && + ( EQ_16( st->last_core, HQ_CORE ) || NE_16( st->L_frame, st->last_L_frame ) || ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) ) ) + { + set16_fx( st->hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); + + InitSWBencBufferStates_fx( st->hBWE_TD, NULL ); + swb_tbe_reset_fx( st->hBWE_TD->mem_csfilt_fx, st->hBWE_TD->mem_genSHBexc_filt_down_shb_fx, st->hBWE_TD->state_lpc_syn_fx, st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->state_syn_shbexc_fx, &( st->hBWE_TD->tbe_demph_fx ), &( st->hBWE_TD->tbe_premph_fx ), st->hBWE_TD->mem_stp_swb_fx, &( st->hBWE_TD->gain_prec_swb_fx ) ); + + set16_fx( st->hBWE_TD->dec_2_over_3_mem_fx, 0, L_FILT_2OVER3 ); + set16_fx( st->hBWE_TD->dec_2_over_3_mem_lp_fx, 0, L_FILT_2OVER3_LP ); + } + ELSE IF( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && ( ( EQ_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_32( st->last_total_brate, st->total_brate ) ) || ( NE_16( st->last_bwidth, st->bwidth ) ) || ( NE_16( st->last_codec_mode, MODE1 ) ) || ( NE_16( st->rf_mode_last, st->rf_mode ) ) ) ) + { + set16_fx( st->hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); + set16_fx( st->hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); + set16_fx( st->hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); + set16_fx( st->hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); + st->hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; + move16(); + } + ELSE IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) + { + TBEreset_enc_fx( st, st->bwidth ); + } + + test(); + test(); + test(); + test(); + /* Interp_3_2 CNG buffers reset */ + IF( EQ_16( st->extl, FB_TBE ) && ( ( NE_16( st->last_extl, FB_TBE ) && NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) || NE_16( st->L_frame, st->last_L_frame ) ) ) + { + set16_fx( st->hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); + st->hBWE_TD->fb_tbe_demph_fx = 0; + move16(); + fb_tbe_reset_enc_fx( st->hBWE_TD->elliptic_bpf_2_48k_mem_fx, &st->hBWE_TD->prev_fb_energy_fx, st->hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &st->hBWE_TD->prev_fb_energy_fx_Q ); + } + /* Fade towards init value for non HQ_CORE */ + IF( st->hHQ_core != NULL ) + { + st->hHQ_core->crest_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_THRESHOLD_FX, sub( Q28, st->hHQ_core->crest_lp_q ) ) ) ); /*crest_lp_q*/ + move32(); + st->hHQ_core->crest_mod_lp_fx = L_add( Mpy_32_32( HQ_CREST_FAC_SM_FX, st->hHQ_core->crest_mod_lp_fx ), Mpy_32_32( L_sub( ONE_IN_Q31, HQ_CREST_FAC_SM_FX ), L_shr( HQ_CREST_MOD_THRESHOLD_FX, sub( Q29, st->hHQ_core->crest_mod_lp_q ) ) ) ); /*crest_mod_lp_q*/ + move32(); + } + } + + return; +} diff --git a/lib_enc/corr_xh.c b/lib_enc/corr_xh.c deleted file mode 100644 index 9fd3cb8a2..000000000 --- a/lib_enc/corr_xh.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "cnst.h" -#include "wmc_auto.h" diff --git a/lib_enc/decision_matrix_enc.c b/lib_enc/decision_matrix_enc.c deleted file mode 100644 index 5e0c266ca..000000000 --- a/lib_enc/decision_matrix_enc.c +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "prot_fx_enc.h" -#include "stat_enc.h" -#include "stat_dec.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/detect_transient.c b/lib_enc/detect_transient.c deleted file mode 100644 index c2bbde080..000000000 --- a/lib_enc/detect_transient.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "cnst.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/diffcod.c b/lib_enc/diffcod.c deleted file mode 100644 index 9f6bb4283..000000000 --- a/lib_enc/diffcod.c +++ /dev/null @@ -1,149 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*--------------------------------------------------------------------------*/ -/* Function diffcod() */ -/* */ -/* Differential coding for indices of quantized norms */ -/*--------------------------------------------------------------------------*/ - -void diffcod( - const int16_t N, /* i : number of sub-vectors */ - int16_t *y, /* i/o: indices of quantized norms */ - int16_t *difidx /* o : differential code */ -) -{ - int16_t i, k, r; - - for ( i = N - 1; i > 0; i-- ) - { - r = i - 1; - k = y[i] - y[r]; - if ( k < ( -15 ) ) - { - y[r] = y[i] + 15; - } - } - - for ( i = 1; i < N; i++ ) - { - r = i - 1; - k = y[i] - y[r]; - if ( k > 16 ) - { - k = 16; - y[i] = y[r] + 16; - } - difidx[r] = k + 15; - } - - return; -} - - -/*-------------------------------------------------------------------------- - * diffcod_lrmdct() - * - * Differential coding for indices of quantized norms - *--------------------------------------------------------------------------*/ - -void diffcod_lrmdct( - const int16_t N, /* i : number of sub-vectors */ - const int16_t be_ref, /* i : band energy reference */ - int16_t *y, /* i/o: indices of quantized norms */ - int16_t *difidx, /* o : differential code */ - const int16_t is_transient /* i : transient flag */ -) -{ - int16_t i, m, r; - int16_t k; - int16_t thr_l, thr_h; - - if ( is_transient ) - { - thr_l = -15; - thr_h = 16; - } - else - { - thr_l = -32; - thr_h = 31; - } - - difidx[0] = y[0] - be_ref; - if ( difidx[0] > thr_h ) - { - difidx[0] = thr_h; - y[0] = be_ref + thr_h; - } - - if ( difidx[0] < thr_l ) - { - difidx[0] = thr_l; - y[0] = be_ref + thr_l; - } - - m = N - 1; - for ( i = m; i > 0; i-- ) - { - r = i - 1; - k = y[i] - y[r]; - if ( k < thr_l ) - { - y[r] = y[i] - thr_l; - } - } - - for ( i = 1; i < N; i++ ) - { - r = i - 1; - k = y[i] - y[r]; - if ( k > thr_h ) - { - k = thr_h; - y[i] = y[r] + thr_h; - } - difidx[i] = k; - } - - return; -} diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c deleted file mode 100644 index 726508b0c..000000000 --- a/lib_enc/dtx.c +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "ivas_prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/enc_acelp.c b/lib_enc/enc_acelp.c deleted file mode 100644 index bf5688ef1..000000000 --- a/lib_enc/enc_acelp.c +++ /dev/null @@ -1,91 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "wmc_auto.h" - - -/* - * acelp_2pulse_search - * - * Parameters: - * nb_pos_ix I: nb of pos for pulse 1 (1..8) - * track_x I: track of pulse 1 - * track_y I: track of pulse 2 - * ps I/O: correlation of all fixed pulses - * alp I/O: energy of all fixed pulses - * ix O: position of pulse 1 - * iy O: position of pulse 2 - * dn I: corr. between target and h[] - * dn2 I: vector of selected positions - * cor_x I: corr. of pulse 1 with fixed pulses - * cor_y I: corr. of pulse 2 with fixed pulses - * rrixiy I: corr. of pulse 1 with pulse 2 - * - * Function: - * Find the best positions of 2 pulses in a subframe - * - * Returns: - * void - */ - - -/* - * E_ACELP_1pulse_search - * - * Parameters: - * track_x I: track of pulse 1 - * track_y I: track of pulse 2 - * ps I/O: correlation of all fixed pulses - * alp I/O: energy of all fixed pulses - * ix O: position of pulse 1 - * dn I: corr. between target and h[] - * cor_x I: corr. of pulse 1 with fixed pulses - * cor_y I: corr. of pulse 2 with fixed pulses - * - * Function: - * Find the best positions of 1 pulse in a subframe - * - * Returns: - * void - */ diff --git a/lib_enc/enc_acelp_tcx_main.c b/lib_enc/enc_acelp_tcx_main.c deleted file mode 100644 index d029c2fa8..000000000 --- a/lib_enc/enc_acelp_tcx_main.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/enc_acelpx.c b/lib_enc/enc_acelpx.c deleted file mode 100644 index f6e2b0379..000000000 --- a/lib_enc/enc_acelpx.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "rom_enc.h" -#include "wmc_auto.h" diff --git a/lib_enc/enc_amr_wb.c b/lib_enc/enc_amr_wb.c deleted file mode 100644 index c899b52ff..000000000 --- a/lib_enc/enc_amr_wb.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/enc_gain.c b/lib_enc/enc_gain.c deleted file mode 100644 index 491d5d2f3..000000000 --- a/lib_enc/enc_gain.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/enc_gen_voic.c b/lib_enc/enc_gen_voic.c deleted file mode 100644 index c899b52ff..000000000 --- a/lib_enc/enc_gen_voic.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/enc_prm.c b/lib_enc/enc_prm.c deleted file mode 100644 index 554521732..000000000 --- a/lib_enc/enc_prm.c +++ /dev/null @@ -1,231 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - - -/*-------------------------------------------------------------------* - * writeTCXMode_fx() - * - * write TCX mode - *--------------------------------------------------------------------*/ - -void writeTCXMode_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - Word16 *nbits_start /* o : nbits start Q0*/ -) -{ - UWord16 index; - Word16 idx, start_idx; - Word16 nBits; - - IF( st->tcxonly ) - { - push_next_indice( hBstr, (UWord16) EQ_16( st->core, TCX_10_CORE ), 1 ); - - test(); - IF( EQ_16( st->clas, UNVOICED_CLAS ) ) - { - index = 0; - move16(); - } - ELSE IF( EQ_16( st->clas, VOICED_TRANSITION ) || EQ_16( st->clas, UNVOICED_TRANSITION ) ) - { - index = 1; - move16(); - } - ELSE IF( EQ_16( st->clas, VOICED_CLAS ) ) - { - index = 2; - move16(); - } - ELSE - { - index = 3; - move16(); - } - - push_next_indice( hBstr, index, 2 ); - - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag ) - { - push_next_indice( hBstr, st->vad_flag, 1 ); - } - } - ELSE - { - IF( EQ_16( st->core, ACELP_CORE ) ) - { - /* write the RF signaling information */ - IF( EQ_16( st->rf_mode, 1 ) ) - { - /* find the section in the ACELP signaling table corresponding to bitrate */ - idx = 0; - move16(); - WHILE( NE_32( acelp_sig_tbl[idx], st->total_brate ) ) /* total bitrate is kept at 13.2kbps */ - { - idx = add( idx, 1 ); - } - - /* retrieve the number of bits for signaling */ - idx = add( idx, 1 ); /* Q0 */ - nBits = extract_l( acelp_sig_tbl[idx] ); /* Q0 */ - - /* retrieve the signaling index */ - idx = add( idx, 1 ); - start_idx = idx; - move16(); - WHILE( NE_32( acelp_sig_tbl[idx], SIG2IND( st->coder_type, st->bwidth, st->sharpFlag, st->rf_mode ) ) ) - { - idx = add( idx, 1 ); - } - push_next_indice( hBstr, sub( idx, start_idx ), nBits ); - push_next_indice( hBstr, 0, 1 ); /* Indicate to the decoder that the core is ACELP*/ - *nbits_start = 3; - move16(); - } - ELSE - { - push_next_indice( hBstr, st->coder_type, 3 ); - } - } - ELSE - { - IF( EQ_16( st->mdct_sw, MODE1 ) ) - { - /* 2 bits instead of 3 as TCX is already signaled */ - push_next_indice( hBstr, st->hTcxCfg->coder_type, 2 ); - } - ELSE - { - IF( EQ_16( st->mdct_sw_enable, MODE2 ) ) - { - push_next_indice( hBstr, 1, 1 ); /* TCX */ - push_next_indice( hBstr, 0, 1 ); /* not HQ_CORE */ - push_next_indice( hBstr, st->hTcxCfg->coder_type, 2 ); - } - ELSE - { - /*write the RF signaling information*/ - IF( EQ_16( st->rf_mode, 1 ) ) - { - /* find the section in the ACELP signaling table corresponding to bitrate */ - idx = 0; - move16(); - WHILE( NE_32( acelp_sig_tbl[idx], st->total_brate ) ) - { - idx = add( idx, 1 ); - } - - /* retrieve the number of bits for signaling */ - idx = add( idx, 1 ); - nBits = extract_l( acelp_sig_tbl[idx] ); - - test(); - test(); - IF( EQ_16( st->hTcxCfg->coder_type, VOICED ) || EQ_16( st->hTcxCfg->coder_type, GENERIC ) || EQ_16( st->hTcxCfg->coder_type, TRANSITION ) ) - { - st->sharpFlag = 1; - move16(); - } - ELSE - { - st->sharpFlag = 0; - move16(); - } - - /* retrieve the signaling index */ - idx = add( idx, 1 ); - start_idx = idx; - move16(); - WHILE( NE_32( acelp_sig_tbl[idx], SIG2IND( st->hTcxCfg->coder_type, st->bwidth, st->sharpFlag, st->rf_mode ) ) ) - { - idx = add( idx, 1 ); - } - push_next_indice( hBstr, sub( idx, start_idx ), nBits ); - push_next_indice( hBstr, 1, 1 ); /* Indicate to the decoder that the core is TCX*/ - *nbits_start = 3; - move16(); - } - ELSE - { - push_next_indice( hBstr, add( ACELP_MODE_MAX, st->hTcxCfg->coder_type ), 3 ); - } - } - } - } - } - - return; -} - - -/*-------------------------------------------------------------------* - * writeTCXWindowing_fx() - * - * write TCX transform type - *-------------------------------------------------------------------*/ - -void writeTCXWindowing_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 overlap_mode /* i : overlap mode Q0*/ -) -{ - - IF( EQ_16( overlap_mode, MIN_OVERLAP ) ) - { - push_next_indice( hBstr, 2, 2 ); - } - ELSE IF( EQ_16( overlap_mode, HALF_OVERLAP ) ) - { - push_next_indice( hBstr, 3, 2 ); - } - ELSE - { - push_next_indice( hBstr, 0, 1 ); - } - - return; -} diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index d394fa2d3..da2ea5863 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -11,7 +11,7 @@ #include "rom_com_fx.h" #include "rom_com.h" #include "stl.h" -//#include "prot_fx.h" +#include "prot.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ @@ -1512,3 +1512,190 @@ void writeTCXparam_fx( return; } + +/*-------------------------------------------------------------------* + * writeTCXMode_fx() + * + * write TCX mode + *--------------------------------------------------------------------*/ + +void writeTCXMode_fx( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + Word16 *nbits_start /* o : nbits start Q0*/ +) +{ + UWord16 index; + Word16 idx, start_idx; + Word16 nBits; + + IF( st->tcxonly ) + { + push_next_indice( hBstr, (UWord16) EQ_16( st->core, TCX_10_CORE ), 1 ); + + test(); + IF( EQ_16( st->clas, UNVOICED_CLAS ) ) + { + index = 0; + move16(); + } + ELSE IF( EQ_16( st->clas, VOICED_TRANSITION ) || EQ_16( st->clas, UNVOICED_TRANSITION ) ) + { + index = 1; + move16(); + } + ELSE IF( EQ_16( st->clas, VOICED_CLAS ) ) + { + index = 2; + move16(); + } + ELSE + { + index = 3; + move16(); + } + + push_next_indice( hBstr, index, 2 ); + + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag ) + { + push_next_indice( hBstr, st->vad_flag, 1 ); + } + } + ELSE + { + IF( EQ_16( st->core, ACELP_CORE ) ) + { + /* write the RF signaling information */ + IF( EQ_16( st->rf_mode, 1 ) ) + { + /* find the section in the ACELP signaling table corresponding to bitrate */ + idx = 0; + move16(); + WHILE( NE_32( acelp_sig_tbl[idx], st->total_brate ) ) /* total bitrate is kept at 13.2kbps */ + { + idx = add( idx, 1 ); + } + + /* retrieve the number of bits for signaling */ + idx = add( idx, 1 ); /* Q0 */ + nBits = extract_l( acelp_sig_tbl[idx] ); /* Q0 */ + + /* retrieve the signaling index */ + idx = add( idx, 1 ); + start_idx = idx; + move16(); + WHILE( NE_32( acelp_sig_tbl[idx], SIG2IND( st->coder_type, st->bwidth, st->sharpFlag, st->rf_mode ) ) ) + { + idx = add( idx, 1 ); + } + push_next_indice( hBstr, sub( idx, start_idx ), nBits ); + push_next_indice( hBstr, 0, 1 ); /* Indicate to the decoder that the core is ACELP*/ + *nbits_start = 3; + move16(); + } + ELSE + { + push_next_indice( hBstr, st->coder_type, 3 ); + } + } + ELSE + { + IF( EQ_16( st->mdct_sw, MODE1 ) ) + { + /* 2 bits instead of 3 as TCX is already signaled */ + push_next_indice( hBstr, st->hTcxCfg->coder_type, 2 ); + } + ELSE + { + IF( EQ_16( st->mdct_sw_enable, MODE2 ) ) + { + push_next_indice( hBstr, 1, 1 ); /* TCX */ + push_next_indice( hBstr, 0, 1 ); /* not HQ_CORE */ + push_next_indice( hBstr, st->hTcxCfg->coder_type, 2 ); + } + ELSE + { + /*write the RF signaling information*/ + IF( EQ_16( st->rf_mode, 1 ) ) + { + /* find the section in the ACELP signaling table corresponding to bitrate */ + idx = 0; + move16(); + WHILE( NE_32( acelp_sig_tbl[idx], st->total_brate ) ) + { + idx = add( idx, 1 ); + } + + /* retrieve the number of bits for signaling */ + idx = add( idx, 1 ); + nBits = extract_l( acelp_sig_tbl[idx] ); + + test(); + test(); + IF( EQ_16( st->hTcxCfg->coder_type, VOICED ) || EQ_16( st->hTcxCfg->coder_type, GENERIC ) || EQ_16( st->hTcxCfg->coder_type, TRANSITION ) ) + { + st->sharpFlag = 1; + move16(); + } + ELSE + { + st->sharpFlag = 0; + move16(); + } + + /* retrieve the signaling index */ + idx = add( idx, 1 ); + start_idx = idx; + move16(); + WHILE( NE_32( acelp_sig_tbl[idx], SIG2IND( st->hTcxCfg->coder_type, st->bwidth, st->sharpFlag, st->rf_mode ) ) ) + { + idx = add( idx, 1 ); + } + push_next_indice( hBstr, sub( idx, start_idx ), nBits ); + push_next_indice( hBstr, 1, 1 ); /* Indicate to the decoder that the core is TCX*/ + *nbits_start = 3; + move16(); + } + ELSE + { + push_next_indice( hBstr, add( ACELP_MODE_MAX, st->hTcxCfg->coder_type ), 3 ); + } + } + } + } + } + + return; +} + + +/*-------------------------------------------------------------------* + * writeTCXWindowing_fx() + * + * write TCX transform type + *-------------------------------------------------------------------*/ + +void writeTCXWindowing_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 overlap_mode /* i : overlap mode Q0*/ +) +{ + + IF( EQ_16( overlap_mode, MIN_OVERLAP ) ) + { + push_next_indice( hBstr, 2, 2 ); + } + ELSE IF( EQ_16( overlap_mode, HALF_OVERLAP ) ) + { + push_next_indice( hBstr, 3, 2 ); + } + ELSE + { + push_next_indice( hBstr, 0, 1 ); + } + + return; +} diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c deleted file mode 100644 index 3b1b81730..000000000 --- a/lib_enc/fd_cng_enc.c +++ /dev/null @@ -1,1172 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" -#include "ivas_prot.h" -#include "ivas_prot_fx.h" -#include "stat_enc.h" -#include "wmc_auto.h" - -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * initFdCngEnc() - * - * Initialize FD_CNG - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * deleteFdCngEnc() - * - * Delete the instance of type FD_CNG - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * resetFdCngEnc() - * - * Reset the instance of type FD_CNG - *-------------------------------------------------------------------*/ -/*-------------------------------------------------------------------* - * perform_noise_estimation_enc() - * - * Perform noise estimation - *-------------------------------------------------------------------*/ -void perform_noise_estimation_enc_ivas_fx( - Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ - Word16 band_energies_exp, - Word32 *enerBuffer, /* enerBuffer_exp */ - Word16 enerBuffer_exp, - HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */ - const Word32 input_Fs, /* i : input sampling rate Q0*/ - CPE_ENC_HANDLE hCPE /* i : CPE encoder structure */ -) -{ - Word16 i, j, s, s1, s2; - Word16 numBands; - Word16 numCoreBands = hFdCngEnc->hFdCngCom->numCoreBands; /* Q0 */ - move16(); - Word16 regularStopBand = hFdCngEnc->hFdCngCom->regularStopBand; /* Q0 */ - move16(); - Word16 numSlots = hFdCngEnc->hFdCngCom->numSlots; /* Q0 */ - move16(); - assert( numSlots == 16 ); - - Word32 numSlots_inv_fx = 1073741824; // Q34 of .0625 - move32(); - Word32 *periodog = hFdCngEnc->hFdCngCom->periodog; /* exp(peridog_exp) */ - Word32 *ptr_per_fx = periodog; - Word64 periodog_64; - Word16 periodog_exp[PERIODOGLEN]; - Word16 npart = hFdCngEnc->hFdCngCom->npart; /* Q0 */ - move16(); - Word16 nFFTpart = hFdCngEnc->hFdCngCom->nFFTpart; /* Q0 */ - move16(); - Word16 nCLDFBpart = hFdCngEnc->hFdCngCom->nCLDFBpart; /* Q0 */ - move16(); - - Word16 *psize = hFdCngEnc->hFdCngCom->psize; // 6Q9 - Word32 *msPeriodog_fx = hFdCngEnc->msPeriodog_fx; - Word32 *msNoiseEst_fx = hFdCngEnc->msNoiseEst_fx; /* exp(msNoiseEst_fx_exp) */ - - Word16 *msLogPeriodog_fx = hFdCngEnc->msLogPeriodog_fx; - Word16 *msLogNoiseEst_fx = hFdCngEnc->msLogNoiseEst_fx; - - Word32 scaleEB_fx = 0; - move32(); - Word32 tmp; - - test(); - IF( hCPE != NULL && hCPE->hStereoDft != NULL ) - { - // band_res_dft = ( (float) input_Fs ) / hCPE->hStereoDft->NFFT; - // chan_width_f = 24000.f / CLDFB_NO_CHANNELS_MAX; - // chan_width_bins = chan_width_f / band_res_dft; - - ///* Scaling of Energy buffer to get energy per sample, same scaling as for band_energies, 3 is to compensate for the 1/3 scaling in calculate_energy_buffer */ - // scaleEB = 3 * 4.0f / ( hCPE->hStereoDft->NFFT * hCPE->hStereoDft->NFFT ); - - ///* Scale with number of bins in one band */ - // scaleEB = scaleEB / chan_width_bins; - - SWITCH( input_Fs ) - { - case 8000: - scaleEB_fx = 251648; // Q35 - move32(); - BREAK; - case 16000: - scaleEB_fx = 62912; // Q35 - move32(); - BREAK; - case 32000: - scaleEB_fx = 15728; // Q35 - move32(); - BREAK; - case 48000: - scaleEB_fx = 6991; // Q35 - move32(); - BREAK; - default: - assert( 0 && "invalid sample rate" ); - } - } - ELSE - { - scaleEB_fx = Mpy_32_32( numSlots_inv_fx, L_deposit_l( hFdCngEnc->hFdCngCom->scalingFactor ) ); // Q34 + Q30 - Q31 = Q33 - scaleEB_fx = L_shl( scaleEB_fx, 2 ); // Q35 - } - - /* preemphasis compensation and grouping of per bin energies into msPeriodog */ - FOR( i = 0; i < nFFTpart; i++ ) - { - tmp = L_add( L_shr( band_energies[i], 1 ), L_shr( band_energies[i + NB_BANDS], 1 ) ); - msPeriodog_fx[i] = Mpy_32_16_1( tmp, preemphCompensation_fx[i] ); - move32(); - } - - /* exponent for fft part of msPeriodog */ - hFdCngEnc->msPeriodog_fx_exp_fft = add( band_energies_exp, PREEMPH_COMPENSATION_EXP ); - move16(); - - Word16 max_exp = -31; - move16(); - i = 0; - move16(); - /* Adjust to the desired time resolution by averaging the periodograms over the time slots */ - FOR( j = numCoreBands; j < regularStopBand; j++ ) - { - periodog_64 = W_mult_32_32( enerBuffer[j], scaleEB_fx ); - Word16 scale = W_norm( periodog_64 ); - *ptr_per_fx = W_extract_h( W_shl( periodog_64, scale ) ); - move32(); - periodog_exp[i] = sub( Q31, add( add( sub( Q31, enerBuffer_exp ), 35 - 31 ), scale ) ); - move16(); - max_exp = s_max( max_exp, periodog_exp[i] ); - - ptr_per_fx++; - i++; - } - /* exponent for cldfb part of msPeriodog */ - // hFdCngEnc->hFdCngCom->exp_cldfb_periodog = add( sub( enerBuffer_exp, 4 ), CLDFBscalingFactor_EXP ); - // move16(); - - numBands = sub( regularStopBand, numCoreBands ); /* Q0 */ - FOR( i = 0; i < numBands; i++ ) - { - - periodog[i] = L_shr( periodog[i], sub( max_exp, periodog_exp[i] ) ); - - move16(); - } - hFdCngEnc->hFdCngCom->exp_cldfb_periodog = max_exp; - move16(); - IF( numBands > 0 ) - { - ///* Adjust CLDFB filterbank to the desired frequency resolution by averaging over spectral partitions for SID transmission */ - bandcombinepow( - periodog, - hFdCngEnc->hFdCngCom->exp_cldfb_periodog, - numBands, - hFdCngEnc->hFdCngCom->CLDFBpart, - nCLDFBpart, - hFdCngEnc->hFdCngCom->CLDFBpsize_inv, - &msPeriodog_fx[nFFTpart], - &hFdCngEnc->msPeriodog_fx_exp_cldfb ); - - ///* find common exponent for fft part and cldfb part of msperiodog */ - s1 = getScaleFactor32( msPeriodog_fx, nFFTpart ); - s2 = getScaleFactor32( &msPeriodog_fx[nFFTpart], nCLDFBpart ); - - s = s_max( sub( hFdCngEnc->msPeriodog_fx_exp_fft, s1 ), sub( hFdCngEnc->msPeriodog_fx_exp_cldfb, s2 ) ); - s1 = sub( s, hFdCngEnc->msPeriodog_fx_exp_fft ); - s2 = sub( s, hFdCngEnc->msPeriodog_fx_exp_cldfb ); - - hFdCngEnc->msPeriodog_fx_exp_fft = s; - move16(); - hFdCngEnc->msPeriodog_fx_exp_cldfb = s; - move16(); - - FOR( i = 0; i < nFFTpart; i++ ) - { - msPeriodog_fx[i] = L_shr( msPeriodog_fx[i], s1 ); /* hFdCngEnc->msPeriodog_fx_exp_fft */ - move32(); - } - - FOR( i = 0; i < nCLDFBpart; i++ ) - { - msPeriodog_fx[nFFTpart + i] = L_shr( msPeriodog_fx[nFFTpart + i], s_min( 31, s2 ) ); /* hFdCngEnc->msPeriodog_fx_exp_fft */ - move32(); - } - } - /* exponent for entire msPeriodog vector */ - hFdCngEnc->msPeriodog_fx_exp = hFdCngEnc->msPeriodog_fx_exp_fft; - move16(); - - /* Compress MS inputs */ - // compress_range_flt( msPeriodog, msLogPeriodog, npart ); - compress_range( msPeriodog_fx, hFdCngEnc->msPeriodog_fx_exp, msLogPeriodog_fx, npart ); - - - /* Call the minimum statistics routine for noise estimation */ - - minimum_statistics_fx( npart, nFFTpart, psize, msLogPeriodog_fx, hFdCngEnc->msNoiseFloor_fx, msLogNoiseEst_fx, hFdCngEnc->msAlpha_fx, hFdCngEnc->msPsd_fx, hFdCngEnc->msPsdFirstMoment_fx, - hFdCngEnc->msPsdSecondMoment_fx, hFdCngEnc->msMinBuf_fx, hFdCngEnc->msBminWin_fx, hFdCngEnc->msBminSubWin_fx, hFdCngEnc->msCurrentMin_fx, hFdCngEnc->msCurrentMinOut_fx, hFdCngEnc->msCurrentMinSubWindow_fx, hFdCngEnc->msLocalMinFlag, hFdCngEnc->msNewMinFlag, hFdCngEnc->msPeriodogBuf_fx, &( hFdCngEnc->msPeriodogBufPtr ), hFdCngEnc->hFdCngCom, - ENC, ( hCPE == NULL ) ? 0 : hCPE->element_mode ); - - /* Expand MS outputs */ - expand_range( msLogNoiseEst_fx, msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart ); - - return; -} - - -/*-------------------------------------------------------------------* - * FdCng_encodeSID() - * - * Generate a bitstream out of the partition levels - *-------------------------------------------------------------------*/ -void FdCng_encodeSID_ivas_fx( - Encoder_State *st /* i/o: encoder state structure */ -) -{ - Word16 N; - HANDLE_FD_CNG_ENC hFdCngEnc = st->hFdCngEnc; - HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; - BSTR_ENC_HANDLE hBstr = st->hBstr; - - Word32 *invTrfMatrix_fx, *E_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word32 v_fx[32], gain_fx, e_fx, temp; - Word16 w_fx[32], indices[32], exp[32]; - Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; - Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN]; - Word16 v_e, gain_q_offset, preemph_fac; - Word16 i, index; - - gain_q_offset = GAIN_Q_OFFSET_IVAS_FX_Q0; - move16(); - - if ( st->element_mode == EVS_MONO ) - { - gain_q_offset = GAIN_Q_OFFSET_EVS_FX_Q0; - move16(); - } - - preemph_fac = st->preemph_fac; // Q15 - move16(); - - /* Init */ - N = hFdCngEnc->npartDec; - move16(); - - E_fx = hFdCngEnc->msNoiseEst_fx; - - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ - - set_zero_fx( v_fx, FDCNG_VQ_MAX_LEN ); - - /* Convert to LOG */ - e_fx = 0; - move32(); - FOR( i = 0; i < N; i++ ) - { - IF( E_fx[i] == 0 ) - { - /* 10 * log(1e-4) = 10 * (-4) = -40 */ - v_fx[i] = -41943040; // -40.0 in Q20 - move32(); - } - ELSE - { - v_fx[i] = Mpy_32_32( 671088640 /*10 in Q26*/, BASOP_Util_Log10( E_fx[i], hFdCngEnc->msNoiseEst_fx_exp ) ); // Q20 = 26+25-31 - move32(); - } - e_fx = L_add( e_fx, v_fx[i] ); // Q20 - } - - /* Normalize MSVQ input */ - gain_fx = 0; - move32(); - FOR( i = N_GAIN_MIN; i < N_GAIN_MAX; i++ ) - { - gain_fx = L_add( gain_fx, v_fx[i] ); // Q20 - } - - /*gain /= (float) ( N_GAIN_MAX - N_GAIN_MIN );*/ - gain_fx = Mpy_32_32( gain_fx, 165191050 /* 1/13 in Q31*/ ); // Q20 - - FOR( i = 0; i < N; i++ ) - { - v_fx[i] = L_sub( v_fx[i], gain_fx ); // Q20 - move32(); - } - - v_e = 11; // Q20 - move16(); - - /* MSVQ encoder */ - set_val_Word16( w_fx, ONE_IN_Q8, N ); - - IF( st->element_mode != EVS_MONO ) - { - /* DCT domain compressed/truncated indices used for first stage */ - /* quantization with stage1 stored in DCT24 domain, stages 2 through 6 directly dearched - in FDCNG band domain - */ - IF( EQ_16( N, FDCNG_VQ_MAX_LEN_WB ) ) - { - /* truncated DCT21 analysis */ - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); // Q31 - - dctT2_N_apply_matrix_fx( v_fx /*Q20*/, dct_target_fx, FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); // Q20 - - /* truncated IDCT21 extension to 24 bands */ - extend_dctN_input_fx( v_fx, dct_target_fx, N, tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); // Q20 - - Copy32( tot_sig_ext_fx, v_fx, FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 */ // Q20 - } - - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); // Q31 - - msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, v_fx, v_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w_fx, N, FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices ); - - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v_fx, NULL, 7 ); - - v_e = sub( 31, sub( 20, find_guarded_bits_fx( N ) ) ); - } - ELSE - { /* EVS_MONO tables */ - msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, v_fx, v_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w_fx, N, FD_CNG_maxN_37bits, 0, NULL, indices ); - - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v_fx, NULL, 7 ); - - v_e = sub( 31, sub( 20, find_guarded_bits_fx( N ) ) ); - } - - /* Compute gain */ - gain_fx = 0; - move32(); - FOR( i = 0; i < N; i++ ) - { - gain_fx = L_add( gain_fx, v_fx[i] ); // Q = 31 - v_e - } - - e_fx = L_shl( e_fx, sub( 11, v_e ) ); // Q = 31 - v_e - gain_fx = Mpy_32_16_1( L_sub( e_fx, gain_fx ), div_s( 1, N ) ); // Q = 31 - v_e - gain_fx = L_shl( gain_fx, sub( v_e, 8 ) ); // Q23 - - /* Apply bitrate-dependant scale */ - IF( st->element_mode > EVS_MONO ) - { - apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); - } - ELSE - { - apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableMono, SIZE_SCALE_TABLE_MONO ); - } - - /* Quantize gain */ - temp = Madd_32_32( L_shl( gain_q_offset, 22 ), gain_fx, 1610612736 /*1.5 in Q30*/ ); // Q22 - index = extract_l( L_shr( L_add( temp, ONE_IN_Q21 ), 22 ) ); // Q0 - - if ( index < 0 ) - { - index = 0; - move16(); - } - - if ( GT_16( index, 127 ) ) - { - index = 127; - move16(); - } - - gain_fx = L_shl( L_mult0( sub( index, gain_q_offset ), 21845 /*1.5 in Q15*/ ), sub( 16, v_e ) ); // Q = 31-v_e - - /* Apply gain and undo log */ - FOR( i = 0; i < N; i++ ) - { - temp = Mpy_32_32( L_add( v_fx[i], gain_fx ), 214748365 /* 0.1 in Q31*/ ); // Q = 31-v_e - hFdCngCom->sidNoiseEst[i] = BASOP_Util_fPow( 10, 31, temp, v_e, &exp[i] ); - move32(); - } - - maximum_s( exp, N, &hFdCngCom->sidNoiseEstExp ); - - FOR( i = 0; i < N; i++ ) - { - hFdCngCom->sidNoiseEst[i] = L_shr( hFdCngCom->sidNoiseEst[i], sub( hFdCngCom->sidNoiseEstExp, exp[i] ) ); // exp = hFdCngCom->sidNoiseEstExp - move32(); - } - - /* NB last band energy compensation */ - IF( hFdCngCom->CngBandwidth == NB ) - { - hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], NB_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp) - move32(); - } - - test(); - IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) - { - hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp) - move32(); - } - - /* Write bitstream */ - IF( EQ_16( st->codec_mode, MODE2 ) ) - { - FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) - { - push_next_indice( hBstr, indices[i], bits_37bits[i] ); - } - - push_next_indice( hBstr, index, 7 ); - } - ELSE - { - Word16 is_frame_len_16k = 0; - move16(); - if ( EQ_16( st->L_frame, L_FRAME16k ) ) - { - is_frame_len_16k = 1; - move16(); - } - push_indice( hBstr, IND_SID_TYPE, 1, 1 ); - push_indice( hBstr, IND_BWIDTH, st->bwidth, 2 ); - push_indice( hBstr, IND_ACELP_16KHZ, is_frame_len_16k, 1 ); - - FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) - { - push_indice( hBstr, IND_LSF, indices[i], bits_37bits[i] ); - } - - push_indice( hBstr, IND_ENERGY, index, 7 ); - } - - /* Interpolate the bin/band-wise levels from the partition levels */ - scalebands( hFdCngCom->sidNoiseEst, hFdCngEnc->partDec, hFdCngEnc->npartDec, hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); - hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; - move16(); - - lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, preemph_fac ); - - return; -} - - -/*-------------------------------------------------------------------* - * stereoFdCngCoherence() - * - * compute coherence of channels for use in FD-CNG - *-------------------------------------------------------------------*/ -void stereoFdCngCoherence_fx( - Encoder_State **sts, /* i/o: core encoder structures */ - const Word16 last_element_mode, /* i : last element mode Q0*/ - Word16 fft_buf_fx[CPE_CHANNELS][2 * L_FFT], /* i : fft buffers for L and R channels fft_exp*/ - Word16 fft_exp ) -{ - const Word16 *pt_fftL, *pt_fftR; - Word16 i_subfr, i; - Word32 cr, ci, eL, eR; - Word16 cr_exp, ci_exp, eL_exp, eR_exp; - Word32 *mem; - Word16 *mem_exp; - - IF( NE_16( last_element_mode, IVAS_CPE_MDCT ) ) - { - set32_fx( sts[0]->hFdCngEnc->mem_coherence_fx, EPSILON_FX, 4 ); - set16_fx( sts[0]->hFdCngEnc->mem_coherence_exp, 0, 4 ); - } - test(); - test(); - IF( EQ_32( sts[0]->core_brate, -1 ) || EQ_32( sts[1]->core_brate, -1 ) ) - { - /* case: at least one channel has triggered VAD -> ACTIVE FRAME */ - IF( EQ_32( sts[0]->core_brate, -1 ) ) - { - sts[1]->total_brate = sts[0]->total_brate; /* Q0 */ - move32(); - sts[1]->active_cnt = sts[0]->active_cnt; /* Q0 */ - move16(); - if ( GE_32( sts[1]->active_cnt, CNG_TYPE_HO ) ) - { - sts[1]->last_total_brate_cng = -1; - move16(); - } - } - IF( EQ_32( sts[1]->core_brate, -1 ) ) - { - sts[0]->total_brate = sts[1]->total_brate; /* Q0 */ - move32(); - sts[0]->active_cnt = sts[1]->active_cnt; /* Q0 */ - move16(); - if ( GE_16( sts[0]->active_cnt, CNG_TYPE_HO ) ) - { - sts[0]->last_total_brate_cng = -1; - move16(); - } - } - sts[0]->core_brate = -1; - move32(); - sts[1]->core_brate = -1; - move32(); - sts[0]->hDtxEnc->cnt_SID = 0; - move16(); - sts[1]->hDtxEnc->cnt_SID = 0; - move16(); - } - ELSE IF( LE_32( sts[0]->core_brate, SID_2k40 ) && LE_32( sts[1]->core_brate, SID_2k40 ) ) - { - /* case: no VAD for both channels -> INACTIVE FRAME */ - reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); - - reset_indices_enc( sts[1]->hBstr, sts[1]->hBstr->nb_ind_tot ); - - /* synchronize SID sending for variable SID rate */ - IF( EQ_32( sts[0]->core_brate, sts[1]->core_brate ) ) - { - sts[0]->core_brate = SID_2k40; - move32(); - sts[1]->core_brate = SID_2k40; - move32(); - } - - /* synchronize SID counters */ - sts[0]->hDtxEnc->cnt_SID = s_min( sts[0]->hDtxEnc->cnt_SID, sts[1]->hDtxEnc->cnt_SID ); /* Q0 */ - sts[1]->hDtxEnc->cnt_SID = sts[0]->hDtxEnc->cnt_SID; /* Q0 */ - move16(); - move16(); - } - - pt_fftL = fft_buf_fx[0]; - pt_fftR = fft_buf_fx[1]; - mem = sts[0]->hFdCngEnc->mem_coherence_fx; /* exp(sts[0]->hFdCngEnc->mem_coherence_exp) */ - mem_exp = sts[0]->hFdCngEnc->mem_coherence_exp; - FOR( i_subfr = 0; i_subfr < 2; i_subfr++ ) - { - cr = ci = eL = eR = EPSILON_FX; - move32(); - move32(); - move32(); - move32(); - cr_exp = ci_exp = eL_exp = eR_exp = 0; - move16(); - move16(); - move16(); - move16(); - - cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[0], pt_fftR[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ - eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[0], pt_fftL[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ - eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[0], pt_fftR[0] ), L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ - - FOR( i = 1; i < L_FFT / 2; i++ ) - { - cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[i], pt_fftR[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ - ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_add( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[i] ) ), shl( fft_exp, 1 ), &ci_exp ); /* exp(ci_exp) */ - eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[i], pt_fftL[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ - eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[i], pt_fftR[i] ), L_mult( pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ - } - test(); - test(); - IF( LE_32( sts[0]->ini_frame, 50 ) || ( sts[0]->vad_flag == 0 && sts[1]->vad_flag == 0 ) ) - { - mem[0] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[0], 31129 /*0.95f*/ ), mem_exp[0], Mpy_32_16_1( cr, 1638 /*0.05f*/ ), cr_exp, &mem_exp[0] ); /* exp(mem_exp[0]) */ - move32(); - mem[1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[1], 31129 /*0.95f*/ ), mem_exp[1], Mpy_32_16_1( ci, 1638 /*0.05f*/ ), ci_exp, &mem_exp[1] ); /* exp(mem_exp[1]) */ - move32(); - mem[2] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[2], 31129 /*0.95f*/ ), mem_exp[2], Mpy_32_16_1( eL, 1638 /*0.05f*/ ), eL_exp, &mem_exp[2] ); /* exp(mem_exp[2]) */ - move32(); - mem[3] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[3], 31129 /*0.95f*/ ), mem_exp[3], Mpy_32_16_1( eR, 1638 /*0.05f*/ ), eR_exp, &mem_exp[3] ); /* exp(mem_exp[3]) */ - move32(); - } - - pt_fftL += L_FFT; - pt_fftR += L_FFT; - } - - Word16 sqr_inp, temp, sqr_out, sqr_inp_exp; - Word32 sqr_inp32 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( mem[0], mem[0] ), shl( mem_exp[0], 1 ), Mpy_32_32( mem[1], mem[1] ), shl( mem_exp[1], 1 ), &sqr_inp_exp ); /* exp(sqr_inp_exp) */ - sqr_inp = BASOP_Util_Divide3232_Scale( sqr_inp32, Mpy_32_32( mem[2], mem[3] ), &temp ); - sqr_inp_exp = add( temp, sub( sqr_inp_exp, add( mem_exp[2], mem_exp[3] ) ) ); - sqr_out = Sqrt16( sqr_inp, &sqr_inp_exp ); - sts[0]->hFdCngEnc->hFdCngCom->coherence_fx = shl_sat( sqr_out, sqr_inp_exp ); // Q15 expected. - move16(); - return; -} - -/*-------------------------------------------------------------------* - * FdCngEncodeMDCTStereoSID() - * - * Encode DTX parameters and noise shapes into SID for MDCT-Stereo DTX - *-------------------------------------------------------------------*/ - -void FdCngEncodeMDCTStereoSID_fx( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ -) -{ - ENC_CORE_HANDLE sts[CPE_CHANNELS]; - Word16 indices[CPE_CHANNELS][FD_CNG_stages_37bits]; - Word16 gain_idx[CPE_CHANNELS]; - Word16 N, stages, ch, p, coh_idx; - Word32 *lr_in_ptr_fx[CPE_CHANNELS]; - Word16 lr_in_ptr_e[CPE_CHANNELS]; - Word32 *ms_ptr_fx[CPE_CHANNELS]; - Word16 ms_ptr_e; - Word32 *lr_out_ptr_fx[CPE_CHANNELS]; - Word16 lr_out_ptr_e[CPE_CHANNELS]; - Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; - Word32 E_fx[CPE_CHANNELS]; - Word32 gain_fx[CPE_CHANNELS]; - Word16 weights_fx[NPART]; - Word32 side_energy_fx; - Word16 Qside_energy; - Word32 *invTrfMatrix_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; /*24*18*/ - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ - Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN], dct_target_fx[CPE_CHANNELS][FDCNG_VQ_DCT_MAXTRUNC]; /* 24 +2*18*/ - Word16 tmp, tmp_e; - Word16 no_side_flag; - Word16 is_inp_ms; - Word16 size_value, temp_e, gb, shift; - Word32 tmp32, t1, t2; - - is_inp_ms = 0; - move16(); - IF( EQ_16( hCPE->hCoreCoder[0]->cng_sba_flag, 1 ) ) - { - is_inp_ms = 1; - move16(); - } - - /* set pointers and initialize */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - lr_in_ptr_fx[ch] = &sts[ch]->hFdCngEnc->msNoiseEst_fx[0]; /* exp(sts[ch]->hFdCngEnc->msNoiseEst_fx_exp) */ - lr_in_ptr_e[ch] = sts[ch]->hFdCngEnc->msNoiseEst_fx_exp; - ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; - lr_out_ptr_fx[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0]; /* exp(sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp) */ - lr_out_ptr_e[ch] = sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp; - } - N = sts[0]->hFdCngEnc->npartDec; /* Q0 */ - move16(); - set16_fx( weights_fx, ONE_IN_Q8, NPART ); - - /* apply log and save energy of original left and right channels */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - // E[ch] = 0.0f; - E_fx[ch] = 0; - move32(); - FOR( p = 0; p < N; p++ ) - { - IF( lr_in_ptr_fx[ch][p] ) - { - t1 = BASOP_Util_Log2( lr_in_ptr_fx[ch][p] ); // Q25 - t2 = L_add( t1, L_shl( lr_in_ptr_e[ch], Q25 ) ); // Q25 - } - ELSE - { - t2 = 0; - move32(); - } - ms_ptr_fx[ch][p] = Mpy_32_32( t2, TEN_MULT_LOG10_2_IN_Q29 ); // Q23 - move32(); - E_fx[ch] = L_add( E_fx[ch], L_shr( ms_ptr_fx[ch][p], 4 ) ); // Q19 - move32(); - } - } - ms_ptr_e = Q31 - Q23; - move16(); - - /* M/S transform on log envelopes */ - IF( is_inp_ms == 0 ) - { - convertToMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q30 ); // ms_ptr_e = Q23; - } - - gb = find_guarded_bits_fx( N ); - side_energy_fx = sum2_f_32_fx( ms_ptr_fx[1], N, gb ); - Qside_energy = sub( sub( shl( sub( 31, ms_ptr_e ), 1 ), 31 ), gb ); - - /* do not transmit side shape if initial noise shapes are very similar */ - IF( LE_32( side_energy_fx, L_shl( 214748365, sub( Qside_energy, Q31 ) ) ) ) - { - no_side_flag = 1; - move16(); - } - ELSE - { - no_side_flag = 0; - move16(); - } - - /* Quantize noise shapes */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - /* Normalize MSVQ input */ - gain_fx[ch] = 0; - move32(); - FOR( p = N_GAIN_MIN; p < N_GAIN_MAX; p++ ) - { - tmp32 = Mpy_32_32( ms_ptr_fx[ch][p], 165191050 /* 0.07 in Q31*/ ); // Q23 - gain_fx[ch] = L_add( gain_fx[ch], tmp32 ); // Q23 - move32(); - } - - FOR( p = 0; p < N; p++ ) - { - ms_ptr_fx[ch][p] = L_sub( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q23 - move32(); - } - } - - /* always split channel targetloop */ - - /* extend fdcng envelope from length 21 to a 24 length fdncg domain envelope signal */ - /* High quality cosine smooth basis extension used to not introduce noise in stage#1 DCT24 analysis and subsequent VQ-steps */ - IF( EQ_16( N, FDCNG_VQ_MAX_LEN_WB ) ) - { - size_value = BASOP_Util_Divide1616_Scale( sizeof( tmpRAM_fx ), ( sizeof( Word32 ) ), &temp_e ); /*Q15*/ - size_value = shr( size_value, sub( 15, temp_e ) ); - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N, FDCNG_VQ_DCT_MAXTRUNC, size_value ); // Q31 /*WB: create truncated IDCT21 matrix */ - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - /* run DCT_N N==21 , truncated at 18/21 ~= 86% , i.e use a bit better better quality in extrapolation , than subsequent DCT24 analysis which is truncated at 75%*/ - /* truncated DCT 21 analysis */ - dctT2_N_apply_matrix_fx( (const Word32 *) ms_ptr_fx[ch], dct_target_fx[ch], FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); - /* extrapolate extend fdcng envelope signal in the fdncg ienvelope/"time" domain using DCT21 basis vectors, - estimated DCT21 coeffs scaling extended basis vectors are used to create extrapolated length 24 input target envelope signal */ - /* this DCT21 extension does not introduce DCT24 coefficient noise for the subsequent dct24 target analysis, and later in IDCT24 synthesis */ - - /* truncated IDCT 21 extension synthesis */ - extend_dctN_input_fx( ms_ptr_fx[ch], dct_target_fx[ch], N, tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx /* DCT_N basis vectors */, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); /* use 18 basis vectors*/ - - Copy32( tot_sig_ext_fx, ms_ptr_fx[ch], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ */ - } - } - - size_value = BASOP_Util_Divide1616_Scale( sizeof( tmpRAM_fx ), ( sizeof( Word32 ) ), &temp_e ); /*Q15*/ - size_value = shr( size_value, sub( 15, temp_e ) ); - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, size_value ); /*always create/set up IDCT24 matrix in RAM */ - - /* end split */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - /* MSVQ */ - IF( ch ) - { - stages = FD_CNG_JOINT_stages_25bits; - move16(); - } - ELSE - { - stages = FD_CNG_stages_37bits; - move16(); - } - - /* DCT24 domain compressed/truncated indices used for first stage */ - /* mid channel quantization using stages 1 through 6 */ - /* & side channel quantization using stages 1 through 4 */ - - { - msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, ms_ptr_fx[ch], ms_ptr_e, levels_37bits, FD_CNG_maxC_37bits, stages, weights_fx, N, FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices[ch] ); - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices[ch], 1, invTrfMatrix_fx, ms_ptr_fx[ch], NULL, 7 ); - } - } - shift = find_guarded_bits_fx( N ); - ms_ptr_e = sub( 31, sub( 20, shift ) ); - - IF( no_side_flag ) - { - set32_fx( ms_ptr_fx[1], 0, N ); - } - - /* undo M/S */ - IF( is_inp_ms == 0 ) - { - convertToMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 ); - } - - /* Compute gain against original left and right channels */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - gain_fx[ch] = 0; - move32(); - - tmp_e = 15; - move16(); - tmp = Inv16( N, &tmp_e ); - FOR( p = 0; p < N; p++ ) - { - gain_fx[ch] = L_add( gain_fx[ch], Mpy_32_16_1( ms_ptr_fx[ch][p], shl( tmp, tmp_e ) ) ); // Q23 - move32(); - } - gain_fx[ch] = L_sub( L_shl( Mpy_32_16_1( E_fx[ch], shl( tmp, tmp_e ) ), Q23 - Q19 ), L_shl( gain_fx[ch], sub( ms_ptr_e, 8 ) ) ); // Q23 - move32(); - - apply_scale( &gain_fx[ch], sts[ch]->hFdCngEnc->hFdCngCom->CngBandwidth, sts[ch]->element_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); - - /* quantize gain */ - gain_idx[ch] = (Word16) Mpy_32_32_r( L_add( gain_fx[ch], 251658240 ), 384 ); // Q23 - move16(); - gain_idx[ch] = s_max( 0, s_min( 127, gain_idx[ch] ) ); - move16(); - - gain_fx[ch] = Mpy_32_16_1( L_shl( sub( gain_idx[ch], GAIN_Q_OFFSET_IVAS_FX_Q0 ), 23 ), 21845 ); // Q23 - move32(); - } - - /* restore channel noise envelopes */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - HANDLE_FD_CNG_ENC hFdCngEnc = sts[ch]->hFdCngEnc; - HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; - - tmp_e = 0; - move16(); - Word32 pow; - - Word16 e_lr_out[NPART]; - - FOR( p = 0; p < N; p++ ) - { - pow = L_shl( gain_fx[ch], 8 - ms_ptr_e ); - pow = L_add( ms_ptr_fx[ch][p], pow ); - pow = Mpy_32_32( pow, 214748365 ); /*pow = 0.1*/ - lr_out_ptr_fx[ch][p] = BASOP_Util_fPow( 10, 31, pow, ms_ptr_e, &e_lr_out[p] ); - move32(); - tmp_e = s_max( tmp_e, e_lr_out[p] ); - } - - FOR( p = 0; p < N; p++ ) - { - lr_out_ptr_fx[ch][p] = L_shl( lr_out_ptr_fx[ch][p], e_lr_out[p] - tmp_e ); - move32(); - } - lr_out_ptr_e[ch] = tmp_e; - move32(); - - sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp = tmp_e; - move16(); - - /* scale bands and get scalefactors */ - scalebands( lr_out_ptr_fx[ch], hFdCngEnc->partDec, N, hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); - hFdCngCom->cngNoiseLevelExp = lr_out_ptr_e[ch]; - move16(); - - lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac ); - - sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; - } - - /* quantize channel coherence */ - coh_idx = mult_r( sts[0]->hFdCngEnc->hFdCngCom->coherence_fx, 15 ); - coh_idx = max( 0, min( coh_idx, 15 ) ); - - /* ---- Write SID bitstream ---- */ - - - /* noise shapes and channel gains */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - IF( ch ) - { - stages = FD_CNG_JOINT_stages_25bits; - sts[ch]->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot; - - /* side info */ - push_indice( sts[ch]->hBstr, IND_SID_TYPE, coh_idx, 4 ); - push_indice( sts[ch]->hBstr, IND_SID_TYPE, no_side_flag, 1 ); - } - ELSE - { - stages = FD_CNG_stages_37bits; - /* side info */ - push_indice( sts[ch]->hBstr, IND_SID_TYPE, 1, 1 ); - push_indice( sts[ch]->hBstr, IND_BWIDTH, sts[0]->bwidth, 2 ); - push_indice( sts[ch]->hBstr, IND_ACELP_16KHZ, sts[0]->L_frame == L_FRAME16k ? 1 : 0, 1 ); - } - - FOR( Word16 i = 0; i < stages; i++ ) - { - push_indice( sts[ch]->hBstr, IND_LSF, indices[ch][i], bits_37bits[i] ); - } - push_indice( sts[ch]->hBstr, IND_ENERGY, gain_idx[ch], 7 ); - } - - /* pad with zeros to reach common SID frame size */ - push_indice( sts[1]->hBstr, IND_ENERGY, 0, ( IVAS_SID_5k2 - 4400 ) / FRAMES_PER_SEC ); - - return; -} - -/*-------------------------------------------------------------------* - * FdCngEncodeDiracMDCTStereoSID() - * - * Encode DTX parameters and noise shapes into SID for MDCT-Stereo DTX - * together with Dirac - *-------------------------------------------------------------------*/ - -void FdCngEncodeDiracMDCTStereoSID_fx( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ -) -{ - ENC_CORE_HANDLE sts[CPE_CHANNELS]; - Word32 *lr_in_ptr_fx[CPE_CHANNELS]; - Word16 lr_in_ptr_e[CPE_CHANNELS]; - Word32 *ms_ptr_fx[CPE_CHANNELS]; - Word16 ms_ptr_e; - Word32 *lr_out_ptr_fx[CPE_CHANNELS]; - Word16 lr_out_ptr_e[CPE_CHANNELS]; - Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; - Word32 E_fx[CPE_CHANNELS]; - Word32 gain_fx[CPE_CHANNELS]; - Word16 weights_fx[NPART]; - Word16 N[CPE_CHANNELS]; - Word16 indices[CPE_CHANNELS][FD_CNG_stages_37bits]; - Word16 gain_idx[CPE_CHANNELS]; - Word16 ch, p; - Word16 tmp, tmp_e, shift; - Word32 *invTrfMatrix_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; - Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN]; - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ - Word32 t1, t2, tmp32; - /* set pointers and initialize */ - - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - N[ch] = sts[ch]->hFdCngEnc->npartDec; - lr_in_ptr_fx[ch] = &sts[ch]->hFdCngEnc->msNoiseEst_fx[0]; - lr_in_ptr_e[ch] = sts[ch]->hFdCngEnc->msNoiseEst_fx_exp; - ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; - lr_out_ptr_fx[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0]; - lr_out_ptr_e[ch] = sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp; - move16(); - } - set16_fx( weights_fx, ONE_IN_Q8, NPART ); - - /* apply log and save energy of original left and right channels */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - // E[ch] = 0.0f; - E_fx[ch] = 0; - move32(); - FOR( p = 0; p < N[ch]; p++ ) - { - t1 = BASOP_Util_Log2( lr_in_ptr_fx[ch][p] + EPSILLON_FX ); // Q25 - t2 = L_add( t1, L_shl( lr_in_ptr_e[ch], Q25 ) ); // Q25 - ms_ptr_fx[ch][p] = Mpy_32_32( t2, TEN_MULT_LOG10_2_IN_Q29 ); // Q23 - move32(); - E_fx[ch] = L_add( E_fx[ch], L_shr( ms_ptr_fx[ch][p], 5 ) ); // Q18 - move32(); - } - } - ms_ptr_e = Q31 - Q23; - move16(); - - /* M/S transform on log envelopes */ - convertToMS_fx( N[0], ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q30 ); - E_fx[0] = 0; - move32(); - FOR( p = 0; p < N[0]; p++ ) - { - E_fx[0] = L_add( E_fx[0], L_shr( ms_ptr_fx[0][p], 5 ) ); // Q18 - move32(); - } - - /* Quantize M noise shape */ - /* Normalize MSVQ input */ - gain_fx[0] = 0; - move16(); - FOR( p = N_GAIN_MIN; p < N_GAIN_MAX; p++ ) - { - tmp32 = Mpy_32_32( ms_ptr_fx[0][p], 165191050 /* 0.07 in Q31 */ ); // Q23 - gain_fx[0] = L_add( gain_fx[0], tmp32 ); // Q23 - move32(); - } - - FOR( p = 0; p < N[0]; p++ ) - { - ms_ptr_fx[0][p] = L_sub( ms_ptr_fx[0][p], gain_fx[0] ); // Q23 - move32(); - } - - - /* MSVQ */ - /* DCT domain compressed/truncated indices used for first stage */ - /* mid quantization using stages #1 through 6 */ - scale_sig32( ms_ptr_fx[0], N[0], -6 ); - ms_ptr_e = add( ms_ptr_e, 6 ); - move16(); - IF( EQ_16( N[0], FDCNG_VQ_MAX_LEN_WB ) ) - { - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N[0], FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); - /* truncated DCT 21 analysis */ - dctT2_N_apply_matrix_fx( (const Word32 *) ms_ptr_fx[0], dct_target_fx, FDCNG_VQ_DCT_MAXTRUNC, N[0], invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); - /* truncated IDCT21 extension to 24 synthesis */ - - extend_dctN_input_fx( ms_ptr_fx[0], dct_target_fx, N[0], tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); /* use 18 basis vectors*/ - - Copy32( tot_sig_ext_fx, ms_ptr_fx[0], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 Q23*/ - } - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); - - msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, ms_ptr_fx[0], ms_ptr_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, weights_fx, N[0], FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices[0] ); - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N[0], FD_CNG_maxN_37bits, indices[0], 1, invTrfMatrix_fx, ms_ptr_fx[0], NULL, 7 ); - shift = find_guarded_bits_fx( N[0] ); - ms_ptr_e = sub( 31, sub( 20, shift ) ); - scale_sig32( ms_ptr_fx[1], N[1], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */ - - /* set S to zero */ - set32_fx( ms_ptr_fx[1], 0, NPART ); - - /* compute M gain */ - gain_fx[0] = 0; - move32(); - tmp_e = 15; - move16(); - tmp = Inv16( N[0], &tmp_e ); - FOR( p = 0; p < N[0]; p++ ) - { - gain_fx[0] = L_add( gain_fx[0], Mpy_32_16_1( ms_ptr_fx[0][p], shl( tmp, tmp_e ) ) ); // Q23 - move32(); - } - gain_fx[0] = L_sub( L_shl( Mpy_32_16_1( E_fx[0], shl( tmp, tmp_e ) ), Q23 - Q18 ), L_shl( gain_fx[0], ms_ptr_e - 8 ) ); // Q23 - move32(); - - apply_scale( &gain_fx[0], sts[0]->hFdCngEnc->hFdCngCom->CngBandwidth, sts[0]->hDtxEnc->last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); - - /* quantize gain */ - gain_idx[0] = extract_l( Mpy_32_32_r( L_add( gain_fx[0], 251658240 ), 384 ) ); - move16(); - gain_idx[0] = s_max( 0, s_min( 127, gain_idx[0] ) ); - move16(); - - gain_fx[0] = Mpy_32_16_1( L_shl( sub( gain_idx[0], GAIN_Q_OFFSET_IVAS_FX_Q0 ), 23 ), 21845 /* 0.66 in Q15 */ ); // Q23 - move32(); - gain_fx[1] = gain_fx[0]; // Q23 - move32(); - - /* undo M/S */ - convertToMS_fx( NPART, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 ); - - /* restore channel noise envelopes */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - HANDLE_FD_CNG_ENC hFdCngEnc = sts[ch]->hFdCngEnc; - HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; - - Word32 pow; - Word16 e_lr_out[NPART]; - tmp_e = -MAX_16; - FOR( p = 0; p < N[ch]; p++ ) - { - pow = L_shl( gain_fx[ch], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */ - pow = L_add( ms_ptr_fx[ch][p], pow ); /* Q31 - ms_ptr_e */ - pow = Mpy_32_32( pow, 214748365 /* 0.1 in Q31 */ ); /*pow = 0.1 Q31 - ms_ptr_e*/ - lr_out_ptr_fx[ch][p] = BASOP_Util_fPow( 10, 31, pow, ms_ptr_e, &e_lr_out[p] ); - tmp_e = s_max( tmp_e, e_lr_out[p] ); - } - - FOR( p = 0; p < N[ch]; p++ ) - { - lr_out_ptr_fx[ch][p] = L_shl( lr_out_ptr_fx[ch][p], sub( e_lr_out[p], tmp_e ) ); // Q(31 - tmp_e) - } - - sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp = tmp_e; - move16(); - lr_out_ptr_e[ch] = tmp_e; - move16(); - - /* NB last band energy compensation */ - IF( hFdCngCom->CngBandwidth == NB ) - { - lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], NB_LAST_BAND_SCALE ); // Q(31 - tmp_e) - move32(); - } - ELSE IF( hFdCngCom->CngBandwidth == SWB && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) - { - lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], SWB_13k2_LAST_BAND_SCALE ); // Q(31 - tmp_e) - move32(); - } - /* scale bands and get scalefactors */ - scalebands( lr_out_ptr_fx[ch], hFdCngEnc->partDec, N[ch], hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); - hFdCngCom->cngNoiseLevelExp = lr_out_ptr_e[ch]; - move16(); - lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac ); - sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; - } - sts[0]->hFdCngEnc->hFdCngCom->coherence_fx = 0; - move16(); - sts[1]->hFdCngEnc->hFdCngCom->coherence_fx = 0; - move16(); - - /* ---- Write SID bitstream ---- */ - - /* side info */ - push_indice( sts[0]->hBstr, IND_SID_TYPE, 1, 1 ); - push_indice( sts[0]->hBstr, IND_BWIDTH, sts[0]->bwidth, 2 ); - IF( EQ_16( sts[0]->L_frame, L_FRAME16k ) ) - { - push_indice( sts[0]->hBstr, IND_ACELP_16KHZ, 1, 1 ); - } - ELSE - { - push_indice( sts[0]->hBstr, IND_ACELP_16KHZ, 0, 1 ); - } - - /* noise shapes and channel gains */ - FOR( Word16 i = 0; i < FD_CNG_stages_37bits; i++ ) - { - push_indice( sts[0]->hBstr, IND_LSF, indices[0][i], bits_37bits[i] ); - } - push_indice( sts[0]->hBstr, IND_ENERGY, gain_idx[0], 7 ); - - return; -} diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 93a954ae8..50f479d8d 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -14,6 +14,7 @@ #include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" +#include "ivas_prot_fx.h" #include "basop_util.h" #include "rom_basop_util.h" @@ -2267,3 +2268,1102 @@ Word16 cng_energy_ivas_fx( } return enr; } + +void perform_noise_estimation_enc_ivas_fx( + Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN band_energies_exp*/ + Word16 band_energies_exp, + Word32 *enerBuffer, /* enerBuffer_exp */ + Word16 enerBuffer_exp, + HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */ + const Word32 input_Fs, /* i : input sampling rate Q0*/ + CPE_ENC_HANDLE hCPE /* i : CPE encoder structure */ +) +{ + Word16 i, j, s, s1, s2; + Word16 numBands; + Word16 numCoreBands = hFdCngEnc->hFdCngCom->numCoreBands; /* Q0 */ + move16(); + Word16 regularStopBand = hFdCngEnc->hFdCngCom->regularStopBand; /* Q0 */ + move16(); + Word16 numSlots = hFdCngEnc->hFdCngCom->numSlots; /* Q0 */ + move16(); + assert( numSlots == 16 ); + + Word32 numSlots_inv_fx = 1073741824; // Q34 of .0625 + move32(); + Word32 *periodog = hFdCngEnc->hFdCngCom->periodog; /* exp(peridog_exp) */ + Word32 *ptr_per_fx = periodog; + Word64 periodog_64; + Word16 periodog_exp[PERIODOGLEN]; + Word16 npart = hFdCngEnc->hFdCngCom->npart; /* Q0 */ + move16(); + Word16 nFFTpart = hFdCngEnc->hFdCngCom->nFFTpart; /* Q0 */ + move16(); + Word16 nCLDFBpart = hFdCngEnc->hFdCngCom->nCLDFBpart; /* Q0 */ + move16(); + + Word16 *psize = hFdCngEnc->hFdCngCom->psize; // 6Q9 + Word32 *msPeriodog_fx = hFdCngEnc->msPeriodog_fx; + Word32 *msNoiseEst_fx = hFdCngEnc->msNoiseEst_fx; /* exp(msNoiseEst_fx_exp) */ + + Word16 *msLogPeriodog_fx = hFdCngEnc->msLogPeriodog_fx; + Word16 *msLogNoiseEst_fx = hFdCngEnc->msLogNoiseEst_fx; + + Word32 scaleEB_fx = 0; + move32(); + Word32 tmp; + + test(); + IF( hCPE != NULL && hCPE->hStereoDft != NULL ) + { + // band_res_dft = ( (float) input_Fs ) / hCPE->hStereoDft->NFFT; + // chan_width_f = 24000.f / CLDFB_NO_CHANNELS_MAX; + // chan_width_bins = chan_width_f / band_res_dft; + + ///* Scaling of Energy buffer to get energy per sample, same scaling as for band_energies, 3 is to compensate for the 1/3 scaling in calculate_energy_buffer */ + // scaleEB = 3 * 4.0f / ( hCPE->hStereoDft->NFFT * hCPE->hStereoDft->NFFT ); + + ///* Scale with number of bins in one band */ + // scaleEB = scaleEB / chan_width_bins; + + SWITCH( input_Fs ) + { + case 8000: + scaleEB_fx = 251648; // Q35 + move32(); + BREAK; + case 16000: + scaleEB_fx = 62912; // Q35 + move32(); + BREAK; + case 32000: + scaleEB_fx = 15728; // Q35 + move32(); + BREAK; + case 48000: + scaleEB_fx = 6991; // Q35 + move32(); + BREAK; + default: + assert( 0 && "invalid sample rate" ); + } + } + ELSE + { + scaleEB_fx = Mpy_32_32( numSlots_inv_fx, L_deposit_l( hFdCngEnc->hFdCngCom->scalingFactor ) ); // Q34 + Q30 - Q31 = Q33 + scaleEB_fx = L_shl( scaleEB_fx, 2 ); // Q35 + } + + /* preemphasis compensation and grouping of per bin energies into msPeriodog */ + FOR( i = 0; i < nFFTpart; i++ ) + { + tmp = L_add( L_shr( band_energies[i], 1 ), L_shr( band_energies[i + NB_BANDS], 1 ) ); + msPeriodog_fx[i] = Mpy_32_16_1( tmp, preemphCompensation_fx[i] ); + move32(); + } + + /* exponent for fft part of msPeriodog */ + hFdCngEnc->msPeriodog_fx_exp_fft = add( band_energies_exp, PREEMPH_COMPENSATION_EXP ); + move16(); + + Word16 max_exp = -31; + move16(); + i = 0; + move16(); + /* Adjust to the desired time resolution by averaging the periodograms over the time slots */ + FOR( j = numCoreBands; j < regularStopBand; j++ ) + { + periodog_64 = W_mult_32_32( enerBuffer[j], scaleEB_fx ); + Word16 scale = W_norm( periodog_64 ); + *ptr_per_fx = W_extract_h( W_shl( periodog_64, scale ) ); + move32(); + periodog_exp[i] = sub( Q31, add( add( sub( Q31, enerBuffer_exp ), 35 - 31 ), scale ) ); + move16(); + max_exp = s_max( max_exp, periodog_exp[i] ); + + ptr_per_fx++; + i++; + } + /* exponent for cldfb part of msPeriodog */ + // hFdCngEnc->hFdCngCom->exp_cldfb_periodog = add( sub( enerBuffer_exp, 4 ), CLDFBscalingFactor_EXP ); + // move16(); + + numBands = sub( regularStopBand, numCoreBands ); /* Q0 */ + FOR( i = 0; i < numBands; i++ ) + { + + periodog[i] = L_shr( periodog[i], sub( max_exp, periodog_exp[i] ) ); + + move16(); + } + hFdCngEnc->hFdCngCom->exp_cldfb_periodog = max_exp; + move16(); + IF( numBands > 0 ) + { + ///* Adjust CLDFB filterbank to the desired frequency resolution by averaging over spectral partitions for SID transmission */ + bandcombinepow( + periodog, + hFdCngEnc->hFdCngCom->exp_cldfb_periodog, + numBands, + hFdCngEnc->hFdCngCom->CLDFBpart, + nCLDFBpart, + hFdCngEnc->hFdCngCom->CLDFBpsize_inv, + &msPeriodog_fx[nFFTpart], + &hFdCngEnc->msPeriodog_fx_exp_cldfb ); + + ///* find common exponent for fft part and cldfb part of msperiodog */ + s1 = getScaleFactor32( msPeriodog_fx, nFFTpart ); + s2 = getScaleFactor32( &msPeriodog_fx[nFFTpart], nCLDFBpart ); + + s = s_max( sub( hFdCngEnc->msPeriodog_fx_exp_fft, s1 ), sub( hFdCngEnc->msPeriodog_fx_exp_cldfb, s2 ) ); + s1 = sub( s, hFdCngEnc->msPeriodog_fx_exp_fft ); + s2 = sub( s, hFdCngEnc->msPeriodog_fx_exp_cldfb ); + + hFdCngEnc->msPeriodog_fx_exp_fft = s; + move16(); + hFdCngEnc->msPeriodog_fx_exp_cldfb = s; + move16(); + + FOR( i = 0; i < nFFTpart; i++ ) + { + msPeriodog_fx[i] = L_shr( msPeriodog_fx[i], s1 ); /* hFdCngEnc->msPeriodog_fx_exp_fft */ + move32(); + } + + FOR( i = 0; i < nCLDFBpart; i++ ) + { + msPeriodog_fx[nFFTpart + i] = L_shr( msPeriodog_fx[nFFTpart + i], s_min( 31, s2 ) ); /* hFdCngEnc->msPeriodog_fx_exp_fft */ + move32(); + } + } + /* exponent for entire msPeriodog vector */ + hFdCngEnc->msPeriodog_fx_exp = hFdCngEnc->msPeriodog_fx_exp_fft; + move16(); + + /* Compress MS inputs */ + // compress_range_flt( msPeriodog, msLogPeriodog, npart ); + compress_range( msPeriodog_fx, hFdCngEnc->msPeriodog_fx_exp, msLogPeriodog_fx, npart ); + + + /* Call the minimum statistics routine for noise estimation */ + + minimum_statistics_fx( npart, nFFTpart, psize, msLogPeriodog_fx, hFdCngEnc->msNoiseFloor_fx, msLogNoiseEst_fx, hFdCngEnc->msAlpha_fx, hFdCngEnc->msPsd_fx, hFdCngEnc->msPsdFirstMoment_fx, + hFdCngEnc->msPsdSecondMoment_fx, hFdCngEnc->msMinBuf_fx, hFdCngEnc->msBminWin_fx, hFdCngEnc->msBminSubWin_fx, hFdCngEnc->msCurrentMin_fx, hFdCngEnc->msCurrentMinOut_fx, hFdCngEnc->msCurrentMinSubWindow_fx, hFdCngEnc->msLocalMinFlag, hFdCngEnc->msNewMinFlag, hFdCngEnc->msPeriodogBuf_fx, &( hFdCngEnc->msPeriodogBufPtr ), hFdCngEnc->hFdCngCom, + ENC, ( hCPE == NULL ) ? 0 : hCPE->element_mode ); + + /* Expand MS outputs */ + expand_range( msLogNoiseEst_fx, msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart ); + + return; +} + + +/*-------------------------------------------------------------------* + * FdCng_encodeSID() + * + * Generate a bitstream out of the partition levels + *-------------------------------------------------------------------*/ +void FdCng_encodeSID_ivas_fx( + Encoder_State *st /* i/o: encoder state structure */ +) +{ + Word16 N; + HANDLE_FD_CNG_ENC hFdCngEnc = st->hFdCngEnc; + HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; + BSTR_ENC_HANDLE hBstr = st->hBstr; + + Word32 *invTrfMatrix_fx, *E_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + Word32 v_fx[32], gain_fx, e_fx, temp; + Word16 w_fx[32], indices[32], exp[32]; + Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; + Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN]; + Word16 v_e, gain_q_offset, preemph_fac; + Word16 i, index; + + gain_q_offset = GAIN_Q_OFFSET_IVAS_FX_Q0; + move16(); + + if ( st->element_mode == EVS_MONO ) + { + gain_q_offset = GAIN_Q_OFFSET_EVS_FX_Q0; + move16(); + } + + preemph_fac = st->preemph_fac; // Q15 + move16(); + + /* Init */ + N = hFdCngEnc->npartDec; + move16(); + + E_fx = hFdCngEnc->msNoiseEst_fx; + + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ + + set_zero_fx( v_fx, FDCNG_VQ_MAX_LEN ); + + /* Convert to LOG */ + e_fx = 0; + move32(); + FOR( i = 0; i < N; i++ ) + { + IF( E_fx[i] == 0 ) + { + /* 10 * log(1e-4) = 10 * (-4) = -40 */ + v_fx[i] = -41943040; // -40.0 in Q20 + move32(); + } + ELSE + { + v_fx[i] = Mpy_32_32( 671088640 /*10 in Q26*/, BASOP_Util_Log10( E_fx[i], hFdCngEnc->msNoiseEst_fx_exp ) ); // Q20 = 26+25-31 + move32(); + } + e_fx = L_add( e_fx, v_fx[i] ); // Q20 + } + + /* Normalize MSVQ input */ + gain_fx = 0; + move32(); + FOR( i = N_GAIN_MIN; i < N_GAIN_MAX; i++ ) + { + gain_fx = L_add( gain_fx, v_fx[i] ); // Q20 + } + + /*gain /= (float) ( N_GAIN_MAX - N_GAIN_MIN );*/ + gain_fx = Mpy_32_32( gain_fx, 165191050 /* 1/13 in Q31*/ ); // Q20 + + FOR( i = 0; i < N; i++ ) + { + v_fx[i] = L_sub( v_fx[i], gain_fx ); // Q20 + move32(); + } + + v_e = 11; // Q20 + move16(); + + /* MSVQ encoder */ + set_val_Word16( w_fx, ONE_IN_Q8, N ); + + IF( st->element_mode != EVS_MONO ) + { + /* DCT domain compressed/truncated indices used for first stage */ + /* quantization with stage1 stored in DCT24 domain, stages 2 through 6 directly dearched + in FDCNG band domain + */ + IF( EQ_16( N, FDCNG_VQ_MAX_LEN_WB ) ) + { + /* truncated DCT21 analysis */ + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); // Q31 + + dctT2_N_apply_matrix_fx( v_fx /*Q20*/, dct_target_fx, FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); // Q20 + + /* truncated IDCT21 extension to 24 bands */ + extend_dctN_input_fx( v_fx, dct_target_fx, N, tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); // Q20 + + Copy32( tot_sig_ext_fx, v_fx, FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 */ // Q20 + } + + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); // Q31 + + msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, v_fx, v_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w_fx, N, FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices ); + + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v_fx, NULL, 7 ); + + v_e = sub( 31, sub( 20, find_guarded_bits_fx( N ) ) ); + } + ELSE + { /* EVS_MONO tables */ + msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, v_fx, v_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w_fx, N, FD_CNG_maxN_37bits, 0, NULL, indices ); + + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v_fx, NULL, 7 ); + + v_e = sub( 31, sub( 20, find_guarded_bits_fx( N ) ) ); + } + + /* Compute gain */ + gain_fx = 0; + move32(); + FOR( i = 0; i < N; i++ ) + { + gain_fx = L_add( gain_fx, v_fx[i] ); // Q = 31 - v_e + } + + e_fx = L_shl( e_fx, sub( 11, v_e ) ); // Q = 31 - v_e + gain_fx = Mpy_32_16_1( L_sub( e_fx, gain_fx ), div_s( 1, N ) ); // Q = 31 - v_e + gain_fx = L_shl( gain_fx, sub( v_e, 8 ) ); // Q23 + + /* Apply bitrate-dependant scale */ + IF( st->element_mode > EVS_MONO ) + { + apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); + } + ELSE + { + apply_scale( &gain_fx, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableMono, SIZE_SCALE_TABLE_MONO ); + } + + /* Quantize gain */ + temp = Madd_32_32( L_shl( gain_q_offset, 22 ), gain_fx, 1610612736 /*1.5 in Q30*/ ); // Q22 + index = extract_l( L_shr( L_add( temp, ONE_IN_Q21 ), 22 ) ); // Q0 + + if ( index < 0 ) + { + index = 0; + move16(); + } + + if ( GT_16( index, 127 ) ) + { + index = 127; + move16(); + } + + gain_fx = L_shl( L_mult0( sub( index, gain_q_offset ), 21845 /*1.5 in Q15*/ ), sub( 16, v_e ) ); // Q = 31-v_e + + /* Apply gain and undo log */ + FOR( i = 0; i < N; i++ ) + { + temp = Mpy_32_32( L_add( v_fx[i], gain_fx ), 214748365 /* 0.1 in Q31*/ ); // Q = 31-v_e + hFdCngCom->sidNoiseEst[i] = BASOP_Util_fPow( 10, 31, temp, v_e, &exp[i] ); + move32(); + } + + maximum_s( exp, N, &hFdCngCom->sidNoiseEstExp ); + + FOR( i = 0; i < N; i++ ) + { + hFdCngCom->sidNoiseEst[i] = L_shr( hFdCngCom->sidNoiseEst[i], sub( hFdCngCom->sidNoiseEstExp, exp[i] ) ); // exp = hFdCngCom->sidNoiseEstExp + move32(); + } + + /* NB last band energy compensation */ + IF( hFdCngCom->CngBandwidth == NB ) + { + hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], NB_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp) + move32(); + } + + test(); + IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) + { + hFdCngCom->sidNoiseEst[N - 1] = Mpy_32_16_1( hFdCngCom->sidNoiseEst[N - 1], SWB_13k2_LAST_BAND_SCALE ); // exp(hFdCngCom->sidNoiseEstExp) + move32(); + } + + /* Write bitstream */ + IF( EQ_16( st->codec_mode, MODE2 ) ) + { + FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) + { + push_next_indice( hBstr, indices[i], bits_37bits[i] ); + } + + push_next_indice( hBstr, index, 7 ); + } + ELSE + { + Word16 is_frame_len_16k = 0; + move16(); + if ( EQ_16( st->L_frame, L_FRAME16k ) ) + { + is_frame_len_16k = 1; + move16(); + } + push_indice( hBstr, IND_SID_TYPE, 1, 1 ); + push_indice( hBstr, IND_BWIDTH, st->bwidth, 2 ); + push_indice( hBstr, IND_ACELP_16KHZ, is_frame_len_16k, 1 ); + + FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) + { + push_indice( hBstr, IND_LSF, indices[i], bits_37bits[i] ); + } + + push_indice( hBstr, IND_ENERGY, index, 7 ); + } + + /* Interpolate the bin/band-wise levels from the partition levels */ + scalebands( hFdCngCom->sidNoiseEst, hFdCngEnc->partDec, hFdCngEnc->npartDec, hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); + hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; + move16(); + + lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, preemph_fac ); + + return; +} + + +/*-------------------------------------------------------------------* + * stereoFdCngCoherence() + * + * compute coherence of channels for use in FD-CNG + *-------------------------------------------------------------------*/ +void stereoFdCngCoherence_fx( + Encoder_State **sts, /* i/o: core encoder structures */ + const Word16 last_element_mode, /* i : last element mode Q0*/ + Word16 fft_buf_fx[CPE_CHANNELS][2 * L_FFT], /* i : fft buffers for L and R channels fft_exp*/ + Word16 fft_exp ) +{ + const Word16 *pt_fftL, *pt_fftR; + Word16 i_subfr, i; + Word32 cr, ci, eL, eR; + Word16 cr_exp, ci_exp, eL_exp, eR_exp; + Word32 *mem; + Word16 *mem_exp; + + IF( NE_16( last_element_mode, IVAS_CPE_MDCT ) ) + { + set32_fx( sts[0]->hFdCngEnc->mem_coherence_fx, EPSILON_FX, 4 ); + set16_fx( sts[0]->hFdCngEnc->mem_coherence_exp, 0, 4 ); + } + test(); + test(); + IF( EQ_32( sts[0]->core_brate, -1 ) || EQ_32( sts[1]->core_brate, -1 ) ) + { + /* case: at least one channel has triggered VAD -> ACTIVE FRAME */ + IF( EQ_32( sts[0]->core_brate, -1 ) ) + { + sts[1]->total_brate = sts[0]->total_brate; /* Q0 */ + move32(); + sts[1]->active_cnt = sts[0]->active_cnt; /* Q0 */ + move16(); + if ( GE_32( sts[1]->active_cnt, CNG_TYPE_HO ) ) + { + sts[1]->last_total_brate_cng = -1; + move16(); + } + } + IF( EQ_32( sts[1]->core_brate, -1 ) ) + { + sts[0]->total_brate = sts[1]->total_brate; /* Q0 */ + move32(); + sts[0]->active_cnt = sts[1]->active_cnt; /* Q0 */ + move16(); + if ( GE_16( sts[0]->active_cnt, CNG_TYPE_HO ) ) + { + sts[0]->last_total_brate_cng = -1; + move16(); + } + } + sts[0]->core_brate = -1; + move32(); + sts[1]->core_brate = -1; + move32(); + sts[0]->hDtxEnc->cnt_SID = 0; + move16(); + sts[1]->hDtxEnc->cnt_SID = 0; + move16(); + } + ELSE IF( LE_32( sts[0]->core_brate, SID_2k40 ) && LE_32( sts[1]->core_brate, SID_2k40 ) ) + { + /* case: no VAD for both channels -> INACTIVE FRAME */ + reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); + + reset_indices_enc( sts[1]->hBstr, sts[1]->hBstr->nb_ind_tot ); + + /* synchronize SID sending for variable SID rate */ + IF( EQ_32( sts[0]->core_brate, sts[1]->core_brate ) ) + { + sts[0]->core_brate = SID_2k40; + move32(); + sts[1]->core_brate = SID_2k40; + move32(); + } + + /* synchronize SID counters */ + sts[0]->hDtxEnc->cnt_SID = s_min( sts[0]->hDtxEnc->cnt_SID, sts[1]->hDtxEnc->cnt_SID ); /* Q0 */ + sts[1]->hDtxEnc->cnt_SID = sts[0]->hDtxEnc->cnt_SID; /* Q0 */ + move16(); + move16(); + } + + pt_fftL = fft_buf_fx[0]; + pt_fftR = fft_buf_fx[1]; + mem = sts[0]->hFdCngEnc->mem_coherence_fx; /* exp(sts[0]->hFdCngEnc->mem_coherence_exp) */ + mem_exp = sts[0]->hFdCngEnc->mem_coherence_exp; + FOR( i_subfr = 0; i_subfr < 2; i_subfr++ ) + { + cr = ci = eL = eR = EPSILON_FX; + move32(); + move32(); + move32(); + move32(); + cr_exp = ci_exp = eL_exp = eR_exp = 0; + move16(); + move16(); + move16(); + move16(); + + cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[0], pt_fftR[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ + eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[0], pt_fftL[0] ), L_mult( pt_fftL[L_FFT / 2], pt_fftL[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ + eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[0], pt_fftR[0] ), L_mult( pt_fftR[L_FFT / 2], pt_fftR[L_FFT / 2] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ + + FOR( i = 1; i < L_FFT / 2; i++ ) + { + cr = BASOP_Util_Add_Mant32Exp( cr, cr_exp, L_add( L_mult( pt_fftL[i], pt_fftR[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &cr_exp ); /* exp(cr_exp) */ + ci = BASOP_Util_Add_Mant32Exp( ci, ci_exp, L_add( L_mult( -pt_fftL[i], pt_fftR[L_FFT - i] ), L_mult( pt_fftL[L_FFT - i], pt_fftR[i] ) ), shl( fft_exp, 1 ), &ci_exp ); /* exp(ci_exp) */ + eL = BASOP_Util_Add_Mant32Exp( eL, eL_exp, L_add( L_mult( pt_fftL[i], pt_fftL[i] ), L_mult( pt_fftL[L_FFT - i], pt_fftL[L_FFT - i] ) ), shl( fft_exp, 1 ), &eL_exp ); /* exp(eL_exp) */ + eR = BASOP_Util_Add_Mant32Exp( eR, eR_exp, L_add( L_mult( pt_fftR[i], pt_fftR[i] ), L_mult( pt_fftR[L_FFT - i], pt_fftR[L_FFT - i] ) ), shl( fft_exp, 1 ), &eR_exp ); /* exp(eR_exp) */ + } + test(); + test(); + IF( LE_32( sts[0]->ini_frame, 50 ) || ( sts[0]->vad_flag == 0 && sts[1]->vad_flag == 0 ) ) + { + mem[0] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[0], 31129 /*0.95f*/ ), mem_exp[0], Mpy_32_16_1( cr, 1638 /*0.05f*/ ), cr_exp, &mem_exp[0] ); /* exp(mem_exp[0]) */ + move32(); + mem[1] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[1], 31129 /*0.95f*/ ), mem_exp[1], Mpy_32_16_1( ci, 1638 /*0.05f*/ ), ci_exp, &mem_exp[1] ); /* exp(mem_exp[1]) */ + move32(); + mem[2] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[2], 31129 /*0.95f*/ ), mem_exp[2], Mpy_32_16_1( eL, 1638 /*0.05f*/ ), eL_exp, &mem_exp[2] ); /* exp(mem_exp[2]) */ + move32(); + mem[3] = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( mem[3], 31129 /*0.95f*/ ), mem_exp[3], Mpy_32_16_1( eR, 1638 /*0.05f*/ ), eR_exp, &mem_exp[3] ); /* exp(mem_exp[3]) */ + move32(); + } + + pt_fftL += L_FFT; + pt_fftR += L_FFT; + } + + Word16 sqr_inp, temp, sqr_out, sqr_inp_exp; + Word32 sqr_inp32 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( mem[0], mem[0] ), shl( mem_exp[0], 1 ), Mpy_32_32( mem[1], mem[1] ), shl( mem_exp[1], 1 ), &sqr_inp_exp ); /* exp(sqr_inp_exp) */ + sqr_inp = BASOP_Util_Divide3232_Scale( sqr_inp32, Mpy_32_32( mem[2], mem[3] ), &temp ); + sqr_inp_exp = add( temp, sub( sqr_inp_exp, add( mem_exp[2], mem_exp[3] ) ) ); + sqr_out = Sqrt16( sqr_inp, &sqr_inp_exp ); + sts[0]->hFdCngEnc->hFdCngCom->coherence_fx = shl_sat( sqr_out, sqr_inp_exp ); // Q15 expected. + move16(); + return; +} + +/*-------------------------------------------------------------------* + * FdCngEncodeMDCTStereoSID() + * + * Encode DTX parameters and noise shapes into SID for MDCT-Stereo DTX + *-------------------------------------------------------------------*/ + +void FdCngEncodeMDCTStereoSID_fx( + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ +) +{ + ENC_CORE_HANDLE sts[CPE_CHANNELS]; + Word16 indices[CPE_CHANNELS][FD_CNG_stages_37bits]; + Word16 gain_idx[CPE_CHANNELS]; + Word16 N, stages, ch, p, coh_idx; + Word32 *lr_in_ptr_fx[CPE_CHANNELS]; + Word16 lr_in_ptr_e[CPE_CHANNELS]; + Word32 *ms_ptr_fx[CPE_CHANNELS]; + Word16 ms_ptr_e; + Word32 *lr_out_ptr_fx[CPE_CHANNELS]; + Word16 lr_out_ptr_e[CPE_CHANNELS]; + Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; + Word32 E_fx[CPE_CHANNELS]; + Word32 gain_fx[CPE_CHANNELS]; + Word16 weights_fx[NPART]; + Word32 side_energy_fx; + Word16 Qside_energy; + Word32 *invTrfMatrix_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; /*24*18*/ + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ + Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN], dct_target_fx[CPE_CHANNELS][FDCNG_VQ_DCT_MAXTRUNC]; /* 24 +2*18*/ + Word16 tmp, tmp_e; + Word16 no_side_flag; + Word16 is_inp_ms; + Word16 size_value, temp_e, gb, shift; + Word32 tmp32, t1, t2; + + is_inp_ms = 0; + move16(); + IF( EQ_16( hCPE->hCoreCoder[0]->cng_sba_flag, 1 ) ) + { + is_inp_ms = 1; + move16(); + } + + /* set pointers and initialize */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + sts[ch] = hCPE->hCoreCoder[ch]; + lr_in_ptr_fx[ch] = &sts[ch]->hFdCngEnc->msNoiseEst_fx[0]; /* exp(sts[ch]->hFdCngEnc->msNoiseEst_fx_exp) */ + lr_in_ptr_e[ch] = sts[ch]->hFdCngEnc->msNoiseEst_fx_exp; + ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; + lr_out_ptr_fx[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0]; /* exp(sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp) */ + lr_out_ptr_e[ch] = sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp; + } + N = sts[0]->hFdCngEnc->npartDec; /* Q0 */ + move16(); + set16_fx( weights_fx, ONE_IN_Q8, NPART ); + + /* apply log and save energy of original left and right channels */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + // E[ch] = 0.0f; + E_fx[ch] = 0; + move32(); + FOR( p = 0; p < N; p++ ) + { + IF( lr_in_ptr_fx[ch][p] ) + { + t1 = BASOP_Util_Log2( lr_in_ptr_fx[ch][p] ); // Q25 + t2 = L_add( t1, L_shl( lr_in_ptr_e[ch], Q25 ) ); // Q25 + } + ELSE + { + t2 = 0; + move32(); + } + ms_ptr_fx[ch][p] = Mpy_32_32( t2, TEN_MULT_LOG10_2_IN_Q29 ); // Q23 + move32(); + E_fx[ch] = L_add( E_fx[ch], L_shr( ms_ptr_fx[ch][p], 4 ) ); // Q19 + move32(); + } + } + ms_ptr_e = Q31 - Q23; + move16(); + + /* M/S transform on log envelopes */ + IF( is_inp_ms == 0 ) + { + convertToMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q30 ); // ms_ptr_e = Q23; + } + + gb = find_guarded_bits_fx( N ); + side_energy_fx = sum2_f_32_fx( ms_ptr_fx[1], N, gb ); + Qside_energy = sub( sub( shl( sub( 31, ms_ptr_e ), 1 ), 31 ), gb ); + + /* do not transmit side shape if initial noise shapes are very similar */ + IF( LE_32( side_energy_fx, L_shl( 214748365, sub( Qside_energy, Q31 ) ) ) ) + { + no_side_flag = 1; + move16(); + } + ELSE + { + no_side_flag = 0; + move16(); + } + + /* Quantize noise shapes */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + /* Normalize MSVQ input */ + gain_fx[ch] = 0; + move32(); + FOR( p = N_GAIN_MIN; p < N_GAIN_MAX; p++ ) + { + tmp32 = Mpy_32_32( ms_ptr_fx[ch][p], 165191050 /* 0.07 in Q31*/ ); // Q23 + gain_fx[ch] = L_add( gain_fx[ch], tmp32 ); // Q23 + move32(); + } + + FOR( p = 0; p < N; p++ ) + { + ms_ptr_fx[ch][p] = L_sub( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q23 + move32(); + } + } + + /* always split channel targetloop */ + + /* extend fdcng envelope from length 21 to a 24 length fdncg domain envelope signal */ + /* High quality cosine smooth basis extension used to not introduce noise in stage#1 DCT24 analysis and subsequent VQ-steps */ + IF( EQ_16( N, FDCNG_VQ_MAX_LEN_WB ) ) + { + size_value = BASOP_Util_Divide1616_Scale( sizeof( tmpRAM_fx ), ( sizeof( Word32 ) ), &temp_e ); /*Q15*/ + size_value = shr( size_value, sub( 15, temp_e ) ); + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N, FDCNG_VQ_DCT_MAXTRUNC, size_value ); // Q31 /*WB: create truncated IDCT21 matrix */ + for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + /* run DCT_N N==21 , truncated at 18/21 ~= 86% , i.e use a bit better better quality in extrapolation , than subsequent DCT24 analysis which is truncated at 75%*/ + /* truncated DCT 21 analysis */ + dctT2_N_apply_matrix_fx( (const Word32 *) ms_ptr_fx[ch], dct_target_fx[ch], FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); + /* extrapolate extend fdcng envelope signal in the fdncg ienvelope/"time" domain using DCT21 basis vectors, + estimated DCT21 coeffs scaling extended basis vectors are used to create extrapolated length 24 input target envelope signal */ + /* this DCT21 extension does not introduce DCT24 coefficient noise for the subsequent dct24 target analysis, and later in IDCT24 synthesis */ + + /* truncated IDCT 21 extension synthesis */ + extend_dctN_input_fx( ms_ptr_fx[ch], dct_target_fx[ch], N, tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx /* DCT_N basis vectors */, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); /* use 18 basis vectors*/ + + Copy32( tot_sig_ext_fx, ms_ptr_fx[ch], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ */ + } + } + + size_value = BASOP_Util_Divide1616_Scale( sizeof( tmpRAM_fx ), ( sizeof( Word32 ) ), &temp_e ); /*Q15*/ + size_value = shr( size_value, sub( 15, temp_e ) ); + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, size_value ); /*always create/set up IDCT24 matrix in RAM */ + + /* end split */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + /* MSVQ */ + IF( ch ) + { + stages = FD_CNG_JOINT_stages_25bits; + move16(); + } + ELSE + { + stages = FD_CNG_stages_37bits; + move16(); + } + + /* DCT24 domain compressed/truncated indices used for first stage */ + /* mid channel quantization using stages 1 through 6 */ + /* & side channel quantization using stages 1 through 4 */ + + { + msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, ms_ptr_fx[ch], ms_ptr_e, levels_37bits, FD_CNG_maxC_37bits, stages, weights_fx, N, FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices[ch] ); + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices[ch], 1, invTrfMatrix_fx, ms_ptr_fx[ch], NULL, 7 ); + } + } + shift = find_guarded_bits_fx( N ); + ms_ptr_e = sub( 31, sub( 20, shift ) ); + + IF( no_side_flag ) + { + set32_fx( ms_ptr_fx[1], 0, N ); + } + + /* undo M/S */ + IF( is_inp_ms == 0 ) + { + convertToMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 ); + } + + /* Compute gain against original left and right channels */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + gain_fx[ch] = 0; + move32(); + + tmp_e = 15; + move16(); + tmp = Inv16( N, &tmp_e ); + FOR( p = 0; p < N; p++ ) + { + gain_fx[ch] = L_add( gain_fx[ch], Mpy_32_16_1( ms_ptr_fx[ch][p], shl( tmp, tmp_e ) ) ); // Q23 + move32(); + } + gain_fx[ch] = L_sub( L_shl( Mpy_32_16_1( E_fx[ch], shl( tmp, tmp_e ) ), Q23 - Q19 ), L_shl( gain_fx[ch], sub( ms_ptr_e, 8 ) ) ); // Q23 + move32(); + + apply_scale( &gain_fx[ch], sts[ch]->hFdCngEnc->hFdCngCom->CngBandwidth, sts[ch]->element_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); + + /* quantize gain */ + gain_idx[ch] = (Word16) Mpy_32_32_r( L_add( gain_fx[ch], 251658240 ), 384 ); // Q23 + move16(); + gain_idx[ch] = s_max( 0, s_min( 127, gain_idx[ch] ) ); + move16(); + + gain_fx[ch] = Mpy_32_16_1( L_shl( sub( gain_idx[ch], GAIN_Q_OFFSET_IVAS_FX_Q0 ), 23 ), 21845 ); // Q23 + move32(); + } + + /* restore channel noise envelopes */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + HANDLE_FD_CNG_ENC hFdCngEnc = sts[ch]->hFdCngEnc; + HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; + + tmp_e = 0; + move16(); + Word32 pow; + + Word16 e_lr_out[NPART]; + + FOR( p = 0; p < N; p++ ) + { + pow = L_shl( gain_fx[ch], 8 - ms_ptr_e ); + pow = L_add( ms_ptr_fx[ch][p], pow ); + pow = Mpy_32_32( pow, 214748365 ); /*pow = 0.1*/ + lr_out_ptr_fx[ch][p] = BASOP_Util_fPow( 10, 31, pow, ms_ptr_e, &e_lr_out[p] ); + move32(); + tmp_e = s_max( tmp_e, e_lr_out[p] ); + } + + FOR( p = 0; p < N; p++ ) + { + lr_out_ptr_fx[ch][p] = L_shl( lr_out_ptr_fx[ch][p], e_lr_out[p] - tmp_e ); + move32(); + } + lr_out_ptr_e[ch] = tmp_e; + move32(); + + sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp = tmp_e; + move16(); + + /* scale bands and get scalefactors */ + scalebands( lr_out_ptr_fx[ch], hFdCngEnc->partDec, N, hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); + hFdCngCom->cngNoiseLevelExp = lr_out_ptr_e[ch]; + move16(); + + lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac ); + + sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; + } + + /* quantize channel coherence */ + coh_idx = mult_r( sts[0]->hFdCngEnc->hFdCngCom->coherence_fx, 15 ); + coh_idx = max( 0, min( coh_idx, 15 ) ); + + /* ---- Write SID bitstream ---- */ + + + /* noise shapes and channel gains */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + IF( ch ) + { + stages = FD_CNG_JOINT_stages_25bits; + sts[ch]->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot; + + /* side info */ + push_indice( sts[ch]->hBstr, IND_SID_TYPE, coh_idx, 4 ); + push_indice( sts[ch]->hBstr, IND_SID_TYPE, no_side_flag, 1 ); + } + ELSE + { + stages = FD_CNG_stages_37bits; + /* side info */ + push_indice( sts[ch]->hBstr, IND_SID_TYPE, 1, 1 ); + push_indice( sts[ch]->hBstr, IND_BWIDTH, sts[0]->bwidth, 2 ); + push_indice( sts[ch]->hBstr, IND_ACELP_16KHZ, sts[0]->L_frame == L_FRAME16k ? 1 : 0, 1 ); + } + + FOR( Word16 i = 0; i < stages; i++ ) + { + push_indice( sts[ch]->hBstr, IND_LSF, indices[ch][i], bits_37bits[i] ); + } + push_indice( sts[ch]->hBstr, IND_ENERGY, gain_idx[ch], 7 ); + } + + /* pad with zeros to reach common SID frame size */ + push_indice( sts[1]->hBstr, IND_ENERGY, 0, ( IVAS_SID_5k2 - 4400 ) / FRAMES_PER_SEC ); + + return; +} + +/*-------------------------------------------------------------------* + * FdCngEncodeDiracMDCTStereoSID() + * + * Encode DTX parameters and noise shapes into SID for MDCT-Stereo DTX + * together with Dirac + *-------------------------------------------------------------------*/ + +void FdCngEncodeDiracMDCTStereoSID_fx( + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ +) +{ + ENC_CORE_HANDLE sts[CPE_CHANNELS]; + Word32 *lr_in_ptr_fx[CPE_CHANNELS]; + Word16 lr_in_ptr_e[CPE_CHANNELS]; + Word32 *ms_ptr_fx[CPE_CHANNELS]; + Word16 ms_ptr_e; + Word32 *lr_out_ptr_fx[CPE_CHANNELS]; + Word16 lr_out_ptr_e[CPE_CHANNELS]; + Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; + Word32 E_fx[CPE_CHANNELS]; + Word32 gain_fx[CPE_CHANNELS]; + Word16 weights_fx[NPART]; + Word16 N[CPE_CHANNELS]; + Word16 indices[CPE_CHANNELS][FD_CNG_stages_37bits]; + Word16 gain_idx[CPE_CHANNELS]; + Word16 ch, p; + Word16 tmp, tmp_e, shift; + Word32 *invTrfMatrix_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; + Word32 tot_sig_ext_fx[FDCNG_VQ_MAX_LEN]; + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ + Word32 t1, t2, tmp32; + /* set pointers and initialize */ + + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + sts[ch] = hCPE->hCoreCoder[ch]; + N[ch] = sts[ch]->hFdCngEnc->npartDec; + lr_in_ptr_fx[ch] = &sts[ch]->hFdCngEnc->msNoiseEst_fx[0]; + lr_in_ptr_e[ch] = sts[ch]->hFdCngEnc->msNoiseEst_fx_exp; + ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; + lr_out_ptr_fx[ch] = &sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEst[0]; + lr_out_ptr_e[ch] = sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp; + move16(); + } + set16_fx( weights_fx, ONE_IN_Q8, NPART ); + + /* apply log and save energy of original left and right channels */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + // E[ch] = 0.0f; + E_fx[ch] = 0; + move32(); + FOR( p = 0; p < N[ch]; p++ ) + { + t1 = BASOP_Util_Log2( lr_in_ptr_fx[ch][p] + EPSILLON_FX ); // Q25 + t2 = L_add( t1, L_shl( lr_in_ptr_e[ch], Q25 ) ); // Q25 + ms_ptr_fx[ch][p] = Mpy_32_32( t2, TEN_MULT_LOG10_2_IN_Q29 ); // Q23 + move32(); + E_fx[ch] = L_add( E_fx[ch], L_shr( ms_ptr_fx[ch][p], 5 ) ); // Q18 + move32(); + } + } + ms_ptr_e = Q31 - Q23; + move16(); + + /* M/S transform on log envelopes */ + convertToMS_fx( N[0], ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q30 ); + E_fx[0] = 0; + move32(); + FOR( p = 0; p < N[0]; p++ ) + { + E_fx[0] = L_add( E_fx[0], L_shr( ms_ptr_fx[0][p], 5 ) ); // Q18 + move32(); + } + + /* Quantize M noise shape */ + /* Normalize MSVQ input */ + gain_fx[0] = 0; + move16(); + FOR( p = N_GAIN_MIN; p < N_GAIN_MAX; p++ ) + { + tmp32 = Mpy_32_32( ms_ptr_fx[0][p], 165191050 /* 0.07 in Q31 */ ); // Q23 + gain_fx[0] = L_add( gain_fx[0], tmp32 ); // Q23 + move32(); + } + + FOR( p = 0; p < N[0]; p++ ) + { + ms_ptr_fx[0][p] = L_sub( ms_ptr_fx[0][p], gain_fx[0] ); // Q23 + move32(); + } + + + /* MSVQ */ + /* DCT domain compressed/truncated indices used for first stage */ + /* mid quantization using stages #1 through 6 */ + scale_sig32( ms_ptr_fx[0], N[0], -6 ); + ms_ptr_e = add( ms_ptr_e, 6 ); + move16(); + IF( EQ_16( N[0], FDCNG_VQ_MAX_LEN_WB ) ) + { + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, N[0], FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); + /* truncated DCT 21 analysis */ + dctT2_N_apply_matrix_fx( (const Word32 *) ms_ptr_fx[0], dct_target_fx, FDCNG_VQ_DCT_MAXTRUNC, N[0], invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); + /* truncated IDCT21 extension to 24 synthesis */ + + extend_dctN_input_fx( ms_ptr_fx[0], dct_target_fx, N[0], tot_sig_ext_fx, FDCNG_VQ_MAX_LEN, invTrfMatrix_fx, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); /* use 18 basis vectors*/ + + Copy32( tot_sig_ext_fx, ms_ptr_fx[0], FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 Q23*/ + } + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM_fx ) / ( sizeof( Word32 ) ) ); + + msvq_enc_ivas_fx( ivas_cdk_37bits_fx, Q7, NULL, NULL, ms_ptr_fx[0], ms_ptr_e, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, weights_fx, N[0], FD_CNG_maxN_37bits, 1, invTrfMatrix_fx, indices[0] ); + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N[0], FD_CNG_maxN_37bits, indices[0], 1, invTrfMatrix_fx, ms_ptr_fx[0], NULL, 7 ); + shift = find_guarded_bits_fx( N[0] ); + ms_ptr_e = sub( 31, sub( 20, shift ) ); + scale_sig32( ms_ptr_fx[1], N[1], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */ + + /* set S to zero */ + set32_fx( ms_ptr_fx[1], 0, NPART ); + + /* compute M gain */ + gain_fx[0] = 0; + move32(); + tmp_e = 15; + move16(); + tmp = Inv16( N[0], &tmp_e ); + FOR( p = 0; p < N[0]; p++ ) + { + gain_fx[0] = L_add( gain_fx[0], Mpy_32_16_1( ms_ptr_fx[0][p], shl( tmp, tmp_e ) ) ); // Q23 + move32(); + } + gain_fx[0] = L_sub( L_shl( Mpy_32_16_1( E_fx[0], shl( tmp, tmp_e ) ), Q23 - Q18 ), L_shl( gain_fx[0], ms_ptr_e - 8 ) ); // Q23 + move32(); + + apply_scale( &gain_fx[0], sts[0]->hFdCngEnc->hFdCngCom->CngBandwidth, sts[0]->hDtxEnc->last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); + + /* quantize gain */ + gain_idx[0] = extract_l( Mpy_32_32_r( L_add( gain_fx[0], 251658240 ), 384 ) ); + move16(); + gain_idx[0] = s_max( 0, s_min( 127, gain_idx[0] ) ); + move16(); + + gain_fx[0] = Mpy_32_16_1( L_shl( sub( gain_idx[0], GAIN_Q_OFFSET_IVAS_FX_Q0 ), 23 ), 21845 /* 0.66 in Q15 */ ); // Q23 + move32(); + gain_fx[1] = gain_fx[0]; // Q23 + move32(); + + /* undo M/S */ + convertToMS_fx( NPART, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 ); + + /* restore channel noise envelopes */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + HANDLE_FD_CNG_ENC hFdCngEnc = sts[ch]->hFdCngEnc; + HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom; + + Word32 pow; + Word16 e_lr_out[NPART]; + tmp_e = -MAX_16; + FOR( p = 0; p < N[ch]; p++ ) + { + pow = L_shl( gain_fx[ch], sub( 8, ms_ptr_e ) ); /* Q31 - ms_ptr_e */ + pow = L_add( ms_ptr_fx[ch][p], pow ); /* Q31 - ms_ptr_e */ + pow = Mpy_32_32( pow, 214748365 /* 0.1 in Q31 */ ); /*pow = 0.1 Q31 - ms_ptr_e*/ + lr_out_ptr_fx[ch][p] = BASOP_Util_fPow( 10, 31, pow, ms_ptr_e, &e_lr_out[p] ); + tmp_e = s_max( tmp_e, e_lr_out[p] ); + } + + FOR( p = 0; p < N[ch]; p++ ) + { + lr_out_ptr_fx[ch][p] = L_shl( lr_out_ptr_fx[ch][p], sub( e_lr_out[p], tmp_e ) ); // Q(31 - tmp_e) + } + + sts[ch]->hFdCngEnc->hFdCngCom->sidNoiseEstExp = tmp_e; + move16(); + lr_out_ptr_e[ch] = tmp_e; + move16(); + + /* NB last band energy compensation */ + IF( hFdCngCom->CngBandwidth == NB ) + { + lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], NB_LAST_BAND_SCALE ); // Q(31 - tmp_e) + move32(); + } + ELSE IF( hFdCngCom->CngBandwidth == SWB && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) + { + lr_out_ptr_fx[ch][N[ch] - 1] = Mpy_32_16_1( lr_out_ptr_fx[ch][N[ch] - 1], SWB_13k2_LAST_BAND_SCALE ); // Q(31 - tmp_e) + move32(); + } + /* scale bands and get scalefactors */ + scalebands( lr_out_ptr_fx[ch], hFdCngEnc->partDec, N[ch], hFdCngEnc->midbandDec, hFdCngEnc->nFFTpartDec, sub( hFdCngEnc->stopBandDec, hFdCngEnc->startBandDec ), hFdCngCom->cngNoiseLevel, 1 ); + hFdCngCom->cngNoiseLevelExp = lr_out_ptr_e[ch]; + move16(); + lpc_from_spectrum( hFdCngCom, hFdCngEnc->startBandDec, hFdCngEnc->stopFFTbinDec, sts[ch]->preemph_fac ); + sts[ch]->hDtxEnc->last_CNG_L_frame = sts[ch]->L_frame; + } + sts[0]->hFdCngEnc->hFdCngCom->coherence_fx = 0; + move16(); + sts[1]->hFdCngEnc->hFdCngCom->coherence_fx = 0; + move16(); + + /* ---- Write SID bitstream ---- */ + + /* side info */ + push_indice( sts[0]->hBstr, IND_SID_TYPE, 1, 1 ); + push_indice( sts[0]->hBstr, IND_BWIDTH, sts[0]->bwidth, 2 ); + IF( EQ_16( sts[0]->L_frame, L_FRAME16k ) ) + { + push_indice( sts[0]->hBstr, IND_ACELP_16KHZ, 1, 1 ); + } + ELSE + { + push_indice( sts[0]->hBstr, IND_ACELP_16KHZ, 0, 1 ); + } + + /* noise shapes and channel gains */ + FOR( Word16 i = 0; i < FD_CNG_stages_37bits; i++ ) + { + push_indice( sts[0]->hBstr, IND_LSF, indices[0][i], bits_37bits[i] ); + } + push_indice( sts[0]->hBstr, IND_ENERGY, gain_idx[0], 7 ); + + return; +} diff --git a/lib_enc/find_tilt.c b/lib_enc/find_tilt.c deleted file mode 100644 index efd1b44d2..000000000 --- a/lib_enc/find_tilt.c +++ /dev/null @@ -1,303 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ - - -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * find_tilt() - * - * Find LF/HF energy ratio - *-------------------------------------------------------------------*/ -void find_tilt_ivas_fx( - const Word32 fr_bands[], /* i : energy in frequency bands q_fr_bands*/ - const Word16 q_fr_bands, /* i : Q of fr_bands Q0*/ - const Word32 bckr[], /* i : per band background noise energy estimate q_bckr*/ - const Word16 q_bckr, /* i : Q of bckr Q0*/ - Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/ - const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/ - const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/ - const Word32 *lf_E, /* i : per bin energy for low frequencies q_lf_E*/ - const Word16 q_lf_E, /* i : Q of lf_E */ - const Word16 corr_shift, /* i : normalized correlation correction Q15*/ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 max_band, /* i : maximum critical band */ - Word32 hp_E[], /* o : energy in HF Q_new*/ - const Word16 codec_mode, /* i : MODE1 or MODE2 */ - Word32 *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise Q16 */ - Word16 Opt_vbr_mode ) -{ - Word32 lp_bckr = 0, hp_bckr = 0, lp_E, Ltmp; - const Word32 *pt_E, *pt_bands, *pt_bckr, *hf_bands, *tmp_E; - Word16 tmp, freq, f0, f1, f2, mean_voi, bin; - Word16 i, nb_bands; - Word16 e_tmp, m_tmp; - Word16 m_Fs, e_Fs; - Word16 m_cnt, e_cnt; - Word16 m_hpE, e_hpE; - Word64 sum; - Word16 inv_bands, q_lp_E; - Word32 Le_min_scaled, Ltmp2; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - move32(); - move32(); - /*-----------------------------------------------------------------* - * Initializations - *-----------------------------------------------------------------*/ - - IF( ( bwidth != NB ) ) - { - /* WB processing */ - bin = BIN4_FX; - move16(); /* First useful frequency bin ~ 50 Hz */ - pt_bands = fr_bands; /* Q_new */ - tmp_E = lf_E; /* Q_new - 2 */ - pt_bckr = bckr; /* Q_new */ - nb_bands = 10; - inv_bands = 3277 /* 1/10 in Q15 */; - move16(); - move16(); - } - ELSE - { - /* NB processing */ - bin = 3 * BIN4_FX; /* First useful frequency bin ~ 150 Hz */ - pt_bands = fr_bands + 1; /* Exlcude 1st critical band */ - tmp_E = lf_E + 2; /* Start at the 3rd bin (150 Hz) */ - pt_bckr = bckr + 1; /* Exlcude 1st critical band */ - nb_bands = 9; - inv_bands = 3641; /* 1/9 in Q15 */ - move16(); - move16(); /* Nb. of "low" frequency bands taken into account in NB processing */ - } - - /*-----------------------------------------------------------------* - * Find spectrum tilt - *-----------------------------------------------------------------*/ - - pt_E = tmp_E; /* Point at the 1st useful element of the per-bin energy vector */ - hf_bands = fr_bands; - - /* bckr + voicing */ - /*lp_bckr = mean( pt_bckr, nb_bands );*/ /* estimated noise E in first critical bands, up to 1270 Hz */ - sum = 0; - move64(); - FOR( i = 0; i < nb_bands; i++ ) - { - sum = W_mac_32_16( sum, pt_bckr[i], inv_bands ); // q_bckr+16 - } - lp_bckr = W_shl_sat_l( sum, -16 ); // q_bckr - /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */ - hp_bckr = W_extract_h( W_mac_32_32( W_mult_32_32( bckr[max_band - 1], ONE_IN_Q30 ), bckr[max_band], ONE_IN_Q30 ) ); // q_bckr - if ( hp_bckr == 0 ) /* Avoid division by zero. */ - { - hp_bckr = L_deposit_l( 1 ); - } - Ltmp = BASOP_Util_Divide3232_Scale_cadence( lp_bckr, hp_bckr, &e_tmp ); - Ltmp = Mpy_32_16_r( Ltmp, 3277 /* 0.1f in Q15 */ ); - Ltmp = L_shr_sat( Ltmp, sub( 15, e_tmp ) ); - *bckr_tilt_lt = L_add_sat( Mpy_32_16_r( *bckr_tilt_lt, 29491 /* 0.9f in Q15 */ ), Ltmp ); // Q16 - move32(); - - test(); - IF( EQ_16( codec_mode, MODE2 ) || EQ_16( Opt_vbr_mode, 1 ) ) - { - /*lp_bckr *= FACT;*/ - /*hp_bckr *= FACT;*/ - lp_bckr = L_add_sat( L_shl_sat( lp_bckr, 1 ), lp_bckr ); /* Q_new */ - hp_bckr = L_add_sat( L_shl_sat( hp_bckr, 1 ), hp_bckr ); /* Q_new */ - } - /*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/ - Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); // Q31 - Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); // Q31 - Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31 - mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15 - - /*f0 = INT_FS_FX / pitch[2];*/ - e_tmp = norm_s( pitch[2] ); - m_tmp = shl( pitch[2], e_tmp ); - - m_Fs = div_s( INT_FS_FX, m_tmp ); /* exp(e_tmp) */ - e_Fs = sub( 15, e_tmp ); - f0 = shr( m_Fs, sub( e_Fs, 4 ) ); /* Q4 */ - - Le_min_scaled = L_shl( E_MIN_FXQ31, sub( q_fr_bands, Q31 ) ); // q_fr_bands=q_bckr - - FOR( i = 0; i < 2; i++ ) - { - /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */ - Ltmp = W_extract_h( W_mac_32_32( W_mult_32_32( hf_bands[max_band - 1], ONE_IN_Q30 ), hf_bands[max_band], ONE_IN_Q30 ) ); // q_fr_bands - Ltmp = L_sub( Ltmp, hp_bckr ); // q_fr_bands - - Ltmp2 = L_max( Ltmp, L_shl_sat( 1, q_fr_bands ) ); // q_fr_bands, saturation is added because q_fr_bands is limited to 31 - if ( Opt_vbr_mode == 0 ) - { - Ltmp2 = L_max( Ltmp, Le_min_scaled ); // q_fr_bands - } - hp_E[i] = L_max( Ltmp2, 1 ); // to prevent division by zero - move32(); - - test(); - IF( GT_16( mean_voi, TH_COR_FX ) && LT_16( pitch[2], TH_PIT_FX ) ) /* High-pitched voiced frames */ - { - freq = bin; // Q4 - move16(); /* 1st useful frequency bin */ - m_cnt = 0; - move16(); - sum = 0; - move64(); - - f1 = add( shr( f0, 1 ), f0 ); /* Middle between 2 harmonics */ - f2 = f0; - move16(); - WHILE( LE_16( freq, 20320 /* 1270.0f in Q4 */ ) ) /* End frequency of 10th critical band */ - { - FOR( ; freq <= f1; freq += BIN4_FX ) - { - /* include only bins sufficiently close to harmonics */ - tmp = sub( freq, f2 ); - IF( L_mac0( -TH_D_FX * TH_D_FX, tmp, tmp ) < 0 ) - { - sum = W_mac_32_16( sum, *pt_E, 1 ); // q_lf_E+1 - m_cnt = add( m_cnt, 1 ); - } - pt_E++; - } - f1 = add_o( f1, f0, &Overflow ); - f2 = add_o( f2, f0, &Overflow ); - } - /*lp_E = lp_E / (float)cnt - lp_bckr;*/ - e_tmp = sub( W_norm( sum ), 1 ); - m_tmp = extract_h( W_extract_h( W_shl( sum, e_tmp ) ) ); // q_lf_E+1+e_tmp-32-16 - e_tmp = sub( add( q_lf_E, e_tmp ), 47 ); - - e_cnt = norm_s( m_cnt ); - m_cnt = shl( m_cnt, e_cnt ); // e_cnt - - m_tmp = div_s( m_tmp, m_cnt ); // Q15+e_tmp-e_cnt - e_tmp = add( Q15, sub( e_tmp, e_cnt ) ); - sum = W_shl( m_tmp, sub( add( q_bckr, 1 ), e_tmp ) ); // q_bckr+1 - sum = W_msu_32_16( sum, lp_bckr, 1 ); // q_bckr+1 - q_lp_E = W_norm( sum ); - lp_E = W_extract_h( W_shl( sum, q_lp_E ) ); // q_bckr+1+q_lp_E-32 - q_lp_E = sub( add( q_lp_E, q_bckr ), Q31 ); - - pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame Q_new - 1 */ - } - ELSE /* Other than high-pitched voiced frames */ - { - /*lp_E = mean( pt_bands, nb_bands ) - lp_bckr;*/ /* averaged E in first critical bands, up to 1270 Hz */ - sum = 0; - move64(); - FOR( Word16 j = 0; j < nb_bands; j++ ) - { - sum = W_mac_32_16( sum, pt_bands[j], inv_bands ); // q_fr_bands+16 - } - sum = W_mac_32_16( sum, lp_bckr, -ONE_IN_Q15 ); // q_fr_bands+16 - lp_E = W_round48_L( sum ); // q_fr_bands=q_bckr - q_lp_E = q_bckr; // q_fr_bands=q_bckr - move16(); - } - test(); - IF( Opt_vbr_mode == 0 && GT_32( L_shl_sat( Le_min_scaled, sub( q_lp_E, q_bckr ) ), lp_E ) ) - { - lp_E = E_MIN_FXQ31; - q_lp_E = Q31; - move32(); - move16(); - } - if ( Opt_vbr_mode != 0 ) - { - lp_E = L_max( lp_E, 0 ); // q_lp_E - } - /*ee[i] = lp_E / hp_E[i];*/ /* LF/HF ratio */ - - if ( lp_E == 0 ) - { - ee[i] = 0; - move32(); - } - test(); - IF( lp_E != 0 ) - { - e_tmp = sub( norm_l( lp_E ), 1 ); - m_tmp = extract_h( L_shl( lp_E, e_tmp ) ); // e_tmp+q_lp_E-16 - e_hpE = norm_l( hp_E[i] ); - m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) ); // e_hpE+q_bckr-16 - m_tmp = div_s( m_tmp, m_hpE ); // Q15+(e_tmp+q_lp_E)-(e_hpE+q_bckr) - e_tmp = sub( add( e_tmp, q_lp_E ), add( e_hpE, q_bckr ) ); - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ - move32(); - } - - IF( bwidth == NB ) /* For NB input, compensate for the missing bands */ - { - Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */ - IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ - { - Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ - ee[i] = L_shl_sat( Ltmp, 3 ); /* Q6 */ - move32(); /* x8 */ - } - ELSE - { - ee[i] = Mult_32_16( Ltmp, 24576 /* 0.75 in Q15 */ ); - move32(); /* 6/8 */ - } - } - - pt_bands += NB_BANDS; /* Update for next half-frame */ - hf_bands += NB_BANDS; - } - - return; -} diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 44ad404e3..ea71b09bc 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -240,3 +240,255 @@ void find_tilt_fx( return; } + +/*-------------------------------------------------------------------* + * find_tilt() + * + * Find LF/HF energy ratio + *-------------------------------------------------------------------*/ +void find_tilt_ivas_fx( + const Word32 fr_bands[], /* i : energy in frequency bands q_fr_bands*/ + const Word16 q_fr_bands, /* i : Q of fr_bands Q0*/ + const Word32 bckr[], /* i : per band background noise energy estimate q_bckr*/ + const Word16 q_bckr, /* i : Q of bckr Q0*/ + Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/ + const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/ + const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/ + const Word32 *lf_E, /* i : per bin energy for low frequencies q_lf_E*/ + const Word16 q_lf_E, /* i : Q of lf_E */ + const Word16 corr_shift, /* i : normalized correlation correction Q15*/ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 max_band, /* i : maximum critical band */ + Word32 hp_E[], /* o : energy in HF Q_new*/ + const Word16 codec_mode, /* i : MODE1 or MODE2 */ + Word32 *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise Q16 */ + Word16 Opt_vbr_mode ) +{ + Word32 lp_bckr = 0, hp_bckr = 0, lp_E, Ltmp; + const Word32 *pt_E, *pt_bands, *pt_bckr, *hf_bands, *tmp_E; + Word16 tmp, freq, f0, f1, f2, mean_voi, bin; + Word16 i, nb_bands; + Word16 e_tmp, m_tmp; + Word16 m_Fs, e_Fs; + Word16 m_cnt, e_cnt; + Word16 m_hpE, e_hpE; + Word64 sum; + Word16 inv_bands, q_lp_E; + Word32 Le_min_scaled, Ltmp2; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move32(); +#endif + move32(); + move32(); + /*-----------------------------------------------------------------* + * Initializations + *-----------------------------------------------------------------*/ + + IF( ( bwidth != NB ) ) + { + /* WB processing */ + bin = BIN4_FX; + move16(); /* First useful frequency bin ~ 50 Hz */ + pt_bands = fr_bands; /* Q_new */ + tmp_E = lf_E; /* Q_new - 2 */ + pt_bckr = bckr; /* Q_new */ + nb_bands = 10; + inv_bands = 3277 /* 1/10 in Q15 */; + move16(); + move16(); + } + ELSE + { + /* NB processing */ + bin = 3 * BIN4_FX; /* First useful frequency bin ~ 150 Hz */ + pt_bands = fr_bands + 1; /* Exlcude 1st critical band */ + tmp_E = lf_E + 2; /* Start at the 3rd bin (150 Hz) */ + pt_bckr = bckr + 1; /* Exlcude 1st critical band */ + nb_bands = 9; + inv_bands = 3641; /* 1/9 in Q15 */ + move16(); + move16(); /* Nb. of "low" frequency bands taken into account in NB processing */ + } + + /*-----------------------------------------------------------------* + * Find spectrum tilt + *-----------------------------------------------------------------*/ + + pt_E = tmp_E; /* Point at the 1st useful element of the per-bin energy vector */ + hf_bands = fr_bands; + + /* bckr + voicing */ + /*lp_bckr = mean( pt_bckr, nb_bands );*/ /* estimated noise E in first critical bands, up to 1270 Hz */ + sum = 0; + move64(); + FOR( i = 0; i < nb_bands; i++ ) + { + sum = W_mac_32_16( sum, pt_bckr[i], inv_bands ); // q_bckr+16 + } + lp_bckr = W_shl_sat_l( sum, -16 ); // q_bckr + /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */ + hp_bckr = W_extract_h( W_mac_32_32( W_mult_32_32( bckr[max_band - 1], ONE_IN_Q30 ), bckr[max_band], ONE_IN_Q30 ) ); // q_bckr + if ( hp_bckr == 0 ) /* Avoid division by zero. */ + { + hp_bckr = L_deposit_l( 1 ); + } + Ltmp = BASOP_Util_Divide3232_Scale_cadence( lp_bckr, hp_bckr, &e_tmp ); + Ltmp = Mpy_32_16_r( Ltmp, 3277 /* 0.1f in Q15 */ ); + Ltmp = L_shr_sat( Ltmp, sub( 15, e_tmp ) ); + *bckr_tilt_lt = L_add_sat( Mpy_32_16_r( *bckr_tilt_lt, 29491 /* 0.9f in Q15 */ ), Ltmp ); // Q16 + move32(); + + test(); + IF( EQ_16( codec_mode, MODE2 ) || EQ_16( Opt_vbr_mode, 1 ) ) + { + /*lp_bckr *= FACT;*/ + /*hp_bckr *= FACT;*/ + lp_bckr = L_add_sat( L_shl_sat( lp_bckr, 1 ), lp_bckr ); /* Q_new */ + hp_bckr = L_add_sat( L_shl_sat( hp_bckr, 1 ), hp_bckr ); /* Q_new */ + } + /*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/ + Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); // Q31 + Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); // Q31 + Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31 + mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15 + + /*f0 = INT_FS_FX / pitch[2];*/ + e_tmp = norm_s( pitch[2] ); + m_tmp = shl( pitch[2], e_tmp ); + + m_Fs = div_s( INT_FS_FX, m_tmp ); /* exp(e_tmp) */ + e_Fs = sub( 15, e_tmp ); + f0 = shr( m_Fs, sub( e_Fs, 4 ) ); /* Q4 */ + + Le_min_scaled = L_shl( E_MIN_FXQ31, sub( q_fr_bands, Q31 ) ); // q_fr_bands=q_bckr + + FOR( i = 0; i < 2; i++ ) + { + /*hp_E[i] = 0.5f * (hf_bands[max_band-1] + hf_bands[max_band]) - hp_bckr; */ /* averaged E in last 2 critical bands */ + Ltmp = W_extract_h( W_mac_32_32( W_mult_32_32( hf_bands[max_band - 1], ONE_IN_Q30 ), hf_bands[max_band], ONE_IN_Q30 ) ); // q_fr_bands + Ltmp = L_sub( Ltmp, hp_bckr ); // q_fr_bands + + Ltmp2 = L_max( Ltmp, L_shl_sat( 1, q_fr_bands ) ); // q_fr_bands, saturation is added because q_fr_bands is limited to 31 + if ( Opt_vbr_mode == 0 ) + { + Ltmp2 = L_max( Ltmp, Le_min_scaled ); // q_fr_bands + } + hp_E[i] = L_max( Ltmp2, 1 ); // to prevent division by zero + move32(); + + test(); + IF( GT_16( mean_voi, TH_COR_FX ) && LT_16( pitch[2], TH_PIT_FX ) ) /* High-pitched voiced frames */ + { + freq = bin; // Q4 + move16(); /* 1st useful frequency bin */ + m_cnt = 0; + move16(); + sum = 0; + move64(); + + f1 = add( shr( f0, 1 ), f0 ); /* Middle between 2 harmonics */ + f2 = f0; + move16(); + WHILE( LE_16( freq, 20320 /* 1270.0f in Q4 */ ) ) /* End frequency of 10th critical band */ + { + FOR( ; freq <= f1; freq += BIN4_FX ) + { + /* include only bins sufficiently close to harmonics */ + tmp = sub( freq, f2 ); + IF( L_mac0( -TH_D_FX * TH_D_FX, tmp, tmp ) < 0 ) + { + sum = W_mac_32_16( sum, *pt_E, 1 ); // q_lf_E+1 + m_cnt = add( m_cnt, 1 ); + } + pt_E++; + } + f1 = add_o( f1, f0, &Overflow ); + f2 = add_o( f2, f0, &Overflow ); + } + /*lp_E = lp_E / (float)cnt - lp_bckr;*/ + e_tmp = sub( W_norm( sum ), 1 ); + m_tmp = extract_h( W_extract_h( W_shl( sum, e_tmp ) ) ); // q_lf_E+1+e_tmp-32-16 + e_tmp = sub( add( q_lf_E, e_tmp ), 47 ); + + e_cnt = norm_s( m_cnt ); + m_cnt = shl( m_cnt, e_cnt ); // e_cnt + + m_tmp = div_s( m_tmp, m_cnt ); // Q15+e_tmp-e_cnt + e_tmp = add( Q15, sub( e_tmp, e_cnt ) ); + sum = W_shl( m_tmp, sub( add( q_bckr, 1 ), e_tmp ) ); // q_bckr+1 + sum = W_msu_32_16( sum, lp_bckr, 1 ); // q_bckr+1 + q_lp_E = W_norm( sum ); + lp_E = W_extract_h( W_shl( sum, q_lp_E ) ); // q_bckr+1+q_lp_E-32 + q_lp_E = sub( add( q_lp_E, q_bckr ), Q31 ); + + pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame Q_new - 1 */ + } + ELSE /* Other than high-pitched voiced frames */ + { + /*lp_E = mean( pt_bands, nb_bands ) - lp_bckr;*/ /* averaged E in first critical bands, up to 1270 Hz */ + sum = 0; + move64(); + FOR( Word16 j = 0; j < nb_bands; j++ ) + { + sum = W_mac_32_16( sum, pt_bands[j], inv_bands ); // q_fr_bands+16 + } + sum = W_mac_32_16( sum, lp_bckr, -ONE_IN_Q15 ); // q_fr_bands+16 + lp_E = W_round48_L( sum ); // q_fr_bands=q_bckr + q_lp_E = q_bckr; // q_fr_bands=q_bckr + move16(); + } + test(); + IF( Opt_vbr_mode == 0 && GT_32( L_shl_sat( Le_min_scaled, sub( q_lp_E, q_bckr ) ), lp_E ) ) + { + lp_E = E_MIN_FXQ31; + q_lp_E = Q31; + move32(); + move16(); + } + if ( Opt_vbr_mode != 0 ) + { + lp_E = L_max( lp_E, 0 ); // q_lp_E + } + /*ee[i] = lp_E / hp_E[i];*/ /* LF/HF ratio */ + + if ( lp_E == 0 ) + { + ee[i] = 0; + move32(); + } + test(); + IF( lp_E != 0 ) + { + e_tmp = sub( norm_l( lp_E ), 1 ); + m_tmp = extract_h( L_shl( lp_E, e_tmp ) ); // e_tmp+q_lp_E-16 + e_hpE = norm_l( hp_E[i] ); + m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) ); // e_hpE+q_bckr-16 + m_tmp = div_s( m_tmp, m_hpE ); // Q15+(e_tmp+q_lp_E)-(e_hpE+q_bckr) + e_tmp = sub( add( e_tmp, q_lp_E ), add( e_hpE, q_bckr ) ); + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + move32(); + } + + IF( bwidth == NB ) /* For NB input, compensate for the missing bands */ + { + Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */ + IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ + { + Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ + ee[i] = L_shl_sat( Ltmp, 3 ); /* Q6 */ + move32(); /* x8 */ + } + ELSE + { + ee[i] = Mult_32_16( Ltmp, 24576 /* 0.75 in Q15 */ ); + move32(); /* 6/8 */ + } + } + + pt_bands += NB_BANDS; /* Update for next half-frame */ + hf_bands += NB_BANDS; + } + + return; +} diff --git a/lib_enc/find_uv.c b/lib_enc/find_uv.c deleted file mode 100644 index c6ae02a76..000000000 --- a/lib_enc/find_uv.c +++ /dev/null @@ -1,660 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -#define L_ENR ( NB_SSF + 2 ) - -/*-------------------------------------------------------------------* - * find_ener_decrease() - * - * Find maximum energy ratio between short sub-subframes in case - * energy is trailing off after a spike - *-------------------------------------------------------------------*/ - -/*! r: maximum energy ratio */ -static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10*/ - const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/ - const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/ -) -{ - Word16 i, j, end, flag; - Word16 wtmp0, wtmp1; - Word32 maxEnr, minEnr; - Word16 dE2, exp0, exp1; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - dE2 = 0; - move16(); - - j = add( ind_deltaMax, 2 ); /* Q0 */ - move16(); - end = add( j, L_ENR ); - move16(); - maxEnr = L_add( pt_enr_ssf[j], 0 ); - j = add( j, 1 ); - flag = 0; - move16(); - FOR( i = j; i < end; i++ ) - { - test(); - IF( ( GT_32( pt_enr_ssf[i], maxEnr ) ) && ( flag == 0 ) ) - { - maxEnr = pt_enr_ssf[i]; /* Qx */ - j = add( j, 1 ); - } - ELSE - { - flag = 1; - move16(); - } - } - - minEnr = L_add( maxEnr, 0 ); - FOR( i = j; i < end; i++ ) - { - minEnr = L_min( minEnr, pt_enr_ssf[i] ); /* Qx */ - } - - - minEnr = L_add_sat( minEnr, 100000 ); - exp0 = norm_l( minEnr ); - wtmp0 = extract_h( L_shl( minEnr, exp0 ) ); - exp1 = sub( norm_l( maxEnr ), 1 ); - wtmp1 = extract_h( L_shl( maxEnr, exp1 ) ); - wtmp1 = div_s( wtmp1, wtmp0 ); - dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ - - return dE2; -} - -/*-------------------------------------------------------------------* - * find_uv() - * - * Decision about coder type - *-------------------------------------------------------------------*/ -Word16 find_uv_ivas_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*/ - 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 q_hp_E ) -{ - 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; - 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; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - Word16 Last_Resort; - Word16 vadnoise; - - IF( hSC_VBR != NULL ) - { - Last_Resort = hSC_VBR->Last_Resort; /* Q0 */ - move16(); - vadnoise = hSC_VBR->vadnoise_fx; /* Q8 */ - move16(); - } - ELSE - { - Last_Resort = 0; - move16(); - vadnoise = 0; - move16(); - } - - /*-----------------------------------------------------------------* - * 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; - pt_enr_ssf = enr_ssf + 2 * NB_SSF; - FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ ) - { - emaximum_fx( Q_new, 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_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* 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++; - } - - IF( hStereoClassif != NULL ) - { - IF( st_fx->idchan == 0 ) - { - hStereoClassif->dE1_ch1_fx = dE1; /* Q13 */ - move32(); - hStereoClassif->dE1_ch1_e = 31 - Q13; - move16(); - } - ELSE - { - hStereoClassif->dE1_ch2_fx = dE1; /* Q13 */ - move32(); - hStereoClassif->dE1_ch2_e = 31 - Q13; - move16(); - } - } - - if ( dE1X != NULL ) - { - *dE1X = dE1; /* Q13 */ - move32(); - } - - /*-----------------------------------------------------------------* - * 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_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ - mean_ee = Mult_32_16( mean_ee, 10923 ); /*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( st_fx->input_bwidth == NB ) - { - dE2_th = 21 << 10; - move32(); - if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 ) ) /*( 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( 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(); - } - - E_min_th = L_shl( E_MIN_IVAS_FX_Q31, sub( q_hp_E, Q31 ) ); - - 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], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ - ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), 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(); - test(); - test(); - 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( 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 ( 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 */ - coder_type = GENERIC; - move16(); - IF( st_fx->input_bwidth == NB ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 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(); - if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* 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 Q16 */ ) ) && ( 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 && 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 /* 1.0f in Q6 */ ) ) && /* 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 */ ); /* 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( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) ) - { - core_coder_mode_switch_ivas_fx( st_fx, st_fx->last_total_brate, 0 ); - } - } - } - - /*-----------------------------------------------------------------* - * UNCLR classifier - *-----------------------------------------------------------------*/ - - IF( hStereoClassif != NULL ) - { - test(); - test(); - test(); - test(); - test(); - IF( st_fx->element_mode > EVS_MONO && ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, UNVOICED ) || coder_type == INACTIVE || st_fx->localVAD == 0 ) && LT_16( hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan], MAX_UV_CNT ) ) - { - hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan] = add( hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan], 1 ); - move16(); - } - ELSE - { - hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan] = 0; - move16(); - } - } - - /*-----------------------------------------------------------------* - * 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 */ - move16(); - } - - /* 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 /* 13 in Q8 */ ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 /* 0.695 in Q15 */ ) ) ) ) ) /* 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; /* Q0 */ - move16(); - - return coder_type; -} -/*-------------------------------------------------------------------* - * find_uv() - * - * Decision about coder type - *-------------------------------------------------------------------*/ diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 3f4c8abc7..200e538e4 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -618,3 +618,542 @@ Word16 find_uv_fx( /* o : coding type */ return coder_type; } + +/*-------------------------------------------------------------------* + * find_uv() + * + * Decision about coder type + *-------------------------------------------------------------------*/ +Word16 find_uv_ivas_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*/ + 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 q_hp_E ) +{ + 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; + 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; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move32(); +#endif + Word16 Last_Resort; + Word16 vadnoise; + + IF( hSC_VBR != NULL ) + { + Last_Resort = hSC_VBR->Last_Resort; /* Q0 */ + move16(); + vadnoise = hSC_VBR->vadnoise_fx; /* Q8 */ + move16(); + } + ELSE + { + Last_Resort = 0; + move16(); + vadnoise = 0; + move16(); + } + + /*-----------------------------------------------------------------* + * 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; + pt_enr_ssf = enr_ssf + 2 * NB_SSF; + FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ ) + { + emaximum_fx( Q_new, 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_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* 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++; + } + + IF( hStereoClassif != NULL ) + { + IF( st_fx->idchan == 0 ) + { + hStereoClassif->dE1_ch1_fx = dE1; /* Q13 */ + move32(); + hStereoClassif->dE1_ch1_e = 31 - Q13; + move16(); + } + ELSE + { + hStereoClassif->dE1_ch2_fx = dE1; /* Q13 */ + move32(); + hStereoClassif->dE1_ch2_e = 31 - Q13; + move16(); + } + } + + if ( dE1X != NULL ) + { + *dE1X = dE1; /* Q13 */ + move32(); + } + + /*-----------------------------------------------------------------* + * 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_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ + mean_ee = Mult_32_16( mean_ee, 10923 ); /*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( st_fx->input_bwidth == NB ) + { + dE2_th = 21 << 10; + move32(); + if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 ) ) /*( 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( 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(); + } + + E_min_th = L_shl( E_MIN_IVAS_FX_Q31, sub( q_hp_E, Q31 ) ); + + 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], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ + ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), 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(); + test(); + test(); + 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( 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 ( 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 */ + coder_type = GENERIC; + move16(); + IF( st_fx->input_bwidth == NB ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 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(); + if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* 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 Q16 */ ) ) && ( 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 && 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 /* 1.0f in Q6 */ ) ) && /* 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 */ ); /* 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( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) ) + { + core_coder_mode_switch_ivas_fx( st_fx, st_fx->last_total_brate, 0 ); + } + } + } + + /*-----------------------------------------------------------------* + * UNCLR classifier + *-----------------------------------------------------------------*/ + + IF( hStereoClassif != NULL ) + { + test(); + test(); + test(); + test(); + test(); + IF( st_fx->element_mode > EVS_MONO && ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, UNVOICED ) || coder_type == INACTIVE || st_fx->localVAD == 0 ) && LT_16( hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan], MAX_UV_CNT ) ) + { + hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan] = add( hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan], 1 ); + move16(); + } + ELSE + { + hStereoClassif->unclr_sw_enable_cnt[st_fx->idchan] = 0; + move16(); + } + } + + /*-----------------------------------------------------------------* + * 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 */ + move16(); + } + + /* 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 /* 13 in Q8 */ ) && ( GT_16( add_sat( mean_voi3, corr_shift ), 22774 /* 0.695 in Q15 */ ) ) ) ) ) /* 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; /* Q0 */ + move16(); + + return coder_type; +} diff --git a/lib_enc/find_wsp.c b/lib_enc/find_wsp.c deleted file mode 100644 index 89b77d351..000000000 --- a/lib_enc/find_wsp.c +++ /dev/null @@ -1,98 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" -/*-------------------------------------------------------------------* - * ivas_find_wsp_fx() - * - * Compute weighted speech used in open-loop pitch search - *-------------------------------------------------------------------*/ -void ivas_find_wsp_fx( - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 L_subfr, /* i : length of subframe Q0*/ - const Word16 nb_subfr, /* i : number of subframes Q0*/ - const Word16 *A_fx, - /* i : A(z) filter coefficients */ // Q12 - Word16 *Aw_fx, - /* o : weighted A(z) filter coefficients */ // Q12 - const Word16 *speech_fx, - /* i : pointer to the denoised speech frame */ // Q_new - const Word16 tilt_fact, - /* i : tilt factor */ // Q15 - Word16 *wsp_fx, - /* o : poitnter to the weighted speech frame */ // Q_new - Word16 *mem_wsp_fx, - /* i/o: W(Z) denominator memory */ // Q_new - const Word16 gamma, - /* i : weighting factor */ // Q15 - const Word16 L_look /* i : look-ahead Q0*/ -) -{ - Word16 *p_Aw_fx, tmp_fx; - Word16 i_subfr; - - - /*-----------------------------------------------------------------* - * Compute weighted A(z) unquantized for subframes - *-----------------------------------------------------------------*/ - weight_a_subfr_fx( nb_subfr, A_fx, Aw_fx, gamma, M ); - - /*-----------------------------------------------------------------* - * Compute weighted speech for all subframes - *-----------------------------------------------------------------*/ - p_Aw_fx = Aw_fx; - FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr ) - { - Residu3_fx( p_Aw_fx, &speech_fx[i_subfr], &wsp_fx[i_subfr], L_subfr, 0 ); - p_Aw_fx += ( M + 1 ); - } - p_Aw_fx -= ( M + 1 ); - - /*-----------------------------------------------------------------* - * Weighted speech computation is extended on look-ahead - *-----------------------------------------------------------------*/ - - deemph_fx( wsp_fx, tilt_fact, L_frame, mem_wsp_fx ); - Residu3_fx( p_Aw_fx, &speech_fx[L_frame], &wsp_fx[L_frame], L_look, 0 ); - tmp_fx = *mem_wsp_fx; - deemph_fx( &wsp_fx[L_frame], tilt_fact, L_look, &tmp_fx ); - return; -} diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c index 7468c3dc7..d08922a2a 100644 --- a/lib_enc/find_wsp_fx.c +++ b/lib_enc/find_wsp_fx.c @@ -6,7 +6,7 @@ #include #include "options.h" #include "cnst.h" -//#include "prot_fx.h" +#include "prot.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ @@ -78,3 +78,60 @@ void find_wsp_fx( deemph_fx( &wsp[L_frame], preemph_fac, lookahead, &wtmp ); } } + +/*-------------------------------------------------------------------* + * ivas_find_wsp_fx() + * + * Compute weighted speech used in open-loop pitch search + *-------------------------------------------------------------------*/ +void ivas_find_wsp_fx( + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 L_subfr, /* i : length of subframe Q0*/ + const Word16 nb_subfr, /* i : number of subframes Q0*/ + const Word16 *A_fx, + /* i : A(z) filter coefficients */ // Q12 + Word16 *Aw_fx, + /* o : weighted A(z) filter coefficients */ // Q12 + const Word16 *speech_fx, + /* i : pointer to the denoised speech frame */ // Q_new + const Word16 tilt_fact, + /* i : tilt factor */ // Q15 + Word16 *wsp_fx, + /* o : poitnter to the weighted speech frame */ // Q_new + Word16 *mem_wsp_fx, + /* i/o: W(Z) denominator memory */ // Q_new + const Word16 gamma, + /* i : weighting factor */ // Q15 + const Word16 L_look /* i : look-ahead Q0*/ +) +{ + Word16 *p_Aw_fx, tmp_fx; + Word16 i_subfr; + + + /*-----------------------------------------------------------------* + * Compute weighted A(z) unquantized for subframes + *-----------------------------------------------------------------*/ + weight_a_subfr_fx( nb_subfr, A_fx, Aw_fx, gamma, M ); + + /*-----------------------------------------------------------------* + * Compute weighted speech for all subframes + *-----------------------------------------------------------------*/ + p_Aw_fx = Aw_fx; + FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_subfr ) + { + Residu3_fx( p_Aw_fx, &speech_fx[i_subfr], &wsp_fx[i_subfr], L_subfr, 0 ); + p_Aw_fx += ( M + 1 ); + } + p_Aw_fx -= ( M + 1 ); + + /*-----------------------------------------------------------------* + * Weighted speech computation is extended on look-ahead + *-----------------------------------------------------------------*/ + + deemph_fx( wsp_fx, tilt_fact, L_frame, mem_wsp_fx ); + Residu3_fx( p_Aw_fx, &speech_fx[L_frame], &wsp_fx[L_frame], L_look, 0 ); + tmp_fx = *mem_wsp_fx; + deemph_fx( &wsp_fx[L_frame], tilt_fact, L_look, &tmp_fx ); + return; +} diff --git a/lib_enc/frame_spec_dif_cor_rate.c b/lib_enc/frame_spec_dif_cor_rate.c deleted file mode 100644 index 9185f37bd..000000000 --- a/lib_enc/frame_spec_dif_cor_rate.c +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * frame_spec_dif_cor_rate() - * - * - *-------------------------------------------------------------------*/ diff --git a/lib_enc/gain_enc.c b/lib_enc/gain_enc.c deleted file mode 100644 index 276e20738..000000000 --- a/lib_enc/gain_enc.c +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -#define RANGE 64 - -/*---------------------------------------------------------------------* - * Es_pred_enc() - * - * Calculation and quantization of average predicted innovation energy to be - *---------------------------------------------------------------------*/ diff --git a/lib_enc/gs_enc.c b/lib_enc/gs_enc.c deleted file mode 100644 index 900c381bf..000000000 --- a/lib_enc/gs_enc.c +++ /dev/null @@ -1,56 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "ivas_prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * Local function prototypes - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * GSC_enc_init() - * - * Initialize GSC encoder state structure - *-------------------------------------------------------------------*/ diff --git a/lib_enc/guided_plc_enc.c b/lib_enc/guided_plc_enc.c deleted file mode 100644 index 6c0e9022d..000000000 --- a/lib_enc/guided_plc_enc.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "stat_enc.h" -#include "wmc_auto.h" diff --git a/lib_enc/hf_cod_amrwb.c b/lib_enc/hf_cod_amrwb.c deleted file mode 100644 index 7ea6e47a5..000000000 --- a/lib_enc/hf_cod_amrwb.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/hq_classifier_enc.c b/lib_enc/hq_classifier_enc.c deleted file mode 100644 index 634f42971..000000000 --- a/lib_enc/hq_classifier_enc.c +++ /dev/null @@ -1,52 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" -/*-----------------------------------------------------------------* - * Local constants - *-----------------------------------------------------------------*/ - -/*-----------------------------------------------------------------* - * Local function prototypes - *-----------------------------------------------------------------*/ diff --git a/lib_enc/hq_core_enc.c b/lib_enc/hq_core_enc.c deleted file mode 100644 index 24579e74e..000000000 --- a/lib_enc/hq_core_enc.c +++ /dev/null @@ -1,410 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -#include "prot_fx.h" -#include "prot_fx_enc.h" - -/*-------------------------------------------------------------------------- - * hq_core_enc() - * - * HQ core encoder - *--------------------------------------------------------------------------*/ - -void hq_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *audio_fx, /* i : input audio signal Q0 */ - const Word16 input_frame_orig, /* i : frame length Q0*/ - const Word16 hq_core_type, /* i : HQ core type Q0*/ - const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ -) -{ - Word16 i, is_transient, num_bits, extra_unused; - - Word32 t_audio_fx[L_FRAME48k_EXT]; - Word16 wtda_audio_fx16[2 * L_FRAME48k]; - Word32 wtda_audio_fx32[2 * L_FRAME48k]; - Word16 two_frames_buffer[2 * L_FRAME48k]; - Word16 tmp; - Word16 Aq_old_fx[M + 1]; - Word16 output_fx[L_FRAME48k]; - Word16 Q_audio; - Word16 out_q = 0, old_q = 0; - move16(); - move16(); - Word16 inner_frame, input_frame, L_frame; - Word16 L_spec, overlap, nz, tcx_offset; - Word16 left_overlap, right_overlap; - BSTR_ENC_HANDLE hBstr = st->hBstr; - Word16 q = 0; - Word16 exp; - move16(); - - push_wmops( "hq_core_enc" ); - - set16_fx( wtda_audio_fx16, 0, 2 * L_FRAME48k ); - set32_fx( wtda_audio_fx32, 0, 2 * L_FRAME48k ); - st->Nb_ACELP_frames = 0; - move16(); - set_zero_fx( t_audio_fx, L_FRAME48k_EXT ); - /* set input_frame length */ - input_frame = input_frame_orig; /* Q0 */ - - /* Sanity check, it should never happen at the encoder side (no BFI) */ - IF( st->hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) - { - st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; - move16(); - } - ELSE - { - st->hTcxCfg->tcx_last_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode; - move16(); - } - st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; - move16(); - - /*-------------------------------------------------------------------------- - * Preprocessing in the first HQ frame after ACELP frame - * Find the number of bits for PVQ coding - * Write signaling information - *--------------------------------------------------------------------------*/ - - num_bits = BASOP_Util_Divide3232_Scale( st->total_brate, FRAMES_PER_SEC, &exp ); /* Q15-exp */ - num_bits = shr( num_bits, sub( 15, exp ) ); /* Q0 */ - extra_unused = 0; - move16(); - - /*-------------------------------------------------------------------------- - * Detect signal transition - *--------------------------------------------------------------------------*/ - - is_transient = detect_transient_fx( audio_fx, input_frame, 0, st ); /* Q0 */ - move16(); - - test(); - test(); - IF( st->element_mode > EVS_MONO && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) ) - { - /*-------------------------------------------------------------------------- - * IVAS switching frame - *--------------------------------------------------------------------------*/ - - L_spec = input_frame; - left_overlap = -1; - right_overlap = -1; - move16(); - move16(); - move16(); - - WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, TRANSITION_OVERLAP, FULL_OVERLAP, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_spec, wtda_audio_fx16, 1, 1 ); - - q = 0; - move16(); - Q_audio = sub( Q16, q ); - TCX_MDCT( wtda_audio_fx16, t_audio_fx, &Q_audio, left_overlap, sub( L_spec, shr( add( left_overlap, right_overlap ), 1 ) ), right_overlap, st->element_mode ); - Q_audio = sub( Q31, Q_audio ); -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( wtda_audio_fx16, wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, q ) ); /* Q_audio */ -#else - Copy_Scale_sig_16_32_DEPREC( wtda_audio_fx16, wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, q ) ); /* Q_audio */ -#endif - inner_frame = inner_frame_tbl[st->bwidth]; /* Q0 */ - L_spec = l_spec_ext_tbl[st->bwidth]; /* Q0 */ - is_transient = 0; - move16(); - move16(); - move16(); - } - ELSE - { - /*-------------------------------------------------------------------------- - * Windowing and time-domain aliasing - * DCT transform - *--------------------------------------------------------------------------*/ - Q_audio = 0; - move16(); - Scale_sig( st->old_input_signal_fx, input_frame, negate( st->q_old_inp ) ); /* Q0 */ - Scale_sig( st->input_fx, add( input_frame, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), negate( st->q_inp ) ); /* Q0 */ - st->q_old_inp = 0; - move16(); - st->q_inp = 0; - move16(); - Copy( st->old_input_signal_fx, two_frames_buffer, input_frame ); /* Q0 */ - Copy( audio_fx, two_frames_buffer + input_frame, input_frame ); /* Q0 */ - - wtda_fx( two_frames_buffer + input_frame, &Q_audio, wtda_audio_fx32, NULL, 0, - st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, input_frame ); - - test(); - IF( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) - { - /* Preprocessing in the first HQ frame after ACELP frame */ - core_switching_hq_prepare_enc_fx( st, &num_bits, input_frame, wtda_audio_fx32, two_frames_buffer + input_frame ); - - /* During ACELP->HQ core switching, limit the HQ core bitrate to 48kbps */ - IF( GT_16( num_bits, ACELP_48k_BITS ) ) - { - extra_unused = sub( num_bits, ACELP_48k_BITS ); - num_bits = ACELP_48k_BITS; - move16(); - } - } - - Word16 tmp_q = Q_audio; - move16(); - direct_transform_fx( wtda_audio_fx32, t_audio_fx, is_transient, input_frame, &Q_audio, st->element_mode ); - scale_sig32( wtda_audio_fx32, L_FRAME48k_EXT, sub( Q_audio, tmp_q ) ); /* Q_audio */ - - /* scale coefficients to their nominal level (8kHz) */ - IF( NE_16( input_frame, NORM_MDCT_FACTOR ) ) - { - UWord16 lsb; - tmp = mult_r( input_frame, 410 / 2 ); /* 1/8000 in Q15 */ - Word16 ener_match_fx = hq_nominal_scaling[tmp]; - move16(); - FOR( i = 0; i < input_frame; i++ ) - { - /*t_audio_q[i] *= ener_match; */ - Mpy_32_16_ss( t_audio_fx[i], ener_match_fx, &t_audio_fx[i], &lsb ); /* Q12 */ - move16(); - } - } - - /* limit encoded band-width according to the command-line OR BWD limitation */ - inner_frame = inner_frame_tbl[st->bwidth]; /* Q0 */ - L_spec = l_spec_tbl[st->bwidth]; /* Q0 */ - - move16(); - move16(); - - - IF( GT_16( input_frame, inner_frame ) ) - { - IF( EQ_16( is_transient, 1 ) ) - { - FOR( i = 1; i < NUM_TIME_SWITCHING_BLOCKS; i++ ) - { - tmp = shr( inner_frame, 2 ); - Copy32( t_audio_fx + i_mult2( i, shr( input_frame, 2 ) ), t_audio_fx + i_mult2( i, tmp ), tmp ); /* Q_audio */ - } - } - - set32_fx( t_audio_fx + inner_frame, 0, sub( input_frame, inner_frame ) ); - } - } - - - /* subtract signaling bits */ - num_bits = sub( num_bits, hBstr->nb_bits_tot ); /* Q0 */ - - /*-------------------------------------------------------------------------- - * High-band gain control in case of BWS - *--------------------------------------------------------------------------*/ - - IF( st->bwidth_sw_cnt > 0 ) - { - Word32 L_tmp; - tmp = BASOP_Util_Divide1616_Scale( 3, BWS_TRAN_PERIOD, &exp ); /* Q15-exp */ - shr( tmp, exp ); - L_tmp = L_deposit_h( tmp ); /* Q31-exp */ - IF( is_transient ) - { - FOR( i = 0; i < NUM_TIME_SWITCHING_BLOCKS; i++ ) - { - v_multc_fixed( t_audio_fx + add( i_mult2( i, shr( inner_frame, 2 ) ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ), L_tmp, t_audio_fx + add( i_mult2( i, shr( inner_frame, 2 ) ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ), sub( shr( inner_frame, 2 ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ) ); // Q_audio + Q31 - Q31 -> Q_audio - } - } - ELSE - { - v_multc_fixed( t_audio_fx + L_FRAME16k, L_tmp, t_audio_fx + L_FRAME16k, L_spec - L_FRAME16k ); // Q_audio + Q31 - Q31 -> Q_audio - } - } - - /*-------------------------------------------------------------------------- - * Classify whether to put extra bits for FER mitigation - *--------------------------------------------------------------------------*/ - - test(); - test(); - test(); - IF( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) && GT_32( st->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) ) - { - IF( Voicing_flag > 0 ) - { - push_indice( hBstr, IND_HQ_VOICING_FLAG, 1, 1 ); - num_bits = sub( num_bits, 1 ); - } - ELSE - { - push_indice( hBstr, IND_HQ_VOICING_FLAG, 0, 1 ); - num_bits = sub( num_bits, 1 ); - } - } - - /*-------------------------------------------------------------------------- - * Transform-domain encoding - *--------------------------------------------------------------------------*/ - - scale_sig32( t_audio_fx, L_FRAME48k_EXT, sub( Q12, Q_audio ) ); - scale_sig32( wtda_audio_fx32, 2 * L_FRAME48k, sub( Q12, Q_audio ) ); - Q_audio = 12; - move16(); - IF( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) - { - - hq_lr_enc_ivas_fx( st, t_audio_fx, inner_frame, &num_bits, is_transient ); - } - ELSE - { - /* HQ high rate encoder */ - hq_hr_enc_ivas_fx( st, t_audio_fx, L_spec, &num_bits, is_transient, vad_hover_flag ); - } - - /* write all unused bits to the bitstream */ - num_bits = add( num_bits, extra_unused ); - - WHILE( GT_16( num_bits, 16 ) ) - { - push_indice( hBstr, IND_UNUSED, 0, 16 ); - num_bits = sub( num_bits, 16 ); - } - - IF( num_bits != 0 ) - { - push_indice( hBstr, IND_UNUSED, 0, num_bits ); - } - - test(); - test(); - IF( st->element_mode > EVS_MONO && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) ) - { - overlap = st->hTcxCfg->tcx_mdct_window_length; /* Q0 */ - move16(); - - nz = NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS ); - move16(); - L_frame = sub( st->L_frame + st->hTcxCfg->tcx_offset, st->hTcxCfg->lfacNext ); - tcx_offset = st->hTcxCfg->lfacNext; - move16(); - - set16_fx( Aq_old_fx, 0, M + 1 ); /* Dummy filter */ - Aq_old_fx[0] = 1; - move16(); - - /* Code taken from InternalTCXDecoder() */ - Copy_Scale_sig_32_16( wtda_audio_fx32, wtda_audio_fx16, 2 * L_FRAME48k, negate( Q_audio ) ); // Q0 - TCX_MDCT_Inverse( t_audio_fx, sub( sub( 31, Q_audio ), 15 ), wtda_audio_fx16, overlap, sub( L_frame, overlap ), overlap, st->element_mode ); - - - /* Window current frame */ - Word16 tcx_offset_tmp; - - IF( tcx_offset < 0 ) - { - tcx_offset_tmp = negate( tcx_offset ); - } - ELSE - { - tcx_offset_tmp = 0; - move16(); - } - tcx_windowing_synthesis_current_frame( wtda_audio_fx16, st->hTcxCfg->tcx_aldo_window_2, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, st->hTcxCfg->tcx_last_overlap_mode, /*left mode*/ st->hTcxEnc->acelp_zir, st->hTcxEnc->Txnq, NULL, Aq_old_fx, st->hTcxCfg->tcx_mdct_window_trans, shr( st->L_frame, 1 ), tcx_offset_tmp, st->last_core, 0, 0 ); - - - /*Compute windowed synthesis in case of switching to ALDO windows in next frame*/ - Copy( wtda_audio_fx16 + sub( L_frame, nz ), st->hTcxEnc->old_out_fx, nz + overlap ); /* Q0 */ - set16_fx( st->hTcxEnc->old_out_fx + add( nz, overlap ), 0, nz ); - - tcx_windowing_synthesis_past_frame( st->hTcxEnc->old_out_fx + nz, st->hTcxCfg->tcx_aldo_window_1_trunc, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, FULL_OVERLAP ); - - FOR( i = 0; i < nz / 2; i++ ) - { - // This implementation is diffrent in float code need to revisit to check its correctness. - st->hTcxEnc->old_out_fx[nz + overlap + i] = mult( wtda_audio_fx16[L_frame - 1 - i], st->hTcxCfg->tcx_aldo_window_1_trunc[i].v.re ); // Q0 + Q15 - Q15 -> Q0; - st->hTcxEnc->old_out_fx[nz / 2 + ( nz + overlap + i )] = mult( wtda_audio_fx16[nz / 2 + ( L_frame - 1 - i )], st->hTcxCfg->tcx_aldo_window_1_trunc[nz / 2 - 1 - i].v.im ); // Q0 + Q15 - Q15 -> Q0; - move16(); - move16(); - } - - Copy( wtda_audio_fx16 + sub( shr( overlap, 1 ), tcx_offset ), output_fx, st->L_frame ); /* Q0 */ - } - ELSE - { - Word16 tmp_q = Q_audio; - move16(); - Word32 ener_match_fx = SQRT2_FIXED; - move32(); - FOR( i = 0; i < input_frame; i++ ) - { - t_audio_fx[i] = Mpy_32_32( t_audio_fx[i], ener_match_fx ); /* Q12 - 1 -> Q11 */ - move32(); - } - - Q_audio = sub( Q_audio, 1 ); - scale_sig32( wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, tmp_q ) ); /* Q_audio */ - Inverse_Transform( t_audio_fx, &Q_audio, wtda_audio_fx32, is_transient, L_FRAME16k, inner_frame, st->element_mode ); - - - out_q = Q_audio; - move16(); - window_ola_fx( wtda_audio_fx32, output_fx, &out_q, st->hTcxEnc->old_out_fx, &old_q, L_FRAME16k, st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL ); - - Scale_sig( output_fx, L_FRAME16k, negate( out_q ) ); /* Q0 */ - Scale_sig( st->hTcxEnc->old_out_fx, L_FRAME32k, negate( old_q ) ); /* Q0 */ - st->hTcxEnc->Q_old_out = 0; - move16(); - } - - IF( st->element_mode > EVS_MONO ) - { - /* Store LB synthesis in case of switch to ACELP */ - Copy( output_fx, st->hLPDmem->old_exc, L_FRAME16k ); - st->hLPDmem->q_lpd_old_exc = 0; - move16(); - } - pop_wmops(); - - return; -} diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c index 6dc7bb5b9..11583ea11 100644 --- a/lib_enc/hq_core_enc_fx.c +++ b/lib_enc/hq_core_enc_fx.c @@ -7,6 +7,7 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ //#include "prot_fx.h" /* Function prototypes */ +#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ @@ -388,3 +389,361 @@ void HQ_core_enc_init_fx( return; } + +void hq_core_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *audio_fx, /* i : input audio signal Q0 */ + const Word16 input_frame_orig, /* i : frame length Q0*/ + const Word16 hq_core_type, /* i : HQ core type Q0*/ + const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ +) +{ + Word16 i, is_transient, num_bits, extra_unused; + + Word32 t_audio_fx[L_FRAME48k_EXT]; + Word16 wtda_audio_fx16[2 * L_FRAME48k]; + Word32 wtda_audio_fx32[2 * L_FRAME48k]; + Word16 two_frames_buffer[2 * L_FRAME48k]; + Word16 tmp; + Word16 Aq_old_fx[M + 1]; + Word16 output_fx[L_FRAME48k]; + Word16 Q_audio; + Word16 out_q = 0, old_q = 0; + move16(); + move16(); + Word16 inner_frame, input_frame, L_frame; + Word16 L_spec, overlap, nz, tcx_offset; + Word16 left_overlap, right_overlap; + BSTR_ENC_HANDLE hBstr = st->hBstr; + Word16 q = 0; + Word16 exp; + move16(); + + push_wmops( "hq_core_enc" ); + + set16_fx( wtda_audio_fx16, 0, 2 * L_FRAME48k ); + set32_fx( wtda_audio_fx32, 0, 2 * L_FRAME48k ); + st->Nb_ACELP_frames = 0; + move16(); + set_zero_fx( t_audio_fx, L_FRAME48k_EXT ); + /* set input_frame length */ + input_frame = input_frame_orig; /* Q0 */ + + /* Sanity check, it should never happen at the encoder side (no BFI) */ + IF( st->hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) + { + st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; + move16(); + } + ELSE + { + st->hTcxCfg->tcx_last_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode; + move16(); + } + st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; + move16(); + + /*-------------------------------------------------------------------------- + * Preprocessing in the first HQ frame after ACELP frame + * Find the number of bits for PVQ coding + * Write signaling information + *--------------------------------------------------------------------------*/ + + num_bits = BASOP_Util_Divide3232_Scale( st->total_brate, FRAMES_PER_SEC, &exp ); /* Q15-exp */ + num_bits = shr( num_bits, sub( 15, exp ) ); /* Q0 */ + extra_unused = 0; + move16(); + + /*-------------------------------------------------------------------------- + * Detect signal transition + *--------------------------------------------------------------------------*/ + + is_transient = detect_transient_fx( audio_fx, input_frame, 0, st ); /* Q0 */ + move16(); + + test(); + test(); + IF( st->element_mode > EVS_MONO && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) ) + { + /*-------------------------------------------------------------------------- + * IVAS switching frame + *--------------------------------------------------------------------------*/ + + L_spec = input_frame; + left_overlap = -1; + right_overlap = -1; + move16(); + move16(); + move16(); + + WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, TRANSITION_OVERLAP, FULL_OVERLAP, &left_overlap, &right_overlap, st->hTcxEnc->speech_TCX, &L_spec, wtda_audio_fx16, 1, 1 ); + + q = 0; + move16(); + Q_audio = sub( Q16, q ); + TCX_MDCT( wtda_audio_fx16, t_audio_fx, &Q_audio, left_overlap, sub( L_spec, shr( add( left_overlap, right_overlap ), 1 ) ), right_overlap, st->element_mode ); + Q_audio = sub( Q31, Q_audio ); +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( wtda_audio_fx16, wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, q ) ); /* Q_audio */ +#else + Copy_Scale_sig_16_32_DEPREC( wtda_audio_fx16, wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, q ) ); /* Q_audio */ +#endif + inner_frame = inner_frame_tbl[st->bwidth]; /* Q0 */ + L_spec = l_spec_ext_tbl[st->bwidth]; /* Q0 */ + is_transient = 0; + move16(); + move16(); + move16(); + } + ELSE + { + /*-------------------------------------------------------------------------- + * Windowing and time-domain aliasing + * DCT transform + *--------------------------------------------------------------------------*/ + Q_audio = 0; + move16(); + Scale_sig( st->old_input_signal_fx, input_frame, negate( st->q_old_inp ) ); /* Q0 */ + Scale_sig( st->input_fx, add( input_frame, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), negate( st->q_inp ) ); /* Q0 */ + st->q_old_inp = 0; + move16(); + st->q_inp = 0; + move16(); + Copy( st->old_input_signal_fx, two_frames_buffer, input_frame ); /* Q0 */ + Copy( audio_fx, two_frames_buffer + input_frame, input_frame ); /* Q0 */ + + wtda_fx( two_frames_buffer + input_frame, &Q_audio, wtda_audio_fx32, NULL, 0, + st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, input_frame ); + + test(); + IF( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) + { + /* Preprocessing in the first HQ frame after ACELP frame */ + core_switching_hq_prepare_enc_fx( st, &num_bits, input_frame, wtda_audio_fx32, two_frames_buffer + input_frame ); + + /* During ACELP->HQ core switching, limit the HQ core bitrate to 48kbps */ + IF( GT_16( num_bits, ACELP_48k_BITS ) ) + { + extra_unused = sub( num_bits, ACELP_48k_BITS ); + num_bits = ACELP_48k_BITS; + move16(); + } + } + + Word16 tmp_q = Q_audio; + move16(); + direct_transform_fx( wtda_audio_fx32, t_audio_fx, is_transient, input_frame, &Q_audio, st->element_mode ); + scale_sig32( wtda_audio_fx32, L_FRAME48k_EXT, sub( Q_audio, tmp_q ) ); /* Q_audio */ + + /* scale coefficients to their nominal level (8kHz) */ + IF( NE_16( input_frame, NORM_MDCT_FACTOR ) ) + { + UWord16 lsb; + tmp = mult_r( input_frame, 410 / 2 ); /* 1/8000 in Q15 */ + Word16 ener_match_fx = hq_nominal_scaling[tmp]; + move16(); + FOR( i = 0; i < input_frame; i++ ) + { + /*t_audio_q[i] *= ener_match; */ + Mpy_32_16_ss( t_audio_fx[i], ener_match_fx, &t_audio_fx[i], &lsb ); /* Q12 */ + move16(); + } + } + + /* limit encoded band-width according to the command-line OR BWD limitation */ + inner_frame = inner_frame_tbl[st->bwidth]; /* Q0 */ + L_spec = l_spec_tbl[st->bwidth]; /* Q0 */ + + move16(); + move16(); + + + IF( GT_16( input_frame, inner_frame ) ) + { + IF( EQ_16( is_transient, 1 ) ) + { + FOR( i = 1; i < NUM_TIME_SWITCHING_BLOCKS; i++ ) + { + tmp = shr( inner_frame, 2 ); + Copy32( t_audio_fx + i_mult2( i, shr( input_frame, 2 ) ), t_audio_fx + i_mult2( i, tmp ), tmp ); /* Q_audio */ + } + } + + set32_fx( t_audio_fx + inner_frame, 0, sub( input_frame, inner_frame ) ); + } + } + + + /* subtract signaling bits */ + num_bits = sub( num_bits, hBstr->nb_bits_tot ); /* Q0 */ + + /*-------------------------------------------------------------------------- + * High-band gain control in case of BWS + *--------------------------------------------------------------------------*/ + + IF( st->bwidth_sw_cnt > 0 ) + { + Word32 L_tmp; + tmp = BASOP_Util_Divide1616_Scale( 3, BWS_TRAN_PERIOD, &exp ); /* Q15-exp */ + shr( tmp, exp ); + L_tmp = L_deposit_h( tmp ); /* Q31-exp */ + IF( is_transient ) + { + FOR( i = 0; i < NUM_TIME_SWITCHING_BLOCKS; i++ ) + { + v_multc_fixed( t_audio_fx + add( i_mult2( i, shr( inner_frame, 2 ) ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ), L_tmp, t_audio_fx + add( i_mult2( i, shr( inner_frame, 2 ) ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ), sub( shr( inner_frame, 2 ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ) ); // Q_audio + Q31 - Q31 -> Q_audio + } + } + ELSE + { + v_multc_fixed( t_audio_fx + L_FRAME16k, L_tmp, t_audio_fx + L_FRAME16k, L_spec - L_FRAME16k ); // Q_audio + Q31 - Q31 -> Q_audio + } + } + + /*-------------------------------------------------------------------------- + * Classify whether to put extra bits for FER mitigation + *--------------------------------------------------------------------------*/ + + test(); + test(); + test(); + IF( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) && GT_32( st->core_brate, MINIMUM_RATE_TO_ENCODE_VOICING_FLAG ) ) + { + IF( Voicing_flag > 0 ) + { + push_indice( hBstr, IND_HQ_VOICING_FLAG, 1, 1 ); + num_bits = sub( num_bits, 1 ); + } + ELSE + { + push_indice( hBstr, IND_HQ_VOICING_FLAG, 0, 1 ); + num_bits = sub( num_bits, 1 ); + } + } + + /*-------------------------------------------------------------------------- + * Transform-domain encoding + *--------------------------------------------------------------------------*/ + + scale_sig32( t_audio_fx, L_FRAME48k_EXT, sub( Q12, Q_audio ) ); + scale_sig32( wtda_audio_fx32, 2 * L_FRAME48k, sub( Q12, Q_audio ) ); + Q_audio = 12; + move16(); + IF( EQ_16( hq_core_type, LOW_RATE_HQ_CORE ) ) + { + + hq_lr_enc_ivas_fx( st, t_audio_fx, inner_frame, &num_bits, is_transient ); + } + ELSE + { + /* HQ high rate encoder */ + hq_hr_enc_ivas_fx( st, t_audio_fx, L_spec, &num_bits, is_transient, vad_hover_flag ); + } + + /* write all unused bits to the bitstream */ + num_bits = add( num_bits, extra_unused ); + + WHILE( GT_16( num_bits, 16 ) ) + { + push_indice( hBstr, IND_UNUSED, 0, 16 ); + num_bits = sub( num_bits, 16 ); + } + + IF( num_bits != 0 ) + { + push_indice( hBstr, IND_UNUSED, 0, num_bits ); + } + + test(); + test(); + IF( st->element_mode > EVS_MONO && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) ) + { + overlap = st->hTcxCfg->tcx_mdct_window_length; /* Q0 */ + move16(); + + nz = NS2SA( st->sr_core, N_ZERO_MDCT_NS ); + move16(); + L_frame = sub( st->L_frame + st->hTcxCfg->tcx_offset, st->hTcxCfg->lfacNext ); + tcx_offset = st->hTcxCfg->lfacNext; + move16(); + + set16_fx( Aq_old_fx, 0, M + 1 ); /* Dummy filter */ + Aq_old_fx[0] = 1; + move16(); + + /* Code taken from InternalTCXDecoder() */ + Copy_Scale_sig_32_16( wtda_audio_fx32, wtda_audio_fx16, 2 * L_FRAME48k, negate( Q_audio ) ); // Q0 + TCX_MDCT_Inverse( t_audio_fx, sub( sub( 31, Q_audio ), 15 ), wtda_audio_fx16, overlap, sub( L_frame, overlap ), overlap, st->element_mode ); + + + /* Window current frame */ + Word16 tcx_offset_tmp; + + IF( tcx_offset < 0 ) + { + tcx_offset_tmp = negate( tcx_offset ); + } + ELSE + { + tcx_offset_tmp = 0; + move16(); + } + tcx_windowing_synthesis_current_frame( wtda_audio_fx16, st->hTcxCfg->tcx_aldo_window_2, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, /*st->hTcxCfg->tcx_mdct_window_length*/ st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, st->last_core == ACELP_CORE, st->hTcxCfg->tcx_last_overlap_mode, /*left mode*/ st->hTcxEnc->acelp_zir, st->hTcxEnc->Txnq, NULL, Aq_old_fx, st->hTcxCfg->tcx_mdct_window_trans, shr( st->L_frame, 1 ), tcx_offset_tmp, st->last_core, 0, 0 ); + + + /*Compute windowed synthesis in case of switching to ALDO windows in next frame*/ + Copy( wtda_audio_fx16 + sub( L_frame, nz ), st->hTcxEnc->old_out_fx, nz + overlap ); /* Q0 */ + set16_fx( st->hTcxEnc->old_out_fx + add( nz, overlap ), 0, nz ); + + tcx_windowing_synthesis_past_frame( st->hTcxEnc->old_out_fx + nz, st->hTcxCfg->tcx_aldo_window_1_trunc, st->hTcxCfg->tcx_mdct_window_half, st->hTcxCfg->tcx_mdct_window_minimum, overlap, st->hTcxCfg->tcx_mdct_window_half_length, st->hTcxCfg->tcx_mdct_window_min_length, FULL_OVERLAP ); + + FOR( i = 0; i < nz / 2; i++ ) + { + // This implementation is diffrent in float code need to revisit to check its correctness. + st->hTcxEnc->old_out_fx[nz + overlap + i] = mult( wtda_audio_fx16[L_frame - 1 - i], st->hTcxCfg->tcx_aldo_window_1_trunc[i].v.re ); // Q0 + Q15 - Q15 -> Q0; + st->hTcxEnc->old_out_fx[nz / 2 + ( nz + overlap + i )] = mult( wtda_audio_fx16[nz / 2 + ( L_frame - 1 - i )], st->hTcxCfg->tcx_aldo_window_1_trunc[nz / 2 - 1 - i].v.im ); // Q0 + Q15 - Q15 -> Q0; + move16(); + move16(); + } + + Copy( wtda_audio_fx16 + sub( shr( overlap, 1 ), tcx_offset ), output_fx, st->L_frame ); /* Q0 */ + } + ELSE + { + Word16 tmp_q = Q_audio; + move16(); + Word32 ener_match_fx = SQRT2_FIXED; + move32(); + FOR( i = 0; i < input_frame; i++ ) + { + t_audio_fx[i] = Mpy_32_32( t_audio_fx[i], ener_match_fx ); /* Q12 - 1 -> Q11 */ + move32(); + } + + Q_audio = sub( Q_audio, 1 ); + scale_sig32( wtda_audio_fx32, 2 * L_FRAME48k, sub( Q_audio, tmp_q ) ); /* Q_audio */ + Inverse_Transform( t_audio_fx, &Q_audio, wtda_audio_fx32, is_transient, L_FRAME16k, inner_frame, st->element_mode ); + + + out_q = Q_audio; + move16(); + window_ola_fx( wtda_audio_fx32, output_fx, &out_q, st->hTcxEnc->old_out_fx, &old_q, L_FRAME16k, st->hTcxCfg->tcx_last_overlap_mode, st->hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL ); + + Scale_sig( output_fx, L_FRAME16k, negate( out_q ) ); /* Q0 */ + Scale_sig( st->hTcxEnc->old_out_fx, L_FRAME32k, negate( old_q ) ); /* Q0 */ + st->hTcxEnc->Q_old_out = 0; + move16(); + } + + IF( st->element_mode > EVS_MONO ) + { + /* Store LB synthesis in case of switch to ACELP */ + Copy( output_fx, st->hLPDmem->old_exc, L_FRAME16k ); + st->hLPDmem->q_lpd_old_exc = 0; + move16(); + } + pop_wmops(); + + return; +} diff --git a/lib_enc/hq_env_enc.c b/lib_enc/hq_env_enc.c deleted file mode 100644 index e8859676c..000000000 --- a/lib_enc/hq_env_enc.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "wmc_auto.h" diff --git a/lib_enc/hq_hr_enc.c b/lib_enc/hq_hr_enc.c deleted file mode 100644 index 42f661f6e..000000000 --- a/lib_enc/hq_hr_enc.c +++ /dev/null @@ -1,280 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "ivas_prot_fx.h" -#include "prot_fx_enc.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*--------------------------------------------------------------------------* - * hq_hr_enc() - * - * HQ high rate encoding routine - *--------------------------------------------------------------------------*/ - -void hq_hr_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word32 *t_audio_fx, /* i/o: transform-domain coefficients Q12*/ - const Word16 length, /* i : length of spectrum Q0*/ - Word16 *num_bits, /* i/o: number of available bits Q0*/ - const Word16 is_transient, /* i : transient flag Q0*/ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ -) -{ - Word16 nb_sfm; - Word16 sum, hcode_l; - Word16 difidx[NB_SFM]; - Word16 normqlg2[NB_SFM], ynrm[NB_SFM]; - Word16 nf_idx; - Word16 bits; - Word16 LCmode; - Word16 shape_bits, num_sfm, numnrmibits; - Word16 hqswb_clas; - Word16 num_env_bands; - Word16 Npeaks, start_norm; - Word16 difidx_org[NB_SFM]; - Word16 R[NB_SFM]; - Word16 peaks[HVQ_MAX_PEAKS]; - Word16 sfmsize[NB_SFM], sfm_start[NB_SFM], sfm_end[NB_SFM]; - Word16 npulses[NB_SFM], maxpulse[NB_SFM]; - Word16 Rsubband[NB_SFM]; /* Q3 */ - Word32 t_audio_q_fx[L_SPEC48k_EXT]; - Word16 noise_level_fx[HVQ_BWE_NOISE_BANDS]; - Word16 hq_generic_offset; - Word16 hq_generic_exc_clas = 0; - move16(); - Word16 core_sfm; - Word16 har_freq_est1 = 0, har_freq_est2 = 0; - move16(); - move16(); - Word16 flag_dis = 1; - move16(); - const Word16 *subband_search_offset; - Word16 wBands[2]; - Word16 b_delta_env; - HQ_ENC_HANDLE hHQ_core = st->hHQ_core; - BSTR_ENC_HANDLE hBstr = st->hBstr; - Word16 att_fx; - Word16 t_audio_norm[L_FRAME48k_EXT]; - Word16 t_audio_q_norm[L_FRAME48k_EXT]; - Word32 nf_gains_fx[HVQ_NF_GROUPS], pe_gains_fx[HVQ_NF_GROUPS]; - Word16 hq_generic_fenv_fx[HQ_FB_FENV]; - /*------------------------------------------------------------------* - * Initializations - *------------------------------------------------------------------*/ - - Npeaks = 0; - move16(); - set16_fx( npulses, 0, NB_SFM ); - set16_fx( maxpulse, 0, NB_SFM ); - set16_fx( difidx_org, 0, NB_SFM ); - set32_fx( t_audio_q_fx, 0, L_FRAME48k ); - set32_fx( nf_gains_fx, 0, HVQ_NF_GROUPS ); - set32_fx( pe_gains_fx, 0, HVQ_NF_GROUPS ); - /*------------------------------------------------------------------* - * Classification - *------------------------------------------------------------------*/ - bits = hq_classifier_enc_ivas_fx( st, length, t_audio_fx, is_transient, &Npeaks, peaks, pe_gains_fx, nf_gains_fx, &hqswb_clas ); /* Q0 */ - *num_bits = sub( *num_bits, bits ); - move16(); - - /*------------------------------------------------------------------* - * Set quantization parameters - *------------------------------------------------------------------*/ - - hq_configure_fx( length, hqswb_clas, st->core_brate, &num_sfm, &nb_sfm, &start_norm, &num_env_bands, &numnrmibits, &hq_generic_offset, sfmsize, sfm_start, sfm_end ); - - /*------------------------------------------------------------------* - * Transient frame handling - *------------------------------------------------------------------*/ - /* Interleave MLT coefficients of 4 sub-vectors in case of transient frame */ - IF( is_transient ) - { - interleave_spectrum_ivas_fx( t_audio_fx, length ); - } - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); - v_multc_att32( t_audio_fx, att_fx, t_audio_fx, sfm_end[( num_sfm - 1 )] ); /* Q12 */ - } - - /*------------------------------------------------------------------* - * Scalar quantization of norms - * Encode norm indices - *------------------------------------------------------------------*/ - - /* calculate and quantize norms */ - calc_norm_ivas_fx( t_audio_fx, ynrm, normqlg2, start_norm, num_env_bands, sfmsize, sfm_start ); - /* create differential code of quantized norm indices */ - diff_envelope_coding_fx( is_transient, num_env_bands, start_norm, ynrm, normqlg2, difidx ); - - /* Find norm coding mode and calculate number of bits */ - hcode_l = encode_envelope_indices_ivas_fx( hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 0, NORMAL_HQ_CORE, is_transient ); /* Q0 */ - - *num_bits = sub( *num_bits, add( hcode_l, NORM0_BITS + FLAGS_BITS ) ); - move16(); - /* Encode norm indices */ - encode_envelope_indices_ivas_fx( hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 1, NORMAL_HQ_CORE, is_transient ); - - /*------------------------------------------------------------------* - * HQ GENERIC BWE encoding - *------------------------------------------------------------------*/ - - test(); - IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) - { - hq_generic_hf_encoding_fx( t_audio_fx, hq_generic_fenv_fx, hq_generic_offset, st, &hq_generic_exc_clas, length ); - - IF( EQ_16( hq_generic_exc_clas, HQ_GENERIC_SP_EXC ) ) - { - *num_bits = add( *num_bits, 1 ); /* conditional 1 bit saving for representing FD3 BWE excitation class */ - move16(); - } - map_hq_generic_fenv_norm_fx( hqswb_clas, hq_generic_fenv_fx, ynrm, normqlg2, num_env_bands, nb_sfm, hq_generic_offset ); - } - - /*------------------------------------------------------------------* - * Bit allocation - *------------------------------------------------------------------*/ - - ivas_hq_bit_allocation_fx( st->core_brate, length, hqswb_clas, num_bits, normqlg2, nb_sfm, sfmsize, noise_level_fx, R, Rsubband, &sum, &core_sfm, num_env_bands ); - - /*------------------------------------------------------------------* - * Normalize coefficients with quantized norms - *------------------------------------------------------------------*/ - IF( NE_16( hqswb_clas, HQ_HVQ ) ) - { - test(); - IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) - { - b_delta_env = calc_nor_delta_hf_ivas_fx( hBstr, t_audio_fx, ynrm, Rsubband, num_env_bands, nb_sfm, sfmsize, sfm_start, core_sfm ); /* Q0 */ - sum = sub( sum, b_delta_env ); - } - normalizecoefs_fx( t_audio_fx, ynrm, nb_sfm, sfm_start, sfm_end, t_audio_norm ); - } - Word16 Q_audio = 12, Q_shift; - move16(); - /*------------------------------------------------------------------* - * Quantize/code spectral fine structure using PVQ or HVQ - *------------------------------------------------------------------*/ - IF( EQ_16( hqswb_clas, HQ_HVQ ) ) - { - sum = hvq_enc_ivas_fx( st, st->core_brate, *num_bits, Npeaks, ynrm, R, peaks, nf_gains_fx, noise_level_fx, pe_gains_fx, t_audio_fx, t_audio_q_fx ); - *num_bits = sub( *num_bits, sum ); - move16(); - } - ELSE - { - shape_bits = pvq_core_enc_ivas_fx( hBstr, t_audio_norm, t_audio_q_norm, &Q_audio, sum, nb_sfm, sfm_start, sfm_end, sfmsize, Rsubband, R, npulses, maxpulse, HQ_CORE ); /* Q0 */ - *num_bits = add( *num_bits, sub( sum, shape_bits ) ); - move16(); - } - - test(); - IF( EQ_16( hqswb_clas, HQ_HVQ ) || EQ_16( hqswb_clas, HQ_HARMONIC ) ) - { - subband_search_offset = subband_search_offsets_13p2kbps_Har; /* Q0 */ - wBands[0] = SWB_SB_BW_LEN0_16KBPS_HAR; /* Q0 */ - wBands[1] = SWB_SB_BW_LEN1_16KBPS_HAR; /* Q0 */ - move16(); - move16(); - IF( EQ_16( hqswb_clas, HQ_HARMONIC ) ) - { - Q_shift = sub( SWB_BWE_LR_Qs, Q_audio ); - FOR( Word16 i = 0; i < 300; i++ ) - { - t_audio_q_fx[i] = L_shl( L_deposit_l( t_audio_q_norm[i] ), Q_shift ); /* Q12 */ - move32(); - } - } - har_est_fx( t_audio_q_fx, 300, &har_freq_est1, &har_freq_est2, &flag_dis, &hHQ_core->prev_frm_hfe2, subband_search_offset, wBands, &hHQ_core->prev_stab_hfe2 ); - - hHQ_core->prev_frm_hfe2 = har_freq_est2; - move16(); - } - - /* reset LR-HQ memories */ - hHQ_core->prev_frm_hfe2 = 0; /*reset*/ - hHQ_core->prev_stab_hfe2 = 0; - move16(); - move16(); - nf_idx = 0; - move16(); - test(); - test(); - test(); - IF( NE_16( is_transient, 1 ) && NE_16( hqswb_clas, HQ_HVQ ) && !( EQ_16( length, L_FRAME16k ) && LE_32( st->core_brate, HQ_32k ) ) ) - { - test(); - IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) - { - nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, s_max( core_sfm, sub( num_env_bands, 1 ) ) ); /* Q0 */ - push_indice( hBstr, IND_NF_IDX, nf_idx, 2 ); - } - ELSE - { - nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, core_sfm ); /* Q0 */ - push_indice( hBstr, IND_NF_IDX, nf_idx, 2 ); - } - } - - - /* updates */ - hHQ_core->prev_hqswb_clas = hqswb_clas; /* Q0 */ - move16(); - /* Prepare synthesis for LB generation in case of switch to ACELP */ - IF( NE_16( hqswb_clas, HQ_HVQ ) ) - { - apply_envelope_enc_ivas_fx( t_audio_q_norm, ynrm, num_sfm, sfm_start, sfm_end, t_audio_q_fx ); - scale_sig32( t_audio_q_fx, length, sub( Q12, Q_audio ) ); // Q12 - } - - IF( is_transient ) - { - ivas_de_interleave_spectrum_fx( t_audio_q_fx, length ); - } - - MVR2R_WORD32( t_audio_q_fx, t_audio_fx, length ); - - return; -} diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c index f73a926dc..4d4742cc1 100644 --- a/lib_enc/hq_hr_enc_fx.c +++ b/lib_enc/hq_hr_enc_fx.c @@ -5,9 +5,11 @@ #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ //#include "prot_fx.h" /* Function prototypes */ -#include "rom_com_fx.h" /* Static table prototypes */ -#include "rom_com.h" /* Static table prototypes */ -#include "prot_fx.h" /* Function prototypes */ +#include "rom_com_fx.h" /* Static table prototypes */ +#include "rom_com.h" /* Static table prototypes */ +#include "prot.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ +#include "ivas_prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ /*--------------------------------------------------------------------------* * hq_hr_enc_fx() @@ -264,3 +266,231 @@ void hq_hr_enc_fx( return; } + +void hq_hr_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word32 *t_audio_fx, /* i/o: transform-domain coefficients Q12*/ + const Word16 length, /* i : length of spectrum Q0*/ + Word16 *num_bits, /* i/o: number of available bits Q0*/ + const Word16 is_transient, /* i : transient flag Q0*/ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ +) +{ + Word16 nb_sfm; + Word16 sum, hcode_l; + Word16 difidx[NB_SFM]; + Word16 normqlg2[NB_SFM], ynrm[NB_SFM]; + Word16 nf_idx; + Word16 bits; + Word16 LCmode; + Word16 shape_bits, num_sfm, numnrmibits; + Word16 hqswb_clas; + Word16 num_env_bands; + Word16 Npeaks, start_norm; + Word16 difidx_org[NB_SFM]; + Word16 R[NB_SFM]; + Word16 peaks[HVQ_MAX_PEAKS]; + Word16 sfmsize[NB_SFM], sfm_start[NB_SFM], sfm_end[NB_SFM]; + Word16 npulses[NB_SFM], maxpulse[NB_SFM]; + Word16 Rsubband[NB_SFM]; /* Q3 */ + Word32 t_audio_q_fx[L_SPEC48k_EXT]; + Word16 noise_level_fx[HVQ_BWE_NOISE_BANDS]; + Word16 hq_generic_offset; + Word16 hq_generic_exc_clas = 0; + move16(); + Word16 core_sfm; + Word16 har_freq_est1 = 0, har_freq_est2 = 0; + move16(); + move16(); + Word16 flag_dis = 1; + move16(); + const Word16 *subband_search_offset; + Word16 wBands[2]; + Word16 b_delta_env; + HQ_ENC_HANDLE hHQ_core = st->hHQ_core; + BSTR_ENC_HANDLE hBstr = st->hBstr; + Word16 att_fx; + Word16 t_audio_norm[L_FRAME48k_EXT]; + Word16 t_audio_q_norm[L_FRAME48k_EXT]; + Word32 nf_gains_fx[HVQ_NF_GROUPS], pe_gains_fx[HVQ_NF_GROUPS]; + Word16 hq_generic_fenv_fx[HQ_FB_FENV]; + /*------------------------------------------------------------------* + * Initializations + *------------------------------------------------------------------*/ + + Npeaks = 0; + move16(); + set16_fx( npulses, 0, NB_SFM ); + set16_fx( maxpulse, 0, NB_SFM ); + set16_fx( difidx_org, 0, NB_SFM ); + set32_fx( t_audio_q_fx, 0, L_FRAME48k ); + set32_fx( nf_gains_fx, 0, HVQ_NF_GROUPS ); + set32_fx( pe_gains_fx, 0, HVQ_NF_GROUPS ); + /*------------------------------------------------------------------* + * Classification + *------------------------------------------------------------------*/ + bits = hq_classifier_enc_ivas_fx( st, length, t_audio_fx, is_transient, &Npeaks, peaks, pe_gains_fx, nf_gains_fx, &hqswb_clas ); /* Q0 */ + *num_bits = sub( *num_bits, bits ); + move16(); + + /*------------------------------------------------------------------* + * Set quantization parameters + *------------------------------------------------------------------*/ + + hq_configure_fx( length, hqswb_clas, st->core_brate, &num_sfm, &nb_sfm, &start_norm, &num_env_bands, &numnrmibits, &hq_generic_offset, sfmsize, sfm_start, sfm_end ); + + /*------------------------------------------------------------------* + * Transient frame handling + *------------------------------------------------------------------*/ + /* Interleave MLT coefficients of 4 sub-vectors in case of transient frame */ + IF( is_transient ) + { + interleave_spectrum_ivas_fx( t_audio_fx, length ); + } + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag ); + v_multc_att32( t_audio_fx, att_fx, t_audio_fx, sfm_end[( num_sfm - 1 )] ); /* Q12 */ + } + + /*------------------------------------------------------------------* + * Scalar quantization of norms + * Encode norm indices + *------------------------------------------------------------------*/ + + /* calculate and quantize norms */ + calc_norm_ivas_fx( t_audio_fx, ynrm, normqlg2, start_norm, num_env_bands, sfmsize, sfm_start ); + /* create differential code of quantized norm indices */ + diff_envelope_coding_fx( is_transient, num_env_bands, start_norm, ynrm, normqlg2, difidx ); + + /* Find norm coding mode and calculate number of bits */ + hcode_l = encode_envelope_indices_ivas_fx( hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 0, NORMAL_HQ_CORE, is_transient ); /* Q0 */ + + *num_bits = sub( *num_bits, add( hcode_l, NORM0_BITS + FLAGS_BITS ) ); + move16(); + /* Encode norm indices */ + encode_envelope_indices_ivas_fx( hBstr, num_env_bands, numnrmibits, difidx, &LCmode, 1, NORMAL_HQ_CORE, is_transient ); + + /*------------------------------------------------------------------* + * HQ GENERIC BWE encoding + *------------------------------------------------------------------*/ + + test(); + IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) + { + hq_generic_hf_encoding_fx( t_audio_fx, hq_generic_fenv_fx, hq_generic_offset, st, &hq_generic_exc_clas, length ); + + IF( EQ_16( hq_generic_exc_clas, HQ_GENERIC_SP_EXC ) ) + { + *num_bits = add( *num_bits, 1 ); /* conditional 1 bit saving for representing FD3 BWE excitation class */ + move16(); + } + map_hq_generic_fenv_norm_fx( hqswb_clas, hq_generic_fenv_fx, ynrm, normqlg2, num_env_bands, nb_sfm, hq_generic_offset ); + } + + /*------------------------------------------------------------------* + * Bit allocation + *------------------------------------------------------------------*/ + + ivas_hq_bit_allocation_fx( st->core_brate, length, hqswb_clas, num_bits, normqlg2, nb_sfm, sfmsize, noise_level_fx, R, Rsubband, &sum, &core_sfm, num_env_bands ); + + /*------------------------------------------------------------------* + * Normalize coefficients with quantized norms + *------------------------------------------------------------------*/ + IF( NE_16( hqswb_clas, HQ_HVQ ) ) + { + test(); + IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) + { + b_delta_env = calc_nor_delta_hf_ivas_fx( hBstr, t_audio_fx, ynrm, Rsubband, num_env_bands, nb_sfm, sfmsize, sfm_start, core_sfm ); /* Q0 */ + sum = sub( sum, b_delta_env ); + } + normalizecoefs_fx( t_audio_fx, ynrm, nb_sfm, sfm_start, sfm_end, t_audio_norm ); + } + Word16 Q_audio = 12, Q_shift; + move16(); + /*------------------------------------------------------------------* + * Quantize/code spectral fine structure using PVQ or HVQ + *------------------------------------------------------------------*/ + IF( EQ_16( hqswb_clas, HQ_HVQ ) ) + { + sum = hvq_enc_ivas_fx( st, st->core_brate, *num_bits, Npeaks, ynrm, R, peaks, nf_gains_fx, noise_level_fx, pe_gains_fx, t_audio_fx, t_audio_q_fx ); + *num_bits = sub( *num_bits, sum ); + move16(); + } + ELSE + { + shape_bits = pvq_core_enc_ivas_fx( hBstr, t_audio_norm, t_audio_q_norm, &Q_audio, sum, nb_sfm, sfm_start, sfm_end, sfmsize, Rsubband, R, npulses, maxpulse, HQ_CORE ); /* Q0 */ + *num_bits = add( *num_bits, sub( sum, shape_bits ) ); + move16(); + } + + test(); + IF( EQ_16( hqswb_clas, HQ_HVQ ) || EQ_16( hqswb_clas, HQ_HARMONIC ) ) + { + subband_search_offset = subband_search_offsets_13p2kbps_Har; /* Q0 */ + wBands[0] = SWB_SB_BW_LEN0_16KBPS_HAR; /* Q0 */ + wBands[1] = SWB_SB_BW_LEN1_16KBPS_HAR; /* Q0 */ + move16(); + move16(); + IF( EQ_16( hqswb_clas, HQ_HARMONIC ) ) + { + Q_shift = sub( SWB_BWE_LR_Qs, Q_audio ); + FOR( Word16 i = 0; i < 300; i++ ) + { + t_audio_q_fx[i] = L_shl( L_deposit_l( t_audio_q_norm[i] ), Q_shift ); /* Q12 */ + move32(); + } + } + har_est_fx( t_audio_q_fx, 300, &har_freq_est1, &har_freq_est2, &flag_dis, &hHQ_core->prev_frm_hfe2, subband_search_offset, wBands, &hHQ_core->prev_stab_hfe2 ); + + hHQ_core->prev_frm_hfe2 = har_freq_est2; + move16(); + } + + /* reset LR-HQ memories */ + hHQ_core->prev_frm_hfe2 = 0; /*reset*/ + hHQ_core->prev_stab_hfe2 = 0; + move16(); + move16(); + nf_idx = 0; + move16(); + test(); + test(); + test(); + IF( NE_16( is_transient, 1 ) && NE_16( hqswb_clas, HQ_HVQ ) && !( EQ_16( length, L_FRAME16k ) && LE_32( st->core_brate, HQ_32k ) ) ) + { + test(); + IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) ) + { + nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, s_max( core_sfm, sub( num_env_bands, 1 ) ) ); /* Q0 */ + push_indice( hBstr, IND_NF_IDX, nf_idx, 2 ); + } + ELSE + { + nf_idx = noise_adjust_fx( t_audio_norm, 12, R, sfm_start, sfm_end, core_sfm ); /* Q0 */ + push_indice( hBstr, IND_NF_IDX, nf_idx, 2 ); + } + } + + + /* updates */ + hHQ_core->prev_hqswb_clas = hqswb_clas; /* Q0 */ + move16(); + /* Prepare synthesis for LB generation in case of switch to ACELP */ + IF( NE_16( hqswb_clas, HQ_HVQ ) ) + { + apply_envelope_enc_ivas_fx( t_audio_q_norm, ynrm, num_sfm, sfm_start, sfm_end, t_audio_q_fx ); + scale_sig32( t_audio_q_fx, length, sub( Q12, Q_audio ) ); // Q12 + } + + IF( is_transient ) + { + ivas_de_interleave_spectrum_fx( t_audio_q_fx, length ); + } + + MVR2R_WORD32( t_audio_q_fx, t_audio_fx, length ); + + return; +} diff --git a/lib_enc/hq_lr_enc.c b/lib_enc/hq_lr_enc.c deleted file mode 100644 index d0941db74..000000000 --- a/lib_enc/hq_lr_enc.c +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "stl.h" -#include "basop_util.h" -#include "wmc_auto.h" diff --git a/lib_enc/hvq_enc.c b/lib_enc/hvq_enc.c deleted file mode 100644 index adf7751a1..000000000 --- a/lib_enc/hvq_enc.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c deleted file mode 100644 index 1d4964ab8..000000000 --- a/lib_enc/init_enc.c +++ /dev/null @@ -1,1215 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "prot.h" -#include "ivas_prot.h" -#include "prot_fx.h" -#include "ivas_cnst.h" -#include "wmc_auto.h" -#include "ivas_prot_fx.h" -#include "prot_fx_enc.h" -ivas_error init_encoder_ivas_fx( - Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - const Word16 idchan, /* i : channel ID */ - const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ - const Word16 interval_SID, /* i : interval for SID update */ - const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const Word32 element_brate /* i : element bitrate */ -) -{ - Word16 i; - ivas_error error; - Word32 igf_brate; - - error = IVAS_ERR_OK; - move32(); - - /*-----------------------------------------------------------------* - * General parameters - *-----------------------------------------------------------------*/ - - IF( st->Opt_AMR_WB ) - { - st->last_core = AMR_WB_CORE; - } - ELSE - { - st->last_core = -1; - } - move16(); - - st->L_frame = L_FRAME; - move16(); - st->last_coder_type = GENERIC; - move16(); - st->coder_type = GENERIC; - move16(); - st->last_total_brate = st->total_brate; - move32(); - st->last_bits_frame_nominal = -1; - move16(); - st->last_total_brate_cng = -1; - move16(); - st->last_core_brate = st->total_brate; - move32(); - st->dtx_sce_sba = 0; - move16(); - st->extl = -1; - move16(); - st->last_extl = -1; - move16(); - st->last_L_frame = L_FRAME; - move16(); - st->rate_switching_reset = 0; - move16(); - st->rate_switching_reset_16kHz = 0; - move16(); - st->clas = UNVOICED_CLAS; - move16(); - st->low_rate_mode = 0; - move16(); - st->ini_frame = 0; - move16(); - st->inactive_coder_type_flag = 0; - move16(); - st->sba_br_sw_while_no_data = 0; - move16(); - - st->coder_type_raw = VOICED; - move16(); - st->last_coder_type_raw = st->coder_type_raw; - move16(); - - st->flag_ACELP16k = set_ACELP_flag_IVAS( st->element_mode, st->total_brate, st->total_brate, idchan, 0, -1, -1 ); - move16(); - - st->is_ism_format = 0; - move16(); - - IF( NE_16( ism_mode, ISM_MODE_NONE ) ) - { - st->is_ism_format = 1; - move16(); - } - - /*-----------------------------------------------------------------* - * Bitstream - *-----------------------------------------------------------------*/ - - IF( !vad_only_flag ) - { - IF( ( st->hBstr = (BSTR_ENC_HANDLE) malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Bitstream structure\n" ) ); - } - - /* set pointer to the buffer of indices */ - st->hBstr->ind_list = st_ivas->ind_list; - st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; - st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; - st->hBstr->nb_ind_tot = 0; - move16(); - st->hBstr->nb_bits_tot = 0; - move16(); - st->hBstr->st_ivas = st_ivas; - } - ELSE - { - st->hBstr = NULL; - } - - /*-----------------------------------------------------------------* - * Pre-processing and ACELP core parameters - *-----------------------------------------------------------------*/ - - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); - Copy( GEWB_Ave_fx, st->lsfoldbfi0_fx, M ); - Copy( GEWB_Ave_fx, st->lsfoldbfi1_fx, M ); - Copy( GEWB_Ave_fx, st->lsf_adaptive_mean_fx, M ); - - st->next_force_safety_net = 0; - move16(); - - st->pstreaklen = 0; - move16(); - st->streaklimit_fx = MAX_WORD16; - move16(); - set16_fx( st->mem_MA_fx, 0, M ); - - init_gp_clip_fx( st->clip_var_fx ); - pitch_ol_init_fx( &st->old_thres_fx, &st->old_pitch, &st->delta_pit, &st->old_corr_fx ); - set16_fx( st->old_wsp_fx, 0, L_WSP_MEM ); - st->exp_old_wsp = 0; - move16(); - set16_fx( st->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); // Needs to change depending on usage. - st->Q_old_wsp2 = 0; - move16(); - - st->mem_preemph_fx = 0; - move16(); - st->mem_preemph16k_fx = 0; - move16(); - st->mem_preemph_enc = 0; - move16(); - st->exp_mem_preemph_enc = 0; - move16(); - -#if 1 // TODO: Float Initializations. To be removed later - st->active_cnt = 0; - move16(); -#endif - - st->pst_mem_deemp_err_fx = 0; - move16(); - st->pst_lp_ener_fx = 0; - move16(); - - /* AVQ pre-quantizer memory */ - st->mem_preemp_preQ_fx = 0; - move16(); - st->mem_deemp_preQ_fx = 0; - move16(); - st->last_nq_preQ = 0; - move16(); - st->last_code_preq = 0; - move16(); - st->use_acelp_preq = 0; - move16(); - st->last_harm_flag_acelp = 0; - move16(); - - /* (Decimated) Weighted Speech Memory */ - st->mem_wsp_enc = 0; - move16(); - st->mem_wsp_fx = 0; - move16(); - st->mem_wsp_q = 0; - move16(); - set16_fx( st->mem_decim2_fx, 0, 3 ); - set32_fx( st->Bin_E_fx, 0, L_FFT ); - st->q_Bin_E = Q31; - move16(); - st->ee_old_fx = 640; /* 10.0f in Q6 */ - move16(); - st->Nb_ACELP_frames = 0; - move16(); - st->audio_frame_cnt = AUDIO_COUNTER_INI; /* Initialization of the audio frame counter mildly into the audio mode */ - move16(); - - /* adaptive lag window memory */ - st->old_pitch_la = 0; - move16(); - - st->prev_Q_new = 0; - move16(); - - IF( EQ_32( st->input_Fs, 8000 ) ) - { - st->min_band = 1; - move16(); - st->max_band = 16; - move16(); - } - ELSE - { - st->min_band = 0; - move16(); - st->max_band = 19; - move16(); - } - - IF( st->Opt_AMR_WB ) - { - Copy( mean_isf_amr_wb_fx, st->lsf_old_fx, M ); - E_LPC_isf_isp_conversion( st->lsf_old_fx, st->lsp_old1_fx, M ); - } - ELSE - { - Copy( GEWB_Ave_fx, st->lsf_old_fx, M ); - lsf2lsp_fx( st->lsf_old_fx, st->lsp_old1_fx, M, INT_FS_12k8 ); - } - - Copy( st->lsf_old_fx, st->lsf_old1_fx, M ); - Copy( st->lsp_old1_fx, st->lsp_old_fx, M ); - Copy( st->lsp_old_fx, st->lsp_old16k_fx, M ); - Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); - - st->stab_fac_fx = 0; - move16(); - - /* Bass post-filter memories - encoder side of MODE2 */ - st->bpf_off = 0; - move16(); - st->pst_mem_deemp_err_fx = 0; - move16(); - st->pst_lp_ener_fx = 0; - move16(); - - /* TC coder type */ - st->tc_cnt = 0; - move16(); - - /* find_uv() parameters */ - st->old_dE1_fx = 0; - move16(); - st->old_ind_deltaMax = 0; - move16(); - set32_fx( st->old_enr_ssf_fx, 0, shl( NB_SSF, 1 ) ); - st->spike_hyst = -1; - move16(); - - /* stereo switching memories */ - st->mem_preemph_DFT_fx = 0; - move16(); - set16_fx( st->inp_12k8_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_12k8, L_MEM_RECALC_12K8 ), L_FILT ) ); - st->mem_preemph16k_DFT_fx = 0; - move16(); - set16_fx( st->inp_16k_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_16k, L_MEM_RECALC_16K ), L_FILT16k ) ); - - st->sharpFlag = 0; - move16(); - - /* Stationary noise UV modification */ - st->ge_sm_fx = L_deposit_l( 640 ); /*Q(GE_SHIFT)*/ - move16(); - st->uv_count = 0; - move16(); - st->act_count = 3; - move16(); - Copy( st->lsp_old_fx, st->lspold_s_fx, M ); - st->noimix_seed = RANDOM_INITSEED; - move16(); - st->min_alpha_fx = 32767; - move16(); - st->exc_pe_fx = 0; - move16(); - st->Q_stat_noise = 15; - move16(); - /* FEC */ - st->last_clas = UNVOICED_CLAS; - move16(); - st->prev_fmerit = 0; - move16(); - st->fmerit_dt = 0; - move16(); - st->Last_pulse_pos = 0; - move16(); - - FOR( i = 0; i < shl( NB_SUBFR16k, 1 ); i++ ) - { - st->old_pitch_buf_fx[i] = L_SUBFR_Q6; - move16(); - } - - /* mode1 core switching */ - st->old_Es_pred_fx = 0; - move16(); - set16_fx( st->old_Aq_12_8_fx + 1, 0, M ); - st->old_Aq_12_8_fx[0] = ONE_IN_Q12; - move16(); - - /* stable short pitch detection */ - st->voicing0_sm_fx = 0; - move16(); - st->voicing_sm_fx = 0; - move16(); - st->LF_EnergyRatio_sm_fx = 1; - move16(); - st->predecision_flag = 0; - move16(); - st->diff_sm_fx = 0; - move32(); - st->energy_sm_fx = 0; - move32(); - - set16_fx( st->pitch, L_SUBFR, 3 ); - set16_fx( st->voicing_fx, 0, 3 ); - - /*-----------------------------------------------------------------* - * General signal buffers - *-----------------------------------------------------------------*/ - - IF( !vad_only_flag ) - { - IF( ( st->hSignalBuf = (SIGNAL_BUFFERS_ENC_HANDLE) malloc( sizeof( SIGNAL_BUFFERS_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Signal buffers\n" ) ); - } - - st->Bin_E_old_fx = st->hSignalBuf->Bin_E_old_fx; - st->mem_decim_fx = st->hSignalBuf->mem_decim_fx; - st->mem_decim16k_fx = st->hSignalBuf->mem_decim16k_fx; - st->old_inp_12k8_fx = st->hSignalBuf->old_inp_12k8_fx; - st->old_inp_16k_fx = st->hSignalBuf->old_inp_16k_fx; - st->buf_speech_enc_pe = st->hSignalBuf->buf_speech_enc_pe; - st->buf_synth = st->hSignalBuf->buf_synth; - st->buf_speech_enc = st->hSignalBuf->buf_speech_enc; - st->buf_wspeech_enc = st->hSignalBuf->buf_wspeech_enc; - - set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); - st->q_Bin_E_old = Q31; - move16(); - set16_fx( st->hSignalBuf->buf_speech_enc, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); - st->exp_buf_speech_enc = 0; - move16(); - set16_fx( st->hSignalBuf->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); - st->exp_buf_wspeech_enc = 0; - move16(); - /* initializations */ -#ifndef MSAN_FIX - set32_fx( st->Bin_E_old_fx, 0, shr( L_FFT, 2 ) ); -#else - set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); -#endif - st->q_Bin_E_old = Q31; - move16(); - set16_fx( st->mem_decim_fx, 0, shl( L_FILT_MAX, 1 ) ); - set16_fx( st->mem_decim16k_fx, 0, shl( L_FILT_MAX, 1 ) ); - set16_fx( st->old_inp_12k8_fx, 0, L_INP_MEM ); - set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM ); - st->exp_old_inp_16k = 0; - st->exp_old_inp_12k8 = 0; - move16(); - move16(); - - st->input_buff_fx = st->hSignalBuf->input_buff; - st->input_buff32_fx = st->hSignalBuf->input_buff32; - set16_fx( st->input_buff_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); - st->q_inp = Q15; - move16(); - st->q_old_inp = Q15; - move16(); - set32_fx( st->input_buff32_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); - st->q_inp32 = Q31; - move16(); - st->old_input_signal_fx = st->input_buff_fx; - /* st->input_Fs / FRAMES_PER_SEC */ - Word16 frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - - IF( st->element_mode == EVS_MONO ) - { - st->input32_fx = st->input_buff32_fx + st->input_Fs / FRAMES_PER_SEC + NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ); - st->input_fx = st->input_buff_fx + add( frame_length, (Word16) NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); - } - ELSE - { - st->input32_fx = st->input_buff32_fx + Mpy_32_32( st->input_Fs, 42949673 ) /* 1/50 in Q31*/; // st->input_Fs / FRAMES_PER_SEC - st->input_fx = st->input_buff_fx + frame_length; - } -#if 1 // TODO: To be removed later -#endif - } - ELSE - { - st->hSignalBuf = NULL; - st->Bin_E_old_fx = NULL; - st->mem_decim_fx = NULL; - st->mem_decim16k_fx = NULL; - st->old_inp_12k8_fx = NULL; - st->old_inp_16k_fx = NULL; - st->buf_speech_enc_pe = NULL; - st->buf_synth = NULL; - st->buf_speech_enc = NULL; - st->buf_wspeech_enc = NULL; - st->input_buff_fx = NULL; -#if 1 -#endif - } - - /*-----------------------------------------------------------------* - * Noise estimator - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) - { - IF( ( st->hNoiseEst = (NOISE_EST_HANDLE) malloc( sizeof( NOISE_EST_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Noise estimation\n" ); - } - - noise_est_init_ivas_fx( st->hNoiseEst ); - } - ELSE - { - st->hNoiseEst = NULL; - } - - /*-----------------------------------------------------------------* - * VAD - *-----------------------------------------------------------------*/ - - st->vad_flag = 1; - move16(); - st->localVAD = 0; - move16(); - - IF( ( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) && ( !vad_only_flag ) ) - { - IF( ( st->hVAD = (VAD_HANDLE) malloc( sizeof( VAD_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VAD\n" ) ); - } - - wb_vad_init_ivas_fx( st->hVAD ); - } - ELSE - { - st->hVAD = NULL; - } - st->Pos_relE_cnt = 20; - move16(); - - /* CLDFB-based VAD */ - IF( st->element_mode == EVS_MONO ) - { - /* This is done to as in EVS T_CldfbVadState structure is present in Encoder State */ - /* - if ( ( st->hVAD_CLDFB = (VAD_CLDFB_HANDLE) malloc( sizeof( T_CldfbVadState ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB VAD\n" ) ); - } - */ - st->hVAD_CLDFB = &st->vad_st; - - vad_init_fx( st->hVAD_CLDFB ); - } - ELSE - { - st->hVAD_CLDFB = NULL; - } - - /*-----------------------------------------------------------------* - * Speech/music classifier - *-----------------------------------------------------------------*/ - - IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) - { - IF( ( st->hSpMusClas = (SP_MUS_CLAS_HANDLE) malloc( sizeof( SP_MUS_CLAS_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Speech/music classifier\n" ) ); - } - - speech_music_clas_init_ivas_fx( st->hSpMusClas ); - st->sp_aud_decision0 = 0; - move16(); - st->sp_aud_decision1 = 0; - move16(); - st->sp_aud_decision2 = 0; - move16(); - } - ELSE - { - st->hSpMusClas = NULL; - } - - - /*-----------------------------------------------------------------* - * WB, SWB and FB bandwidth detector - *-----------------------------------------------------------------*/ - - st->lt_mean_NB_fx = 0; - move16(); - st->lt_mean_WB_fx = 0; - move16(); - st->lt_mean_SWB_fx = 0; - move16(); - st->count_WB = BWD_COUNT_MAX; - move16(); - st->count_SWB = BWD_COUNT_MAX; - move16(); - st->count_FB = BWD_COUNT_MAX; - move16(); - st->bwidth = st->max_bwidth; - move16(); - st->last_input_bwidth = st->bwidth; - move16(); - st->last_bwidth = st->bwidth; - move16(); - st->last_bwidth_cng = st->bwidth; - move16(); - st->bwidth_sw_cnt = 0; - move16(); - - - /*-----------------------------------------------------------------* - * DTX - *-----------------------------------------------------------------*/ - - st->lp_speech_fx = 11520; /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ - move16(); - st->lp_noise_fx = 0; - move16(); - st->flag_noisy_speech_snr = 0; - move16(); - st->fd_cng_reset_flag = 0; - move16(); - st->cng_type = -1; - move16(); - st->bckr_tilt_lt = 0; - move16(); - st->active_cnt = 0; - move16(); - - test(); - test(); - test(); - test(); - IF( ( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) - { - IF( ( st->hDtxEnc = (DTX_ENC_HANDLE) malloc( sizeof( DTX_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); - } - dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); - } - ELSE - { - st->hDtxEnc = NULL; - } - - /*-----------------------------------------------------------------* - * No other handles needed to be allocated for front-VAD structure - *-----------------------------------------------------------------*/ - - IF( vad_only_flag ) - { - st->hTdCngEnc = NULL; - st->cldfbAnaEnc = NULL; - st->hFdCngEnc = NULL; - st->hSC_VBR = NULL; - st->hAmrwb_IO = NULL; - st->hLPDmem = NULL; - st->hGSCEnc = NULL; - st->hBWE_TD = NULL; - st->cldfbSynTd = NULL; - st->hBWE_FD = NULL; - st->hHQ_core = NULL; - st->hRF = NULL; - st->hTECEnc = NULL; - st->hTcxEnc = NULL; - st->hTcxCfg = NULL; - st->hIGFEnc = NULL; - st->hPlcExt = NULL; - st->hTranDet = NULL; - - st->element_mode = IVAS_SCE; - move16(); - st->idchan = 100; /* indicates hCoreCoderVAD */ - move16(); - st->core = -1; - move16(); - st->rf_mode = 0; - move16(); - - return error; - } - - /*-----------------------------------------------------------------* - * LP-CNG - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - test(); - IF( ( ( idchan == 0 && st->Opt_DTX_ON && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || st->element_mode == EVS_MONO ) && !( EQ_16( ism_mode, ISM_MODE_PARAM ) || EQ_16( ism_mode, ISM_MODE_DISC ) ) ) - { - IF( ( st->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); - } - - td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); - } - ELSE - { - st->hTdCngEnc = NULL; - } - - /*-----------------------------------------------------------------* - * CLDFB & resampling tools parameters - *-----------------------------------------------------------------*/ - test(); - test(); - test(); - IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) - { - IF( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE - { - st->cldfbAnaEnc = NULL; - } - - st->energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ - move32(); - st->sf_energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ - move16(); - - /*-----------------------------------------------------------------* - * SC-VBR parameters - *-----------------------------------------------------------------*/ - - test(); - IF( st->Opt_SC_VBR || st->element_mode == EVS_MONO ) - { - IF( ( st->hSC_VBR = (SC_VBR_ENC_HANDLE) malloc( sizeof( SC_VBR_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SC-VBR\n" ) ); - } - - sc_vbr_enc_init_fx( st->hSC_VBR ); - } - ELSE - { - st->hSC_VBR = NULL; - } - - st->last_Opt_SC_VBR = 0; - move16(); - - - /*-----------------------------------------------------------------* - * AMR-WB IO initialization - *-----------------------------------------------------------------*/ - - test(); - IF( st->Opt_AMR_WB || st->element_mode == EVS_MONO ) - { - IF( ( st->hAmrwb_IO = (AMRWB_IO_ENC_HANDLE) malloc( sizeof( AMRWB_IO_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); - } - - amr_wb_enc_init_fx( st->hAmrwb_IO ); - } - ELSE - { - st->hAmrwb_IO = NULL; - } - - /*-----------------------------------------------------------------* - * ACELP LPDmem - *-----------------------------------------------------------------*/ - - test(); - test(); - IF( ( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); - } - - LPDmem_enc_init_ivas_fx( st->hLPDmem ); - } - ELSE - { - st->hLPDmem = NULL; - } - - /*-----------------------------------------------------------------* - * parameters for AC coder type (GSC) - *-----------------------------------------------------------------*/ - - st->GSC_noisy_speech = 0; - move16(); - st->GSC_IVAS_mode = 0; - move16(); - - test(); - test(); - IF( ( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - IF( ( st->hGSCEnc = (GSC_ENC_HANDLE) malloc( sizeof( GSC_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); - } - - GSC_enc_init_fx( st->hGSCEnc ); - } - ELSE - { - st->hGSCEnc = NULL; - } - - /*-----------------------------------------------------------------* - * TBE parameters - *-----------------------------------------------------------------*/ - - test(); - IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st->hBWE_TD = (TD_BWE_ENC_HANDLE) malloc( sizeof( TD_BWE_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); - } - - IF( ( error = openCldfb_ivas_enc( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) - { - return error; - } - - InitSWBencBuffer_ivas_fx( st ); - ResetSHBbuffer_Enc_fx( st ); - } - ELSE - { - st->hBWE_TD = NULL; - st->cldfbSynTd = NULL; - } - - /*-----------------------------------------------------------------* - * SWB BWE parameters - *-----------------------------------------------------------------*/ - - test(); - IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); - } - - fd_bwe_enc_init_fx( st->hBWE_FD ); -#ifdef MSAN_FIX - st->Q_old_wtda = 0; - move16(); -#endif - } - ELSE - { - st->hBWE_FD = NULL; - } - - /*-----------------------------------------------------------------* - * HQ core parameters - *-----------------------------------------------------------------*/ - - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) - { - IF( ( st->hHQ_core = (HQ_ENC_HANDLE) malloc( sizeof( HQ_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); - } - - HQ_core_enc_init_fx( st->hHQ_core ); - } - ELSE - { - st->hHQ_core = NULL; - } - - /* init memory for detect_transient(), used by HQ core and swb_bwe_enc */ - st->old_hpfilt_in_fx = 0; - move16(); - st->old_hpfilt_out_fx = 0; - move16(); - st->EnergyLT_fx = 0; - move32(); - st->Energy_Old_fx = 0; - move32(); - st->TransientHangOver = 0; - move16(); - st->EnergyLT_fx_exp = 30; - move16(); - st->last_enerBuffer_exp = 0; - move16(); - - /*-----------------------------------------------------------------* - * Channel-aware mode - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - IF( !st->Opt_RF_ON || ( NE_16( st->bwidth, WB ) && NE_16( st->bwidth, SWB ) ) || NE_32( st->total_brate, ACELP_13k20 ) ) - { - st->rf_mode = 0; - move16(); - } - ELSE - { - st->rf_mode = st->Opt_RF_ON; - move16(); - } - - st->rf_mode_last = st->rf_mode; - move16(); - - test(); - IF( st->Opt_RF_ON || st->element_mode == EVS_MONO ) - { - IF( ( st->hRF = (RF_ENC_HANDLE) malloc( sizeof( RF_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for RF\n" ) ); - } - - /* initialize RF indice buffers */ - reset_rf_indices_fx( st ); - } - ELSE - { - st->hRF = NULL; - } - - /*-----------------------------------------------------------------* - * Temporal Envelope Coding - *-----------------------------------------------------------------*/ - - IF( st->element_mode == EVS_MONO ) - { - IF( ( st->hTECEnc = (TEC_ENC_HANDLE) malloc( sizeof( TEC_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TEC\n" ) ); - } - } - ELSE - { - st->hTECEnc = NULL; - } - /* note: initialization done later in init_coder_ace_plus() */ - - /*-----------------------------------------------------------------* - * TCX core - *-----------------------------------------------------------------*/ - - // ToDo: reduction possible for MCT_CHAN_MODE_LFE channel - test(); - IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - IF( ( st->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxEnc\n" ) ); - } - set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); - st->hTcxEnc->spectrum_long_e = 0; - move16(); - /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ - st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx; - st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; - move32(); - move32(); - st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; - move16(); - move16(); -#if 1 - // set_f( st->hTcxEnc->spectrum_long, 0, N_MAX ); - // st->hTcxEnc->spectrum[0] = st->hTcxEnc->spectrum_long; - // st->hTcxEnc->spectrum[1] = st->hTcxEnc->spectrum_long + N_TCX10_MAX; - // set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); -#endif - - set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k ); - st->hTcxEnc->Q_old_out = 0; - move16(); - - /* MDCT selector */ - MDCT_selector_reset_fx( st->hTcxEnc ); - - /* MDCT classifier */ - MDCT_classifier_reset_fx( st->hTcxEnc ); - - IF( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); - } - } - ELSE - { - st->hTcxEnc = NULL; - st->hTcxCfg = NULL; - } - - /*-----------------------------------------------------------------* - * IGF - *-----------------------------------------------------------------*/ - - igf_brate = st->total_brate; - move32(); - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->element_mode, IVAS_SCE ) && ( EQ_16( st_ivas->hEncoderConfig->ivas_format, ISM_FORMAT ) || EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) ) - { - igf_brate = L_sub( st->total_brate, i_mult( ISM_NB_BITS_METADATA_NOMINAL, FRAMES_PER_SEC ) ); - } - ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && ( EQ_16( st_ivas->hEncoderConfig->ivas_format, SBA_FORMAT ) || - EQ_16( st_ivas->hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) || - EQ_16( st_ivas->hEncoderConfig->ivas_format, MC_FORMAT ) || - EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_FORMAT ) ) ) ) - { - /* use nominal bitrates for DFT Stereo and (O)SBA, same as in stereo_dft_config()/ivas_spar_config() */ - IF( EQ_32( element_brate, IVAS_13k2 ) ) - { - igf_brate = ACELP_9k60; - } - ELSE IF( EQ_32( element_brate, IVAS_16k4 ) ) - { - igf_brate = ACELP_13k20; - } - ELSE IF( EQ_32( element_brate, IVAS_24k4 ) ) - { - igf_brate = ACELP_16k40; - } - ELSE IF( EQ_32( element_brate, IVAS_32k ) ) - { - igf_brate = ACELP_24k40; - } - } - ELSE IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - igf_brate = element_brate; - } - move32(); - test(); - IF( EQ_16( st->codec_mode, MODE2 ) || GT_16( st->element_mode, EVS_MONO ) ) - { - st->igf = getIgfPresent_fx( st->element_mode, igf_brate, st->max_bwidth, st->rf_mode ); - } - ELSE - { - st->igf = 0; - } - move16(); - - test(); - test(); - test(); - IF( ( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) && ( st->igf || st->element_mode == EVS_MONO ) ) - { - IF( ( st->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); - } - } - ELSE - { - st->hIGFEnc = NULL; - } - - /*-----------------------------------------------------------------* - * Mode 2 initialization - *-----------------------------------------------------------------*/ - - st->last_sr_core = L_mult0( st->last_L_frame, FRAMES_PER_SEC ); - move32(); - - - /* PLC encoder */ - IF( st->element_mode == EVS_MONO ) - { - IF( ( st->hPlcExt = (PLC_ENC_EVS_HANDLE) malloc( sizeof( PLC_ENC_EVS ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hPlcExt\n" ) ); - } - } - ELSE - { - st->hPlcExt = NULL; - } - - /* Init Mode 2 core coder */ - st->last_totalNoise_fx = 0; - move16(); - set16_fx( st->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); - st->totalNoise_increase_len = 0; - move16(); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - IF( hTcxEnc != NULL ) - { - hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ - move16(); - } - st->currEnergyHF_fx = 0; - move32(); - st->currEnergyHF_e_fx = 0; - move16(); -#ifdef MSAN_FIX - st->prevEnergyHF_fx = 0; - move32(); -#endif - - /* Initialize TCX */ - - /* Initialize Signal Buffers */ - Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); - Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); - st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); - move16(); - shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); - Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); - st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); - move16(); - /* Initialize ACELP */ -#endif -#ifdef FIX_920_IGF_INIT_ERROR - init_coder_ace_plus_ivas_fx( st, st->last_total_brate, igf_brate, 0 ); -#else - init_coder_ace_plus_ivas_fx( st, st->last_total_brate, 0 ); -#endif - - IF( st->hLPDmem != NULL ) - { - st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; - move16(); - } - /*-----------------------------------------------------------------* - * FD-CNG encoder - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - IF( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) - { - createFdCngEnc_fx( &st->hFdCngEnc ); - initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); - /* initialization for IVAS modes happens in first frame pre-processing */ - IF( st->element_mode == EVS_MONO ) - { - Word32 total_brate; - - test(); - IF( st->rf_mode && EQ_32( st->total_brate, ACELP_13k20 ) ) - { - total_brate = ACELP_9k60; - move32(); - } - ELSE - { - total_brate = st->total_brate; - move32(); - } - - configureFdCngEnc_ivas_fx( st->hFdCngEnc, st->bwidth, total_brate ); - } - } - ELSE - { - st->hFdCngEnc = NULL; - } - - /*-----------------------------------------------------------------* - * Transient detector - *-----------------------------------------------------------------*/ - - IF( ( st->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); - } - Word16 temp; - Word16 frame_length = BASOP_Util_Divide3232_Scale( st->input_Fs, FRAMES_PER_SEC, &temp ); - frame_length = shr( frame_length, sub( 15, temp ) ); - - IF( GT_16( st->element_mode, EVS_MONO ) ) - { - InitTransientDetection_ivas_fx( frame_length, 0, st->hTranDet, 1 ); - } - ELSE - { - InitTransientDetection_ivas_fx( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); - } - - /*-----------------------------------------------------------------* - * IVAS parameters - *-----------------------------------------------------------------*/ - - st->tdm_LRTD_flag = 0; - move16(); - st->cng_sba_flag = 0; - move16(); - st->bits_frame_channel = 0; - move16(); - st->side_bits_frame_channel = 0; - move16(); - st->Q_syn2 = 0; - move16(); - st->Q_syn = 0; - move16(); - set16_fx( st->Q_max, Q_MAX, L_Q_MEM ); - set16_fx( st->Q_max_16k, Q_MAX, L_Q_MEM ); - st->Q_old = 15; - move16(); - st->old_wsp_max = 0; - move16(); - st->old_wsp_shift = 0; - move16(); - st->sharpFlag = 0; - move16(); - - return error; -} - - -/*-----------------------------------------------------------------------* - * destroy_cldfb_encoder() - * - * Free memory which was allocated in init_encoder() - *-----------------------------------------------------------------------*/ - -void destroy_cldfb_encoder_fx( - Encoder_State *st /* i/o: Encoder static variables structure */ -) -{ - deleteCldfb_ivas_fx( &st->cldfbSynTd ); - deleteCldfb_ivas_fx( &st->cldfbAnaEnc ); - - deleteFdCngEnc_fx( &st->hFdCngEnc ); - - return; -} diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 58706279e..ca8b70ca2 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -10,8 +10,10 @@ #include "stl.h" #include "ivas_cnst.h" #include "ivas_error.h" +#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ +#include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* @@ -1062,3 +1064,1171 @@ void destroy_encoder_fx( return; } + +ivas_error init_encoder_ivas_fx( + Encoder_State *st, /* i/o: state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + const Word16 idchan, /* i : channel ID */ + const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ + const Word16 interval_SID, /* i : interval for SID update */ + const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const Word32 element_brate /* i : element bitrate */ +) +{ + Word16 i; + ivas_error error; + Word32 igf_brate; + + error = IVAS_ERR_OK; + move32(); + + /*-----------------------------------------------------------------* + * General parameters + *-----------------------------------------------------------------*/ + + IF( st->Opt_AMR_WB ) + { + st->last_core = AMR_WB_CORE; + } + ELSE + { + st->last_core = -1; + } + move16(); + + st->L_frame = L_FRAME; + move16(); + st->last_coder_type = GENERIC; + move16(); + st->coder_type = GENERIC; + move16(); + st->last_total_brate = st->total_brate; + move32(); + st->last_bits_frame_nominal = -1; + move16(); + st->last_total_brate_cng = -1; + move16(); + st->last_core_brate = st->total_brate; + move32(); + st->dtx_sce_sba = 0; + move16(); + st->extl = -1; + move16(); + st->last_extl = -1; + move16(); + st->last_L_frame = L_FRAME; + move16(); + st->rate_switching_reset = 0; + move16(); + st->rate_switching_reset_16kHz = 0; + move16(); + st->clas = UNVOICED_CLAS; + move16(); + st->low_rate_mode = 0; + move16(); + st->ini_frame = 0; + move16(); + st->inactive_coder_type_flag = 0; + move16(); + st->sba_br_sw_while_no_data = 0; + move16(); + + st->coder_type_raw = VOICED; + move16(); + st->last_coder_type_raw = st->coder_type_raw; + move16(); + + st->flag_ACELP16k = set_ACELP_flag_IVAS( st->element_mode, st->total_brate, st->total_brate, idchan, 0, -1, -1 ); + move16(); + + st->is_ism_format = 0; + move16(); + + IF( NE_16( ism_mode, ISM_MODE_NONE ) ) + { + st->is_ism_format = 1; + move16(); + } + + /*-----------------------------------------------------------------* + * Bitstream + *-----------------------------------------------------------------*/ + + IF( !vad_only_flag ) + { + IF( ( st->hBstr = (BSTR_ENC_HANDLE) malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Bitstream structure\n" ) ); + } + + /* set pointer to the buffer of indices */ + st->hBstr->ind_list = st_ivas->ind_list; + st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; + st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; + st->hBstr->nb_ind_tot = 0; + move16(); + st->hBstr->nb_bits_tot = 0; + move16(); + st->hBstr->st_ivas = st_ivas; + } + ELSE + { + st->hBstr = NULL; + } + + /*-----------------------------------------------------------------* + * Pre-processing and ACELP core parameters + *-----------------------------------------------------------------*/ + + Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); + Copy( GEWB_Ave_fx, st->lsfoldbfi0_fx, M ); + Copy( GEWB_Ave_fx, st->lsfoldbfi1_fx, M ); + Copy( GEWB_Ave_fx, st->lsf_adaptive_mean_fx, M ); + + st->next_force_safety_net = 0; + move16(); + + st->pstreaklen = 0; + move16(); + st->streaklimit_fx = MAX_WORD16; + move16(); + set16_fx( st->mem_MA_fx, 0, M ); + + init_gp_clip_fx( st->clip_var_fx ); + pitch_ol_init_fx( &st->old_thres_fx, &st->old_pitch, &st->delta_pit, &st->old_corr_fx ); + set16_fx( st->old_wsp_fx, 0, L_WSP_MEM ); + st->exp_old_wsp = 0; + move16(); + set16_fx( st->old_wsp2_fx, 0, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM ); // Needs to change depending on usage. + st->Q_old_wsp2 = 0; + move16(); + + st->mem_preemph_fx = 0; + move16(); + st->mem_preemph16k_fx = 0; + move16(); + st->mem_preemph_enc = 0; + move16(); + st->exp_mem_preemph_enc = 0; + move16(); + +#if 1 // TODO: Float Initializations. To be removed later + st->active_cnt = 0; + move16(); +#endif + + st->pst_mem_deemp_err_fx = 0; + move16(); + st->pst_lp_ener_fx = 0; + move16(); + + /* AVQ pre-quantizer memory */ + st->mem_preemp_preQ_fx = 0; + move16(); + st->mem_deemp_preQ_fx = 0; + move16(); + st->last_nq_preQ = 0; + move16(); + st->last_code_preq = 0; + move16(); + st->use_acelp_preq = 0; + move16(); + st->last_harm_flag_acelp = 0; + move16(); + + /* (Decimated) Weighted Speech Memory */ + st->mem_wsp_enc = 0; + move16(); + st->mem_wsp_fx = 0; + move16(); + st->mem_wsp_q = 0; + move16(); + set16_fx( st->mem_decim2_fx, 0, 3 ); + set32_fx( st->Bin_E_fx, 0, L_FFT ); + st->q_Bin_E = Q31; + move16(); + st->ee_old_fx = 640; /* 10.0f in Q6 */ + move16(); + st->Nb_ACELP_frames = 0; + move16(); + st->audio_frame_cnt = AUDIO_COUNTER_INI; /* Initialization of the audio frame counter mildly into the audio mode */ + move16(); + + /* adaptive lag window memory */ + st->old_pitch_la = 0; + move16(); + + st->prev_Q_new = 0; + move16(); + + IF( EQ_32( st->input_Fs, 8000 ) ) + { + st->min_band = 1; + move16(); + st->max_band = 16; + move16(); + } + ELSE + { + st->min_band = 0; + move16(); + st->max_band = 19; + move16(); + } + + IF( st->Opt_AMR_WB ) + { + Copy( mean_isf_amr_wb_fx, st->lsf_old_fx, M ); + E_LPC_isf_isp_conversion( st->lsf_old_fx, st->lsp_old1_fx, M ); + } + ELSE + { + Copy( GEWB_Ave_fx, st->lsf_old_fx, M ); + lsf2lsp_fx( st->lsf_old_fx, st->lsp_old1_fx, M, INT_FS_12k8 ); + } + + Copy( st->lsf_old_fx, st->lsf_old1_fx, M ); + Copy( st->lsp_old1_fx, st->lsp_old_fx, M ); + Copy( st->lsp_old_fx, st->lsp_old16k_fx, M ); + Copy( st->lsp_old_fx, st->lspold_enc_fx, M ); + + st->stab_fac_fx = 0; + move16(); + + /* Bass post-filter memories - encoder side of MODE2 */ + st->bpf_off = 0; + move16(); + st->pst_mem_deemp_err_fx = 0; + move16(); + st->pst_lp_ener_fx = 0; + move16(); + + /* TC coder type */ + st->tc_cnt = 0; + move16(); + + /* find_uv() parameters */ + st->old_dE1_fx = 0; + move16(); + st->old_ind_deltaMax = 0; + move16(); + set32_fx( st->old_enr_ssf_fx, 0, shl( NB_SSF, 1 ) ); + st->spike_hyst = -1; + move16(); + + /* stereo switching memories */ + st->mem_preemph_DFT_fx = 0; + move16(); + set16_fx( st->inp_12k8_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_12k8, L_MEM_RECALC_12K8 ), L_FILT ) ); + st->mem_preemph16k_DFT_fx = 0; + move16(); + set16_fx( st->inp_16k_mem_stereo_sw_fx, 0, sub( sub( STEREO_DFT_OVL_16k, L_MEM_RECALC_16K ), L_FILT16k ) ); + + st->sharpFlag = 0; + move16(); + + /* Stationary noise UV modification */ + st->ge_sm_fx = L_deposit_l( 640 ); /*Q(GE_SHIFT)*/ + move16(); + st->uv_count = 0; + move16(); + st->act_count = 3; + move16(); + Copy( st->lsp_old_fx, st->lspold_s_fx, M ); + st->noimix_seed = RANDOM_INITSEED; + move16(); + st->min_alpha_fx = 32767; + move16(); + st->exc_pe_fx = 0; + move16(); + st->Q_stat_noise = 15; + move16(); + /* FEC */ + st->last_clas = UNVOICED_CLAS; + move16(); + st->prev_fmerit = 0; + move16(); + st->fmerit_dt = 0; + move16(); + st->Last_pulse_pos = 0; + move16(); + + FOR( i = 0; i < shl( NB_SUBFR16k, 1 ); i++ ) + { + st->old_pitch_buf_fx[i] = L_SUBFR_Q6; + move16(); + } + + /* mode1 core switching */ + st->old_Es_pred_fx = 0; + move16(); + set16_fx( st->old_Aq_12_8_fx + 1, 0, M ); + st->old_Aq_12_8_fx[0] = ONE_IN_Q12; + move16(); + + /* stable short pitch detection */ + st->voicing0_sm_fx = 0; + move16(); + st->voicing_sm_fx = 0; + move16(); + st->LF_EnergyRatio_sm_fx = 1; + move16(); + st->predecision_flag = 0; + move16(); + st->diff_sm_fx = 0; + move32(); + st->energy_sm_fx = 0; + move32(); + + set16_fx( st->pitch, L_SUBFR, 3 ); + set16_fx( st->voicing_fx, 0, 3 ); + + /*-----------------------------------------------------------------* + * General signal buffers + *-----------------------------------------------------------------*/ + + IF( !vad_only_flag ) + { + IF( ( st->hSignalBuf = (SIGNAL_BUFFERS_ENC_HANDLE) malloc( sizeof( SIGNAL_BUFFERS_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Signal buffers\n" ) ); + } + + st->Bin_E_old_fx = st->hSignalBuf->Bin_E_old_fx; + st->mem_decim_fx = st->hSignalBuf->mem_decim_fx; + st->mem_decim16k_fx = st->hSignalBuf->mem_decim16k_fx; + st->old_inp_12k8_fx = st->hSignalBuf->old_inp_12k8_fx; + st->old_inp_16k_fx = st->hSignalBuf->old_inp_16k_fx; + st->buf_speech_enc_pe = st->hSignalBuf->buf_speech_enc_pe; + st->buf_synth = st->hSignalBuf->buf_synth; + st->buf_speech_enc = st->hSignalBuf->buf_speech_enc; + st->buf_wspeech_enc = st->hSignalBuf->buf_wspeech_enc; + + set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); + st->q_Bin_E_old = Q31; + move16(); + set16_fx( st->hSignalBuf->buf_speech_enc, 0, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); + st->exp_buf_speech_enc = 0; + move16(); + set16_fx( st->hSignalBuf->buf_wspeech_enc, 0, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); + st->exp_buf_wspeech_enc = 0; + move16(); + /* initializations */ +#ifndef MSAN_FIX + set32_fx( st->Bin_E_old_fx, 0, shr( L_FFT, 2 ) ); +#else + set32_fx( st->Bin_E_old_fx, 0, L_FFT / 2 ); +#endif + st->q_Bin_E_old = Q31; + move16(); + set16_fx( st->mem_decim_fx, 0, shl( L_FILT_MAX, 1 ) ); + set16_fx( st->mem_decim16k_fx, 0, shl( L_FILT_MAX, 1 ) ); + set16_fx( st->old_inp_12k8_fx, 0, L_INP_MEM ); + set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM ); + st->exp_old_inp_16k = 0; + st->exp_old_inp_12k8 = 0; + move16(); + move16(); + + st->input_buff_fx = st->hSignalBuf->input_buff; + st->input_buff32_fx = st->hSignalBuf->input_buff32; + set16_fx( st->input_buff_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); + st->q_inp = Q15; + move16(); + st->q_old_inp = Q15; + move16(); + set32_fx( st->input_buff32_fx, 0, add( L_FRAME48k, add( L_FRAME48k, NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ) ); + st->q_inp32 = Q31; + move16(); + st->old_input_signal_fx = st->input_buff_fx; + /* st->input_Fs / FRAMES_PER_SEC */ + Word16 frame_length = extract_l( Mpy_32_32( st->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + + IF( st->element_mode == EVS_MONO ) + { + st->input32_fx = st->input_buff32_fx + st->input_Fs / FRAMES_PER_SEC + NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ); + st->input_fx = st->input_buff_fx + add( frame_length, (Word16) NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ) ); + } + ELSE + { + st->input32_fx = st->input_buff32_fx + Mpy_32_32( st->input_Fs, 42949673 ) /* 1/50 in Q31*/; // st->input_Fs / FRAMES_PER_SEC + st->input_fx = st->input_buff_fx + frame_length; + } +#if 1 // TODO: To be removed later +#endif + } + ELSE + { + st->hSignalBuf = NULL; + st->Bin_E_old_fx = NULL; + st->mem_decim_fx = NULL; + st->mem_decim16k_fx = NULL; + st->old_inp_12k8_fx = NULL; + st->old_inp_16k_fx = NULL; + st->buf_speech_enc_pe = NULL; + st->buf_synth = NULL; + st->buf_speech_enc = NULL; + st->buf_wspeech_enc = NULL; + st->input_buff_fx = NULL; +#if 1 +#endif + } + + /*-----------------------------------------------------------------* + * Noise estimator + *-----------------------------------------------------------------*/ + + test(); + test(); + test(); + IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) + { + IF( ( st->hNoiseEst = (NOISE_EST_HANDLE) malloc( sizeof( NOISE_EST_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Noise estimation\n" ); + } + + noise_est_init_ivas_fx( st->hNoiseEst ); + } + ELSE + { + st->hNoiseEst = NULL; + } + + /*-----------------------------------------------------------------* + * VAD + *-----------------------------------------------------------------*/ + + st->vad_flag = 1; + move16(); + st->localVAD = 0; + move16(); + + IF( ( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) && ( !vad_only_flag ) ) + { + IF( ( st->hVAD = (VAD_HANDLE) malloc( sizeof( VAD_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VAD\n" ) ); + } + + wb_vad_init_ivas_fx( st->hVAD ); + } + ELSE + { + st->hVAD = NULL; + } + st->Pos_relE_cnt = 20; + move16(); + + /* CLDFB-based VAD */ + IF( st->element_mode == EVS_MONO ) + { + /* This is done to as in EVS T_CldfbVadState structure is present in Encoder State */ + /* + if ( ( st->hVAD_CLDFB = (VAD_CLDFB_HANDLE) malloc( sizeof( T_CldfbVadState ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB VAD\n" ) ); + } + */ + st->hVAD_CLDFB = &st->vad_st; + + vad_init_fx( st->hVAD_CLDFB ); + } + ELSE + { + st->hVAD_CLDFB = NULL; + } + + /*-----------------------------------------------------------------* + * Speech/music classifier + *-----------------------------------------------------------------*/ + + IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_MDCT ) || st->element_mode == EVS_MONO ) + { + IF( ( st->hSpMusClas = (SP_MUS_CLAS_HANDLE) malloc( sizeof( SP_MUS_CLAS_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Speech/music classifier\n" ) ); + } + + speech_music_clas_init_ivas_fx( st->hSpMusClas ); + st->sp_aud_decision0 = 0; + move16(); + st->sp_aud_decision1 = 0; + move16(); + st->sp_aud_decision2 = 0; + move16(); + } + ELSE + { + st->hSpMusClas = NULL; + } + + + /*-----------------------------------------------------------------* + * WB, SWB and FB bandwidth detector + *-----------------------------------------------------------------*/ + + st->lt_mean_NB_fx = 0; + move16(); + st->lt_mean_WB_fx = 0; + move16(); + st->lt_mean_SWB_fx = 0; + move16(); + st->count_WB = BWD_COUNT_MAX; + move16(); + st->count_SWB = BWD_COUNT_MAX; + move16(); + st->count_FB = BWD_COUNT_MAX; + move16(); + st->bwidth = st->max_bwidth; + move16(); + st->last_input_bwidth = st->bwidth; + move16(); + st->last_bwidth = st->bwidth; + move16(); + st->last_bwidth_cng = st->bwidth; + move16(); + st->bwidth_sw_cnt = 0; + move16(); + + + /*-----------------------------------------------------------------* + * DTX + *-----------------------------------------------------------------*/ + + st->lp_speech_fx = 11520; /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ + move16(); + st->lp_noise_fx = 0; + move16(); + st->flag_noisy_speech_snr = 0; + move16(); + st->fd_cng_reset_flag = 0; + move16(); + st->cng_type = -1; + move16(); + st->bckr_tilt_lt = 0; + move16(); + st->active_cnt = 0; + move16(); + + test(); + test(); + test(); + test(); + IF( ( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) + { + IF( ( st->hDtxEnc = (DTX_ENC_HANDLE) malloc( sizeof( DTX_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) ); + } + dtx_enc_init_fx( st, var_SID_rate_flag, interval_SID ); + } + ELSE + { + st->hDtxEnc = NULL; + } + + /*-----------------------------------------------------------------* + * No other handles needed to be allocated for front-VAD structure + *-----------------------------------------------------------------*/ + + IF( vad_only_flag ) + { + st->hTdCngEnc = NULL; + st->cldfbAnaEnc = NULL; + st->hFdCngEnc = NULL; + st->hSC_VBR = NULL; + st->hAmrwb_IO = NULL; + st->hLPDmem = NULL; + st->hGSCEnc = NULL; + st->hBWE_TD = NULL; + st->cldfbSynTd = NULL; + st->hBWE_FD = NULL; + st->hHQ_core = NULL; + st->hRF = NULL; + st->hTECEnc = NULL; + st->hTcxEnc = NULL; + st->hTcxCfg = NULL; + st->hIGFEnc = NULL; + st->hPlcExt = NULL; + st->hTranDet = NULL; + + st->element_mode = IVAS_SCE; + move16(); + st->idchan = 100; /* indicates hCoreCoderVAD */ + move16(); + st->core = -1; + move16(); + st->rf_mode = 0; + move16(); + + return error; + } + + /*-----------------------------------------------------------------* + * LP-CNG + *-----------------------------------------------------------------*/ + + test(); + test(); + test(); + test(); + test(); + IF( ( ( idchan == 0 && st->Opt_DTX_ON && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || st->element_mode == EVS_MONO ) && !( EQ_16( ism_mode, ISM_MODE_PARAM ) || EQ_16( ism_mode, ISM_MODE_DISC ) ) ) + { + IF( ( st->hTdCngEnc = (TD_CNG_ENC_HANDLE) malloc( sizeof( TD_CNG_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); + } + + td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth ); + } + ELSE + { + st->hTdCngEnc = NULL; + } + + /*-----------------------------------------------------------------* + * CLDFB & resampling tools parameters + *-----------------------------------------------------------------*/ + test(); + test(); + test(); + IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) + { + IF( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { + st->cldfbAnaEnc = NULL; + } + + st->energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ + move32(); + st->sf_energyCoreLookahead_Fx = 2; /* 6.1e-5f in Q15 */ + move16(); + + /*-----------------------------------------------------------------* + * SC-VBR parameters + *-----------------------------------------------------------------*/ + + test(); + IF( st->Opt_SC_VBR || st->element_mode == EVS_MONO ) + { + IF( ( st->hSC_VBR = (SC_VBR_ENC_HANDLE) malloc( sizeof( SC_VBR_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SC-VBR\n" ) ); + } + + sc_vbr_enc_init_fx( st->hSC_VBR ); + } + ELSE + { + st->hSC_VBR = NULL; + } + + st->last_Opt_SC_VBR = 0; + move16(); + + + /*-----------------------------------------------------------------* + * AMR-WB IO initialization + *-----------------------------------------------------------------*/ + + test(); + IF( st->Opt_AMR_WB || st->element_mode == EVS_MONO ) + { + IF( ( st->hAmrwb_IO = (AMRWB_IO_ENC_HANDLE) malloc( sizeof( AMRWB_IO_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AMR-WB IO\n" ) ); + } + + amr_wb_enc_init_fx( st->hAmrwb_IO ); + } + ELSE + { + st->hAmrwb_IO = NULL; + } + + /*-----------------------------------------------------------------* + * ACELP LPDmem + *-----------------------------------------------------------------*/ + + test(); + test(); + IF( ( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st->hLPDmem = (LPD_state_HANDLE) malloc( sizeof( LPD_state ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LPDmem\n" ) ); + } + + LPDmem_enc_init_ivas_fx( st->hLPDmem ); + } + ELSE + { + st->hLPDmem = NULL; + } + + /*-----------------------------------------------------------------* + * parameters for AC coder type (GSC) + *-----------------------------------------------------------------*/ + + st->GSC_noisy_speech = 0; + move16(); + st->GSC_IVAS_mode = 0; + move16(); + + test(); + test(); + IF( ( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + IF( ( st->hGSCEnc = (GSC_ENC_HANDLE) malloc( sizeof( GSC_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for GSC\n" ) ); + } + + GSC_enc_init_fx( st->hGSCEnc ); + } + ELSE + { + st->hGSCEnc = NULL; + } + + /*-----------------------------------------------------------------* + * TBE parameters + *-----------------------------------------------------------------*/ + + test(); + IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + IF( ( st->hBWE_TD = (TD_BWE_ENC_HANDLE) malloc( sizeof( TD_BWE_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); + } + + IF( ( error = openCldfb_ivas_enc( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + { + return error; + } + + InitSWBencBuffer_ivas_fx( st ); + ResetSHBbuffer_Enc_fx( st ); + } + ELSE + { + st->hBWE_TD = NULL; + st->cldfbSynTd = NULL; + } + + /*-----------------------------------------------------------------* + * SWB BWE parameters + *-----------------------------------------------------------------*/ + + test(); + IF( idchan == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + IF( ( st->hBWE_FD = (FD_BWE_ENC_HANDLE) malloc( sizeof( FD_BWE_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FD BWE\n" ) ); + } + + fd_bwe_enc_init_fx( st->hBWE_FD ); +#ifdef MSAN_FIX + st->Q_old_wtda = 0; + move16(); +#endif + } + ELSE + { + st->hBWE_FD = NULL; + } + + /*-----------------------------------------------------------------* + * HQ core parameters + *-----------------------------------------------------------------*/ + + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) + { + IF( ( st->hHQ_core = (HQ_ENC_HANDLE) malloc( sizeof( HQ_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); + } + + HQ_core_enc_init_fx( st->hHQ_core ); + } + ELSE + { + st->hHQ_core = NULL; + } + + /* init memory for detect_transient(), used by HQ core and swb_bwe_enc */ + st->old_hpfilt_in_fx = 0; + move16(); + st->old_hpfilt_out_fx = 0; + move16(); + st->EnergyLT_fx = 0; + move32(); + st->Energy_Old_fx = 0; + move32(); + st->TransientHangOver = 0; + move16(); + st->EnergyLT_fx_exp = 30; + move16(); + st->last_enerBuffer_exp = 0; + move16(); + + /*-----------------------------------------------------------------* + * Channel-aware mode + *-----------------------------------------------------------------*/ + + test(); + test(); + test(); + IF( !st->Opt_RF_ON || ( NE_16( st->bwidth, WB ) && NE_16( st->bwidth, SWB ) ) || NE_32( st->total_brate, ACELP_13k20 ) ) + { + st->rf_mode = 0; + move16(); + } + ELSE + { + st->rf_mode = st->Opt_RF_ON; + move16(); + } + + st->rf_mode_last = st->rf_mode; + move16(); + + test(); + IF( st->Opt_RF_ON || st->element_mode == EVS_MONO ) + { + IF( ( st->hRF = (RF_ENC_HANDLE) malloc( sizeof( RF_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for RF\n" ) ); + } + + /* initialize RF indice buffers */ + reset_rf_indices_fx( st ); + } + ELSE + { + st->hRF = NULL; + } + + /*-----------------------------------------------------------------* + * Temporal Envelope Coding + *-----------------------------------------------------------------*/ + + IF( st->element_mode == EVS_MONO ) + { + IF( ( st->hTECEnc = (TEC_ENC_HANDLE) malloc( sizeof( TEC_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TEC\n" ) ); + } + } + ELSE + { + st->hTECEnc = NULL; + } + /* note: initialization done later in init_coder_ace_plus() */ + + /*-----------------------------------------------------------------* + * TCX core + *-----------------------------------------------------------------*/ + + // ToDo: reduction possible for MCT_CHAN_MODE_LFE channel + test(); + IF( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + IF( ( st->hTcxEnc = (TCX_ENC_HANDLE) malloc( sizeof( TCX_ENC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxEnc\n" ) ); + } + set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); + st->hTcxEnc->spectrum_long_e = 0; + move16(); + /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ + st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx; + st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; + move32(); + move32(); + st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0; + move16(); + move16(); +#if 1 + // set_f( st->hTcxEnc->spectrum_long, 0, N_MAX ); + // st->hTcxEnc->spectrum[0] = st->hTcxEnc->spectrum_long; + // st->hTcxEnc->spectrum[1] = st->hTcxEnc->spectrum_long + N_TCX10_MAX; + // set_f( st->hTcxEnc->old_out, 0, L_FRAME32k ); +#endif + + set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k ); + st->hTcxEnc->Q_old_out = 0; + move16(); + + /* MDCT selector */ + MDCT_selector_reset_fx( st->hTcxEnc ); + + /* MDCT classifier */ + MDCT_classifier_reset_fx( st->hTcxEnc ); + + IF( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); + } + } + ELSE + { + st->hTcxEnc = NULL; + st->hTcxCfg = NULL; + } + + /*-----------------------------------------------------------------* + * IGF + *-----------------------------------------------------------------*/ + + igf_brate = st->total_brate; + move32(); + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->element_mode, IVAS_SCE ) && ( EQ_16( st_ivas->hEncoderConfig->ivas_format, ISM_FORMAT ) || EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) ) + { + igf_brate = L_sub( st->total_brate, i_mult( ISM_NB_BITS_METADATA_NOMINAL, FRAMES_PER_SEC ) ); + } + ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st->element_mode, IVAS_SCE ) && ( EQ_16( st_ivas->hEncoderConfig->ivas_format, SBA_FORMAT ) || + EQ_16( st_ivas->hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) || + EQ_16( st_ivas->hEncoderConfig->ivas_format, MC_FORMAT ) || + EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_FORMAT ) ) ) ) + { + /* use nominal bitrates for DFT Stereo and (O)SBA, same as in stereo_dft_config()/ivas_spar_config() */ + IF( EQ_32( element_brate, IVAS_13k2 ) ) + { + igf_brate = ACELP_9k60; + } + ELSE IF( EQ_32( element_brate, IVAS_16k4 ) ) + { + igf_brate = ACELP_13k20; + } + ELSE IF( EQ_32( element_brate, IVAS_24k4 ) ) + { + igf_brate = ACELP_16k40; + } + ELSE IF( EQ_32( element_brate, IVAS_32k ) ) + { + igf_brate = ACELP_24k40; + } + } + ELSE IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + igf_brate = element_brate; + } + move32(); + test(); + IF( EQ_16( st->codec_mode, MODE2 ) || GT_16( st->element_mode, EVS_MONO ) ) + { + st->igf = getIgfPresent_fx( st->element_mode, igf_brate, st->max_bwidth, st->rf_mode ); + } + ELSE + { + st->igf = 0; + } + move16(); + + test(); + test(); + test(); + IF( ( idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) && ( st->igf || st->element_mode == EVS_MONO ) ) + { + IF( ( st->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) ); + } + } + ELSE + { + st->hIGFEnc = NULL; + } + + /*-----------------------------------------------------------------* + * Mode 2 initialization + *-----------------------------------------------------------------*/ + + st->last_sr_core = L_mult0( st->last_L_frame, FRAMES_PER_SEC ); + move32(); + + + /* PLC encoder */ + IF( st->element_mode == EVS_MONO ) + { + IF( ( st->hPlcExt = (PLC_ENC_EVS_HANDLE) malloc( sizeof( PLC_ENC_EVS ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hPlcExt\n" ) ); + } + } + ELSE + { + st->hPlcExt = NULL; + } + + /* Init Mode 2 core coder */ + st->last_totalNoise_fx = 0; + move16(); + set16_fx( st->totalNoise_increase_hist_fx, 0, TOTALNOISE_HIST_SIZE ); + st->totalNoise_increase_len = 0; + move16(); +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; + IF( hTcxEnc != NULL ) + { + hTcxEnc->L_frameTCX = extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ); /* 0x0290 is 1/FRAMES_PER_SEC in Q15*/ + move16(); + } + st->currEnergyHF_fx = 0; + move32(); + st->currEnergyHF_e_fx = 0; + move16(); +#ifdef MSAN_FIX + st->prevEnergyHF_fx = 0; + move32(); +#endif + + /* Initialize TCX */ + + /* Initialize Signal Buffers */ + Word16 shift = getScaleFactor16( st->old_inp_16k_fx, L_INP_MEM ); + Scale_sig( st->old_inp_16k_fx, L_INP_MEM, shift ); + st->exp_old_inp_16k = sub( st->exp_old_inp_16k, shift ); + move16(); + shift = getScaleFactor16( st->old_inp_12k8_fx, L_INP_MEM ); + Scale_sig( st->old_inp_12k8_fx, L_INP_MEM, shift ); + st->exp_old_inp_12k8 = sub( st->exp_old_inp_12k8, shift ); + move16(); + /* Initialize ACELP */ +#endif +#ifdef FIX_920_IGF_INIT_ERROR + init_coder_ace_plus_ivas_fx( st, st->last_total_brate, igf_brate, 0 ); +#else + init_coder_ace_plus_ivas_fx( st, st->last_total_brate, 0 ); +#endif + + IF( st->hLPDmem != NULL ) + { + st->hLPDmem->q_lpd_old_exc = st->prev_Q_new; + move16(); + } + /*-----------------------------------------------------------------* + * FD-CNG encoder + *-----------------------------------------------------------------*/ + + test(); + test(); + test(); + test(); + IF( ( idchan == 0 && st->Opt_DTX_ON ) || st->element_mode == EVS_MONO || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) + { + createFdCngEnc_fx( &st->hFdCngEnc ); + initFdCngEnc_fx( st->hFdCngEnc, st->input_Fs, st->cldfbAnaEnc->scale ); + /* initialization for IVAS modes happens in first frame pre-processing */ + IF( st->element_mode == EVS_MONO ) + { + Word32 total_brate; + + test(); + IF( st->rf_mode && EQ_32( st->total_brate, ACELP_13k20 ) ) + { + total_brate = ACELP_9k60; + move32(); + } + ELSE + { + total_brate = st->total_brate; + move32(); + } + + configureFdCngEnc_ivas_fx( st->hFdCngEnc, st->bwidth, total_brate ); + } + } + ELSE + { + st->hFdCngEnc = NULL; + } + + /*-----------------------------------------------------------------* + * Transient detector + *-----------------------------------------------------------------*/ + + IF( ( st->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); + } + Word16 temp; + Word16 frame_length = BASOP_Util_Divide3232_Scale( st->input_Fs, FRAMES_PER_SEC, &temp ); + frame_length = shr( frame_length, sub( 15, temp ) ); + + IF( GT_16( st->element_mode, EVS_MONO ) ) + { + InitTransientDetection_ivas_fx( frame_length, 0, st->hTranDet, 1 ); + } + ELSE + { + InitTransientDetection_ivas_fx( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); + } + + /*-----------------------------------------------------------------* + * IVAS parameters + *-----------------------------------------------------------------*/ + + st->tdm_LRTD_flag = 0; + move16(); + st->cng_sba_flag = 0; + move16(); + st->bits_frame_channel = 0; + move16(); + st->side_bits_frame_channel = 0; + move16(); + st->Q_syn2 = 0; + move16(); + st->Q_syn = 0; + move16(); + set16_fx( st->Q_max, Q_MAX, L_Q_MEM ); + set16_fx( st->Q_max_16k, Q_MAX, L_Q_MEM ); + st->Q_old = 15; + move16(); + st->old_wsp_max = 0; + move16(); + st->old_wsp_shift = 0; + move16(); + st->sharpFlag = 0; + move16(); + + return error; +} + + +/*-----------------------------------------------------------------------* + * destroy_cldfb_encoder() + * + * Free memory which was allocated in init_encoder() + *-----------------------------------------------------------------------*/ + +void destroy_cldfb_encoder_fx( + Encoder_State *st /* i/o: Encoder static variables structure */ +) +{ + deleteCldfb_ivas_fx( &st->cldfbSynTd ); + deleteCldfb_ivas_fx( &st->cldfbAnaEnc ); + + deleteFdCngEnc_fx( &st->hFdCngEnc ); + + return; +} diff --git a/lib_enc/inov_enc.c b/lib_enc/inov_enc.c deleted file mode 100644 index 08f1e768f..000000000 --- a/lib_enc/inov_enc.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "ivas_prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * inov_encode() - * - * Encode the algebraic innovation - *---------------------------------------------------------------------*/ diff --git a/lib_enc/isf_enc_amr_wb.c b/lib_enc/isf_enc_amr_wb.c deleted file mode 100644 index 7bb7c56fe..000000000 --- a/lib_enc/isf_enc_amr_wb.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/ivas_entropy_coder.c b/lib_enc/ivas_entropy_coder.c index 0dd0f5aa1..eb82aa78a 100644 --- a/lib_enc/ivas_entropy_coder.c +++ b/lib_enc/ivas_entropy_coder.c @@ -35,6 +35,7 @@ #include "options.h" #include "ivas_cnst.h" #include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "math.h" @@ -174,7 +175,7 @@ static Word16 ivas_arith_encode_array_fx( pCum_freq = pArith->cum_freq[0]; /* Q0 */ } - ari_start_encoding_14bits( &as ); + ari_start_encoding_14bits_ivas_fx( &as ); FOR( i = 0; i < in_len; i++ ) { diff --git a/lib_enc/lead_indexing.c b/lib_enc/lead_indexing.c deleted file mode 100644 index 3a6a477b9..000000000 --- a/lib_enc/lead_indexing.c +++ /dev/null @@ -1,208 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * Local function prototypes - *-------------------------------------------------------------------*/ - -static int16_t fcb_encode_pos( const int16_t pos_vector[], const int16_t pulse_num, const int16_t pos_num ); - - -/*-------------------------------------------------------------------* - * re8_compute_base_index: - * - * Compute base index for RE8 - *-------------------------------------------------------------------*/ - -void re8_compute_base_index( - const int16_t *x, /* i : Elemen of Q2, Q3 or Q4 */ - const int16_t ka, /* i : Identifier of the absolute leader related to x */ - uint16_t *I /* o : index */ -) -{ - int16_t i, j, k1, m; - int16_t setor_8p[8], setor_8p_temp[8]; - int16_t sign_8p; - int16_t code_index, code_level, code_area; - uint16_t offset; - const int16_t *a1, *a2; - - a1 = vals_a[ka]; - a2 = vals_q[ka]; - - /* the sign process */ - - sign_8p = 0; - m = 0; - code_index = 0; - k1 = a2[0]; - - if ( ( a2[1] == 2 ) && ( a1[0] ^ 1 ) && ( ka != 5 ) ) - { - for ( i = 0; i < 8; i++ ) - { - if ( x[i] != 0 ) - { - sign_8p = sign_8p * 2; - setor_8p_temp[m] = i; - m++; - } - if ( x[i] < 0 ) - { - sign_8p += 1; - } - } - - code_index = fcb_encode_pos( setor_8p_temp, 8, m ); - code_index = ( code_index << k1 ) + sign_8p; - - offset = Is[ka]; - - - *I = offset + code_index; - } - else - { - for ( i = 0; i < 8; i++ ) - { - setor_8p[i] = (int16_t) abs( x[i] ); - - if ( x[i] < 0 ) - { - sign_8p = sign_8p * 2 + 1; - m++; - } - if ( x[i] > 0 ) - { - sign_8p = sign_8p * 2; - m++; - } - } - - if ( k1 != m ) - { - sign_8p = sign_8p >> 1; - } - - /* code level by level */ - - code_level = a2[1]; - code_area = 8; - - if ( a2[2] != 1 ) - { - for ( j = 0; j < code_level - 1; j++ ) - { - m = 0; - - for ( i = 0; i < code_area; i++ ) - { - if ( setor_8p[i] != a1[j] ) - { - setor_8p_temp[m] = i; - setor_8p[m] = setor_8p[i]; - m++; - } - } - code_index *= select_table22[m][code_area]; - - code_index += fcb_encode_pos( setor_8p_temp, code_area, m ); - - code_area = m; - } - } - else - { - for ( i = 0; i < code_area; i++ ) - { - if ( setor_8p[i] == a1[1] ) - { - code_index += i; - } - } - } - - code_index = ( code_index << k1 ) + sign_8p; - - offset = Is[ka]; - - *I = offset + code_index; - } - - return; -} - -/*-------------------------------------------------------------------* - * fcb_encode_pos: - * - * Base function to compute base index for RE8 - *-------------------------------------------------------------------*/ - -/*! r: Code index */ -static int16_t fcb_encode_pos( - const int16_t pos_vector[], /* i : Position vectort */ - const int16_t pulse_num, /* i : Pulse number */ - const int16_t pos_num /* i : Position number */ -) -{ - int16_t i, j; - int16_t code_index; - int16_t temp, temp1; - const int16_t *select_table23; - - temp = pulse_num - 1; - - select_table23 = select_table22[pos_num]; - - code_index = select_table23[pulse_num] - select_table23[pulse_num - pos_vector[0]]; - - for ( i = 0, j = 1; i < pos_num - 1; i++, j++ ) - { - temp1 = pos_num - j; - - select_table23 = select_table22[temp1]; - - code_index += select_table23[temp - pos_vector[i]] - select_table23[pulse_num - pos_vector[j]]; - } - - return code_index; -} diff --git a/lib_enc/long_enr.c b/lib_enc/long_enr.c deleted file mode 100644 index 31ab8f019..000000000 --- a/lib_enc/long_enr.c +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------------------------* - * long_enr() - * - * Compute relative energy, long-term average total noise energy and total active speech energy - *-------------------------------------------------------------------*/ diff --git a/lib_enc/lp_exc_e.c b/lib_enc/lp_exc_e.c deleted file mode 100644 index 5c3581f4f..000000000 --- a/lib_enc/lp_exc_e.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/lsf_enc.c b/lib_enc/lsf_enc.c deleted file mode 100644 index 3ac84b28e..000000000 --- a/lib_enc/lsf_enc.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "prot_fx.h" -#include "prot_fx_enc.h" -#include "basop_proto_func.h" -#include "ivas_prot.h" -#include "ivas_prot_fx.h" -#include "ivas_rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/ltd_stable.c b/lib_enc/ltd_stable.c deleted file mode 100644 index 0e2004abf..000000000 --- a/lib_enc/ltd_stable.c +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/mdct_classifier.c b/lib_enc/mdct_classifier.c deleted file mode 100644 index 047f02355..000000000 --- a/lib_enc/mdct_classifier.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" -#include -#include "ivas_prot_fx.h" diff --git a/lib_enc/mdct_selector.c b/lib_enc/mdct_selector.c deleted file mode 100644 index 952043e3a..000000000 --- a/lib_enc/mdct_selector.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/mslvq_enc.c b/lib_enc/mslvq_enc.c deleted file mode 100644 index a49d435c3..000000000 --- a/lib_enc/mslvq_enc.c +++ /dev/null @@ -1,308 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "prot_fx.h" -#include "rom_com.h" -#include "cnst.h" -#include "wmc_auto.h" -#include "ivas_prot.h" - -/*-----------------------------------------------------------------* - * Local function prototypes - *-----------------------------------------------------------------*/ - -Word32 quantize_data_ivas_fx( Word16 *data, const Word16 *w_in, Word16 *qin, Word16 *cv_out, Word16 *idx_lead, Word16 *idx_scale, const Word16 *sigma, const Word16 *inv_sigma, const Word16 *scales, const Word16 *no_lead ); - -/*-----------------------------------------------------------------* - * mslvq() - * - * Encodes the LSF residual - *-----------------------------------------------------------------*/ - -Word32 mslvq_ivas_16( - Word16 *pTmp, /* i : M-dimensional input vector */ - Word16 *quant, /* o : quantized vector */ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - const Word16 *w, /* i : weights for LSF quantization */ - const Word16 mode, /* i : number indicating the coding type (V/UV/G...)*/ - const Word16 mode_glb, /* i : LVQ coding mode */ - const Word16 pred_flag /* i : prediction flag (0: safety net, 1,2 - predictive )*/ - /*Retunr dist in q 22*/ -) -{ - Word32 dist, L_tmp; - const Word16 *p_scales, *p_sigma, *p_inv_sigma; - Word16 i, tmp, tmp1; - Word16 p_no_lead[MAX_NO_SCALES * 2]; - dist = L_deposit_l( 0 ); - IF( pred_flag == 0 ) - { - p_sigma = sigma_MSLVQ_fx[mode]; - /* inverse sigma is precomputed to save complexity */ - p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; - p_scales = scales_ivas_fx[mode_glb]; - - tmp = no_lead_idx[mode_glb][0]; - move16(); - tmp1 = no_lead_idx[mode_glb][1]; - move16(); - test(); - if ( LE_16( tmp, LIMIT_LEADER ) && LT_16( tmp, sub( tmp1, 2 ) ) ) - { - tmp = add( tmp, DELTA_LEADER ); - } - FOR( i = 0; i < MAX_NO_SCALES; i++ ) - { - p_no_lead[i] = (Word16) leaders_short[tmp][i]; - move16(); - p_no_lead[i + MAX_NO_SCALES] = (Word16) leaders_short[tmp1][i]; - move16(); - } - } - ELSE - { - IF( GE_16( pred_flag, 5 ) ) - { - /* assert( pred_flag >= 12 && pred_flag <= 15 ); */ - /* pred_flag is here the number of bits for MSLVQ */ - - p_sigma = &modified_sigma_BWE_fx[mode_glb * LATTICE_DIM]; - - /* inverse sigma is precomputed to save complexity */ - p_inv_sigma = &inv_modified_sigma_BWE_fx[mode_glb * LATTICE_DIM]; - IF( mode_glb == 0 ) - { - p_scales = &scales_BWE_fx_new[i_mult( sub( pred_flag, mslvq_SHB_min_bits[mode_glb] ), 3 )]; - - FOR( i = 0; i < MAX_NO_SCALES; i++ ) - { - p_no_lead[i] = (Word16) no_lead_BWE[i + ( pred_flag - mslvq_SHB_min_bits[mode_glb] ) * 3]; - move16(); - } - } - ELSE - { - p_scales = &scales_BWE_3b_fx_new[i_mult( sub( pred_flag, mslvq_SHB_min_bits[mode_glb] ), 3 )]; - FOR( i = 0; i < MAX_NO_SCALES; i++ ) - { - p_no_lead[i] = (Word16) no_lead_BWE_3b[i + ( pred_flag - mslvq_SHB_min_bits[mode_glb] ) * 3]; - move16(); - } - } - } - ELSE - { - p_sigma = sigma_p_fx[mode]; - - /* inverse sigma is precomputed to save complexity */ - p_inv_sigma = inv_sigma_p_fx[mode]; - - p_scales = scales_p_ivas_fx[mode_glb]; - - tmp = no_lead_p_idx[mode_glb][0]; - move16(); - tmp1 = no_lead_p_idx[mode_glb][1]; - move16(); - - test(); - IF( LE_16( tmp, LIMIT_LEADER ) && LT_16( tmp, sub( tmp1, 2 ) ) ) - { - tmp = add( tmp, DELTA_LEADER ); - } - - test(); - IF( EQ_16( tmp, LIMIT_LEADER ) && ( tmp1 == 0 ) ) - { - tmp = add( tmp, DELTA_LEADER ); - tmp1 = add( tmp1, DELTA_LEADER ); - } - - FOR( i = 0; i < MAX_NO_SCALES; i++ ) - { - p_no_lead[i] = (Word16) leaders_short[tmp][i]; - move16(); - p_no_lead[i + MAX_NO_SCALES] = (Word16) leaders_short[tmp1][i]; - move16(); - } - } - } - - /* first subvector */ - dist = quantize_data_ivas_fx( pTmp, w, quant, cv_out, idx_lead, idx_scale, - p_sigma, p_inv_sigma, p_scales, p_no_lead ); - - IF( LT_16( pred_flag, 5 ) ) - { - /* second subvector */ - L_tmp = quantize_data_ivas_fx( pTmp + LATTICE_DIM, w + LATTICE_DIM, quant + LATTICE_DIM, cv_out + LATTICE_DIM, &idx_lead[1], &idx_scale[1], p_sigma + LATTICE_DIM, p_inv_sigma + LATTICE_DIM, p_scales + MAX_NO_SCALES, p_no_lead + MAX_NO_SCALES ); - - dist = L_add( dist, L_tmp ); - } - - return dist; -} - -/*-----------------------------------------------------------------* - * mslvq_cng() - * - * Encodes the LSF residual in SID frames - *-----------------------------------------------------------------*/ - -/*-----------------------------------------------------------------* - * prepare_data() - * - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * calculate_min_dist() - * - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * quantize_data() - * - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * index_lvq() - * - * sorts in descending order and computes indices in the sorted vector - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * encode_comb() - * - * creates an index for the lattice codevector - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * index_leaders() - * - * gives the index in a class of leaders without considering the sign yet - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * find_pos() - * - * Finds the positions in vector c for which the vector components are equal to 'arg'. - * It returns the number of such positions and their values in the array 'p'. - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * encode_sign_pc1() - * - * Creates an index for signs of the significant codevector components - * Gives the index of the signs - binary representation where negative sign stands for 1 - * and positive sign stands for 1. - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * take_out_val() - * - * removes the value val from the vector v - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * c2idx() - * - *-----------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * index_lvq_SHB() - * - *-----------------------------------------------------------------*/ - - -UWord32 index_lvq_SHB_fx( - const Word16 idx_lead, - const Word16 idx_scale, - const Word16 nbits, - Word16 *lat_cv, - const Word16 mode ) -{ - UWord16 i; - const Word8 *p_no_lead; - UWord32 index; - - IF( mode == 0 ) - { - p_no_lead = &no_lead_BWE[( nbits - mslvq_SHB_min_bits[0] ) * 3]; - } - ELSE - { - p_no_lead = &no_lead_BWE_3b[( nbits - mslvq_SHB_min_bits[1] ) * 3]; - } - - index = 0; - move32(); - IF( GT_16( idx_lead, -1 ) ) - { - index = 1; - move32(); - FOR( i = 0; i < idx_scale; i++ ) - { - index = index + table_no_cv[p_no_lead[i]]; - move32(); - } - - IF( idx_lead > 0 ) - { - index = index + table_no_cv[idx_lead]; - move32(); - } - - index = index + encode_comb_fx( lat_cv, idx_lead ); - move32(); - } - - return index; -} diff --git a/lib_enc/mslvq_enc_fx.c b/lib_enc/mslvq_enc_fx.c index b6445443b..d8a78c525 100644 --- a/lib_enc/mslvq_enc_fx.c +++ b/lib_enc/mslvq_enc_fx.c @@ -1140,3 +1140,180 @@ Word16 c2idx_fx( /* o: index */ return tmp; } } + +/*-----------------------------------------------------------------* + * mslvq() + * + * Encodes the LSF residual + *-----------------------------------------------------------------*/ + +Word32 mslvq_ivas_16( + Word16 *pTmp, /* i : M-dimensional input vector */ + Word16 *quant, /* o : quantized vector */ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + const Word16 *w, /* i : weights for LSF quantization */ + const Word16 mode, /* i : number indicating the coding type (V/UV/G...)*/ + const Word16 mode_glb, /* i : LVQ coding mode */ + const Word16 pred_flag /* i : prediction flag (0: safety net, 1,2 - predictive )*/ + /*Retunr dist in q 22*/ +) +{ + Word32 dist, L_tmp; + const Word16 *p_scales, *p_sigma, *p_inv_sigma; + Word16 i, tmp, tmp1; + Word16 p_no_lead[MAX_NO_SCALES * 2]; + dist = L_deposit_l( 0 ); + IF( pred_flag == 0 ) + { + p_sigma = sigma_MSLVQ_fx[mode]; + /* inverse sigma is precomputed to save complexity */ + p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; + p_scales = scales_ivas_fx[mode_glb]; + + tmp = no_lead_idx[mode_glb][0]; + move16(); + tmp1 = no_lead_idx[mode_glb][1]; + move16(); + test(); + if ( LE_16( tmp, LIMIT_LEADER ) && LT_16( tmp, sub( tmp1, 2 ) ) ) + { + tmp = add( tmp, DELTA_LEADER ); + } + FOR( i = 0; i < MAX_NO_SCALES; i++ ) + { + p_no_lead[i] = (Word16) leaders_short[tmp][i]; + move16(); + p_no_lead[i + MAX_NO_SCALES] = (Word16) leaders_short[tmp1][i]; + move16(); + } + } + ELSE + { + IF( GE_16( pred_flag, 5 ) ) + { + /* assert( pred_flag >= 12 && pred_flag <= 15 ); */ + /* pred_flag is here the number of bits for MSLVQ */ + + p_sigma = &modified_sigma_BWE_fx[mode_glb * LATTICE_DIM]; + + /* inverse sigma is precomputed to save complexity */ + p_inv_sigma = &inv_modified_sigma_BWE_fx[mode_glb * LATTICE_DIM]; + IF( mode_glb == 0 ) + { + p_scales = &scales_BWE_fx_new[i_mult( sub( pred_flag, mslvq_SHB_min_bits[mode_glb] ), 3 )]; + + FOR( i = 0; i < MAX_NO_SCALES; i++ ) + { + p_no_lead[i] = (Word16) no_lead_BWE[i + ( pred_flag - mslvq_SHB_min_bits[mode_glb] ) * 3]; + move16(); + } + } + ELSE + { + p_scales = &scales_BWE_3b_fx_new[i_mult( sub( pred_flag, mslvq_SHB_min_bits[mode_glb] ), 3 )]; + FOR( i = 0; i < MAX_NO_SCALES; i++ ) + { + p_no_lead[i] = (Word16) no_lead_BWE_3b[i + ( pred_flag - mslvq_SHB_min_bits[mode_glb] ) * 3]; + move16(); + } + } + } + ELSE + { + p_sigma = sigma_p_fx[mode]; + + /* inverse sigma is precomputed to save complexity */ + p_inv_sigma = inv_sigma_p_fx[mode]; + + p_scales = scales_p_ivas_fx[mode_glb]; + + tmp = no_lead_p_idx[mode_glb][0]; + move16(); + tmp1 = no_lead_p_idx[mode_glb][1]; + move16(); + + test(); + IF( LE_16( tmp, LIMIT_LEADER ) && LT_16( tmp, sub( tmp1, 2 ) ) ) + { + tmp = add( tmp, DELTA_LEADER ); + } + + test(); + IF( EQ_16( tmp, LIMIT_LEADER ) && ( tmp1 == 0 ) ) + { + tmp = add( tmp, DELTA_LEADER ); + tmp1 = add( tmp1, DELTA_LEADER ); + } + + FOR( i = 0; i < MAX_NO_SCALES; i++ ) + { + p_no_lead[i] = (Word16) leaders_short[tmp][i]; + move16(); + p_no_lead[i + MAX_NO_SCALES] = (Word16) leaders_short[tmp1][i]; + move16(); + } + } + } + + /* first subvector */ + dist = quantize_data_ivas_fx( pTmp, w, quant, cv_out, idx_lead, idx_scale, + p_sigma, p_inv_sigma, p_scales, p_no_lead ); + + IF( LT_16( pred_flag, 5 ) ) + { + /* second subvector */ + L_tmp = quantize_data_ivas_fx( pTmp + LATTICE_DIM, w + LATTICE_DIM, quant + LATTICE_DIM, cv_out + LATTICE_DIM, &idx_lead[1], &idx_scale[1], p_sigma + LATTICE_DIM, p_inv_sigma + LATTICE_DIM, p_scales + MAX_NO_SCALES, p_no_lead + MAX_NO_SCALES ); + + dist = L_add( dist, L_tmp ); + } + + return dist; +} + + +UWord32 index_lvq_SHB_fx( + const Word16 idx_lead, + const Word16 idx_scale, + const Word16 nbits, + Word16 *lat_cv, + const Word16 mode ) +{ + UWord16 i; + const Word8 *p_no_lead; + UWord32 index; + + IF( mode == 0 ) + { + p_no_lead = &no_lead_BWE[( nbits - mslvq_SHB_min_bits[0] ) * 3]; + } + ELSE + { + p_no_lead = &no_lead_BWE_3b[( nbits - mslvq_SHB_min_bits[1] ) * 3]; + } + + index = 0; + move32(); + IF( GT_16( idx_lead, -1 ) ) + { + index = 1; + move32(); + FOR( i = 0; i < idx_scale; i++ ) + { + index = index + table_no_cv[p_no_lead[i]]; + move32(); + } + + IF( idx_lead > 0 ) + { + index = index + table_no_cv[idx_lead]; + move32(); + } + + index = index + encode_comb_fx( lat_cv, idx_lead ); + move32(); + } + + return index; +} diff --git a/lib_enc/multi_harm.c b/lib_enc/multi_harm.c deleted file mode 100644 index 5c3581f4f..000000000 --- a/lib_enc/multi_harm.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" diff --git a/lib_enc/nelp_enc.c b/lib_enc/nelp_enc.c deleted file mode 100644 index 7ea6e47a5..000000000 --- a/lib_enc/nelp_enc.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/pit_enc.c b/lib_enc/pit_enc.c deleted file mode 100644 index 5bde0f450..000000000 --- a/lib_enc/pit_enc.c +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_enc.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/pitch_ol.c b/lib_enc/pitch_ol.c deleted file mode 100644 index 0853fd9fd..000000000 --- a/lib_enc/pitch_ol.c +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "cnst.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ diff --git a/lib_enc/pitch_ol2.c b/lib_enc/pitch_ol2.c deleted file mode 100644 index dc77e0dfa..000000000 --- a/lib_enc/pitch_ol2.c +++ /dev/null @@ -1,274 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "rom_enc.h" -#include "prot.h" -#include "wmc_auto.h" - -#include "prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -#define MAX_DELTA 16 /* half-length of the delta search */ -#define COR_BUF_LEN ( L_INTERPOL1 * 2 + MAX_DELTA * 2 + 1 ) -/*-------------------------------------------------------------------* - * pitch_ol2() - * - * Open-loop pitch precision improvement with 1/4 resolution - * The pitch is searched in the interval 0 ) - { - ratio = 0; - move16(); - } - ELSE - { - ratio = s_max( sub( energy1_16, energy0_16 ), 0 ); /*Q7 */ - } - /*ratio *= max(voicing,0);*/ - tmp = s_max( voicing_m, 0 ); - ratio = mult_r( ratio, tmp ); /*Q7*/ - /**LF_EnergyRatio_sm = (15*(*LF_EnergyRatio_sm) + ratio)/16;*/ - L_tmp = L_mult( ratio, 2048 ); - L_tmp = L_mac( L_tmp, *LF_EnergyRatio_sm, 30720 ); - *LF_EnergyRatio_sm = round_fx( L_tmp ); - move16(); - test(); - if ( GT_16( *LF_EnergyRatio_sm, 4480 /*35.0f Q7*/ ) || GT_16( ratio, 6400 /*50.0f Q7*/ ) ) - { - *predecision_flag = 1; - move16(); - } - - if ( LT_16( *LF_EnergyRatio_sm, 2048 /*16.0f Q7*/ ) ) - { - *predecision_flag = 0; - move16(); - } - - /* short pitch candidate detection */ - Tp = pitch[1]; - move16(); - cor_max = 0; - move16(); - pt_wsp = wsp + 3 * L_SUBFR; - pit_min = PIT_MIN_DOUBLEEXTEND; - move16(); - pit_min_up = PIT_MIN; - move16(); - FOR( T = pit_min; T <= pit_min_up; T++ ) - { - energy1 = Dot_product( pt_wsp, pt_wsp - T, L_SUBFR ); - test(); - IF( ( GT_32( energy1, cor_max ) ) || ( EQ_16( T, pit_min ) ) ) - { - cor_max = L_add( energy1, 0 ); - Tp = T; - move16(); - } - } - energy0 = Dot_product12( pt_wsp, pt_wsp, L_SUBFR, &exp1 ); - exp1 = sub( exp1, shl( Q_new, 1 ) ); - energy1 = Dot_product12( pt_wsp - Tp, pt_wsp - Tp, L_SUBFR, &exp2 ); - exp2 = sub( exp2, shl( Q_new, 1 ) ); - /* cor_max *= inv_sqrt( energy0*energy1 );*/ - L_tmp = Mult_32_32( energy0, energy1 ); - exp = norm_l( L_tmp ); - L_tmp1 = L_shl( L_tmp, exp ); - - exp = sub( sub( 31, exp ), ( sub( sub( 31, exp1 ), exp2 ) ) ); - move16(); - L_tmp1 = Isqrt_lc( L_tmp1, &exp ); /*Q(31-exp)*/ - cor_max = Mult_32_32( cor_max, L_tmp1 ); - exp = add( sub( sub( 31, add( shl( Q_new, 1 ), 1 ) ), sub( 31, exp ) ), 31 ); - cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ - /**voicing0_sm = add(mult_r(24576 ,(*voicing0_sm)) , mult_r(8192 , cor_max16));*/ - *voicing0_sm = round_fx( L_mac( L_mult( 24576 /*.75f Q15*/, *voicing0_sm ), 8192 /*.25f Q15*/, cor_max16 ) ); - move16(); - - /* final short pitch detection */ - test(); - test(); - test(); - *flag_spitch = 0; - move16(); - IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && - ( GT_16( *voicing0_sm, 21299 /*.65f in Q15*/ ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 22938 /*.7f in Q15*/ ) ) ) ) - { - *flag_spitch = 1; - move16(); - pitch[0] = Tp; - move16(); - pitch[1] = Tp; - move16(); - pitch[2] = Tp; - move16(); - } - - return; -} diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 5d68216c9..7ca13171e 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -404,3 +404,227 @@ void StableHighPitchDetect_fx( return; } + + +/*-------------------------------------------------------------------* + * pitch_ol2() + * + * Open-loop pitch precision improvement with 1/4 resolution + * The pitch is searched in the interval 0 ) + { + ratio = 0; + move16(); + } + ELSE + { + ratio = s_max( sub( energy1_16, energy0_16 ), 0 ); /*Q7 */ + } + /*ratio *= max(voicing,0);*/ + tmp = s_max( voicing_m, 0 ); + ratio = mult_r( ratio, tmp ); /*Q7*/ + /**LF_EnergyRatio_sm = (15*(*LF_EnergyRatio_sm) + ratio)/16;*/ + L_tmp = L_mult( ratio, 2048 ); + L_tmp = L_mac( L_tmp, *LF_EnergyRatio_sm, 30720 ); + *LF_EnergyRatio_sm = round_fx( L_tmp ); + move16(); + test(); + if ( GT_16( *LF_EnergyRatio_sm, 4480 /*35.0f Q7*/ ) || GT_16( ratio, 6400 /*50.0f Q7*/ ) ) + { + *predecision_flag = 1; + move16(); + } + + if ( LT_16( *LF_EnergyRatio_sm, 2048 /*16.0f Q7*/ ) ) + { + *predecision_flag = 0; + move16(); + } + + /* short pitch candidate detection */ + Tp = pitch[1]; + move16(); + cor_max = 0; + move16(); + pt_wsp = wsp + 3 * L_SUBFR; + pit_min = PIT_MIN_DOUBLEEXTEND; + move16(); + pit_min_up = PIT_MIN; + move16(); + FOR( T = pit_min; T <= pit_min_up; T++ ) + { + energy1 = Dot_product( pt_wsp, pt_wsp - T, L_SUBFR ); + test(); + IF( ( GT_32( energy1, cor_max ) ) || ( EQ_16( T, pit_min ) ) ) + { + cor_max = L_add( energy1, 0 ); + Tp = T; + move16(); + } + } + energy0 = Dot_product12( pt_wsp, pt_wsp, L_SUBFR, &exp1 ); + exp1 = sub( exp1, shl( Q_new, 1 ) ); + energy1 = Dot_product12( pt_wsp - Tp, pt_wsp - Tp, L_SUBFR, &exp2 ); + exp2 = sub( exp2, shl( Q_new, 1 ) ); + /* cor_max *= inv_sqrt( energy0*energy1 );*/ + L_tmp = Mult_32_32( energy0, energy1 ); + exp = norm_l( L_tmp ); + L_tmp1 = L_shl( L_tmp, exp ); + + exp = sub( sub( 31, exp ), ( sub( sub( 31, exp1 ), exp2 ) ) ); + move16(); + L_tmp1 = Isqrt_lc( L_tmp1, &exp ); /*Q(31-exp)*/ + cor_max = Mult_32_32( cor_max, L_tmp1 ); + exp = add( sub( sub( 31, add( shl( Q_new, 1 ), 1 ) ), sub( 31, exp ) ), 31 ); + cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ + /**voicing0_sm = add(mult_r(24576 ,(*voicing0_sm)) , mult_r(8192 , cor_max16));*/ + *voicing0_sm = round_fx( L_mac( L_mult( 24576 /*.75f Q15*/, *voicing0_sm ), 8192 /*.25f Q15*/, cor_max16 ) ); + move16(); + + /* final short pitch detection */ + test(); + test(); + test(); + *flag_spitch = 0; + move16(); + IF( ( EQ_16( localVAD, 1 ) ) && ( EQ_16( *predecision_flag, 1 ) ) && + ( GT_16( *voicing0_sm, 21299 /*.65f in Q15*/ ) ) && ( GT_16( *voicing0_sm, mult_r( *voicing_sm, 22938 /*.7f in Q15*/ ) ) ) ) + { + *flag_spitch = 1; + move16(); + pitch[0] = Tp; + move16(); + pitch[1] = Tp; + move16(); + pitch[2] = Tp; + move16(); + } + + return; +} diff --git a/lib_enc/plc_enc_ext.c b/lib_enc/plc_enc_ext.c deleted file mode 100644 index 17c76dee6..000000000 --- a/lib_enc/plc_enc_ext.c +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "stat_enc.h" -#include "cnst.h" -#include "rom_com.h" -#include "wmc_auto.h" diff --git a/lib_enc/setmodeindex.c b/lib_enc/setmodeindex.c deleted file mode 100644 index b7ff1d2b6..000000000 --- a/lib_enc/setmodeindex.c +++ /dev/null @@ -1,97 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "cnst.h" -#include "ivas_cnst.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*--------------------------------------------------------------------------- - - function name: SetModeIndex - description: function for configuring the codec between frames - currently bitrate and bandwidth only - must not be called while a frame is encoded - hence mutexes must be used in MT environments - - format: BANDWIDTH*16 + BITRATE (mode index) - - ---------------------------------------------------------------------------*/ - -void SetModeIndex_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate Q0*/ - const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ -) -{ - Word16 ini_frame_loc = st->ini_frame; // Q0 - move16(); - - test(); - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( last_element_mode, IVAS_CPE_MDCT ) && EQ_16( st->idchan, 1 ) ) - { - st->ini_frame = 0; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - /* Reconfigure the core coder */ - IF( ( NE_32( last_total_brate, st->total_brate ) ) || - ( NE_16( st->last_bwidth, st->bwidth ) ) || - ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) || - ( ( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) || - ( NE_16( st->rf_mode_last, st->rf_mode ) ) || - ( st->element_mode > EVS_MONO && st->ini_frame == 0 ) ) - { - core_coder_mode_switch_ivas_fx( st, last_total_brate, MCT_flag ); - } - - st->ini_frame = ini_frame_loc; // Q0 - move16(); - - return; -} diff --git a/lib_enc/setmodeindex_fx.c b/lib_enc/setmodeindex_fx.c index fc3025f51..012c5757f 100644 --- a/lib_enc/setmodeindex_fx.c +++ b/lib_enc/setmodeindex_fx.c @@ -55,3 +55,48 @@ void SetModeIndex_fx( return; } + + +void SetModeIndex_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate Q0*/ + const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ +) +{ + Word16 ini_frame_loc = st->ini_frame; // Q0 + move16(); + + test(); + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && NE_16( last_element_mode, IVAS_CPE_MDCT ) && EQ_16( st->idchan, 1 ) ) + { + st->ini_frame = 0; + move16(); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + /* Reconfigure the core coder */ + IF( ( NE_32( last_total_brate, st->total_brate ) ) || + ( NE_16( st->last_bwidth, st->bwidth ) ) || + ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) || + ( ( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) && GT_16( st->element_mode, EVS_MONO ) ) || + ( NE_16( st->rf_mode_last, st->rf_mode ) ) || + ( st->element_mode > EVS_MONO && st->ini_frame == 0 ) ) + { + core_coder_mode_switch_ivas_fx( st, last_total_brate, MCT_flag ); + } + + st->ini_frame = ini_frame_loc; // Q0 + move16(); + + return; +} -- GitLab From ffd9acccfccfb915b783e0c8fcc4ac9649181786 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 4 Mar 2025 11:54:54 +0530 Subject: [PATCH 11/97] Restore cod_tcx_fx.c fix and LTV crash fix for +10dB files --- lib_enc/cod_tcx_fx.c | 127 +++++++++++++++++++++++++++++++++++++------ lib_enc/gs_enc_fx.c | 4 +- 2 files changed, 112 insertions(+), 19 deletions(-) diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index bf20608b0..0ed7535f1 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -5384,8 +5384,11 @@ void TNSAnalysisStereo_fx( TCX_ENC_HANDLE hTcxEnc = NULL; Word16 individual_decision[NB_DIV]; Word32 maxPredictionGain_fx = 0, meanPredictionGain_fx; + move32(); + Word16 maxPredictionGain_e = Q31, meanPredictionGain_e; + move16(); + Word16 sum_e = 0; move16(); - individual_decision[0] = 0; move16(); individual_decision[1] = 0; @@ -5520,7 +5523,9 @@ void TNSAnalysisStereo_fx( test(); IF( sts[0]->hTcxCfg->fIsTNSAllowed && NE_16( individual_decision[k], 1 ) && ( !bWhitenedDomain || sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) { - Word32 maxPredGain_fx = -ONE_IN_Q23; + Word32 maxPredGain_fx = -ONE_IN_Q31; + move32(); + Word16 maxPredGain_e = 0; move16(); sts[0]->hTcxCfg->pCurrentTnsConfig = &sts[0]->hTcxCfg->tnsConfig[sts[0]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[0]->last_core == ACELP_CORE )]; sts[1]->hTcxCfg->pCurrentTnsConfig = &sts[1]->hTcxCfg->tnsConfig[sts[1]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[1]->last_core == ACELP_CORE )]; @@ -5538,30 +5543,74 @@ void TNSAnalysisStereo_fx( * both filters for the decision */ - meanPredictionGain_fx = L_add( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ) ); // Q23 - maxPredictionGain_fx = L_max( maxPredictionGain_fx, meanPredictionGain_fx ); // Q23 - + meanPredictionGain_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[0]->predictionGain_e, Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[1]->predictionGain_e, &meanPredictionGain_e ); // meanPredictionGain_e + Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, meanPredictionGain_fx, meanPredictionGain_e ); + IF( flag < 0 ) + { + maxPredictionGain_fx = meanPredictionGain_fx; + maxPredictionGain_e = meanPredictionGain_e; + move32(); + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } + Word16 flag_1 = BASOP_Util_Cmp_Mant32Exp( pFilter[1]->predictionGain32, pFilter[1]->predictionGain_e, L_deposit_h( pTnsParameters[1]->minPredictionGain ), PRED_GAIN_E ); + if ( flag_1 < 0 ) + { + flag_1 = 0; + move16(); + } test(); test(); test(); - IF( GT_32( pFilter[0]->predictionGain32, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) && - GT_32( pFilter[1]->predictionGain32, L_shl( pTnsParameters[1]->minPredictionGain, 16 ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + IF( flag && LT_32( sts[0]->element_brate, IVAS_80k ) && + flag_1 && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) { pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ + move32(); + move32(); + pFilter[0]->predictionGain_e = pFilter[1]->predictionGain_e = meanPredictionGain_e; /* more TNS filter sync at 48kbps */ + move16(); move16(); + pFilter[0]->predictionGain = pFilter[1]->predictionGain = shl_sat( extract_h( meanPredictionGain_fx ), sub( meanPredictionGain_e, PRED_GAIN_E ) ); /* Q7 */ + move16(); + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ), meanPredictionGain_e, L_abs( BASOP_Util_Add_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_negate( pFilter[1]->predictionGain32 ), pFilter[1]->predictionGain_e, &sum_e ) ), sum_e ); + if ( flag < 0 ) + { + flag = 0; move16(); } test(); - IF( LT_32( L_abs( L_sub( pFilter[0]->predictionGain32, pFilter[1]->predictionGain32 ) ), Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ) ) && + IF( flag && ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) ) { Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15 Word16 meanLtpGain_fx = add( shr( sts[0]->hTcxEnc->tcxltp_gain, 1 ), shr( sts[1]->hTcxEnc->tcxltp_gain, 1 ) ); - maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); + // maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); + flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, meanPredictionGain_fx, meanPredictionGain_e ); + IF( flag < 0 ) + { + maxPredGain_fx = meanPredictionGain_fx; + maxPredGain_e = meanPredictionGain_e; + move32(); + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( meanPredictionGain_fx, meanPredictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); test(); - IF( GT_32( meanPredictionGain_fx, L_shl( pTnsParameters[0]->minPredictionGain, 16 ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) + IF( flag || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) { test(); test(); @@ -5764,10 +5813,16 @@ void TNSAnalysisStereo_fx( move16(); } } + Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); test(); test(); - IF( !bWhitenedDomain && individual_decision[k] == 0 && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && individual_decision[k] == 0 && flag && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; move16(); @@ -5787,7 +5842,15 @@ void TNSAnalysisStereo_fx( ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter ); } } - maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); + IF( flag < 0 ) + { + maxPredictionGain_fx = maxPredGain_fx; + maxPredictionGain_e = maxPredGain_e; + move32(); + move16(); + } } } } @@ -5825,7 +5888,9 @@ void TNSAnalysisStereo_fx( IF( sts[ch]->hTcxCfg->fIsTNSAllowed && ( individual_decision[k] || mct_on ) && ( !bWhitenedDomain || sts[ch]->hTcxEnc->bTnsOnWhithenedSpectra[k] ) ) { - Word32 maxPredGain_fx = -ONE_IN_Q23; // Q23 + Word32 maxPredGain_fx = -ONE_IN_Q31; // Q31 + move32(); + Word16 maxPredGain_e = 0; move16(); sts[ch]->hTcxCfg->pCurrentTnsConfig = &sts[ch]->hTcxCfg->tnsConfig[sts[ch]->hTcxEnc->transform_type[k] == TCX_20][( k == 0 ) && ( sts[ch]->last_core == ACELP_CORE )]; @@ -5836,9 +5901,23 @@ void TNSAnalysisStereo_fx( pFilter = sts[ch]->hTcxEnc->tnsData[k].filter + iFilter; pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; - maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); + // maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); + Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, pFilter->predictionGain32, pFilter->predictionGain_e ); + IF ( flag < 0 ) + { + maxPredGain_fx = pFilter->predictionGain32; + move32(); + maxPredGain_e = pFilter->predictionGain_e; + move16(); + } + flag = BASOP_Util_Cmp_Mant32Exp( pFilter->predictionGain32, pFilter->predictionGain_e, L_deposit_h( pTnsParameters->minPredictionGain ), PRED_GAIN_E ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); - IF( GT_32( pFilter->predictionGain32, L_shl( pTnsParameters->minPredictionGain, 16 ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) + IF( flag || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) { test(); test(); @@ -5910,9 +5989,15 @@ void TNSAnalysisStereo_fx( sts[ch]->hTcxEnc->fUseTns[k] = 0; } move16(); + Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); + if ( flag < 0 ) + { + flag = 0; + move16(); + } test(); test(); - IF( !bWhitenedDomain && LT_32( maxPredGain_fx, TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && flag && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[ch]->hTcxEnc->fUseTns[k] = 0; move16(); @@ -5927,7 +6012,15 @@ void TNSAnalysisStereo_fx( move16(); } } - maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); + flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); + IF( flag < 0 ) + { + maxPredictionGain_fx = maxPredGain_fx; + maxPredictionGain_e = maxPredGain_e; + move32(); + move16(); + } } } } diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 7ae8fb42e..a804c1311 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -679,9 +679,9 @@ void encod_audio_ivas_fx( *--------------------------------------------------------------------------------------*/ edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode ); - scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); + Scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode ); - scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) ); + Scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) ); Q_exc = Q_new; move16(); /*--------------------------------------------------------------------------------------* -- GitLab From 7a7515d693a14f7af64802c8cbe1b8496b1cd808 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 4 Mar 2025 11:57:37 +0530 Subject: [PATCH 12/97] Clang formatting changes --- lib_enc/cod_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 0ed7535f1..93c1dc58d 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -5903,7 +5903,7 @@ void TNSAnalysisStereo_fx( // maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, pFilter->predictionGain32, pFilter->predictionGain_e ); - IF ( flag < 0 ) + IF( flag < 0 ) { maxPredGain_fx = pFilter->predictionGain32; move32(); -- GitLab From defa4937cc74af9928015fd67aa64d8aabcedbdd Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 4 Mar 2025 13:42:55 +0530 Subject: [PATCH 13/97] Optimization of stereo decode path 32kHz @32kbps --- lib_com/fft_fx.c | 334 ++++++++++++++++++++++++++++ lib_com/hp50_fx.c | 66 ++++++ lib_com/modif_fs.c | 94 ++++++++ lib_com/mslvq_com_fx.c | 50 +++++ lib_com/options.h | 1 + lib_com/scale_mem_fx.c | 13 ++ lib_com/trans_inv_fx.c | 31 ++- lib_dec/acelp_core_dec_ivas_fx.c | 18 +- lib_dec/ivas_stereo_cng_dec.c | 19 +- lib_dec/ivas_stereo_dft_dec_fx.c | 167 ++++++++++++-- lib_dec/ivas_stereo_switching_dec.c | 38 +++- lib_dec/ivas_stereo_td_dec.c | 24 +- 12 files changed, 833 insertions(+), 22 deletions(-) diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 1b095e346..acadbb06b 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -4727,6 +4727,16 @@ static void fft_len16( cmplx t[4]; cmplx y[16]; +#ifdef OPT_STEREO_32KBPS_V1 + s[0] = x[0]; // Qx + move64(); + s[1] = x[4]; // Qx + move64(); + s[2] = x[8]; // Qx + move64(); + s[3] = x[12]; // Qx + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_shr( x[0], SCALEFACTOR16 ); // Qx move64(); s[1] = CL_shr( x[4], SCALEFACTOR16 ); // Qx @@ -4735,6 +4745,7 @@ static void fft_len16( move64(); s[3] = CL_shr( x[12], SCALEFACTOR16 ); // Qx move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4754,6 +4765,16 @@ static void fft_len16( y[3] = CL_add( t[1], t[3] ); move64(); +#ifdef OPT_STEREO_32KBPS_V1 + s[0] = x[1]; // Qx + move64(); + s[1] = x[5]; // Qx + move64(); + s[2] = x[9]; // Qx + move64(); + s[3] = x[13]; // Qx + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_shr( x[1], SCALEFACTOR16 ); // Qx move64(); s[1] = CL_shr( x[5], SCALEFACTOR16 ); // Qx @@ -4762,6 +4783,7 @@ static void fft_len16( move64(); s[3] = CL_shr( x[13], SCALEFACTOR16 ); // Qx move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4781,6 +4803,16 @@ static void fft_len16( y[7] = CL_add( t[1], t[3] ); move64(); +#ifdef OPT_STEREO_32KBPS_V1 + s[0] = x[2]; // Qx + move64(); + s[1] = x[6]; // Qx + move64(); + s[2] = x[10]; // Qx + move64(); + s[3] = x[14]; // Qx + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_shr( x[2], SCALEFACTOR16 ); // Qx move64(); s[1] = CL_shr( x[6], SCALEFACTOR16 ); // Qx @@ -4789,6 +4821,7 @@ static void fft_len16( move64(); s[3] = CL_shr( x[14], SCALEFACTOR16 ); // Qx move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4810,6 +4843,16 @@ static void fft_len16( y[11] = CL_add( t[1], t[3] ); move64(); +#ifdef OPT_STEREO_32KBPS_V1 + s[0] = x[3]; // Qx + move64(); + s[1] = x[7]; // Qx + move64(); + s[2] = x[11]; // Qx + move64(); + s[3] = x[15]; // Qx + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_shr( x[3], SCALEFACTOR16 ); // Qx move64(); s[1] = CL_shr( x[7], SCALEFACTOR16 ); // Qx @@ -4818,6 +4861,7 @@ static void fft_len16( move64(); s[3] = CL_shr( x[15], SCALEFACTOR16 ); // Qx move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4978,6 +5022,18 @@ static void fft_len20_fx( cmplx tt[4]; cmplx y[20]; +#ifdef OPT_STEREO_32KBPS_V1 + xx[0] = x[0]; // Qx + move64(); + xx[1] = x[16]; // Qx + move64(); + xx[2] = x[12]; // Qx + move64(); + xx[3] = x[8]; // Qx + move64(); + xx[4] = x[4]; // Qx + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ xx[0] = CL_shr( x[0], SCALEFACTOR20 ); // Qx move64(); xx[1] = CL_shr( x[16], SCALEFACTOR20 ); // Qx @@ -4988,6 +5044,7 @@ static void fft_len20_fx( move64(); xx[4] = CL_shr( x[4], SCALEFACTOR20 ); // Qx move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -5023,6 +5080,18 @@ static void fft_len20_fx( y[12] = CL_msu_j( s[2], s[3] ); move64(); +#ifdef OPT_STEREO_32KBPS_V1 + xx[0] = x[5]; + move64(); + xx[1] = x[1]; + move64(); + xx[2] = x[17]; + move64(); + xx[3] = x[13]; + move64(); + xx[4] = x[9]; + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ xx[0] = CL_shr( x[5], SCALEFACTOR20 ); move64(); xx[1] = CL_shr( x[1], SCALEFACTOR20 ); @@ -5033,6 +5102,7 @@ static void fft_len20_fx( move64(); xx[4] = CL_shr( x[9], SCALEFACTOR20 ); move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -5068,6 +5138,18 @@ static void fft_len20_fx( y[13] = CL_msu_j( s[2], s[3] ); move64(); +#ifdef OPT_STEREO_32KBPS_V1 + xx[0] = x[10]; + move64(); + xx[1] = x[6]; + move64(); + xx[2] = x[2]; + move64(); + xx[3] = x[18]; + move64(); + xx[4] = x[14]; + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ xx[0] = CL_shr( x[10], SCALEFACTOR20 ); move64(); xx[1] = CL_shr( x[6], SCALEFACTOR20 ); @@ -5078,6 +5160,7 @@ static void fft_len20_fx( move64(); xx[4] = CL_shr( x[14], SCALEFACTOR20 ); move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -5113,6 +5196,18 @@ static void fft_len20_fx( y[14] = CL_msu_j( s[2], s[3] ); move64(); +#ifdef OPT_STEREO_32KBPS_V1 + xx[0] = x[15]; + move64(); + xx[1] = x[11]; + move64(); + xx[2] = x[7]; + move64(); + xx[3] = x[3]; + move64(); + xx[4] = x[19]; + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ xx[0] = CL_shr( x[15], SCALEFACTOR20 ); move64(); xx[1] = CL_shr( x[11], SCALEFACTOR20 ); @@ -5123,6 +5218,7 @@ static void fft_len20_fx( move64(); xx[4] = CL_shr( x[19], SCALEFACTOR20 ); move64(); +#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -6501,6 +6597,239 @@ static void fft_lenN( cmplx s[8]; cmplx y[8]; +#ifdef OPT_STEREO_32KBPS_V1 + y[1] = xx[1 * dim1]; + move64(); + y[2] = xx[2 * dim1]; + move64(); + y[3] = xx[3 * dim1]; + move64(); + y[4] = xx[4 * dim1]; + move64(); + y[5] = xx[5 * dim1]; + move64(); + y[6] = xx[6 * dim1]; + move64(); + y[7] = xx[7 * dim1]; + move64(); + + test(); + test(); + IF( EQ_16( dim1, 8 ) || EQ_16( dim1, 16 ) || EQ_16( dim1, 32 ) ) + { + FOR( i = 0; i < dim1; i++ ) + { + { + y[0] = xx[i]; + move64(); + }; + IF( i > 0 ) + { + { + y[1] = CL_mac_j( CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 1 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 1 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[2] = CL_mac_j( CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 2 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 2 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[3] = CL_mac_j( CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 3 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 3 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[4] = CL_mac_j( CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 4 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 4 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[5] = CL_mac_j( CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 5 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 5 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[6] = CL_mac_j( CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 6 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 6 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[7] = CL_mac_j( CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 7 ) * dim1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 7 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + } + + t[0] = CL_add( y[0], y[4] ); + move64(); + t[1] = CL_sub( y[0], y[4] ); + move64(); + t[2] = CL_add( y[1], y[5] ); + move64(); + t[3] = CL_sub( y[1], y[5] ); + move64(); + t[4] = CL_add( y[2], y[6] ); + move64(); + t[5] = CL_sub( y[2], y[6] ); + move64(); + t[6] = CL_add( y[3], y[7] ); + move64(); + t[7] = CL_sub( y[3], y[7] ); + move64(); + + s[0] = CL_add( t[0], t[4] ); + move64(); + s[2] = CL_sub( t[0], t[4] ); + move64(); + s[4] = CL_mac_j( t[1], t[5] ); + move64(); + s[5] = CL_msu_j( t[1], t[5] ); + move64(); + s[1] = CL_add( t[2], t[6] ); + move64(); + s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) ); + move64(); + + t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) ); + move64(); + t[1] = CL_sub( t[3], t[7] ); + move64(); + + s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 ); // Qx + move64(); + s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 ); // Qx + move64(); + s[7] = CL_conjugate( s[7] ); + move64(); + + x[i] = CL_add( s[0], s[1] ); + move64(); + x[( i + ( 1 * dim1 ) )] = CL_add( s[5], s[6] ); + move64(); + x[( i + ( 2 * dim1 ) )] = CL_sub( s[2], s[3] ); + move64(); + x[( i + ( 3 * dim1 ) )] = CL_add( s[4], s[7] ); + move64(); + x[( i + ( 4 * dim1 ) )] = CL_sub( s[0], s[1] ); + move64(); + x[( i + ( 5 * dim1 ) )] = CL_sub( s[5], s[6] ); + move64(); + x[( i + ( 6 * dim1 ) )] = CL_add( s[2], s[3] ); + move64(); + x[( i + ( 7 * dim1 ) )] = CL_sub( s[4], s[7] ); + move64(); + } + } + ELSE + { + FOR( i = 0; i < dim1; i++ ) + { + { + y[0] = xx[i]; + move64(); + }; + IF( i > 0 ) + { + { + y[1] = CL_mac_j( CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 1 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 1 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[2] = CL_mac_j( CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 2 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 2 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[3] = CL_mac_j( CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 3 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 3 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[4] = CL_mac_j( CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 4 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 4 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[5] = CL_mac_j( CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 5 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 5 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[6] = CL_mac_j( CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 6 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 6 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + { + y[7] = CL_mac_j( CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 7 ) * dim1 ) << 1 ) ) - Woff )] ), + CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 7 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx + move64(); + }; + } + + t[0] = CL_add( y[0], y[4] ); + move64(); + t[1] = CL_sub( y[0], y[4] ); + move64(); + t[2] = CL_add( y[1], y[5] ); + move64(); + t[3] = CL_sub( y[1], y[5] ); + move64(); + t[4] = CL_add( y[2], y[6] ); + move64(); + t[5] = CL_sub( y[2], y[6] ); + move64(); + t[6] = CL_add( y[3], y[7] ); + move64(); + t[7] = CL_sub( y[3], y[7] ); + move64(); + + s[0] = CL_add( t[0], t[4] ); + move64(); + s[2] = CL_sub( t[0], t[4] ); + move64(); + s[4] = CL_mac_j( t[1], t[5] ); + move64(); + s[5] = CL_msu_j( t[1], t[5] ); + move64(); + s[1] = CL_add( t[2], t[6] ); + move64(); + s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) ); + move64(); + + t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) ); + move64(); + t[1] = CL_sub( t[3], t[7] ); + move64(); + + s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 ); // Qx + move64(); + s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 ); // Qx + move64(); + s[7] = CL_conjugate( s[7] ); + move64(); + + x[i] = CL_add( s[0], s[1] ); + move64(); + x[( i + ( 1 * dim1 ) )] = CL_add( s[5], s[6] ); + move64(); + x[( i + ( 2 * dim1 ) )] = CL_sub( s[2], s[3] ); + move64(); + x[( i + ( 3 * dim1 ) )] = CL_add( s[4], s[7] ); + move64(); + x[( i + ( 4 * dim1 ) )] = CL_sub( s[0], s[1] ); + move64(); + x[( i + ( 5 * dim1 ) )] = CL_sub( s[5], s[6] ); + move64(); + x[( i + ( 6 * dim1 ) )] = CL_add( s[2], s[3] ); + move64(); + x[( i + ( 7 * dim1 ) )] = CL_sub( s[4], s[7] ); + move64(); + } + } +#else /* OPT_STEREO_32KBPS_V1 */ test(); test(); test(); @@ -6781,6 +7110,7 @@ static void fft_lenN( move64(); } } +#endif /* OPT_STEREO_32KBPS_V1 */ BREAK; } @@ -7173,7 +7503,11 @@ void rfft_fx( move32(); x[( length - ( i << 1 ) )] = Mpy_32_16_1( L_add( t1, t3 ), 16384 /*0.5.Q15*/ ); move32(); +#ifdef OPT_STEREO_32KBPS_V1 + x[( ( length - ( i << 1 ) ) + 1 )] = Mpy_32_16_1( L_add( t2, t4 ), -16384 /*0.5.Q15*/ ); +#else /* OPT_STEREO_32KBPS_V1 */ x[( ( length - ( i << 1 ) ) + 1 )] = Mpy_32_16_1( L_negate( L_add( t2, t4 ) ), 16384 /*0.5.Q15*/ ); +#endif /* OPT_STEREO_32KBPS_V1 */ move32(); } diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index 84bbf8b3c..d13835f4c 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -469,8 +469,14 @@ void hp20_fx_32( { Word16 i; Word32 a1_fx, a2_fx, b1_fx, b2_fx; +#ifdef OPT_STEREO_32KBPS_V1 + Word16 Qy1, Qy2, Qmin; + Word64 y0_fx64, y1_fx64, y2_fx64; + Word32 x0, x1, x2; +#else /* OPT_STEREO_32KBPS_V1 */ Word16 Qx0, Qx1, Qx2, Qy1, Qprev_y1, Qy2, Qprev_y2, Qmin; Word64 x0_fx64, x1_fx64, x2_fx64, y0_fx64, y1_fx64, y2_fx64, R1, R2, R3, R4, R5; +#endif /* OPT_STEREO_32KBPS_V1 */ IF( EQ_32( Fs, 8000 ) ) { @@ -521,15 +527,64 @@ void hp20_fx_32( move32(); move32(); +#ifdef OPT_STEREO_32KBPS_V1 + y1_fx64 = W_add( W_deposit32_l( mem_fx[0] ), W_deposit32_h( mem_fx[1] ) ); + y2_fx64 = W_add( W_deposit32_l( mem_fx[2] ), W_deposit32_h( mem_fx[3] ) ); + + x0 = mem_fx[4]; + move32(); + x1 = mem_fx[5]; + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ Qprev_y1 = extract_l( mem_fx[4] ); Qprev_y2 = extract_l( mem_fx[5] ); y1_fx64 = W_deposit32_l( mem_fx[0] ); y2_fx64 = W_deposit32_l( mem_fx[1] ); x0_fx64 = W_deposit32_l( mem_fx[2] ); x1_fx64 = W_deposit32_l( mem_fx[3] ); +#endif /* OPT_STEREO_32KBPS_V1 */ FOR( i = 0; i < lg; i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + x2 = x1; + move32(); + x1 = x0; + move32(); + x0 = signal_fx[i]; + move32(); + + Qy1 = W_norm( y1_fx64 ); + if ( y1_fx64 == 0 ) + { + Qy1 = 62; + move16(); + } + + Qy2 = W_norm( y2_fx64 ); + if ( y2_fx64 == 0 ) + { + Qy2 = 62; + move16(); + } + + Qmin = s_min( Qy1, Qy2 ); + + Qmin = sub( Qmin, 34 ); + + y0_fx64 = W_mac_32_32( W_mult_32_32( W_shl_sat_l( y1_fx64, Qmin ), a1_fx ), W_shl_sat_l( y2_fx64, Qmin ), a2_fx ); // Qmin + Q29 + Q30 + 1 + + Word64 temp = W_mac_32_32( W_mac_32_32( W_mult_32_32( x2, b2_fx ), x1, b1_fx ), x0, b2_fx ); // Q30 + Word64 y0_fx = W_shr( y0_fx64, add( Qmin, Q30 ) ); // Q30 + y0_fx64 = W_add( temp, y0_fx ); // Q30 + signal_fx[i] = W_shl_sat_l( y0_fx64, -Q30 ); + move32(); + + y2_fx64 = y1_fx64; + move64(); + y1_fx64 = y0_fx64; + move64(); +#else /* OPT_STEREO_32KBPS_V1 */ x2_fx64 = x1_fx64; move64(); x1_fx64 = x0_fx64; @@ -611,8 +666,17 @@ void hp20_fx_32( move64(); move16(); move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ } +#ifdef OPT_STEREO_32KBPS_V1 + mem_fx[0] = W_extract_l( y1_fx64 ); + mem_fx[1] = W_extract_h( y1_fx64 ); + mem_fx[2] = W_extract_l( y2_fx64 ); + mem_fx[3] = W_extract_h( y2_fx64 ); + mem_fx[4] = x0; + mem_fx[5] = x1; +#else /* OPT_STEREO_32KBPS_V1 */ Qy1 = W_norm( y1_fx64 ); test(); IF( y1_fx64 != 0 && LT_16( Qy1, 32 ) ) @@ -635,6 +699,8 @@ void hp20_fx_32( mem_fx[3] = W_extract_l( x1_fx64 ); mem_fx[4] = Qprev_y1; mem_fx[5] = Qprev_y2; +#endif /* OPT_STEREO_32KBPS_V1 */ + move32(); move32(); move32(); diff --git a/lib_com/modif_fs.c b/lib_com/modif_fs.c index 4af93522d..1b2836252 100644 --- a/lib_com/modif_fs.c +++ b/lib_com/modif_fs.c @@ -115,6 +115,22 @@ void Decimate_allpass_steep_fx32( /* upper allpass filter chain */ FOR( k = 0; k < N / 2; k++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + temp[0] = Madd_32_16( mem[0], in[2 * k], AP1_STEEP_FX[0] ); // Qx + move32(); + mem[0] = Msub_32_16( in[2 * k], temp[0], AP1_STEEP_FX[0] ); // Qx + move32(); + + temp[1] = Madd_32_16( mem[1], temp[0], AP1_STEEP_FX[1] ); // Qx + move32(); + mem[1] = Msub_32_16( temp[0], temp[1], AP1_STEEP_FX[1] ); // Qx + move32(); + + out[k] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx + move32(); + mem[ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[0] = L_add( mem[0], Mpy_32_16_1( in[2 * k], AP1_STEEP_FX[0] ) ); // Qx move32(); mem[0] = L_sub( in[2 * k], Mpy_32_16_1( temp[0], AP1_STEEP_FX[0] ) ); // Qx @@ -129,17 +145,31 @@ void Decimate_allpass_steep_fx32( move32(); mem[ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ } /* lower allpass filter chain */ +#ifdef OPT_STEREO_32KBPS_V1 + temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ); // Qx + move32(); + mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( mem[2 * ALLPASSSECTIONS_STEEP], temp[0], AP2_STEEP_FX[0] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ) ); // Qx move32(); mem[ALLPASSSECTIONS_STEEP] = L_sub( mem[2 * ALLPASSSECTIONS_STEEP], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ /* for better performance, unroll this loop */ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx + move32(); + mem[ALLPASSSECTIONS_STEEP + 1] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx move32(); /*if ( fabs( temp[n] ) < 1e-12 ) @@ -148,26 +178,48 @@ void Decimate_allpass_steep_fx32( }*/ mem[ALLPASSSECTIONS_STEEP + 1] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ } +#ifdef OPT_STEREO_32KBPS_V1 + temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx + move32(); + + mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx move32(); mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ out[0] = W_round48_L( W_mac_32_16( W_mult_32_16( out[0], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx move32(); FOR( k = 1; k < N / 2; k++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], in[2 * k - 1], AP2_STEEP_FX[0] ); // Qx + move32(); + mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( in[2 * k - 1], temp[0], AP2_STEEP_FX[0] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( in[sub( shl( k, 1 ), 1 )], AP2_STEEP_FX[0] ) ); // Qx move32(); mem[ALLPASSSECTIONS_STEEP] = L_sub( in[sub( shl( k, 1 ), 1 )], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ /* for better performance, unroll this loop */ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx + move32(); + mem[ALLPASSSECTIONS_STEEP + n] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx move32(); /*if ( fabs( temp[n] ) < 1e-12 ) @@ -176,12 +228,20 @@ void Decimate_allpass_steep_fx32( }*/ mem[ALLPASSSECTIONS_STEEP + n] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ } +#ifdef OPT_STEREO_32KBPS_V1 + temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx + move32(); + mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx move32(); mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ out[k] = W_round48_L( W_mac_32_16( W_mult_32_16( out[k], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx move32(); } @@ -211,12 +271,21 @@ void interpolate_3_over_2_allpass_32( FOR( i = 0; i < len; i++ ) { /* Upper branch */ +#ifdef OPT_STEREO_32KBPS_V1 + Vu[0] = Madd_32_16( mem[0], L_sub( input[i], mem[1] ), filt_coeff[0] ); // Qx + Q15 - Q15 -> Qx + move32(); + Vu[1] = Madd_32_16( mem[1], L_sub( Vu[0], mem[2] ), filt_coeff[1] ); // Qx + Q15 - Q15 -> Qx + move32(); + mem[3] = Madd_32_16( mem[2], L_sub( Vu[1], mem[3] ), filt_coeff[2] ); // Qx + Q15 - Q15 -> Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ Vu[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[1] ), filt_coeff[0] ) ); // Qx + Q15 - Q15 -> Qx move32(); Vu[1] = L_add( mem[1], Mpy_32_16_1( L_sub( Vu[0], mem[2] ), filt_coeff[1] ) ); // Qx + Q15 - Q15 -> Qx move32(); mem[3] = L_add( mem[2], Mpy_32_16_1( L_sub( Vu[1], mem[3] ), filt_coeff[2] ) ); // Qx + Q15 - Q15 -> Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ mem[1] = Vu[0]; // Qx move32(); @@ -226,12 +295,21 @@ void interpolate_3_over_2_allpass_32( move32(); /* Middle branch */ +#ifdef OPT_STEREO_32KBPS_V1 + Vm[0] = Madd_32_16( mem[0], L_sub( input[i], mem[4] ), filt_coeff[3] ); // Qx + Q15 - Q15 -> Qx + move32(); + Vm[1] = Madd_32_16( mem[4], L_sub( Vm[0], mem[5] ), filt_coeff[4] ); // Qx + Q15 - Q15 -> Qx + move32(); + mem[6] = Madd_32_16( mem[5], L_sub( Vm[1], mem[6] ), filt_coeff[5] ); // Qx + Q15 - Q15 -> Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ Vm[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[4] ), filt_coeff[3] ) ); // Qx + Q15 - Q15 -> Qx move32(); Vm[1] = L_add( mem[4], Mpy_32_16_1( L_sub( Vm[0], mem[5] ), filt_coeff[4] ) ); // Qx + Q15 - Q15 -> Qx move32(); mem[6] = L_add( mem[5], Mpy_32_16_1( L_sub( Vm[1], mem[6] ), filt_coeff[5] ) ); // Qx + Q15 - Q15 -> Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ mem[4] = Vm[0]; // Qx move32(); @@ -241,12 +319,21 @@ void interpolate_3_over_2_allpass_32( move32(); /* Lower branch */ +#ifdef OPT_STEREO_32KBPS_V1 + Vl[0] = Madd_32_16( mem[0], L_sub( input[i], mem[7] ), filt_coeff[6] ); // Qx + Q15 - Q15 -> Qx + move32(); + Vl[1] = Madd_32_16( mem[7], L_sub( Vl[0], mem[8] ), filt_coeff[7] ); // Qx + Q15 - Q15 -> Qx + move32(); + mem[9] = Madd_32_16( mem[8], L_sub( Vl[1], mem[9] ), filt_coeff[8] ); // Qx + Q15 - Q15 -> Qx + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ Vl[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[7] ), filt_coeff[6] ) ); // Qx + Q15 - Q15 -> Qx move32(); Vl[1] = L_add( mem[7], Mpy_32_16_1( L_sub( Vl[0], mem[8] ), filt_coeff[7] ) ); // Qx + Q15 - Q15 -> Qx move32(); mem[9] = L_add( mem[8], Mpy_32_16_1( L_sub( Vl[1], mem[9] ), filt_coeff[8] ) ); // Qx + Q15 - Q15 -> Qx move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ mem[0] = input[i]; // Qx move32(); @@ -265,10 +352,17 @@ void interpolate_3_over_2_allpass_32( { mem_temp = out1_buff[2 * i]; move32(); +#ifdef OPT_STEREO_32KBPS_V1 + out[i] = Madd_32_16( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), L_add( mem[11], mem[14] ), -4965 ); // Qx + Q15 - Q15 -> Qx + // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965 + out[i] = Madd_32_16( out[i], L_add( mem[12], mem[13] ), 20125 ); + // 0.614152f in Q15 -> 20125 +#else /* OPT_STEREO_32KBPS_V1 */ out[i] = L_add( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), Mpy_32_16_1( L_add( mem[11], mem[14] ), -4965 ) ); // Qx + Q15 - Q15 -> Qx // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965 out[i] = L_add( out[i], Mpy_32_16_1( L_add( mem[12], mem[13] ), 20125 ) ); // 0.614152f in Q15 -> 20125 +#endif /* OPT_STEREO_32KBPS_V1 */ mem[10] = mem[11]; // Qx move32(); mem[11] = mem[12]; // Qx diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c index 14c9b6d97..d97830a5f 100644 --- a/lib_com/mslvq_com_fx.c +++ b/lib_com/mslvq_com_fx.c @@ -122,9 +122,33 @@ void init_lvq_fx( ) { Word16 i, j; +#ifdef OPT_STEREO_32KBPS_V1 + Word16 k; +#endif /* OPT_STEREO_32KBPS_V1 */ /* safety-net mode */ FOR( i = 0; i < MAX_NO_MODES; i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; ( j++, k++ ) ) + { + if ( ( no_lead_fx[i][j] <= 0 ) ) + { + j = MAX_NO_SCALES; + } + } + no_scales[i][0] = k; + move16(); + + FOR( k = 0; j < MAX_NO_SCALES << 1; ( j++, k++ ) ) + { + if ( no_lead_fx[i][j] <= 0 ) + { + j = MAX_NO_SCALES << 1; + } + } + no_scales[i][1] = k; + move16(); +#else /* OPT_STEREO_32KBPS_V1 */ j = 0; move16(); test(); @@ -143,10 +167,35 @@ void init_lvq_fx( } no_scales[i][1] = sub( j, MAX_NO_SCALES ); move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ } /* predictive mode */ FOR( i = 0; i < MAX_NO_MODES_p; i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; ( j++, k++ ) ) + { + + if ( ( no_lead_p_fx[i][j] <= 0 ) ) + { + j = MAX_NO_SCALES; + } + } + no_scales_p[i][0] = k; + move16(); + + FOR( k = 0; j < MAX_NO_SCALES << 1; ( j++, k++ ) ) + { + + if ( ( no_lead_p_fx[i][j] <= 0 ) ) + { + j = MAX_NO_SCALES << 1; + } + } + + no_scales_p[i][1] = k; + move16(); +#else /* OPT_STEREO_32KBPS_V1 */ j = 0; move16(); WHILE( ( LT_16( j, MAX_NO_SCALES ) ) && ( no_lead_p_fx[i][j] > 0 ) ) @@ -165,6 +214,7 @@ void init_lvq_fx( } no_scales_p[i][1] = sub( j, MAX_NO_SCALES ); move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ } /* index offsets for each truncation */ init_offset_fx( offset_scale1, offset_scale2, offset_scale1_p, offset_scale2_p, no_scales, no_scales_p ); diff --git a/lib_com/options.h b/lib_com/options.h index b24ac8267..d3570004d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -172,4 +172,5 @@ #define FIX_1301_CORRECT_TD_CNST /* VA: Fix 1301, correct wrong constant in TD stereo */ #define NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD /* VA/Eri: FLP issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP */ #define NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH /* FhG: issue 708: fix crash in OSBA BR switching with long test vectors */ +//#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ #endif diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c index 002821050..2ce2ffd12 100644 --- a/lib_com/scale_mem_fx.c +++ b/lib_com/scale_mem_fx.c @@ -307,8 +307,15 @@ void scale_sig32( /* saturation can occur here */ x[i] = L_shl( x[i], exp0 ); move32(); +#ifdef OPT_STEREO_32KBPS_V1 + if ( 0 == exp0 ) + { + i = lg; + } +#endif /* OPT_STEREO_32KBPS_V1 */ } } + void scale_sig32_r( Word32 x[], /* i/o: signal to scale Qx */ const Word16 lg, /* i : size of x[] Q0 */ @@ -322,6 +329,12 @@ void scale_sig32_r( /* saturation can occur here */ x[i] = L_shl_r( x[i], exp0 ); move32(); +#ifdef OPT_STEREO_32KBPS_V1 + if ( 0 == exp0 ) + { + i = lg; + } +#endif /* OPT_STEREO_32KBPS_V1 */ } } diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c index fbe0f0d6d..0033e2c9e 100644 --- a/lib_com/trans_inv_fx.c +++ b/lib_com/trans_inv_fx.c @@ -84,7 +84,9 @@ void preecho_sb_fx( UWord16 tmp_u16; Word32 mean_prev_hb_fx_loc, mean_prev_nc_fx_loc, mean_prev_fx_loc; /* */ Word16 q16p1, qmemp1, qtmp; - +#ifdef OPT_STEREO_32KBPS_V1 + Word16 shift_q = sub( 15, q_sig32 ); +#endif /* OPT_STEREO_32KBPS_V1 */ q16p1 = add( q_sig16, 1 ); qmemp1 = q16p1; @@ -137,6 +139,18 @@ void preecho_sb_fx( /* len3xLp20 = framelength/2-(short)((float)framelength*N_ZERO_MDCT/FRAME_SIZE_MS); in float*/ fxptr1 = imdct_mem_fx; +#ifdef OPT_STEREO_32KBPS_V1 + FOR( i = 0; i < len3xLp20; i++ ) + { + *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[len3xLp20 - 1 - i], shift_q ) ) ); /*Q-1*/ + move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ + } + FOR( i = 0; i < framelength >> 1; i++ ) + { + *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[i], shift_q ) ) ); /*Q-1*/ + move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ + } +#else /* OPT_STEREO_32KBPS_V1 */ fx32ptr1 = wtda_audio_fx + len3xLp20 - 1; /*q_sig32*/ FOR( i = 0; i < len3xLp20; i++ ) { @@ -148,7 +162,10 @@ void preecho_sb_fx( *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[i], sub( 15, q_sig32 ) ) ) ); /*Q-1*/ move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ } +#endif /* OPT_STEREO_32KBPS_V1 */ + qmemp1 = 0; /*already in q-1*/ + move16(); subframelength = shr( framelength, LOG2_NUMSF ); /*Q0*/ subsubframelength = shr( subframelength, log2_num_subsubframes ); /*Q0*/ @@ -391,6 +408,17 @@ void preecho_sb_fx( move16(); FOR( i = 1; i <= NUMSF; i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + max_es_hb_fx = L_max( max_es_hb_fx, es_mdct_hb_fx[i] ); /* max energy low band, 8 present and 1 future subframes */ + + max_es_fx = L_max( max_es_fx, es_mdct_fx[i] ); /* max energy low band, 8 present and 1 future subframes */ + + if ( GE_32( es_mdct_fx[i], max_es_fx ) ) /* '=' to handle the first window*/ + { + maxind = i; + move16(); + } +#else /* OPT_STEREO_32KBPS_V1 */ IF( GE_32( es_mdct_hb_fx[i], max_es_hb_fx ) ) /* '=' to handle the first window*/ { max_es_hb_fx = L_add( es_mdct_hb_fx[i], 0 ); /* max energy low band, 8 present and 1 future subframes */ @@ -402,6 +430,7 @@ void preecho_sb_fx( maxind = i; move16(); } +#endif /* OPT_STEREO_32KBPS_V1 */ } cnt2 = cnt5 = 0; diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 6e56bc154..5c16bc3e9 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1908,7 +1908,11 @@ ivas_error acelp_core_dec_ivas_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag ); // Q_imag } - scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) +#ifdef OPT_STEREO_32KBPS_V1 + scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) +#else /* OPT_STEREO_32KBPS_V1 */ + scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) +#endif /* OPT_STEREO_32KBPS_V1 */ st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); move16(); #ifndef MSAN_FIX @@ -1989,7 +1993,11 @@ ivas_error acelp_core_dec_ivas_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) +#ifdef OPT_STEREO_32KBPS_V1 + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) +#else /* OPT_STEREO_32KBPS_V1 */ + scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) +#endif /* OPT_STEREO_32KBPS_V1 */ st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); move16(); #ifndef MSAN_FIX @@ -2096,7 +2104,11 @@ ivas_error acelp_core_dec_ivas_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) +#ifdef OPT_STEREO_32KBPS_V1 + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) +#else /* OPT_STEREO_32KBPS_V1 */ + scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) +#endif /* OPT_STEREO_32KBPS_V1 */ #ifndef MSAN_FIX Scale_sig32( synth_fx, L_FRAME48k, Q_real - 1 ); #endif diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index c8985d7cd..b3bddae59 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -1450,7 +1450,11 @@ void stereo_cna_update_params_fx( { IF( EQ_16( hCPE->nchan_out, 1 ) ) { +#ifdef OPT_STEREO_32KBPS_V1 + c_LR_fx = MAX_32; +#else /* OPT_STEREO_32KBPS_V1 */ c_LR_fx = MAX_WORD16; +#endif /* OPT_STEREO_32KBPS_V1 */ move32(); c_ILD_fx = 0; move32(); @@ -1512,8 +1516,12 @@ void stereo_cna_update_params_fx( dotLR_fx = Mpy_32_32( W_extract_l( dotLR_fx ), energy_xy_fx ); /* dotLR_fx_q + ((31 - temp_res_q) - 31)) */ dotLR_fx_q = add( dotLR_fx_q, sub( sub( 31, temp_res_q ), 31 ) ); dotLR_fx = W_deposit32_l( L_shl_sat( W_extract_l( dotLR_fx ), sub( 31, dotLR_fx_q ) ) ); /* Q31 */ - /* estimate L/R correlation factor and ILD in time domain */ + /* estimate L/R correlation factor and ILD in time domain */ +#ifdef OPT_STEREO_32KBPS_V1 + c_LR_fx = W_extract_l( dotLR_fx ); /* Q31 */ +#else /* OPT_STEREO_32KBPS_V1 */ c_LR_fx = extract_h( W_extract_l( dotLR_fx ) ); /* Q15 */ +#endif /* OPT_STEREO_32KBPS_V1 */ temp_res_q = 0; move16(); @@ -1552,15 +1560,24 @@ void stereo_cna_update_params_fx( /* update of long-term ILD and LR correlation factors for stereo CNA */ IF( !hFdCngDec->first_cna_noise_updated ) { +#ifdef OPT_STEREO_32KBPS_V1 + hFdCngDec->cna_LR_LT_fx = extract_h( c_LR_fx ); +#else /* OPT_STEREO_32KBPS_V1 */ hFdCngDec->cna_LR_LT_fx = extract_l( c_LR_fx ); +#endif /* OPT_STEREO_32KBPS_V1 */ move16(); hFdCngDec->cna_ILD_LT_fx = extract_l( c_ILD_fx ); move16(); } ELSE { +#ifdef OPT_STEREO_32KBPS_V1 + hFdCngDec->cna_LR_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_LR_CORR_LT_FILT_FX, hFdCngDec->cna_LR_LT_fx ), + Mpy_32_32( ONE_IN_Q31 - STEREO_CNA_LR_CORR_LT_FILT_FX, c_LR_fx ) ) ); /* Q31 */ +#else /* OPT_STEREO_32KBPS_V1 */ hFdCngDec->cna_LR_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_LR_CORR_LT_FILT_FX, hFdCngDec->cna_LR_LT_fx ), Mpy_32_16_1( L_sub( ONE_IN_Q31, STEREO_CNA_LR_CORR_LT_FILT_FX ), extract_l( c_LR_fx ) ) ) ); /* Q31 */ +#endif /* OPT_STEREO_32KBPS_V1 */ move16(); hFdCngDec->cna_ILD_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_ILD_LT_FILT_FX, hFdCngDec->cna_ILD_LT_fx ), diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index ca4cfdb69..7c1c892aa 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -1519,8 +1519,10 @@ void stereo_dft_dec_fx( HANDLE_FD_CNG_COM hFdCngCom = hFdCngDec->hFdCngCom; Word16 *cna_seed = &( hFdCngCom->seed ); Word32 DFT_W, DFT_Y; +#ifndef OPT_STEREO_32KBPS_V1 Word16 q_samp_ratio = Q15; move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ output_frame = (Word16) Mpy_32_32( L_add( st0->output_Fs, FRAMES_PER_SEC_BY_2 ), ONE_BY_FRAMES_PER_SEC_Q31 ); /* Q0 */ @@ -1528,8 +1530,12 @@ void stereo_dft_dec_fx( * Initialization *-----------------------------------------------------------------*/ +#ifdef OPT_STEREO_32KBPS_V1 + samp_ratio = divide3232( st0->sr_core, st0->output_Fs ); // Q15 +#else /* OPT_STEREO_32KBPS_V1 */ samp_ratio = (Word16) BASOP_Util_Divide3232_Scale( st0->sr_core, st0->output_Fs, &q_samp_ratio ); samp_ratio = shr( samp_ratio, sub( Q15 - Q12, q_samp_ratio ) ); +#endif /* OPT_STEREO_32KBPS_V1 */ stop = shr( STEREO_DFT32MS_N_32k, 1 ); @@ -2102,10 +2108,17 @@ void stereo_dft_dec_fx( /*Nyquist Freq.*/ IF( EQ_16( hStereoDft->band_limits[b], shr( hStereoDft->NFFT, 1 ) ) ) { +#ifdef OPT_STEREO_32KBPS_V1 + DFT_L[1] = Madd_32_16( pDFT_DMX[1], pDFT_DMX[1], g ); /* qDFT */ + move32(); + DFT_R[1] = Msub_32_16( pDFT_DMX[1], pDFT_DMX[1], g ); /* qDFT */ + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ DFT_L[1] = L_add( pDFT_DMX[1], Mpy_32_16_1( pDFT_DMX[1], g ) ); /* qDFT */ move32(); DFT_R[1] = L_sub( pDFT_DMX[1], Mpy_32_16_1( pDFT_DMX[1], g ) ); /* qDFT */ move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ DFT_L[1] = Mpy_32_16_1( DFT_L[1], INV_SQRT2_FX_Q15 ); /* qDFT */ move32(); DFT_R[1] = Mpy_32_16_1( DFT_R[1], INV_SQRT2_FX_Q15 ); /* qDFT */ @@ -2238,27 +2251,52 @@ void stereo_dft_dec_fx( q_cna_level = sub( Q31, add( q_cna_level, Q16 ) ); /* generate comfort noise from gaussian noise and add to the decoded DFT spectrum */ +#ifdef OPT_STEREO_32KBPS_V1 + Word16 shift = sub( q_cna_level, hStereoDft->q_dft ); +#endif /* OPT_STEREO_32KBPS_V1 */ N1 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ N2 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ - l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ - DFT_L[2 * i] = L_add( DFT_L[2 * i], l_tmp ); /* q_dft */ +#ifdef OPT_STEREO_32KBPS_V1 + l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, shift ); /* q_dft */ +#else /* OPT_STEREO_32KBPS_V1 */ + l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ +#endif /* OPT_STEREO_32KBPS_V1 */ + DFT_L[2 * i] = L_add( DFT_L[2 * i], l_tmp ); /* q_dft */ move32(); +#ifdef OPT_STEREO_32KBPS_V1 + l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, shift ); /* q_dft */ + DFT_R[2 * i] = L_add( DFT_R[2 * i], l_tmp ); /* q_dft */ +#else /* OPT_STEREO_32KBPS_V1 */ l_tmp = L_sub( Msub_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ DFT_R[2 * i] = L_add( DFT_R[2 * i], l_tmp ); /* q_dft */ +#endif /* OPT_STEREO_32KBPS_V1 */ move32(); N1 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ N2 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ - l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ - DFT_L[2 * i + 1] = L_add( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ +#ifdef OPT_STEREO_32KBPS_V1 + l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, shift ); /* q_dft */ + DFT_L[2 * i + 1] = L_add( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ + move32(); + l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, shift ); /* q_dft */ + DFT_R[2 * i + 1] = L_add( DFT_R[2 * i + 1], l_tmp ); /* q_dft */ + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ + l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ + DFT_L[2 * i + 1] = L_add( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ move32(); l_tmp = L_sub( Msub_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ DFT_R[2 * i + 1] = L_add( DFT_R[2 * i + 1], l_tmp ); /* q_dft */ move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ } } @@ -2346,8 +2384,12 @@ static void stereo_dft_compute_td_stefi_params_fx( return; } +#ifdef OPT_STEREO_32KBPS_V1 + bin0 = round_fx( L_mult0( hStereoDft->NFFT, samp_ratio ) ); +#else /* OPT_STEREO_32KBPS_V1 */ bin0 = extract_l( L_shr_r( Mpy_32_16_1( (Word32) hStereoDft->NFFT, samp_ratio ), 1 ) ); /* Q0 */ bin0 = shl( bin0, Q3 ); +#endif /* OPT_STEREO_32KBPS_V1 */ bin0 = s_min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); /* Q0 */ b = hStereoDft->nbands; /* Q0 */ move16(); @@ -2512,14 +2554,18 @@ static void stereo_dft_dequantize_ipd_fx( *-------------------------------------------------------------------------*/ void stereo_dft_generate_res_pred_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word16 samp_ratio, /* i : sampling ratio Q13*/ - Word32 *pDFT_DMX, /* i : downmix signal qDFT*/ - Word32 *DFT_PRED_RES, /* o : residual prediction signal qDFT*/ - Word32 *pPredGain, /* i : residual prediction gains Q31*/ - const Word16 k, /* i : subframe index Q0*/ - Word32 *ap_filt_DMX, /* i : enhanced stereo filling signal qDFT*/ - Word16 *stop, /* o : last FD stereo filling bin Q0*/ - const Word16 bfi /* i : BFI flag Q0*/ +#ifdef OPT_STEREO_32KBPS_V1 + const Word16 samp_ratio, /* i : sampling ratio Q15*/ +#else /* OPT_STEREO_32KBPS_V1 */ + const Word16 samp_ratio, /* i : sampling ratio Q13*/ +#endif /* OPT_STEREO_32KBPS_V1 */ + Word32 *pDFT_DMX, /* i : downmix signal qDFT*/ + Word32 *DFT_PRED_RES, /* o : residual prediction signal qDFT*/ + Word32 *pPredGain, /* i : residual prediction gains Q31*/ + const Word16 k, /* i : subframe index Q0*/ + Word32 *ap_filt_DMX, /* i : enhanced stereo filling signal qDFT*/ + Word16 *stop, /* o : last FD stereo filling bin Q0*/ + const Word16 bfi /* i : BFI flag Q0*/ ) { /* general variables */ @@ -2529,7 +2575,10 @@ void stereo_dft_generate_res_pred_fx( Word16 lb_stefi_start_band; /* variables for enhanced stereo filling */ - Word16 norm_fac, q_norm_fac, lim_norm_fac; + Word16 norm_fac, q_norm_fac; +#ifndef OPT_STEREO_32KBPS_V1 + Word16 lim_norm_fac; +#endif /* OPT_STEREO_32KBPS_V1 */ Word16 q_sqrt; Word16 alpha; // gain_limit; @@ -2543,8 +2592,12 @@ void stereo_dft_generate_res_pred_fx( Word32 pred_gain_avg; Word32 g2; Word16 nbands_respred; +#ifdef OPT_STEREO_32KBPS_V1 + Word16 q_new, diff; +#else /* OPT_STEREO_32KBPS_V1 */ q_norm_fac = 0; move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ push_wmops( "gen_respred" ); /* smoothing and limiting parameters */ @@ -2566,8 +2619,12 @@ void stereo_dft_generate_res_pred_fx( /* In ACELP mode the downmix signal is not available in bandwidth extension area. * * Therefore, the downmix energy in the corresponding subbands is estimated. */ +#ifdef OPT_STEREO_32KBPS_V1 + bin0 = round_fx( L_mult0( hStereoDft->NFFT, samp_ratio ) ); +#else /* OPT_STEREO_32KBPS_V1 */ bin0 = (Word16) ( L_shr( L_add( L_mult0( hStereoDft->NFFT, samp_ratio ), ONE_IN_Q12 ), Q12 + 1 ) ); /* Q0 */ move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ bin0 = s_min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); /* Q0 */ b = hStereoDft->nbands; move16(); @@ -2611,37 +2668,78 @@ void stereo_dft_generate_res_pred_fx( /* calculate band energies (low band only in case of ACELP) */ FOR( i = hStereoDft->band_limits[b]; i < min( hStereoDft->band_limits[b + 1], bin0 ); i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + dmx_nrg_64bit = W_mac_32_32( W_mac_32_32( dmx_nrg_64bit, pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), + pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ); /* 2 * q_dft + 1 */ + rev_nrg_64bit = W_mac_32_32( W_mac_32_32( rev_nrg_64bit, ap_filt_DMX[2 * i], ap_filt_DMX[2 * i] ), + ap_filt_DMX[2 * i + 1], ap_filt_DMX[2 * i + 1] ); /* 2 * q_dft + 1 */ +#else /* OPT_STEREO_32KBPS_V1 */ dmx_nrg_64bit = W_add( dmx_nrg_64bit, W_add( W_mult0_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), W_mult0_32_32( pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) ) ); /* 2 * q_dft */ rev_nrg_64bit = W_add( rev_nrg_64bit, W_add( W_mult0_32_32( ap_filt_DMX[2 * i], ap_filt_DMX[2 * i] ), W_mult0_32_32( ap_filt_DMX[2 * i + 1], ap_filt_DMX[2 * i + 1] ) ) ); /* 2 * q_dft */ +#endif /* OPT_STEREO_32KBPS_V1 */ } + +#ifdef OPT_STEREO_32KBPS_V1 + q_new = add( shl( hStereoDft->q_dft, 1 ), 1 ); + q_shift = W_norm( dmx_nrg_64bit ); + dmx_nrg = W_shl_sat_l( dmx_nrg_64bit, sub( q_shift, 32 ) ); // 2 * hStereoDft->q_dft + 1 - (q_shift - 32) + dmx_nrg_q = add( q_new, sub( q_shift, 32 ) ); + q_shift = W_norm( rev_nrg_64bit ); + rev_nrg = W_shl_sat_l( rev_nrg_64bit, sub( q_shift, 32 ) ); // 2 * hStereoDft->q_dft + 1 - (q_shift - 32) + rev_nrg_q = add( q_new, sub( q_shift, 32 ) ); + move16(); +#else /* OPT_STEREO_32KBPS_V1 */ q_shift = W_norm( dmx_nrg_64bit ); dmx_nrg = W_extract_l( W_shl( dmx_nrg_64bit, sub( q_shift, 32 ) ) ); // 2 * hStereoDft->q_dft + (q_shift - 32) dmx_nrg_q = add( imult1616( 2, hStereoDft->q_dft ), sub( q_shift, 32 ) ); q_shift = W_norm( rev_nrg_64bit ); rev_nrg = W_extract_l( W_shl( rev_nrg_64bit, sub( q_shift, 32 ) ) ); // 2 * hStereoDft->q_dft + (q_shift - 32) rev_nrg_q = add( imult1616( 2, hStereoDft->q_dft ), sub( q_shift, 32 ) ); +#endif /* OPT_STEREO_32KBPS_V1 */ /* Reach a common Q for dmx_nrg and rev_nrg */ q_com = s_min( dmx_nrg_q, rev_nrg_q ); dmx_nrg = L_shl( dmx_nrg, sub( q_com, dmx_nrg_q ) ); /* q_com */ rev_nrg = L_shl( rev_nrg, sub( q_com, rev_nrg_q ) ); /* q_com */ + +#ifdef OPT_STEREO_32KBPS_V1 + diff = sub( hStereoDft->q_smoothed_nrg, q_com ); + IF( diff < 0 ) +#else /* OPT_STEREO_32KBPS_V1 */ IF( LT_16( hStereoDft->q_smoothed_nrg, q_com ) ) +#endif /* OPT_STEREO_32KBPS_V1 */ { +#ifdef OPT_STEREO_32KBPS_V1 + rev_nrg = L_shl( rev_nrg, shl( diff, 1 ) ); + dmx_nrg = L_shl( dmx_nrg, shl( diff, 1 ) ); +#else /* OPT_STEREO_32KBPS_V1 */ rev_nrg = L_shr( rev_nrg, shl( sub( q_com, hStereoDft->q_smoothed_nrg ), 1 ) ); dmx_nrg = L_shr( dmx_nrg, shl( sub( q_com, hStereoDft->q_smoothed_nrg ), 1 ) ); +#endif /* OPT_STEREO_32KBPS_V1 */ q_com = hStereoDft->q_smoothed_nrg; move16(); } +#ifdef OPT_STEREO_32KBPS_V1 + ELSE +#else /* OPT_STEREO_32KBPS_V1 */ ELSE IF( GT_16( hStereoDft->q_smoothed_nrg, q_com ) ) +#endif /* OPT_STEREO_32KBPS_V1 */ { +#ifdef OPT_STEREO_32KBPS_V1 + hStereoDft->smooth_res_nrg_fx[b] = L_shr( hStereoDft->smooth_res_nrg_fx[b], shl( diff, 1 ) ); /* hStereoDft->q_smoothed_nrg */ + move32(); + hStereoDft->smooth_dmx_nrg_fx[b] = L_shr( hStereoDft->smooth_dmx_nrg_fx[b], shl( diff, 1 ) ); /* hStereoDft->q_smoothed_nrg */ + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ hStereoDft->smooth_res_nrg_fx[b] = L_shr( hStereoDft->smooth_res_nrg_fx[b], shl( sub( hStereoDft->q_smoothed_nrg, q_com ), 1 ) ); /* hStereoDft->q_smoothed_nrg */ move32(); hStereoDft->smooth_dmx_nrg_fx[b] = L_shr( hStereoDft->smooth_dmx_nrg_fx[b], shl( sub( hStereoDft->q_smoothed_nrg, q_com ), 1 ) ); /* hStereoDft->q_smoothed_nrg */ move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ q_smoothed_nrg_local[b] = q_com; move16(); } @@ -2651,9 +2749,38 @@ void stereo_dft_generate_res_pred_fx( hStereoDft->smooth_dmx_nrg_fx[b] = Madd_32_16( Mpy_32_16_1( hStereoDft->smooth_dmx_nrg_fx[b], alpha ), dmx_nrg, sub( (Word16) ( 0x7FFF ), alpha ) ); /* hStereoDft->q_smoothed_nrg */ move32(); +#ifdef OPT_STEREO_32KBPS_V1 + // Compute norm_fac in Q14 + norm_fac = MAX_16; + move16(); +#endif /* OPT_STEREO_32KBPS_V1 */ /* normalization factor */ IF( hStereoDft->smooth_res_nrg_fx[b] != 0 ) { +#ifdef OPT_STEREO_32KBPS_V1 + norm_fac = 0; + move16(); + IF( hStereoDft->smooth_dmx_nrg_fx[b] != 0 ) + { + Word16 quo, quo_e; + Word32 prod; + + norm_fac = BASOP_Util_Divide3232_Scale( hStereoDft->smooth_dmx_nrg_fx[b], hStereoDft->smooth_res_nrg_fx[b], &q_norm_fac ); /* q_norm_fac */ + norm_fac = Sqrt16( norm_fac, &q_norm_fac ); + + quo = BASOP_Util_Divide1616_Scale( 32767, norm_fac, &quo_e ); /* q_norm_fac */ + quo_e = sub( quo_e, q_norm_fac ); + quo = shl_sat( quo, sub( quo_e, 1 ) ); // Q14 + quo = s_max( 13107 /*0.8 in Q14 */, quo ); + quo = s_min( quo, 20480 /* 1.25 in Q14*/ ); + + prod = L_mult( norm_fac, quo ); // exp:q_norm_fac+1 + // Bring to Q30 + prod = L_shl_sat( prod, q_norm_fac ); + + norm_fac = extract_h( prod ); + } +#else /* OPT_STEREO_32KBPS_V1 */ norm_fac = BASOP_Util_Divide3232_Scale( hStereoDft->smooth_dmx_nrg_fx[b], hStereoDft->smooth_res_nrg_fx[b], &q_norm_fac ); /* q_norm_fac */ norm_fac = Sqrt16( norm_fac, &q_norm_fac ); IF( norm_fac != 0 ) @@ -2709,7 +2836,9 @@ void stereo_dft_generate_res_pred_fx( } } } +#endif /* OPT_STEREO_32KBPS_V1 */ } +#ifndef OPT_STEREO_32KBPS_V1 ELSE { norm_fac = MAX_16; @@ -2717,13 +2846,21 @@ void stereo_dft_generate_res_pred_fx( q_norm_fac = Q1; move16(); } +#endif /* OPT_STEREO_32KBPS_V1 */ FOR( i = hStereoDft->band_limits[b]; i < min( hStereoDft->band_limits[b + 1], bin0 ); i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), 1 ); /* q_dft */ + move32(); + DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i + 1] ), 1 ); /* q_dft */ + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), q_norm_fac ); /* q_dft */ move32(); DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i + 1] ), q_norm_fac ); /* q_dft */ move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ } } diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index c6466183b..c8a59cd6a 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -2343,15 +2343,20 @@ static Word32 ncross_corr_self_fx( { Word64 c_c_fx; Word32 c_c_fx_return; + Word64 energy_x_fx, energy_y_fx; +#ifndef OPT_STEREO_32KBPS_V1 Word16 c_c_fx_q; - Word64 energy_xy_fx, energy_x_fx, energy_y_fx; + Word64 energy_xy_fx; +#endif /* OPT_STEREO_32KBPS_V1 */ UWord16 j; Word32 *signal_a_fx, *signal_b_fx; Word32 temp_x, temp_y; Word16 headroom_left_x, headroom_left_y; +#ifndef OPT_STEREO_32KBPS_V1 Word16 x_inv_q, y_inv_q; Word16 x_q, y_q; Word16 res_q; +#endif /* OPT_STEREO_32KBPS_V1 */ c_c_fx = 0; move64(); energy_x_fx = 0; @@ -2362,13 +2367,43 @@ static Word32 ncross_corr_self_fx( signal_b_fx = &signal_fx[y]; /* Q11 */ FOR( j = 0; j < corr_len; j += subsampling ) { +#ifdef OPT_STEREO_32KBPS_V1 + c_c_fx = W_mac_32_32( c_c_fx, signal_a_fx[j], signal_b_fx[j] ); /* 2 * Q11 + 1*/ + energy_x_fx = W_mac_32_32( energy_x_fx, signal_a_fx[j], signal_a_fx[j] ); /* 2 * Q11+ 1 */ + energy_y_fx = W_mac_32_32( energy_y_fx, signal_b_fx[j], signal_b_fx[j] ); /* 2 * Q11+ 1 */ +#else /* OPT_STEREO_32KBPS_V1 */ c_c_fx = W_add( c_c_fx, W_mult0_32_32( ( signal_a_fx[j] ), ( signal_b_fx[j] ) ) ); /* 2 * Q11 */ energy_x_fx = W_add( energy_x_fx, W_mult0_32_32( ( signal_a_fx[j] ), ( signal_a_fx[j] ) ) ); /* 2 * Q11 */ energy_y_fx = W_add( energy_y_fx, W_mult0_32_32( ( signal_b_fx[j] ), ( signal_b_fx[j] ) ) ); /* 2 * Q11 */ +#endif /* OPT_STEREO_32KBPS_V1 */ } headroom_left_x = W_norm( energy_x_fx ); headroom_left_y = W_norm( energy_y_fx ); +#ifdef OPT_STEREO_32KBPS_V1 + temp_x = W_extract_h( W_shl( energy_x_fx, headroom_left_x ) ); // Q23 + headroom_left_x -32 + temp_y = W_extract_h( W_shl( energy_y_fx, headroom_left_y ) ); // Q23 + headroom_left_y -32 + Word64 prod = W_mult0_32_32( temp_x, temp_y ); // Q(headroom_left_x + headroom_left_y - 18) + Word16 q_prod = W_norm( prod ); + Word32 energy = W_extract_h( W_shl( prod, q_prod ) ); // Q(headroom_left_x + headroom_left_y + q_prod - 18) - 32 + q_prod = sub( 81, add( add( headroom_left_x, headroom_left_y ), q_prod ) ); + energy = Sqrt32( energy, &q_prod ); + + IF( LT_32( energy, L_shl_sat( 1, sub( 31, q_prod ) ) ) ) + { + c_c_fx_return = W_shl_sat_l( c_c_fx, 31 - ( 2 * OUTPUT_Q + 1 ) ); // Q31 + } + ELSE + { + // Maximize c_c_fx + Word16 q_cc = W_norm( c_c_fx ); + Word32 num = W_extract_h( W_shl( c_c_fx, q_cc ) ); // Q(23 + q_cc - 32) -> e(40 - q_cc) + Word16 quo_e; + num = BASOP_Util_Divide3232_Scale_cadence( num, energy, &quo_e ); + quo_e = add( sub( sub( 40, q_cc ), q_prod ), quo_e ); + c_c_fx_return = L_shl_sat( num, quo_e ); // Q31 + } +#else /* OPT_STEREO_32KBPS_V1 */ IF( LT_16( headroom_left_x, 32 ) ) { energy_x_fx = W_shr( energy_x_fx, sub( 32, headroom_left_x ) ); /* 2 * Q11 - (32 -headroom_left_x) */ @@ -2440,6 +2475,7 @@ static Word32 ncross_corr_self_fx( c_c_fx_return = W_extract_l( c_c_fx ); /* Q31 */ move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ return c_c_fx_return; } diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index c975da8d6..e31c9f6bc 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -384,7 +384,7 @@ void tdm_upmix_plain_fx( const Word32 PCh_2_L_fx[], /* i : primary channel Qx*/ const Word32 SCh_2_R_fx[], /* i : secondary channel Qx*/ const Word32 LR_ratio_fx, /* i : mixing ratio Q31*/ - const Word32 inv_den_LR_ratio_fx, /* i : inverse mixing ration Q31*/ + const Word32 inv_den_LR_ratio_fx, /* i : inverse mixing ration Q30*/ const Word16 start_index, /* i : start index Q0*/ const Word16 end_index, /* i : end index Q0*/ const Word16 plus_minus_flag /* i : plus/minus flag Q0*/ @@ -396,16 +396,37 @@ void tdm_upmix_plain_fx( { FOR( i = start_index; i < end_index; i++ ) { +#ifdef OPT_STEREO_32KBPS_V1 + Word32 temp_left = Madd_32_32( SCh_2_R_fx[i], L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ); /* Qx */ + Left_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_left, inv_den_LR_ratio_fx ), -30 ); /* Qx */ + move32(); + Word32 temp_right = Msub_32_32( PCh_2_L_fx[i], L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ); /* Qx */ + Right_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_right, inv_den_LR_ratio_fx ), -30 ); /* Qx */ + move32(); +#else /* OPT_STEREO_32KBPS_V1 */ Word32 temp_left = L_add( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] ); /* Qx */ Left_fx[i] = L_shl_sat( Mpy_32_32( temp_left, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ move32(); Word32 temp_right = L_add( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), L_negate( LR_ratio_fx ) ), PCh_2_L_fx[i] ); /* Qx */ Right_fx[i] = L_shl_sat( Mpy_32_32( temp_right, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ move32(); +#endif /* OPT_STEREO_32KBPS_V1 */ } } ELSE { +#ifdef OPT_STEREO_32KBPS_V1 + Word32 inv_den_LR_ratio_fx_neg = L_negate( inv_den_LR_ratio_fx ); + FOR( i = start_index; i < end_index; i++ ) + { + Word32 temp_left = Msub_32_32( SCh_2_R_fx[i], L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ); /* Qx */ + Left_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_left, inv_den_LR_ratio_fx_neg ), -30 ); /* Qx */ + move32(); + Word32 temp_right = Msub_32_32( PCh_2_L_fx[i], L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ); /* Qx */ + Right_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_right, inv_den_LR_ratio_fx_neg ), -30 ); /* Qx */ + move32(); + } +#else /* OPT_STEREO_32KBPS_V1 */ FOR( i = start_index; i < end_index; i++ ) { Word32 temp_left = L_sub( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] ); /* Qx */ @@ -415,6 +436,7 @@ void tdm_upmix_plain_fx( Right_fx[i] = L_shl_sat( Mpy_32_32( temp_right, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ move32(); } +#endif /* OPT_STEREO_32KBPS_V1 */ } return; -- GitLab From bb55862d3bbd4d106b2f10e9ff6deb35595b32f1 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 4 Mar 2025 20:41:36 +0530 Subject: [PATCH 14/97] Duplicate lib_dec files cleanup --- Workspace_msvc/lib_dec.vcxproj | 14 - Workspace_msvc/lib_dec.vcxproj.filters | 42 - lib_dec/FEC_HQ_core.c | 136 -- lib_dec/FEC_HQ_core_fx.c | 92 + lib_dec/ari_dec.c | 338 ---- lib_dec/ari_dec_fx.c | 289 +++ lib_dec/arith_coder_dec.c | 250 --- lib_dec/arith_coder_dec_fx.c | 208 ++ lib_dec/bass_psfilter.c | 317 --- lib_dec/bass_psfilter_fx.c | 244 +++ lib_dec/core_dec_init.c | 84 - lib_dec/core_dec_init_fx.c | 26 + lib_dec/core_switching_dec.c | 1076 ---------- lib_dec/core_switching_dec_fx.c | 1009 ++++++++++ lib_dec/dec_prm.c | 328 ---- lib_dec/dec_prm_fx.c | 270 +++ lib_dec/dec_tcx.c | 508 ----- lib_dec/dec_tcx_fx.c | 447 +++++ lib_dec/fd_cng_dec.c | 1393 ------------- lib_dec/fd_cng_dec_fx.c | 1280 ++++++++++++ lib_dec/init_dec.c | 76 - lib_dec/init_dec_fx.c | 15 + lib_dec/ivas_mc_param_dec.c | 33 + lib_dec/ivas_mc_param_dec_fx.c | 34 - lib_dec/swb_bwe_dec.c | 681 ------- lib_dec/swb_bwe_dec_fx.c | 369 ++++ lib_dec/swb_tbe_dec.c | 2478 ------------------------ lib_dec/swb_tbe_dec_fx.c | 2034 ++++++++++++++++++- lib_dec/tonalMDCTconcealment.c | 436 ----- lib_dec/tonalMDCTconcealment_fx.c | 391 ++++ 30 files changed, 6701 insertions(+), 8197 deletions(-) delete mode 100644 lib_dec/FEC_HQ_core.c delete mode 100644 lib_dec/ari_dec.c delete mode 100644 lib_dec/arith_coder_dec.c delete mode 100644 lib_dec/bass_psfilter.c delete mode 100644 lib_dec/core_dec_init.c delete mode 100644 lib_dec/core_switching_dec.c delete mode 100644 lib_dec/dec_prm.c delete mode 100644 lib_dec/dec_tcx.c delete mode 100644 lib_dec/fd_cng_dec.c delete mode 100644 lib_dec/init_dec.c delete mode 100644 lib_dec/ivas_mc_param_dec_fx.c delete mode 100644 lib_dec/swb_bwe_dec.c delete mode 100644 lib_dec/swb_tbe_dec.c delete mode 100644 lib_dec/tonalMDCTconcealment.c diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 3d447fe21..b3a847791 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -145,22 +145,17 @@ - - - false - - @@ -176,9 +171,7 @@ - - @@ -191,12 +184,10 @@ - - @@ -216,7 +207,6 @@ - @@ -246,7 +236,6 @@ - @@ -310,18 +299,15 @@ - - - diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index cc7594415..c4e148b89 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -8,9 +8,6 @@ decoder_evs_c - - decoder_evs_c - decoder_evs_c @@ -137,9 +134,6 @@ decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c @@ -275,36 +269,24 @@ decoder_all_c - - decoder_all_c - decoder_all_c decoder_all_c - - decoder_all_c - decoder_all_c decoder_all_c - - decoder_all_c - decoder_all_c decoder_all_c - - decoder_all_c - decoder_all_c @@ -320,15 +302,9 @@ decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c @@ -365,9 +341,6 @@ decoder_all_c - - decoder_all_c - decoder_all_c @@ -380,9 +353,6 @@ decoder_all_c - - decoder_all_c - decoder_all_c @@ -437,9 +407,6 @@ decoder_all_c - - decoder_all_c - decoder_all_c @@ -515,15 +482,9 @@ decoder_all_c - - decoder_all_c - decoder_all_c - - decoder_all_c - decoder_all_c @@ -542,9 +503,6 @@ decoder_all_c - - decoder_all_c - decoder_all_c diff --git a/lib_dec/FEC_HQ_core.c b/lib_dec/FEC_HQ_core.c deleted file mode 100644 index 6a119b365..000000000 --- a/lib_dec/FEC_HQ_core.c +++ /dev/null @@ -1,136 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_dec.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - - -void save_synthesis_hq_fec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 output_fx[], /* i : decoded synthesis */ - const Word16 output_frame, /* i : decoded synthesis */ - CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ -) -{ - Word16 post_hq_delay; - - SWITCH( st->element_mode ) - { - case EVS_MONO: - post_hq_delay = NS2SA_FX2( st->output_Fs, POST_HQ_DELAY_NS ); - BREAK; - case IVAS_SCE: - post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); - BREAK; - case IVAS_CPE_DFT: - test(); - IF( EQ_16( hCPE->nchan_out, 1 ) && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) - { - post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); - } - ELSE - { - post_hq_delay = 0; - move16(); - } - BREAK; - default: - post_hq_delay = 0; - move16(); - BREAK; - } - - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( st->codec_mode, MODE1 ) && st->hTcxDec != NULL ) && ( ( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) ) - { - Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ) ); - FOR( Word16 i = 0; i < output_frame; i++ ) - { - st->hTcxDec->old_synthFB_fx[( ( i + output_frame ) - post_hq_delay )] = extract_h( L_shl_sat( output_fx[i], 16 ) ); // Q16 - move16(); - } - - IF( st->element_mode == EVS_MONO ) - { - /* reset the remaining buffer, which is read in TCX concealment the necessary samples to fill - this buffer are not available for all cases, the impact on the output is limited */ - - set16_fx( st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), 0, post_hq_delay ); - IF( GE_16( output_frame, L_FRAME16k ) ) - { - Copy( st->prev_synth_buffer_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); - } - ELSE - { - Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - } - - IF( st->core != ACELP_CORE ) - { - IF( GE_16( output_frame, L_FRAME16k ) ) - { - Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); - Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - } - ELSE - { - Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); - Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - } - } - } - ELSE - { - IF( st->core != ACELP_CORE ) - { - Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), post_hq_delay ); - Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - } - } - } - return; -} diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index f88927ee5..09bc652be 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -1961,6 +1961,98 @@ static void Next_good_after_burst_erasures_fx( return; } + +void save_synthesis_hq_fec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 output_fx[], /* i : decoded synthesis */ + const Word16 output_frame, /* i : decoded synthesis */ + CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ +) +{ + Word16 post_hq_delay; + + SWITCH( st->element_mode ) + { + case EVS_MONO: + post_hq_delay = NS2SA_FX2( st->output_Fs, POST_HQ_DELAY_NS ); + BREAK; + case IVAS_SCE: + post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); + BREAK; + case IVAS_CPE_DFT: + test(); + IF( EQ_16( hCPE->nchan_out, 1 ) && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) + { + post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); + } + ELSE + { + post_hq_delay = 0; + move16(); + } + BREAK; + default: + post_hq_delay = 0; + move16(); + BREAK; + } + + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( st->codec_mode, MODE1 ) && st->hTcxDec != NULL ) && ( ( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) ) + { + Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ) ); + FOR( Word16 i = 0; i < output_frame; i++ ) + { + st->hTcxDec->old_synthFB_fx[( ( i + output_frame ) - post_hq_delay )] = extract_h( L_shl_sat( output_fx[i], 16 ) ); // Q16 + move16(); + } + + IF( st->element_mode == EVS_MONO ) + { + /* reset the remaining buffer, which is read in TCX concealment the necessary samples to fill + this buffer are not available for all cases, the impact on the output is limited */ + + set16_fx( st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), 0, post_hq_delay ); + IF( GE_16( output_frame, L_FRAME16k ) ) + { + Copy( st->prev_synth_buffer_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + } + ELSE + { + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + } + + IF( st->core != ACELP_CORE ) + { + IF( GE_16( output_frame, L_FRAME16k ) ) + { + Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + } + ELSE + { + Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS ) ), NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ) ); + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + } + } + } + ELSE + { + IF( st->core != ACELP_CORE ) + { + Copy( st->delay_buf_out_fx, st->hTcxDec->old_synthFB_fx + sub( shl( output_frame, 1 ), post_hq_delay ), post_hq_delay ); + Copy( st->hHQ_core->old_out_fx + NS2SA_FX2( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + shl( output_frame, 1 ), NS2SA_FX2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); + } + } + } + return; +} + + #ifdef ADD_IVAS_HQ_CODE_FEC /*-------------------------------------------------------------------------- * save_synthesis_hq_fec() diff --git a/lib_dec/ari_dec.c b/lib_dec/ari_dec.c deleted file mode 100644 index b45cb5d9c..000000000 --- a/lib_dec/ari_dec.c +++ /dev/null @@ -1,338 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "stat_com.h" -#include "basop_util.h" -#include "wmc_auto.h" - - -/*--------------------------------------------------------------- - * Ari decode 14 bits routines - -------------------------------------------------------------*/ - -/*--------------------------------------------------------------- - * ari_start_decoding_14bits_ivas() - * - * Start ArCo decoding - *-------------------------------------------------------------*/ - - -Word16 ari_start_decoding_14bits_prm_ivas_fx( - const Word16 *ptr, - Word16 bp, - Tastat *s ) -{ - Word32 val; - Word16 i; - const Word16 *p; - - val = 0; - move32(); - p = ptr + bp; - - FOR( i = 0; i < cbitsnew; i++ ) - { - val = L_or( L_shl( val, 1 ), *( p + i ) ); - } - s->low = 0; - move32(); - s->high = ari_q4new; - move32(); - s->value = val; - move32(); - - return add( bp, i ); -} - - -Word16 ari_decode_14bits_pow_ivas( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s, - UWord16 base ) -{ - UWord16 symbol; - Word32 low, high; - UWord32 range, value, cum; - Word16 pows[12]; /* "base" to the power of 2, 4, 8,... 2^12 */ - Word16 lowlim, highlim, testval; - Word16 k; - - highlim = 0; - low = s->low; - high = L_add( s->high, 1 ); - value = s->value; - lowlim = 0; - symbol = 0; - move16(); - move32(); - move32(); - move16(); - move16(); - - range = (UWord32) W_sub( high, low ); - move32(); - - /* the value read from bitstream */ - assert( value >= (UWord32) low ); - cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 ); - move32(); - - /* search for the interval where "cum" fits */ - IF( GT_64( W_mult0_32_32( L_shr( base, 1 ), range ), cum ) ) /* below pow-1 */ - { - pows[0] = testval = base; - move16(); - move16(); - /* increase exponent until it is smaller than "cum" */ - FOR( k = 1; k < 12; k++ ) - { - highlim = testval; - move16(); - pows[k] = mult_r( pows[k - 1], pows[k - 1] ); - move16(); - testval = mult_r( pows[k], base ); - IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) ) /* found! big range is [lowlim,testval], (now narrow it down) */ - { - lowlim = testval; - move16(); - k = sub( k, 1 ); - symbol = (UWord16) L_shl( 1, k ); - BREAK; - } - } - assert( k < 12 ); /* maximum 2^10-1*/ - /* narrow the range down */ - FOR( k--; k > 0; k-- ) - { - testval = mult_r( highlim, pows[k] ); - IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) ) - { - lowlim = testval; - move16(); - symbol = (UWord16) L_sub( symbol, L_shl( 1, sub( k, 1 ) ) ); - } - ELSE - { - highlim = testval; - move16(); - } - } - highlim = shr( highlim, 1 ); - lowlim = shr( lowlim, 1 ); - } - ELSE /* trivial case, above pow-1, that is, first symbol */ - { - symbol = 0; - lowlim = extract_l( L_shr( base, 1 ) ); - highlim = 16384; - move16(); - move16(); - } - - - high = L_add( low, mul_sbc_14bits( range, highlim ) ); - - low = L_add( low, mul_sbc_14bits( range, lowlim ) ); - - /*ptr init for ptr*/ - FOR( ; bp < bits; ) - { - IF( GT_32( high, ari_q2new ) ) - { - IF( GE_32( low, ari_q2new ) ) - { - value = (UWord32) W_sub( value, ari_q2new ); - low = L_sub( low, ari_q2new ); - high = L_sub( high, ari_q2new ); - } - ELSE - { - test(); - IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) - { - value = (UWord32) W_sub( value, ari_q1new ); - low = L_sub( low, ari_q1new ); - high = L_sub( high, ari_q1new ); - } - ELSE - { - BREAK; - } - } - } - low = L_add( low, low ); - high = L_add( high, high ); - - assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" ); - - value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] ); - } - - test(); - test(); - test(); - IF( !( NE_16( bp, bits ) || !( EQ_32( s->low, low ) && ( EQ_32( s->high, high ) ) && ( EQ_64( s->value, value ) ) ) ) ) - { - /* This should not happen except of bit errors. */ - s->high = s->low = 0; - move32(); - move32(); - *res = 0; - move16(); - return -1; - } - - s->low = low; - s->high = L_sub( high, 1 ); - s->value = value; - move32(); - move32(); - move32(); - - *res = symbol; - move16(); - return bp; -} - -Word16 ari_decode_14bits_sign_ivas( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s ) -{ - Word16 symbol; - Word32 low, high; - UWord32 range, value, cum; - - low = s->low; - high = L_add( s->high, 1 ); - value = s->value; - move32(); - move32(); - - range = (UWord32) W_sub( high, low ); - - IF( LT_16( bp, bits ) ) - { - assert( value >= (UWord32) low ); - cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 ); - IF( GT_64( W_shl( range, 13 ), cum ) ) - { - symbol = 2; - move16(); - high = L_add( low, W_extract_l( W_shr( range, 1 ) ) ); - } - ELSE - { - symbol = 1; - move16(); - low = L_add( low, W_extract_l( W_shr( range, 1 ) ) ); - } - - /*ptr init for ptr*/ - FOR( ; bp < bits; ) - { - IF( GT_32( high, ari_q2new ) ) - { - IF( GE_32( low, ari_q2new ) ) - { - value = (UWord32) W_sub( value, ari_q2new ); - low = L_sub( low, ari_q2new ); - high = L_sub( high, ari_q2new ); - } - ELSE - { - test(); - IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) - { - value = (UWord32) W_sub( value, ari_q1new ); - low = L_sub( low, ari_q1new ); - high = L_sub( high, ari_q1new ); - } - ELSE - { - BREAK; - } - } - } - low = L_add( low, low ); - high = L_add( high, high ); - - assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" ); - - value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] ); - } - } - ELSE - { - cum = (UWord32) W_sub( value, low ); - range = (UWord32) W_shr( range, 1 ); - IF( GT_64( range, cum ) ) - { - symbol = 2; - move16(); - high = L_add( low, range ); - } - ELSE - { - symbol = 1; - move16(); - low = L_add( low, range ); - } - } - - s->low = low; - s->high = L_sub( high, 1 ); - s->value = value; - move32(); - move32(); - move32(); - - *res = symbol; - move16(); - - return bp; -} diff --git a/lib_dec/ari_dec_fx.c b/lib_dec/ari_dec_fx.c index 3681568f2..524f9d121 100644 --- a/lib_dec/ari_dec_fx.c +++ b/lib_dec/ari_dec_fx.c @@ -551,3 +551,292 @@ Word16 ari_decode_14bits_sign_fx( Word16 *ptr, Word16 bp, Word16 bits, Word16 *r { return ari_decode_14bits_notbl_fx( ptr, bp, bits, res, s, 0, ari_lookup_sign_fx ); } + +/*--------------------------------------------------------------- + * ari_start_decoding_14bits_ivas() + * + * Start ArCo decoding + *-------------------------------------------------------------*/ + + +Word16 ari_start_decoding_14bits_prm_ivas_fx( + const Word16 *ptr, + Word16 bp, + Tastat *s ) +{ + Word32 val; + Word16 i; + const Word16 *p; + + val = 0; + move32(); + p = ptr + bp; + + FOR( i = 0; i < cbitsnew; i++ ) + { + val = L_or( L_shl( val, 1 ), *( p + i ) ); + } + s->low = 0; + move32(); + s->high = ari_q4new; + move32(); + s->value = val; + move32(); + + return add( bp, i ); +} + + +Word16 ari_decode_14bits_pow_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + UWord16 base ) +{ + UWord16 symbol; + Word32 low, high; + UWord32 range, value, cum; + Word16 pows[12]; /* "base" to the power of 2, 4, 8,... 2^12 */ + Word16 lowlim, highlim, testval; + Word16 k; + + highlim = 0; + low = s->low; + high = L_add( s->high, 1 ); + value = s->value; + lowlim = 0; + symbol = 0; + move16(); + move32(); + move32(); + move16(); + move16(); + + range = (UWord32) W_sub( high, low ); + move32(); + + /* the value read from bitstream */ + assert( value >= (UWord32) low ); + cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 ); + move32(); + + /* search for the interval where "cum" fits */ + IF( GT_64( W_mult0_32_32( L_shr( base, 1 ), range ), cum ) ) /* below pow-1 */ + { + pows[0] = testval = base; + move16(); + move16(); + /* increase exponent until it is smaller than "cum" */ + FOR( k = 1; k < 12; k++ ) + { + highlim = testval; + move16(); + pows[k] = mult_r( pows[k - 1], pows[k - 1] ); + move16(); + testval = mult_r( pows[k], base ); + IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) ) /* found! big range is [lowlim,testval], (now narrow it down) */ + { + lowlim = testval; + move16(); + k = sub( k, 1 ); + symbol = (UWord16) L_shl( 1, k ); + BREAK; + } + } + assert( k < 12 ); /* maximum 2^10-1*/ + /* narrow the range down */ + FOR( k--; k > 0; k-- ) + { + testval = mult_r( highlim, pows[k] ); + IF( LE_64( W_mult0_32_32( shr( testval, 1 ), range ), cum ) ) + { + lowlim = testval; + move16(); + symbol = (UWord16) L_sub( symbol, L_shl( 1, sub( k, 1 ) ) ); + } + ELSE + { + highlim = testval; + move16(); + } + } + highlim = shr( highlim, 1 ); + lowlim = shr( lowlim, 1 ); + } + ELSE /* trivial case, above pow-1, that is, first symbol */ + { + symbol = 0; + lowlim = extract_l( L_shr( base, 1 ) ); + highlim = 16384; + move16(); + move16(); + } + + + high = L_add( low, mul_sbc_14bits( range, highlim ) ); + + low = L_add( low, mul_sbc_14bits( range, lowlim ) ); + + /*ptr init for ptr*/ + FOR( ; bp < bits; ) + { + IF( GT_32( high, ari_q2new ) ) + { + IF( GE_32( low, ari_q2new ) ) + { + value = (UWord32) W_sub( value, ari_q2new ); + low = L_sub( low, ari_q2new ); + high = L_sub( high, ari_q2new ); + } + ELSE + { + test(); + IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) + { + value = (UWord32) W_sub( value, ari_q1new ); + low = L_sub( low, ari_q1new ); + high = L_sub( high, ari_q1new ); + } + ELSE + { + BREAK; + } + } + } + low = L_add( low, low ); + high = L_add( high, high ); + + assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" ); + + value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] ); + } + + test(); + test(); + test(); + IF( !( NE_16( bp, bits ) || !( EQ_32( s->low, low ) && ( EQ_32( s->high, high ) ) && ( EQ_64( s->value, value ) ) ) ) ) + { + /* This should not happen except of bit errors. */ + s->high = s->low = 0; + move32(); + move32(); + *res = 0; + move16(); + return -1; + } + + s->low = low; + s->high = L_sub( high, 1 ); + s->value = value; + move32(); + move32(); + move32(); + + *res = symbol; + move16(); + return bp; +} + +Word16 ari_decode_14bits_sign_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ) +{ + Word16 symbol; + Word32 low, high; + UWord32 range, value, cum; + + low = s->low; + high = L_add( s->high, 1 ); + value = s->value; + move32(); + move32(); + + range = (UWord32) W_sub( high, low ); + + IF( LT_16( bp, bits ) ) + { + assert( value >= (UWord32) low ); + cum = (UWord32) W_add( W_shl( ( W_sub( value, low ) ), stat_bitsnew ), ( 1 << stat_bitsnew ) - 1 ); + IF( GT_64( W_shl( range, 13 ), cum ) ) + { + symbol = 2; + move16(); + high = L_add( low, W_extract_l( W_shr( range, 1 ) ) ); + } + ELSE + { + symbol = 1; + move16(); + low = L_add( low, W_extract_l( W_shr( range, 1 ) ) ); + } + + /*ptr init for ptr*/ + FOR( ; bp < bits; ) + { + IF( GT_32( high, ari_q2new ) ) + { + IF( GE_32( low, ari_q2new ) ) + { + value = (UWord32) W_sub( value, ari_q2new ); + low = L_sub( low, ari_q2new ); + high = L_sub( high, ari_q2new ); + } + ELSE + { + test(); + IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) + { + value = (UWord32) W_sub( value, ari_q1new ); + low = L_sub( low, ari_q1new ); + high = L_sub( high, ari_q1new ); + } + ELSE + { + BREAK; + } + } + } + low = L_add( low, low ); + high = L_add( high, high ); + + assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" ); + + value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] ); + } + } + ELSE + { + cum = (UWord32) W_sub( value, low ); + range = (UWord32) W_shr( range, 1 ); + IF( GT_64( range, cum ) ) + { + symbol = 2; + move16(); + high = L_add( low, range ); + } + ELSE + { + symbol = 1; + move16(); + low = L_add( low, range ); + } + } + + s->low = low; + s->high = L_sub( high, 1 ); + s->value = value; + move32(); + move32(); + move32(); + + *res = symbol; + move16(); + + return bp; +} + diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c deleted file mode 100644 index 93bd8877c..000000000 --- a/lib_dec/arith_coder_dec.c +++ /dev/null @@ -1,250 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "basop_util.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------* - * tcx_arith_decode() - * - * - *-------------------------------------------------------*/ - -/*! r: number of bits consumed */ - -static Word16 tcx_arith_decode_ivas_fx( - const Word16 L_frame, /* i : number of spectral lines */ - const Word16 envelope[], /* i : scaled envelope (Q15-envelope_e) */ - Word16 envelope_e, /* i : scaled envelope exponent (Q0) */ - const Word16 target_bits, /* i : target bit budget */ - Word16 prm[], /* i : bitstream parameters */ - Word32 q_spectrum[], /* o : scalar quantized spectrum (Q31-q_spectrum_e) */ - Word16 *q_spectrum_e /* o : spectrum exponent */ -) -{ - Word16 bp, k, q; - Word16 s; - Tastat as; - UWord16 exp_k; - Word16 tmp; - - bp = ari_start_decoding_14bits_prm_ivas_fx( prm, 0, &as ); - - tmp = sub( envelope_e, 1 ); - - FOR( k = 0; k < L_frame; k++ ) - { - IF( EQ_16( envelope[k], 0 ) ) /* safety check in case of bit errors */ - { - set32_fx( q_spectrum, 0, L_frame ); - return -1; - } - ELSE - { - exp_k = expfp_evs_fx( negate( envelope[k] ), tmp ); - } - - /* decode line magnitude */ - bp = ari_decode_14bits_pow_ivas( prm, bp, target_bits, &q, &as, exp_k ); - - IF( q ) - { - /* line is non-zero, decode sign */ - bp = ari_decode_14bits_sign_ivas( prm, bp, target_bits, &s, &as ); - q_spectrum[k] = L_mult( q, sub( 3, shl( s, 1 ) ) ); - move32(); - q_spectrum[k] = L_shl( q_spectrum[k], 30 - SPEC_EXP_DEC ); // Q(31-20) - move32(); - } - ELSE - { - /* line is zero, no sign needed */ - q_spectrum[k] = 0; - move32(); - } - - IF( LE_32( as.high, as.low ) ) - { - if ( LT_16( bp, target_bits ) ) /* safety check in case of bit errors */ - { - bp = -1; - move16(); - } - BREAK; /* no bits left, so exit loop */ - } - } - *q_spectrum_e = SPEC_EXP_DEC; - move16(); - - set32_fx( q_spectrum + k, 0, sub( L_frame, k ) ); - - return bp; -} - -/*-------------------------------------------------------* - * tcx_arith_decode_envelope() - * - * - *-------------------------------------------------------*/ - -void tcx_arith_decode_envelope_ivas_fx( - Decoder_State *st, /* i/o: coder state */ - Word32 q_spectrum[], /* o : quantised MDCT coefficients Q(31-q_spectrum_e) */ - Word16 *q_spectrum_e, /* o : MDCT exponent */ - const Word16 L_frame, /* i : frame or MDCT length */ - Word16 L_spec, /* i : length w/o BW limitation */ - const Word16 A_ind[], /* i : quantised LPC coefficients */ - const Word16 target_bits, /* i : number of available bits */ - Word16 prm[], /* i : bitstream parameters */ - const Word16 use_hm, /* i : use HM in current frame? */ - const Word16 prm_hm[], /* i : HM parameter area */ - Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ - Word16 *arith_bits, /* o : bits used for ari. coding */ - Word16 *signaling_bits, /* o : bits used for signaling */ - const Word16 low_complexity /* i : low-complexity flag */ -) -{ - Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */ - Word16 *envelope; /* scaled envelope (Q15-e) */ - Word16 envelope_e; - Word16 L_spec_core; - TCX_CONFIG_HANDLE hTcxCfg; - TCX_DEC_HANDLE hTcxDec; - Word16 gamma_w, gamma_uw; - Word16 hm_bits; - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( GT_16( L_spec, N_MAX_ARI ) || ( ( st->element_mode == EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) || - ( EQ_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE / FRAMES_PER_SEC ) ) ) ) || - ( GT_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE_CPE / FRAMES_PER_SEC ) ) ) ) || - ( target_bits <= 0 ) ) - { - /* this could happen in case of bit errors */ - st->BER_detect = 1; - move16(); - L_spec = N_MAX_ARI; - move16(); - *signaling_bits = 0; - move16(); - *arith_bits = 0; - move16(); - set32_fx( q_spectrum, 0, L_frame ); - - return; - } - - hTcxCfg = st->hTcxCfg; - hTcxDec = st->hTcxDec; - *signaling_bits = 0; - move16(); - - assert( hTcxDec->enableTcxLpc ); - gamma_w = MAX16B; - move16(); - gamma_uw = st->inv_gamma; - move16(); - -#define WMC_TOOL_SKIP - tcx_arith_render_envelope_ivas_fx( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env ); -#undef WMC_TOOL_SKIP - - IF( use_hm != 0 ) - { - IF( prm_hm[0] != 0 ) - { - tcx_hm_decode( L_spec, env, target_bits, st->coder_type, prm_hm, tcxltp_pitch, &hm_bits ); - - IF( hm_bits < 0 ) - { - st->BER_detect = 1; - move16(); - *signaling_bits = 0; - move16(); - *arith_bits = 0; - move16(); - set32_fx( q_spectrum, 0, L_frame ); - - return; - } - } - ELSE - { - hm_bits = 1; - move16(); - } - *signaling_bits = add( *signaling_bits, hm_bits ); - move16(); - } - - L_spec_core = L_spec; - move16(); - IF( st->igf ) - { - L_spec_core = s_min( L_spec_core, st->hIGFDec->infoIGFStartLine ); - } - - envelope = (Word16 *) env; - tcx_arith_scale_envelope( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e ); - - *arith_bits = tcx_arith_decode_ivas_fx( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum, q_spectrum_e ); - move16(); - - /* safety check in case of bit errors */ - IF( *arith_bits < 0 ) - { - st->BER_detect = 1; - move16(); - set32_fx( q_spectrum, 0, L_frame ); - } - - set32_fx( q_spectrum + L_spec, 0, sub( L_frame, L_spec ) ); - - return; -} diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index 4a18f64f9..6df1eb268 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -8,6 +8,9 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" +#include "basop_util.h" +#include "basop_proto_func.h" +#include "prot.h" /* Returns: number of bits consumed */ static Word16 tcx_arith_decode_fx( @@ -213,3 +216,208 @@ void tcx_arith_decode_envelope_fx( set32_fx( q_spectrum + L_spec, 0, sub( L_frame, L_spec ) ); } + +/*-------------------------------------------------------* + * tcx_arith_decode() + * + * + *-------------------------------------------------------*/ + +/*! r: number of bits consumed */ + +static Word16 tcx_arith_decode_ivas_fx( + const Word16 L_frame, /* i : number of spectral lines */ + const Word16 envelope[], /* i : scaled envelope (Q15-envelope_e) */ + Word16 envelope_e, /* i : scaled envelope exponent (Q0) */ + const Word16 target_bits, /* i : target bit budget */ + Word16 prm[], /* i : bitstream parameters */ + Word32 q_spectrum[], /* o : scalar quantized spectrum (Q31-q_spectrum_e) */ + Word16 *q_spectrum_e /* o : spectrum exponent */ +) +{ + Word16 bp, k, q; + Word16 s; + Tastat as; + UWord16 exp_k; + Word16 tmp; + + bp = ari_start_decoding_14bits_prm_ivas_fx( prm, 0, &as ); + + tmp = sub( envelope_e, 1 ); + + FOR( k = 0; k < L_frame; k++ ) + { + IF( EQ_16( envelope[k], 0 ) ) /* safety check in case of bit errors */ + { + set32_fx( q_spectrum, 0, L_frame ); + return -1; + } + ELSE + { + exp_k = expfp_evs_fx( negate( envelope[k] ), tmp ); + } + + /* decode line magnitude */ + bp = ari_decode_14bits_pow_ivas( prm, bp, target_bits, &q, &as, exp_k ); + + IF( q ) + { + /* line is non-zero, decode sign */ + bp = ari_decode_14bits_sign_ivas( prm, bp, target_bits, &s, &as ); + q_spectrum[k] = L_mult( q, sub( 3, shl( s, 1 ) ) ); + move32(); + q_spectrum[k] = L_shl( q_spectrum[k], 30 - SPEC_EXP_DEC ); // Q(31-20) + move32(); + } + ELSE + { + /* line is zero, no sign needed */ + q_spectrum[k] = 0; + move32(); + } + + IF( LE_32( as.high, as.low ) ) + { + if ( LT_16( bp, target_bits ) ) /* safety check in case of bit errors */ + { + bp = -1; + move16(); + } + BREAK; /* no bits left, so exit loop */ + } + } + *q_spectrum_e = SPEC_EXP_DEC; + move16(); + + set32_fx( q_spectrum + k, 0, sub( L_frame, k ) ); + + return bp; +} + +/*-------------------------------------------------------* + * tcx_arith_decode_envelope() + * + * + *-------------------------------------------------------*/ + +void tcx_arith_decode_envelope_ivas_fx( + Decoder_State *st, /* i/o: coder state */ + Word32 q_spectrum[], /* o : quantised MDCT coefficients Q(31-q_spectrum_e) */ + Word16 *q_spectrum_e, /* o : MDCT exponent */ + const Word16 L_frame, /* i : frame or MDCT length */ + Word16 L_spec, /* i : length w/o BW limitation */ + const Word16 A_ind[], /* i : quantised LPC coefficients */ + const Word16 target_bits, /* i : number of available bits */ + Word16 prm[], /* i : bitstream parameters */ + const Word16 use_hm, /* i : use HM in current frame? */ + const Word16 prm_hm[], /* i : HM parameter area */ + Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ + Word16 *arith_bits, /* o : bits used for ari. coding */ + Word16 *signaling_bits, /* o : bits used for signaling */ + const Word16 low_complexity /* i : low-complexity flag */ +) +{ + Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */ + Word16 *envelope; /* scaled envelope (Q15-e) */ + Word16 envelope_e; + Word16 L_spec_core; + TCX_CONFIG_HANDLE hTcxCfg; + TCX_DEC_HANDLE hTcxDec; + Word16 gamma_w, gamma_uw; + Word16 hm_bits; + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( GT_16( L_spec, N_MAX_ARI ) || ( ( st->element_mode == EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) || + ( EQ_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE / FRAMES_PER_SEC ) ) ) ) || + ( GT_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE_CPE / FRAMES_PER_SEC ) ) ) ) || + ( target_bits <= 0 ) ) + { + /* this could happen in case of bit errors */ + st->BER_detect = 1; + move16(); + L_spec = N_MAX_ARI; + move16(); + *signaling_bits = 0; + move16(); + *arith_bits = 0; + move16(); + set32_fx( q_spectrum, 0, L_frame ); + + return; + } + + hTcxCfg = st->hTcxCfg; + hTcxDec = st->hTcxDec; + *signaling_bits = 0; + move16(); + + assert( hTcxDec->enableTcxLpc ); + gamma_w = MAX16B; + move16(); + gamma_uw = st->inv_gamma; + move16(); + +#define WMC_TOOL_SKIP + tcx_arith_render_envelope_ivas_fx( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env ); +#undef WMC_TOOL_SKIP + + IF( use_hm != 0 ) + { + IF( prm_hm[0] != 0 ) + { + tcx_hm_decode( L_spec, env, target_bits, st->coder_type, prm_hm, tcxltp_pitch, &hm_bits ); + + IF( hm_bits < 0 ) + { + st->BER_detect = 1; + move16(); + *signaling_bits = 0; + move16(); + *arith_bits = 0; + move16(); + set32_fx( q_spectrum, 0, L_frame ); + + return; + } + } + ELSE + { + hm_bits = 1; + move16(); + } + *signaling_bits = add( *signaling_bits, hm_bits ); + move16(); + } + + L_spec_core = L_spec; + move16(); + IF( st->igf ) + { + L_spec_core = s_min( L_spec_core, st->hIGFDec->infoIGFStartLine ); + } + + envelope = (Word16 *) env; + tcx_arith_scale_envelope( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e ); + + *arith_bits = tcx_arith_decode_ivas_fx( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum, q_spectrum_e ); + move16(); + + /* safety check in case of bit errors */ + IF( *arith_bits < 0 ) + { + st->BER_detect = 1; + move16(); + set32_fx( q_spectrum, 0, L_frame ); + } + + set32_fx( q_spectrum + L_spec, 0, sub( L_frame, L_spec ) ); + + return; +} + diff --git a/lib_dec/bass_psfilter.c b/lib_dec/bass_psfilter.c deleted file mode 100644 index 478a81474..000000000 --- a/lib_dec/bass_psfilter.c +++ /dev/null @@ -1,317 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "prot.h" -#include "prot_fx.h" -#include "ivas_prot.h" -#include "cnst.h" -#include "stat_dec.h" -#include "rom_com.h" -#include -#include "wmc_auto.h" -#include "ivas_prot_fx.h" - -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - - -#define NBPSF_L_EXTRA 120 -#define BPF_STOP_STOPBAND_16 16 -#define K_PC_DEC_FX -1170 /* -0.0357f in Q15 */ -#define K_PC_DEC_FX32 -76665166 /* -0.0357f in Q31 */ -#define C_PC_DEC_FX 6583 /*in Q8*/ - -/*---------------------------------------------------------------------* - * Local function prototypes - *---------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------* - * bass_psfilter() - * - * Perform low-frequency postfiltering - *---------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------* - * Pit_track() - * - * Perform pitch tracking and test pitch/2 to avoid continuous pitch doubling - *---------------------------------------------------------------------*/ - -/*! r: Pitch */ - - -/*---------------------------------------------------------------------* - * addBassPostFilter() - * - * Add BPF component in cldfb domain - *---------------------------------------------------------------------*/ - - -void addBassPostFilter_ivas_fx( - const Word32 *harm_timeIn_fx, // Qx - const Word16 samplesToProcess, - Word32 **rAnalysis_fx, // Qx - 5 - Word32 **iAnalysis_fx, // Qx - 5 - HANDLE_CLDFB_FILTER_BANK cldfb ) -{ - Word32 *tmp_R_fx[CLDFB_NO_COL_MAX]; - Word32 *tmp_I_fx[CLDFB_NO_COL_MAX]; - Word32 cldfbBufferReal_fx[CLDFB_NO_COL_MAX][20]; - Word32 cldfbBufferImag_fx[CLDFB_NO_COL_MAX][20]; - Word16 i, b; - Word16 maxBand; - const Word32 *weights_fx; - Word16 nCol = cldfb->no_col; - move16(); - Word16 nColToProcess = nCol; - move16(); - Word16 nChan = cldfb->no_channels; - move16(); - IF( GT_16( samplesToProcess, -1 ) ) - { - nColToProcess = idiv1616( sub( add( samplesToProcess, cldfb->no_channels ), 1 ), cldfb->no_channels ); - move16(); - } - - assert( nCol == 16 ); - - weights_fx = bpf_weights_16_ivas_fx_32; - - IF( GT_16( nChan, BPF_STOP_STOPBAND_16 ) ) - { - maxBand = BPF_STOP_STOPBAND_16; - move16(); - } - ELSE - { - maxBand = nChan; - move16(); - } - - FOR( i = 0; i < nColToProcess; i++ ) - { - tmp_R_fx[i] = cldfbBufferReal_fx[i]; - tmp_I_fx[i] = cldfbBufferImag_fx[i]; - } - - cldfbAnalysis_ivas_fx( harm_timeIn_fx, tmp_R_fx, tmp_I_fx, samplesToProcess, cldfb ); - - /* now do the subtraction */ - FOR( i = 0; i < nColToProcess; i++ ) - { - /* loop over low frequency bands */ - FOR( b = 0; b < maxBand; b++ ) - { - rAnalysis_fx[i][b] = Msub_32_32( rAnalysis_fx[i][b], tmp_R_fx[i][b], weights_fx[b] ); // Qx - 6 - move32(); - iAnalysis_fx[i][b] = Msub_32_32( iAnalysis_fx[i][b], tmp_I_fx[i][b], weights_fx[b] ); // Qx - 6 - move32(); - } - } - - return; -} - - -/*---------------------------------------------------------------------* - * res_bpf_adapt_ivas_fx() - * - * Analyze BPF output and decide if it should be applied on DFT stereo - * residual signal - *---------------------------------------------------------------------*/ - -/*! r: Decision to enable or disable BPF on DFT stereo residual */ -Word16 res_bpf_adapt_ivas_fx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo decoder handle */ - const Word32 *bpf_error_signal_8k, /* i : BPF modification signal */ - Word32 res_buf[STEREO_DFT_N_8k], /* i : residual buffer Q12 */ - Word16 q_res ) -{ - Word32 error_nrg; - Word32 tmp; - Word32 res_hb_nrg; - Word16 bpf_error_ratio; - Word16 res_bpf_flag; - Word16 i; - Word16 i_start; - Word16 i_end; - Word16 bw_inv; - Word64 W_tmp; - - IF( EQ_16( hStereoDft->res_cod_band_max, 6 ) ) - { - i_start = 39; - move16(); - i_end = 64; - move16(); - bw_inv = 1311; - move16(); /* 1/(64 - 39) in Q15 */ - } - ELSE - { - i_start = 28; - move16(); - i_end = 40; - move16(); - bw_inv = 2720; - move16(); /* 1/(40 - 28) in Q15*/ - } - - /* Measure energy of high frequency band in MDCT domain */ - res_hb_nrg = L_deposit_l( 0 ); - W_tmp = W_deposit32_l( 0 ); - FOR( i = i_start; i < i_end; i++ ) - { - W_tmp = W_add_nosat( W_tmp, W_mult0_32_32( res_buf[i], res_buf[i] ) ); - } - - res_hb_nrg = W_extract_l( W_shr( W_tmp, shl( q_res, 1 ) ) ); // Q0 - res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv ); // Q0 - res_hb_nrg = L_add( Mpy_32_16_1( res_hb_nrg, STEREO_DFT_BPF_ADAPT_ALPHA_FX ), Mpy_32_16_1( hStereoDft->res_hb_nrg_mem_fx, sub( MAX_16, STEREO_DFT_BPF_ADAPT_ALPHA_FX ) ) ); - hStereoDft->res_hb_nrg_mem_fx = res_hb_nrg; - move32(); - - /* Measure energy of discontinuities at subframe boundaries */ - error_nrg = 0; - move32(); - FOR( i = 0; i < L_FRAME8k; i += STEREO_DFT_L_SUBFR_8k ) - { - tmp = L_sub( bpf_error_signal_8k[i], hStereoDft->bpf_error_signal_last_fx ); - error_nrg = Madd_32_32( error_nrg, tmp, tmp ); - hStereoDft->bpf_error_signal_last_fx = bpf_error_signal_8k[( i + ( STEREO_DFT_L_SUBFR_8k - 1 ) )]; - move32(); - } - error_nrg = L_shl( error_nrg, 1 ); // Q0 - error_nrg = Mpy_32_16_1( error_nrg, 6553 /* 0.2f in Q15 */ ); /* Division by 5 for average value */ - /* Form decision variable and apply limit */ - IF( LT_32( ( L_shr( error_nrg, 1 ) ), res_hb_nrg ) ) - { - Word16 temp; - bpf_error_ratio = BASOP_Util_Divide3232_Scale( error_nrg, res_hb_nrg, &temp ); - bpf_error_ratio = shl( bpf_error_ratio, sub( 13, sub( 15, temp ) ) ); - } - ELSE - { - bpf_error_ratio = ONE_IN_Q14; // Q13 - move16(); - } - bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) ); - hStereoDft->bpf_error_ratio_mem_fx = bpf_error_ratio; - move16(); - - res_bpf_flag = (Word16) LT_16( bpf_error_ratio, ONE_IN_Q13 ); - move16(); - - return res_bpf_flag; -} - -void bpf_pitch_coherence_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 pitch_buf[] /* i : pitch for every subfr [0,1,2,3] Q20 */ -) -{ - Word16 nb_subfr; - Word32 pc, pcn1, pcn2, pcn3; - Word32 scaled_inv_L_frame; // Q8 + Q23 - - SWITCH( st->L_frame ) - { - case 80: - scaled_inv_L_frame = 26843545; // 1/80 in Q31 - move32(); - BREAK; - case 160: - scaled_inv_L_frame = 13421773; // 1/160 in Q31 - move32(); - BREAK; - case 256: - scaled_inv_L_frame = 8388608; // 1/256 in Q31 - move32(); - BREAK; - case 320: - scaled_inv_L_frame = 6710886; // 1/320 in Q31 - move32(); - BREAK; - case 512: - scaled_inv_L_frame = 4194304; // 1/512 in Q31 - move32(); - BREAK; - case 640: - scaled_inv_L_frame = 3355443; // 1/640 in Q31 - move32(); - BREAK; - case 960: - scaled_inv_L_frame = 2236962; // 1/80 in Q31 - move32(); - BREAK; - default: - scaled_inv_L_frame = 0; - move32(); - } - - nb_subfr = shr( st->L_frame, 6 ); - test(); - IF( GT_16( st->clas_dec, UNVOICED_CLAS ) && ( st->element_mode != EVS_MONO ) ) - { - pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( st->old_pitch_buf_fx[nb_subfr], st->old_pitch_buf_fx[nb_subfr + 1] ) ) ); - pc = Mpy_32_32( pc, scaled_inv_L_frame ); - pcn1 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); - pcn1 = L_max( L_min( pcn1, 4096 ), 0 ); // 4096 = 1 in Q12 - - pc = L_abs( L_sub( L_add( pitch_buf[nb_subfr - 1], pitch_buf[nb_subfr - 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) ); - pc = Mpy_32_32( pc, scaled_inv_L_frame ); - pcn2 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); - pcn2 = L_max( L_min( pcn2, 4096 ), 0 ); // 4096 = 1 in Q12 - - pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) ); - pc = Mpy_32_32( pc, scaled_inv_L_frame ); - pcn3 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); - pcn3 = L_max( L_min( pcn3, 4096 ), 0 ); // 4096 = 1 in Q12 - - IF( LT_32( L_add( pcn1, L_add( pcn2, pcn3 ) ), 10240 /*2.5f in Q12*/ ) ) - { - st->hBPF->psf_att_fx = 13107; //.4 in Q15 - move16(); /*Q15*/ - set16_fx( &st->hBPF->Track_on_hist[L_TRACK_HIST - nb_subfr], 1, nb_subfr ); - } - } - - return; -} diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c index c11e30c93..7d2be2c52 100644 --- a/lib_dec/bass_psfilter_fx.c +++ b/lib_dec/bass_psfilter_fx.c @@ -6,6 +6,7 @@ #include #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ +#include "ivas_prot_fx.h" /* Function prototypes */ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ #include "rom_dec.h" /* Static table prototypes */ @@ -17,6 +18,9 @@ #define NBPSF_L_EXTRA 120 #define BPF_STOP_STOPBAND_16 16 +#define K_PC_DEC_FX -1170 /* -0.0357f in Q15 */ +#define K_PC_DEC_FX32 -76665166 /* -0.0357f in Q31 */ +#define C_PC_DEC_FX 6583 /*in Q8*/ /*---------------------------------------------------------------------* * Local function prototypes @@ -889,6 +893,246 @@ void addBassPostFilter_fx( return; } +/*---------------------------------------------------------------------* + * addBassPostFilter() + * + * Add BPF component in cldfb domain + *---------------------------------------------------------------------*/ + + +void addBassPostFilter_ivas_fx( + const Word32 *harm_timeIn_fx, // Qx + const Word16 samplesToProcess, + Word32 **rAnalysis_fx, // Qx - 5 + Word32 **iAnalysis_fx, // Qx - 5 + HANDLE_CLDFB_FILTER_BANK cldfb ) +{ + Word32 *tmp_R_fx[CLDFB_NO_COL_MAX]; + Word32 *tmp_I_fx[CLDFB_NO_COL_MAX]; + Word32 cldfbBufferReal_fx[CLDFB_NO_COL_MAX][20]; + Word32 cldfbBufferImag_fx[CLDFB_NO_COL_MAX][20]; + Word16 i, b; + Word16 maxBand; + const Word32 *weights_fx; + Word16 nCol = cldfb->no_col; + move16(); + Word16 nColToProcess = nCol; + move16(); + Word16 nChan = cldfb->no_channels; + move16(); + IF( GT_16( samplesToProcess, -1 ) ) + { + nColToProcess = idiv1616( sub( add( samplesToProcess, cldfb->no_channels ), 1 ), cldfb->no_channels ); + move16(); + } + + assert( nCol == 16 ); + + weights_fx = bpf_weights_16_ivas_fx_32; + + IF( GT_16( nChan, BPF_STOP_STOPBAND_16 ) ) + { + maxBand = BPF_STOP_STOPBAND_16; + move16(); + } + ELSE + { + maxBand = nChan; + move16(); + } + + FOR( i = 0; i < nColToProcess; i++ ) + { + tmp_R_fx[i] = cldfbBufferReal_fx[i]; + tmp_I_fx[i] = cldfbBufferImag_fx[i]; + } + + cldfbAnalysis_ivas_fx( harm_timeIn_fx, tmp_R_fx, tmp_I_fx, samplesToProcess, cldfb ); + + /* now do the subtraction */ + FOR( i = 0; i < nColToProcess; i++ ) + { + /* loop over low frequency bands */ + FOR( b = 0; b < maxBand; b++ ) + { + rAnalysis_fx[i][b] = Msub_32_32( rAnalysis_fx[i][b], tmp_R_fx[i][b], weights_fx[b] ); // Qx - 6 + move32(); + iAnalysis_fx[i][b] = Msub_32_32( iAnalysis_fx[i][b], tmp_I_fx[i][b], weights_fx[b] ); // Qx - 6 + move32(); + } + } + + return; +} + + +/*---------------------------------------------------------------------* + * res_bpf_adapt_ivas_fx() + * + * Analyze BPF output and decide if it should be applied on DFT stereo + * residual signal + *---------------------------------------------------------------------*/ + +/*! r: Decision to enable or disable BPF on DFT stereo residual */ +Word16 res_bpf_adapt_ivas_fx( + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo decoder handle */ + const Word32 *bpf_error_signal_8k, /* i : BPF modification signal */ + Word32 res_buf[STEREO_DFT_N_8k], /* i : residual buffer Q12 */ + Word16 q_res ) +{ + Word32 error_nrg; + Word32 tmp; + Word32 res_hb_nrg; + Word16 bpf_error_ratio; + Word16 res_bpf_flag; + Word16 i; + Word16 i_start; + Word16 i_end; + Word16 bw_inv; + Word64 W_tmp; + + IF( EQ_16( hStereoDft->res_cod_band_max, 6 ) ) + { + i_start = 39; + move16(); + i_end = 64; + move16(); + bw_inv = 1311; + move16(); /* 1/(64 - 39) in Q15 */ + } + ELSE + { + i_start = 28; + move16(); + i_end = 40; + move16(); + bw_inv = 2720; + move16(); /* 1/(40 - 28) in Q15*/ + } + + /* Measure energy of high frequency band in MDCT domain */ + res_hb_nrg = L_deposit_l( 0 ); + W_tmp = W_deposit32_l( 0 ); + FOR( i = i_start; i < i_end; i++ ) + { + W_tmp = W_add_nosat( W_tmp, W_mult0_32_32( res_buf[i], res_buf[i] ) ); + } + + res_hb_nrg = W_extract_l( W_shr( W_tmp, shl( q_res, 1 ) ) ); // Q0 + res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv ); // Q0 + res_hb_nrg = L_add( Mpy_32_16_1( res_hb_nrg, STEREO_DFT_BPF_ADAPT_ALPHA_FX ), Mpy_32_16_1( hStereoDft->res_hb_nrg_mem_fx, sub( MAX_16, STEREO_DFT_BPF_ADAPT_ALPHA_FX ) ) ); + hStereoDft->res_hb_nrg_mem_fx = res_hb_nrg; + move32(); + + /* Measure energy of discontinuities at subframe boundaries */ + error_nrg = 0; + move32(); + FOR( i = 0; i < L_FRAME8k; i += STEREO_DFT_L_SUBFR_8k ) + { + tmp = L_sub( bpf_error_signal_8k[i], hStereoDft->bpf_error_signal_last_fx ); + error_nrg = Madd_32_32( error_nrg, tmp, tmp ); + hStereoDft->bpf_error_signal_last_fx = bpf_error_signal_8k[( i + ( STEREO_DFT_L_SUBFR_8k - 1 ) )]; + move32(); + } + error_nrg = L_shl( error_nrg, 1 ); // Q0 + error_nrg = Mpy_32_16_1( error_nrg, 6553 /* 0.2f in Q15 */ ); /* Division by 5 for average value */ + /* Form decision variable and apply limit */ + IF( LT_32( ( L_shr( error_nrg, 1 ) ), res_hb_nrg ) ) + { + Word16 temp; + bpf_error_ratio = BASOP_Util_Divide3232_Scale( error_nrg, res_hb_nrg, &temp ); + bpf_error_ratio = shl( bpf_error_ratio, sub( 13, sub( 15, temp ) ) ); + } + ELSE + { + bpf_error_ratio = ONE_IN_Q14; // Q13 + move16(); + } + bpf_error_ratio = add( mult( STEREO_DFT_BPF_ADAPT_BETA_FX, bpf_error_ratio ), mult( ( MAX_16 - STEREO_DFT_BPF_ADAPT_BETA_FX ), hStereoDft->bpf_error_ratio_mem_fx ) ); + hStereoDft->bpf_error_ratio_mem_fx = bpf_error_ratio; + move16(); + + res_bpf_flag = (Word16) LT_16( bpf_error_ratio, ONE_IN_Q13 ); + move16(); + + return res_bpf_flag; +} + +void bpf_pitch_coherence_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 pitch_buf[] /* i : pitch for every subfr [0,1,2,3] Q20 */ +) +{ + Word16 nb_subfr; + Word32 pc, pcn1, pcn2, pcn3; + Word32 scaled_inv_L_frame; // Q8 + Q23 + + SWITCH( st->L_frame ) + { + case 80: + scaled_inv_L_frame = 26843545; // 1/80 in Q31 + move32(); + BREAK; + case 160: + scaled_inv_L_frame = 13421773; // 1/160 in Q31 + move32(); + BREAK; + case 256: + scaled_inv_L_frame = 8388608; // 1/256 in Q31 + move32(); + BREAK; + case 320: + scaled_inv_L_frame = 6710886; // 1/320 in Q31 + move32(); + BREAK; + case 512: + scaled_inv_L_frame = 4194304; // 1/512 in Q31 + move32(); + BREAK; + case 640: + scaled_inv_L_frame = 3355443; // 1/640 in Q31 + move32(); + BREAK; + case 960: + scaled_inv_L_frame = 2236962; // 1/80 in Q31 + move32(); + BREAK; + default: + scaled_inv_L_frame = 0; + move32(); + } + + nb_subfr = shr( st->L_frame, 6 ); + test(); + IF( GT_16( st->clas_dec, UNVOICED_CLAS ) && ( st->element_mode != EVS_MONO ) ) + { + pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( st->old_pitch_buf_fx[nb_subfr], st->old_pitch_buf_fx[nb_subfr + 1] ) ) ); + pc = Mpy_32_32( pc, scaled_inv_L_frame ); + pcn1 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); + pcn1 = L_max( L_min( pcn1, 4096 ), 0 ); // 4096 = 1 in Q12 + + pc = L_abs( L_sub( L_add( pitch_buf[nb_subfr - 1], pitch_buf[nb_subfr - 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) ); + pc = Mpy_32_32( pc, scaled_inv_L_frame ); + pcn2 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); + pcn2 = L_max( L_min( pcn2, 4096 ), 0 ); // 4096 = 1 in Q12 + + pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) ); + pc = Mpy_32_32( pc, scaled_inv_L_frame ); + pcn3 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); + pcn3 = L_max( L_min( pcn3, 4096 ), 0 ); // 4096 = 1 in Q12 + + IF( LT_32( L_add( pcn1, L_add( pcn2, pcn3 ) ), 10240 /*2.5f in Q12*/ ) ) + { + st->hBPF->psf_att_fx = 13107; //.4 in Q15 + move16(); /*Q15*/ + set16_fx( &st->hBPF->Track_on_hist[L_TRACK_HIST - nb_subfr], 1, nb_subfr ); + } + } + + return; +} + + #ifdef ADD_BPF_ADAPT /*---------------------------------------------------------------------* * res_bpf_adapt() diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c deleted file mode 100644 index 37c397bbf..000000000 --- a/lib_dec/core_dec_init.c +++ /dev/null @@ -1,84 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "stat_com.h" -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "prot_fx.h" -/*-----------------------------------------------------------------------* - * open_decoder_LPD() - * - * Initialization of state variables - *-----------------------------------------------------------------------*/ -/*-----------------------------------------------------------------------* - * tcxltp_dec_init() - * - * Initialization TCX-LTP handle - *-----------------------------------------------------------------------*/ -/*-----------------------------------------------------------------------* - * reset_tcx_overl_buf() - * - * Reset TCX core overlap buffers - *-----------------------------------------------------------------------*/ - -void reset_tcx_overl_buf_fx( - TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ -) -{ - set16_fx( hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ - hTcxDec->Q_old_syn_Overl = 0; - move16(); - set16_fx( hTcxDec->syn_Overl_TDAC, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ - hTcxDec->Q_syn_Overl_TDAC = 0; - move16(); - set16_fx( hTcxDec->syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ - hTcxDec->Q_syn_Overl = 0; - move16(); - set16_fx( hTcxDec->syn_Overl_TDACFB, 0, L_FRAME_MAX / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ - hTcxDec->Q_syn_Overl_TDACFB = 0; - move16(); - return; -} - -/*-----------------------------------------------------------------------* - * acelp_plc_mdct_transition() - * - * Prepare MDCT OLA memories in TCX/HQ after ACELP PLC - *-----------------------------------------------------------------------*/ diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 671dbfd2c..f649772b2 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -2191,3 +2191,29 @@ void open_decoder_LPD_ivas_fx( return; } + +/*-----------------------------------------------------------------------* + * reset_tcx_overl_buf() + * + * Reset TCX core overlap buffers + *-----------------------------------------------------------------------*/ + +void reset_tcx_overl_buf_fx( + TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ +) +{ + set16_fx( hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ + hTcxDec->Q_old_syn_Overl = 0; + move16(); + set16_fx( hTcxDec->syn_Overl_TDAC, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ + hTcxDec->Q_syn_Overl_TDAC = 0; + move16(); + set16_fx( hTcxDec->syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ + hTcxDec->Q_syn_Overl = 0; + move16(); + set16_fx( hTcxDec->syn_Overl_TDACFB, 0, L_FRAME_MAX / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ + hTcxDec->Q_syn_Overl_TDACFB = 0; + move16(); + return; +} + diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c deleted file mode 100644 index aa04a70cb..000000000 --- a/lib_dec/core_switching_dec.c +++ /dev/null @@ -1,1076 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "prot_fx.h" -#include "ivas_cnst.h" -#include "wmc_auto.h" - -#include "ivas_prot_fx.h" -#include "debug.h" -/*---------------------------------------------------------------------* - * Local prototypes - *---------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------* - * core_switching_pre_dec() - * - * Preprocessing/preparation for ACELP/HQ core switching - *---------------------------------------------------------------------*/ -ivas_error core_switching_pre_dec_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 output_frame, /* i : frame length */ - const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - const Word16 last_element_mode, /* i : last_element_mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - Word16 Q_old_synthFB, - Word16 *Q_olapBufferSynth, - Word16 *Q_olapBufferSynth2 ) -{ - Word32 tmp_fx; /*Q-12*/ - Word16 i, oldLenClasBuff, newLenClasBuff; - ivas_error error; - Word16 exp = 25; - move16(); - error = IVAS_ERR_OK; - move32(); - - /* Codec mode switching */ - test(); - test(); - test(); - IF( EQ_16( st->last_codec_mode, MODE2 ) || ( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) && ( st->element_mode > EVS_MONO ) ) ) - { - st->mem_deemph_fx = st->syn[M]; - move16(); - set16_fx( st->agc_mem_fx, 0, 2 ); - Scale_sig( &( st->mem_deemph_fx ), 1, st->Q_syn ); /* Brings mem_deemph to Qsyn */ - - Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/ - - st->bpf_off = 1; - move16(); - IF( st->hPFstat != NULL ) - { - Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ - Scale_sig( st->hPFstat->mem_res2, DECMEM_RES2, st->Q_syn ); /* NB post_filter mem , Q_syn*/ - Scale_sig( st->hPFstat->mem_stp, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ - set16_fx( st->hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ - } - IF( st->hBPF != NULL ) - { - st->hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ - st->hBPF->pst_mem_deemp_err_fx = 0; - move16(); - move16(); - } - st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) ); // Q(23+1-16)->Q8 - move16(); - - /* reset old HB synthesis buffer */ - IF( EQ_16( st->last_L_frame, L_FRAME ) ) - { - st->old_bwe_delay = NS2SA_FX2( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); - } - ELSE - { - st->old_bwe_delay = NS2SA_FX2( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); - } - move16(); - set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); - - test(); - IF( st->hBWE_TD != NULL && ( st->last_core != ACELP_CORE ) ) - { -#ifdef MSAN_FIX - st->hBWE_TD->prev_hb_synth_fx_exp = 31; - move16(); -#endif // MSAN_FIX - /* reset BWE memories */ - set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - - /* reset upd_cnt */ - st->upd_cnt = MAX_UPD_CNT; - move16(); - - st->igf = 0; - move16(); - - test(); - IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) - { - hf_synth_reset_fx( st->hBWE_zero ); -#ifdef MSAN_FIX - set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); -#endif - } - - IF( st->hBWE_FD != NULL ) - { - set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - - IF( st->hHQ_core != NULL ) - { - set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); - set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB ); - - set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); - - st->hHQ_core->last_max_pos_pulse = 0; - move16(); - - IF( GT_32( st->output_Fs, 16000 ) ) - { - set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); - } - - /* pre-echo */ - st->hHQ_core->pastpre = 0; - move16(); - } - - /* reset the GSC pre echo energy threshold in case of switching */ - if ( st->hGSCDec != NULL ) - { - st->hGSCDec->Last_frame_ener_fx = MAX_32; - move32(); - } - - test(); - IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) - { - IF( st->element_mode == EVS_MONO ) - { - st->last_core = HQ_CORE; - move16(); - - Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA_FX2( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); - // Copy_Scale_sig_32_16( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0 - } - - IF( st->hHQ_core != NULL ) - { - set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); - st->hHQ_core->last_max_pos_pulse = 0; - move16(); - - set16_fx( st->hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); - st->hHQ_core->prev_frm_hfe2 = 0; - st->hHQ_core->prev_stab_hfe2 = 0; - move16(); - move16(); - } - } - - IF( st->prev_bfi != 0 ) - { - Word16 delay_comp; - - /*switch off Hq Voicing as it was not updated in MODE2*/ - IF( st->hHQ_core != NULL ) - { - st->hHQ_core->oldHqVoicing = 0; - st->hHQ_core->HqVoicing = 0; - move16(); - move16(); - } - - delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); - /*TODO To be tested:control not entering the block*/ - test(); - test(); - IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) - { - /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/ - assert( 0 ); - Word32 *realBuffer_fx[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer_fx[CLDFB_NO_COL_MAX_SWITCH]; - Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX]; - Word32 syn_Overl_fx[320]; - Word32 fer_samples_fx[960]; - Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 ); - Copy_Scale_sig_16_32_DEPREC( st->hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 ); - - - FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ ) - { - set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer_fx[i] = realBufferTmp_fx[i]; - imagBuffer_fx[i] = imagBufferTmp_fx[i]; - } - - /* CLDFB analysis of the synthesis at internal sampling rate */ - IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbAna ) ), IVAS_ERR_OK ) ) - { - return error; - } - - cldfbAnalysis_ivas_fx( syn_Overl_fx, realBuffer_fx, imagBuffer_fx, delay_comp, st->cldfbAna ); - cldfb_restore_memory_ivas_fx( st->cldfbAna ); /*Assuming Q10*/ - - /* CLDFB synthesis of the combined signal */ - IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbSyn ) ), IVAS_ERR_OK ) ) - { - return error; - } - - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, st->cldfbSyn ); - cldfb_restore_memory_ivas_fx( st->cldfbSyn ); - Copy_Scale_sig_32_16( syn_Overl_fx, st->hTcxDec->syn_Overl, 320, 15 ); - Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 ); - } - - test(); - test(); - IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) - { - lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples_fx + delay_comp, shr( output_frame, 1 ), shr( st->last_L_frame, 1 ) ); - /*Set to zero the remaining part*/ - set16_fx( st->hHQ_core->fer_samples_fx + delay_comp + output_frame / 2, 0, sub( shr( output_frame, 1 ), delay_comp ) ); - } - } - - st->use_acelp_preq = 0; - st->reset_mem_AR = 0; - move16(); - move16(); - } - - /*FEC*/ - IF( LE_16( st->L_frame, L_FRAME16k ) ) - { - test(); - IF( LE_16( st->last_L_frame, L_FRAME16k ) && NE_16( st->core, HQ_CORE ) ) - { - IF( NE_16( st->L_frame, st->last_L_frame ) ) - { - IF( GT_16( st->L_frame, st->last_L_frame ) ) - { - oldLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->last_L_frame, st->L_frame ) ); - newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; - move16(); - } - ELSE - { - oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM; - move16(); - newLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->L_frame, st->last_L_frame ) ); - } - lerp( &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff ); - } - } - ELSE - { - set16_fx( st->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); - } - } - - /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores - within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ - test(); - test(); - IF( ( st->core == ACELP_CORE ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) ) ) - { - st->last_ppp_mode_dec = 0; - st->last_nelp_mode_dec = 0; - move16(); - move16(); - } - - /* Handle state reset of stat_noise_uv_mod memory */ - test(); - test(); - test(); - IF( ( st->core == ACELP_CORE ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || LE_32( st->last_total_brate, PPP_NELP_2k80 ) ) ) - { - st->act_count = 3; - st->uv_count = 0; - move16(); - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && EQ_16( st->last_core, HQ_CORE ) ) || ( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( nchan_out, 2 ) && - NE_32( st->core_brate, SID_2k40 ) && ( st->core_brate != FRAME_NO_DATA ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) ) ) - { - test(); - if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - st->hPFstat->reset = 1; - move16(); - } - - IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - Copy( TRWB2_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */ - Copy( TRWB2_Ave_fx, st->lsfoldbfi1_fx, M ); - Copy( TRWB2_Ave_fx, st->lsfoldbfi0_fx, M ); - Copy( TRWB2_Ave_fx, st->lsf_adaptive_mean_fx, M ); - lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_16k ); - } - ELSE - { - Copy( TRWB_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */ - Copy( TRWB_Ave_fx, st->lsfoldbfi1_fx, M ); - Copy( TRWB_Ave_fx, st->lsfoldbfi0_fx, M ); - Copy( TRWB_Ave_fx, st->lsf_adaptive_mean_fx, M ); - lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_12k8 ); - } - - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_16( nchan_out, 2 ) && GT_32( st->core_brate, SID_2k40 ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) && st->hTcxDec != NULL ) - { - /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ - set16_fx( st->hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); - set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN ); - set16_fx( st->agc_mem_fx, 0, 2 ); - } - st->mem_deemph_fx = 0; - move16(); - IF( !st->last_con_tcx ) - { - set16_fx( st->mem_syn2_fx, 0, M ); - } - set16_fx( st->mem_syn1_fx, 0, M ); - if ( st->hBWE_TD != NULL ) - { - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - - /* Reset ACELP parameters */ - set16_fx( st->mem_MA_fx, 0, M ); - - IF( EQ_32( st->sr_core, INT_FS_16k ) ) - { - Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); - } - ELSE - { - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); - } - - st->tilt_code_fx = 0; - st->gc_threshold_fx = 0; - st->dm_fx.prev_gain_code = 0; - st->dm_fx.prev_state = 0; - move16(); - move32(); - move32(); - move16(); - set16_fx( st->dm_fx.prev_gain_pit, 0, 6 ); - - st->last_coder_type = GENERIC; - move16(); - - fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ - st->lp_gainp_fx = 0; - move16(); - st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ - move16(); - st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/ - move16(); - - st->last_voice_factor_fx = 0; - st->Last_GSC_noisy_speech_flag = 0; - move16(); - move16(); - - /* reset CLDFB memories */ - cldfb_reset_memory_fx( st->cldfbAna ); - cldfb_reset_memory_fx( st->cldfbBPF ); - cldfb_reset_memory_fx( st->cldfbSyn ); - - /* reset TBE memories */ - test(); - test(); - IF( !st->last_con_tcx && !( ( EQ_16( st->last_core, HQ_CORE ) ) && ( st->element_mode > EVS_MONO ) ) ) - { - set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC ); - } - ELSE IF( LT_16( st->L_frame, L_FRAME16k ) ) - { - /* resample from 16kHz to 12.8kHZ */ - synth_mem_updt2( st->L_frame, L_FRAME16k, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, DEC ); - } - - IF( st->hBWE_TD != NULL ) - { - set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - } - - test(); - IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) - { - hf_synth_reset_fx( st->hBWE_zero ); -#ifdef MSAN_FIX - set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); -#endif - } - - IF( st->hBWE_FD != NULL ) - { - set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - } - - test(); - test(); - test(); - IF( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) ) - { - IF( st->hBWE_TD != NULL ) - { - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); - } - - st->tilt_code_fx = 0; - st->gc_threshold_fx = 0; - st->dm_fx.prev_gain_code = 0; - st->dm_fx.prev_state = 0; - move16(); - move32(); - move32(); - move16(); - set16_fx( st->dm_fx.prev_gain_pit, 0, 6 ); - st->last_coder_type = GENERIC; - move16(); - fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ - - st->lp_gainp_fx = 0; - move16(); - st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ - move16(); - st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/ - move16(); - - st->last_voice_factor_fx = 0; - st->Last_GSC_noisy_speech_flag = 0; - move16(); - move16(); - - test(); - IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) - { - hf_synth_reset_fx( st->hBWE_zero ); -#ifdef MSAN_FIX - set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); -#endif - } - - IF( st->hBWE_FD != NULL ) - { - set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - - test(); - test(); - test(); - IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) ) - { - /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ - Word16 offset; - offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); - Word32 *old_synthFB_fx; - IF( ( old_synthFB_fx = (Word32 *) malloc( st->hTcxDec->old_synth_lenFB * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) ); - } -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 -#else - Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 -#endif - Copy32( old_synthFB_fx + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset ); - st->cldfbAna->Q_cldfb_state = Q10; - move16(); - IF( old_synthFB_fx ) - free( old_synthFB_fx ); - } - } - - test(); - test(); - test(); - test(); - IF( EQ_16( st->core, HQ_CORE ) && ( ( st->last_core == ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) || ( ( ( st->element_mode != EVS_MONO ) ) && ( NE_16( st->last_core, HQ_CORE ) ) ) ) ) - { - set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); - set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB ); - - set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); - set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); - st->hHQ_core->last_max_pos_pulse = 0; - move16(); - - set16_fx( st->hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); - st->hHQ_core->prev_frm_hfe2 = 0; - st->hHQ_core->prev_stab_hfe2 = 0; - move16(); - move16(); - IF( GT_32( st->output_Fs, 16000 ) ) - { - set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); - } - - IF( st->element_mode != EVS_MONO ) - { - /* Estimate mem_env_delta to reinit env_stab */ - tmp_fx = L_max( 0, L_add( ENV_STAB_EST1_FX, L_add( Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ), Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ) ) ); /*Q12*/ - - st->hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */ - move16(); - test(); - IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) - { - set16_fx( st->hHQ_core->old_out_fx, 0, output_frame ); - set32_fx( st->hHQ_core->old_outLB_fx, 0, L_FRAME16k ); - set16_fx( st->hHQ_core->old_out_LB_fx, 0, L_FRAME16k ); - } - - st->hHQ_core->no_att_hangover = 0; - move16(); - st->hHQ_core->energy_lt_fx = 2457600; /*300.0f Q13*/ - move32(); - set16_fx( st->hHQ_core->old_is_transient, 0, 3 ); - set16_fx( st->hHQ_core->prev_noise_level_fx, 0, 2 ); - st->hHQ_core->prev_R = 0; - move16(); - set16_fx( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 ); - st->hHQ_core->prev_hqswb_clas = HQ_NORMAL; - st->hHQ_core->prev_ni_ratio_fx = 16384; /*Q15*/ - move16(); - move16(); - set16_fx( st->hHQ_core->prev_En_sb_fx, 0, NB_SWB_SUBBANDS ); - } - ELSE - { - set16_fx( st->hHQ_core->old_out_fx, 0, output_frame ); - set32_fx( st->hHQ_core->old_outLB_fx, 0, L_FRAME16k ); - } - } - - /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */ - IF( st->hHQ_core != NULL ) - { - st->hHQ_core->pastpre = sub( st->hHQ_core->pastpre, 1 ); - move16(); - IF( st->hHQ_core->pastpre < 0 ) - { - reset_preecho_dec_fx( st->hHQ_core ); - } - } - test(); - IF( st->core_brate == FRAME_NO_DATA ) - { - st->VAD = 0; - st->m_frame_type = ZERO_FRAME; - } - ELSE IF( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, SID_1k75 ) ) - { - st->VAD = 0; - st->m_frame_type = SID_FRAME; - } - ELSE - { - st->VAD = 1; - st->m_frame_type = ACTIVE_FRAME; - } - - move16(); - move16(); - /*switch on CNA on active frames*/ - IF( ( st->element_mode == EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */ - { - test(); - test(); - test(); - test(); - test(); - test(); - IF( st->VAD && ( ( NE_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, CNA_MAX_BRATE ) ) || ( EQ_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, ACELP_8k85 ) ) ) ) - { - st->flag_cna = 1; - move16(); - } - ELSE IF( st->VAD || ( EQ_16( st->cng_type, FD_CNG ) && EQ_16( st->L_frame, L_FRAME16k ) ) ) - { - st->flag_cna = 0; - move16(); - } - } - - if ( EQ_16( st->core, AMR_WB_CORE ) ) - { - st->cng_type = LP_CNG; - move16(); - } - - /* Reconfigure CNG */ - test(); - test(); - test(); - test(); - IF( st->hFdCngDec && ( NE_16( st->last_L_frame, st->L_frame ) || NE_16( st->hFdCngDec->hFdCngCom->frameSize, st->L_frame ) || ( st->ini_frame == 0 ) || NE_16( st->bwidth, st->last_bwidth ) ) ) - { - /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/ - IF( NE_16( st->core, AMR_WB_CORE ) ) - { - test(); - IF( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) ) - { - configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, ACELP_9k60, st->L_frame, st->last_L_frame, st->element_mode ); - } - ELSE - { - configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode ); - } - } - ELSE - { - configureFdCngDec_ivas_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode ); - - if ( st->VAD ) - { - st->hFdCngDec->hFdCngCom->CngBitrate = st->total_brate; - move32(); - } - } - test(); - test(); - IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->L_frame, L_FRAME16k ) && LE_16( st->last_L_frame, L_FRAME16k ) ) - { - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame ); - } - - L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); - - test(); - IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) - { - L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth ); - - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) - { - st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); - move32(); - } - } - ELSE - { - FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) - { - st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); - move32(); - } - } - } - } - } - - return error; -} -/*---------------------------------------------------------------------* - * core_switching_hq_prepare_dec() - * - * Preprocessing in the first HQ frame after ACELP frame - * Modify bit allocation for HQ core by removing ACELP subframe budget - *---------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------* - * bandwidth_switching_detect() - * - * Classification for band-width switching - *---------------------------------------------------------------------*/ - -void bandwidth_switching_detect_ivas_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ -) -{ - test(); - test(); - IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) - { - /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */ - st_fx->prev_bws_cnt = 0; - st_fx->bws_cnt = 0; - st_fx->bws_cnt1 = 0; - move16(); - move16(); - move16(); - - return; - } - /* update band-width switching counter */ - test(); - test(); - test(); - test(); - IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) ) - { - st_fx->bws_cnt1 = 0; - move16(); - } - ELSE IF( GT_32( st_fx->total_brate, ACELP_9k60 ) && LT_32( st_fx->last_core_brate, ACELP_9k60 ) && EQ_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) && ( st_fx->last_low_rate_mode == 0 ) ) - { - st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); - move16(); - } - ELSE IF( st_fx->bws_cnt1 > 0 ) - { - IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt = sub( shl( sub( N_NS2W_FRAMES, st_fx->bws_cnt1 ), 1 ), 1 ); - move16(); - } - ELSE - { - st_fx->bws_cnt = 0; - move16(); - } - - IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt1 = 0; - move16(); - } - ELSE - { - IF( EQ_16( st_fx->bwidth, SWB ) ) - { - st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); - move16(); - } - ELSE - { - st_fx->bws_cnt1 = 0; - move16(); - } - } - } - - /* update band-width switching counter */ - test(); - test(); - test(); - IF( GE_16( st_fx->bws_cnt, N_WS2N_FRAMES ) ) - { - st_fx->bws_cnt = 0; - move16(); - } - ELSE IF( LT_32( st_fx->total_brate, ACELP_9k60 ) && GT_32( st_fx->last_core_brate, ACELP_9k60 ) && LT_16( st_fx->bwidth, st_fx->last_bwidth ) && EQ_16( st_fx->bwidth, WB ) ) - { - st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); - move16(); - } - ELSE IF( st_fx->bws_cnt > 0 ) - { - IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt1 = shr( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 1 ); - move16(); - } - ELSE - { - st_fx->bws_cnt1 = 0; - move16(); - } - - IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) ) - { - st_fx->bws_cnt = 0; - move16(); - } - ELSE - { - IF( EQ_16( st_fx->bwidth, WB ) ) - { - st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); - move16(); - } - ELSE - { - st_fx->bws_cnt = 0; - move16(); - } - } - } - - return; -} - - -/*---------------------------------------------------------------------* - * bw_switching_pre_proc() - * - * Band-width switching pre-processing - *---------------------------------------------------------------------*/ -void ivas_bw_switching_pre_proc_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 nchan_out /* i : number of output channels */, - Word32 *old_syn_12k8_16k_fx, - Word16 Q, - Word16 Q_audio ) -{ - Word16 i; - Word32 syn_dct_fx[L_FRAME]; - - - Flag Overflow = 0; - move32(); - - IF( st->element_mode > EVS_MONO ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) && st->hBWE_FD != NULL && !( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) ) - { - /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ - Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k]; - Copy_Scale_sig_32_16( old_syn_12k8_16k_fx, old_syn_12k8_16k_tmp_16fx, st->L_frame, sub( -1, Q ) ); - st->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st->L_frame ), sub( Q, 8 ) ) ); // Q24+(Q-8) - 16 - move16(); - } - - return; - } - - - test(); - test(); - IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) - { - /*----------------------------------------------------------------------* - * Calculate tilt of the ACELP core synthesis - *----------------------------------------------------------------------*/ - - st->tilt_wb_fx = ivas_calc_tilt_bwe_fx( old_syn_12k8_16k_fx, Q, st->L_frame ); - move16(); - /*-------------------------------------------------------------------------------* - * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis - *-------------------------------------------------------------------------------*/ - edct_fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, &Q ); - Word64 W_tmp = 0; - move64(); - Word32 tmp; - Word16 shift; - FOR( i = 0; i < L_FRAME / 2; i++ ) - { - W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); - } - shift = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, shift ); - tmp = W_extract_h( W_tmp ); - tmp = L_shr( tmp, 8 ); - - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); - move16(); - W_tmp = 0; - move64(); - FOR( ; i < L_FRAME; i++ ) - { - W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); - } - shift = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, shift ); - tmp = W_extract_h( W_tmp ); // Q = Q + shift - 32 - tmp = L_shr( tmp, 7 ); // divide by 128 - tmp = getSqrtWord32( tmp ); - st->enerLH_fx = tmp; - move32(); - st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); - move16(); - } - ELSE - { - IF( st->hHQ_core->old_is_transient[0] ) - { - Word32 tmp, L_tmp = 0; - move32(); - FOR( i = 0; i < 32; i++ ) - { - L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); - } - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = Q_audio; - move16(); - - L_tmp = 0; - move32(); - FOR( ; i < 64; i++ ) - { - L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); - } - - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLH_fx = tmp; - move32(); - st->enerLH_fx_Q = Q_audio; - move16(); - } - ELSE - { - Word32 tmp, L_tmp = 0; - move32(); - FOR( i = 0; i < L_FRAME / 2; i++ ) - { - L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); - } - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = Q_audio; - move16(); - - L_tmp = 0; - move32(); - FOR( ; i < L_FRAME; i++ ) - { - L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); - } - tmp = L_shr( L_tmp, 5 ); // divide by 32 - tmp = getSqrtWord32( tmp ); - st->enerLL_fx = tmp; - move32(); - st->enerLL_fx_Q = Q_audio; - move16(); - } - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) ) - { - - st->prev_ener_shb_fx = 0; - move16(); - IF( st->hBWE_FD != NULL ) - { - set16_fx( st->prev_SWB_fenv_fx, 0, SWB_FENV ); - } - } - ELSE IF( ( ( ( st->core == ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) ) - { - st->attenu_fx = 3277; // 0.1f in Q15 - move16(); - } - - test(); - test(); - test(); - test(); - test(); - if ( EQ_16( st->last_core, HQ_CORE ) || ( ( st->last_core == ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) ) - { - st->prev_fractive = 0; - move16(); - } - - return; -} -/*---------------------------------------------------------------------* - * core_switch_lb_upsamp() - * - * Resample HQ/TCX-LB to the output sampling rate (8/16/32/48 kHz) - *---------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------* - * smoothTransitionDtxToTcx() - * - * apply smoothing to the transition part for inactive to active transitions in DTX - *---------------------------------------------------------------------*/ - -#define TRANSITION_SMOOTHING_LEN_16k 15 -#define TRANSITION_SMOOTHING_LEN_32k 31 -#define TRANSITION_SMOOTHING_LEN_48k 47 diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index d654b3af4..caef9485b 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -2435,3 +2435,1012 @@ static void smoothTransitionDtxToTcx_fx( return; } + + +/*---------------------------------------------------------------------* + * core_switching_pre_dec() + * + * Preprocessing/preparation for ACELP/HQ core switching + *---------------------------------------------------------------------*/ +ivas_error core_switching_pre_dec_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 output_frame, /* i : frame length */ + const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + const Word16 last_element_mode, /* i : last_element_mode */ + const Word32 last_element_brate, /* i : last element bitrate */ + Word16 Q_old_synthFB, + Word16 *Q_olapBufferSynth, + Word16 *Q_olapBufferSynth2 ) +{ + Word32 tmp_fx; /*Q-12*/ + Word16 i, oldLenClasBuff, newLenClasBuff; + ivas_error error; + Word16 exp = 25; + move16(); + error = IVAS_ERR_OK; + move32(); + + /* Codec mode switching */ + test(); + test(); + test(); + IF( EQ_16( st->last_codec_mode, MODE2 ) || ( ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) && ( st->element_mode > EVS_MONO ) ) ) + { + st->mem_deemph_fx = st->syn[M]; + move16(); + set16_fx( st->agc_mem_fx, 0, 2 ); + Scale_sig( &( st->mem_deemph_fx ), 1, st->Q_syn ); /* Brings mem_deemph to Qsyn */ + + Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/ + + st->bpf_off = 1; + move16(); + IF( st->hPFstat != NULL ) + { + Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ + Scale_sig( st->hPFstat->mem_res2, DECMEM_RES2, st->Q_syn ); /* NB post_filter mem , Q_syn*/ + Scale_sig( st->hPFstat->mem_stp, L_SUBFR, st->Q_syn ); /* Post_filter mem ,Q_syn*/ + set16_fx( st->hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); /* BPF mem*/ + } + IF( st->hBPF != NULL ) + { + st->hBPF->pst_lp_ener_fx = round_fx( L_shl( Mpy_32_16_1( st->lp_error_ener, 0x6054 ), 2 + 8 ) ); /* convert from 15Q16, log2 -> 7Q8 10*log10 */ + st->hBPF->pst_mem_deemp_err_fx = 0; + move16(); + move16(); + } + st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) ); // Q(23+1-16)->Q8 + move16(); + + /* reset old HB synthesis buffer */ + IF( EQ_16( st->last_L_frame, L_FRAME ) ) + { + st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_12k8_NS ); + } + ELSE + { + st->old_bwe_delay = NS2SA( st->output_Fs, MAX_DELAY_TBE_NS - DELAY_SWB_TBE_16k_NS ); + } + move16(); + set16_fx( st->hb_prev_synth_buffer_fx, 0, NS2SA( 48000, DELAY_BWE_TOTAL_NS ) ); + + test(); + IF( st->hBWE_TD != NULL && ( st->last_core != ACELP_CORE ) ) + { +#ifdef MSAN_FIX + st->hBWE_TD->prev_hb_synth_fx_exp = 31; + move16(); +#endif // MSAN_FIX + /* reset BWE memories */ + set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); + } + + /* reset upd_cnt */ + st->upd_cnt = MAX_UPD_CNT; + move16(); + + st->igf = 0; + move16(); + + test(); + IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) + { + hf_synth_reset_fx( st->hBWE_zero ); +#ifdef MSAN_FIX + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); +#endif + } + + IF( st->hBWE_FD != NULL ) + { + set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + } + + IF( st->hHQ_core != NULL ) + { + set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); + set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB ); + + set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); + + st->hHQ_core->last_max_pos_pulse = 0; + move16(); + + IF( GT_32( st->output_Fs, 16000 ) ) + { + set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); + } + + /* pre-echo */ + st->hHQ_core->pastpre = 0; + move16(); + } + + /* reset the GSC pre echo energy threshold in case of switching */ + if ( st->hGSCDec != NULL ) + { + st->hGSCDec->Last_frame_ener_fx = MAX_32; + move32(); + } + + test(); + IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) + { + IF( st->element_mode == EVS_MONO ) + { + st->last_core = HQ_CORE; + move16(); + + Copy32( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer32_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ) ); + // Copy_Scale_sig_32_16( st->hTcxDec->FBTCXdelayBuf_32, st->prev_synth_buffer_fx, NS2SA( st->output_Fs, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); //Q11 -> Q0 + } + + IF( st->hHQ_core != NULL ) + { + set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); + st->hHQ_core->last_max_pos_pulse = 0; + move16(); + + set16_fx( st->hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); + st->hHQ_core->prev_frm_hfe2 = 0; + st->hHQ_core->prev_stab_hfe2 = 0; + move16(); + move16(); + } + } + + IF( st->prev_bfi != 0 ) + { + Word16 delay_comp; + + /*switch off Hq Voicing as it was not updated in MODE2*/ + IF( st->hHQ_core != NULL ) + { + st->hHQ_core->oldHqVoicing = 0; + st->hHQ_core->HqVoicing = 0; + move16(); + move16(); + } + + delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); + /*TODO To be tested:control not entering the block*/ + test(); + test(); + IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) + { + /*TODO None of the test dtreams are entering this block,hence enabled assert(0)*/ + assert( 0 ); + Word32 *realBuffer_fx[CLDFB_NO_COL_MAX_SWITCH], *imagBuffer_fx[CLDFB_NO_COL_MAX_SWITCH]; + Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX], imagBufferTmp_fx[CLDFB_NO_COL_MAX_SWITCH][CLDFB_NO_CHANNELS_MAX]; + Word32 syn_Overl_fx[320]; + Word32 fer_samples_fx[960]; + Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->syn_Overl, syn_Overl_fx, 320, 15 ); + Copy_Scale_sig_16_32_DEPREC( st->hHQ_core->fer_samples_fx, fer_samples_fx, 960, 15 ); + + + FOR( i = 0; i < CLDFB_NO_COL_MAX_SWITCH; i++ ) + { + set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); + realBuffer_fx[i] = realBufferTmp_fx[i]; + imagBuffer_fx[i] = imagBufferTmp_fx[i]; + } + + /* CLDFB analysis of the synthesis at internal sampling rate */ + IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbAna ) ), IVAS_ERR_OK ) ) + { + return error; + } + + cldfbAnalysis_ivas_fx( syn_Overl_fx, realBuffer_fx, imagBuffer_fx, delay_comp, st->cldfbAna ); + cldfb_restore_memory_ivas_fx( st->cldfbAna ); /*Assuming Q10*/ + + /* CLDFB synthesis of the combined signal */ + IF( NE_32( ( error = cldfb_save_memory_ivas_fx( st->cldfbSyn ) ), IVAS_ERR_OK ) ) + { + return error; + } + + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, st->cldfbSyn ); + cldfb_restore_memory_ivas_fx( st->cldfbSyn ); + Copy_Scale_sig_32_16( syn_Overl_fx, st->hTcxDec->syn_Overl, 320, 15 ); + Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 ); + } + + test(); + test(); + IF( !st->last_con_tcx && ( st->last_core_bfi == ACELP_CORE ) && EQ_16( st->core, HQ_CORE ) ) + { + lerp( st->hTcxDec->syn_Overl, st->hHQ_core->fer_samples_fx + delay_comp, shr( output_frame, 1 ), shr( st->last_L_frame, 1 ) ); + /*Set to zero the remaining part*/ + set16_fx( st->hHQ_core->fer_samples_fx + delay_comp + output_frame / 2, 0, sub( shr( output_frame, 1 ), delay_comp ) ); + } + } + + st->use_acelp_preq = 0; + st->reset_mem_AR = 0; + move16(); + move16(); + } + + /*FEC*/ + IF( LE_16( st->L_frame, L_FRAME16k ) ) + { + test(); + IF( LE_16( st->last_L_frame, L_FRAME16k ) && NE_16( st->core, HQ_CORE ) ) + { + IF( NE_16( st->L_frame, st->last_L_frame ) ) + { + IF( GT_16( st->L_frame, st->last_L_frame ) ) + { + oldLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->last_L_frame, st->L_frame ) ); + newLenClasBuff = L_SYN_MEM_CLAS_ESTIM; + move16(); + } + ELSE + { + oldLenClasBuff = L_SYN_MEM_CLAS_ESTIM; + move16(); + newLenClasBuff = mult_r( L_SYN_MEM_CLAS_ESTIM, div_s( st->L_frame, st->last_L_frame ) ); + } + lerp( &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - oldLenClasBuff], &st->mem_syn_clas_estim_fx[L_SYN_MEM_CLAS_ESTIM - newLenClasBuff], newLenClasBuff, oldLenClasBuff ); + } + } + ELSE + { + set16_fx( st->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); + } + } + + /* Here we only handle cases where last_ppp and last_nelp not updated when coming from CodecB or other cores + within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */ + test(); + test(); + IF( ( st->core == ACELP_CORE ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) ) ) + { + st->last_ppp_mode_dec = 0; + st->last_nelp_mode_dec = 0; + move16(); + move16(); + } + + /* Handle state reset of stat_noise_uv_mod memory */ + test(); + test(); + test(); + IF( ( st->core == ACELP_CORE ) && ( ( st->last_core != ACELP_CORE ) || EQ_16( st->last_codec_mode, MODE2 ) || LE_32( st->last_total_brate, PPP_NELP_2k80 ) ) ) + { + st->act_count = 3; + st->uv_count = 0; + move16(); + move16(); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && EQ_16( st->last_core, HQ_CORE ) ) || ( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( nchan_out, 2 ) && + NE_32( st->core_brate, SID_2k40 ) && ( st->core_brate != FRAME_NO_DATA ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) ) ) + { + test(); + if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + st->hPFstat->reset = 1; + move16(); + } + + IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + Copy( TRWB2_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */ + Copy( TRWB2_Ave_fx, st->lsfoldbfi1_fx, M ); + Copy( TRWB2_Ave_fx, st->lsfoldbfi0_fx, M ); + Copy( TRWB2_Ave_fx, st->lsf_adaptive_mean_fx, M ); + lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_16k ); + } + ELSE + { + Copy( TRWB_Ave_fx, st->lsf_old_fx, M ); /* init of LSP */ + Copy( TRWB_Ave_fx, st->lsfoldbfi1_fx, M ); + Copy( TRWB_Ave_fx, st->lsfoldbfi0_fx, M ); + Copy( TRWB_Ave_fx, st->lsf_adaptive_mean_fx, M ); + lsf2lsp_fx( st->lsf_old_fx, st->lsp_old_fx, M, INT_FS_12k8 ); + } + + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && EQ_16( nchan_out, 2 ) && GT_32( st->core_brate, SID_2k40 ) && ( ( last_core_brate_st0 == FRAME_NO_DATA ) || EQ_32( last_core_brate_st0, SID_2k40 ) ) && st->hTcxDec != NULL ) + { + /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ + set16_fx( st->hTcxDec->old_syn_Overl, 0, L_FRAME32k / 2 ); + set16_fx( st->hFdCngDec->hFdCngCom->olapBufferAna_fx, 0, FFTLEN ); + set16_fx( st->agc_mem_fx, 0, 2 ); + } + st->mem_deemph_fx = 0; + move16(); + IF( !st->last_con_tcx ) + { + set16_fx( st->mem_syn2_fx, 0, M ); + } + set16_fx( st->mem_syn1_fx, 0, M ); + if ( st->hBWE_TD != NULL ) + { + st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); + } + + /* Reset ACELP parameters */ + set16_fx( st->mem_MA_fx, 0, M ); + + IF( EQ_32( st->sr_core, INT_FS_16k ) ) + { + Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); + } + ELSE + { + Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); + } + + st->tilt_code_fx = 0; + st->gc_threshold_fx = 0; + st->dm_fx.prev_gain_code = 0; + st->dm_fx.prev_state = 0; + move16(); + move32(); + move32(); + move16(); + set16_fx( st->dm_fx.prev_gain_pit, 0, 6 ); + + st->last_coder_type = GENERIC; + move16(); + + fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ + st->lp_gainp_fx = 0; + move16(); + st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ + move16(); + st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/ + move16(); + + st->last_voice_factor_fx = 0; + st->Last_GSC_noisy_speech_flag = 0; + move16(); + move16(); + + /* reset CLDFB memories */ + cldfb_reset_memory_fx( st->cldfbAna ); + cldfb_reset_memory_fx( st->cldfbBPF ); + cldfb_reset_memory_fx( st->cldfbSyn ); + + /* reset TBE memories */ + test(); + test(); + IF( !st->last_con_tcx && !( ( EQ_16( st->last_core, HQ_CORE ) ) && ( st->element_mode > EVS_MONO ) ) ) + { + set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC ); + } + ELSE IF( LT_16( st->L_frame, L_FRAME16k ) ) + { + /* resample from 16kHz to 12.8kHZ */ + synth_mem_updt2( st->L_frame, L_FRAME16k, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, DEC ); + } + + IF( st->hBWE_TD != NULL ) + { + set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + } + + test(); + IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) + { + hf_synth_reset_fx( st->hBWE_zero ); +#ifdef MSAN_FIX + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); +#endif + } + + IF( st->hBWE_FD != NULL ) + { + set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + } + } + + test(); + test(); + test(); + IF( ( ( st->core == ACELP_CORE ) || EQ_16( st->core, AMR_WB_CORE ) ) && ( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) ) ) + { + IF( st->hBWE_TD != NULL ) + { + st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; + move32(); + set16_fx( st->hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + } + + st->tilt_code_fx = 0; + st->gc_threshold_fx = 0; + st->dm_fx.prev_gain_code = 0; + st->dm_fx.prev_state = 0; + move16(); + move32(); + move32(); + move16(); + set16_fx( st->dm_fx.prev_gain_pit, 0, 6 ); + st->last_coder_type = GENERIC; + move16(); + fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ + + st->lp_gainp_fx = 0; + move16(); + st->lp_gainc_fx = extract_h( Sqrt32( st->lp_ener_fx, &exp ) ); /*Q=15-exp*/ + move16(); + st->lp_gainc_fx = shr( st->lp_gainc_fx, sub( 12, exp ) ); /*Q3*/ + move16(); + + st->last_voice_factor_fx = 0; + st->Last_GSC_noisy_speech_flag = 0; + move16(); + move16(); + + test(); + IF( GT_32( st->output_Fs, 16000 ) && st->hBWE_zero != NULL ) + { + hf_synth_reset_fx( st->hBWE_zero ); +#ifdef MSAN_FIX + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); +#endif + } + + IF( st->hBWE_FD != NULL ) + { + set16_fx( st->hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); + } + + test(); + test(); + test(); + IF( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->element_brate, IVAS_24k4 ) && GT_32( last_element_brate, IVAS_24k4 ) ) + { + /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ + Word16 offset; + offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); + Word32 *old_synthFB_fx; + IF( ( old_synthFB_fx = (Word32 *) malloc( st->hTcxDec->old_synth_lenFB * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for old_synth_lenFB (32 bit) \n" ) ); + } +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 +#else + Copy_Scale_sig_16_32_DEPREC( st->hTcxDec->old_synthFB_fx, old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( Q10, Q_old_synthFB ) ); // Q10 +#endif + Copy32( old_synthFB_fx + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state_fx, offset ); + st->cldfbAna->Q_cldfb_state = Q10; + move16(); + IF( old_synthFB_fx ) + free( old_synthFB_fx ); + } + } + + test(); + test(); + test(); + test(); + IF( EQ_16( st->core, HQ_CORE ) && ( ( st->last_core == ACELP_CORE ) || EQ_16( st->last_core, AMR_WB_CORE ) || ( ( ( st->element_mode != EVS_MONO ) ) && ( NE_16( st->last_core, HQ_CORE ) ) ) ) ) + { + set32_fx( st->hHQ_core->prev_env_fx, 0, SFM_N_WB ); + set32_fx( st->hHQ_core->prev_normq_fx, 0, SFM_N_WB ); + + set32_fx( st->hHQ_core->last_ni_gain_fx, 0, BANDS_MAX ); + set16_fx( st->hHQ_core->last_env_fx, 0, BANDS_MAX ); + st->hHQ_core->last_max_pos_pulse = 0; + move16(); + + set16_fx( st->hHQ_core->prev_SWB_peak_pos, 0, SPT_SHORTEN_SBNUM ); + st->hHQ_core->prev_frm_hfe2 = 0; + st->hHQ_core->prev_stab_hfe2 = 0; + move16(); + move16(); + IF( GT_32( st->output_Fs, 16000 ) ) + { + set32_fx( st->hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); + } + + IF( st->element_mode != EVS_MONO ) + { + /* Estimate mem_env_delta to reinit env_stab */ + tmp_fx = L_max( 0, L_add( ENV_STAB_EST1_FX, L_add( Mult_32_16( st->stab_fac_smooth_lt_fx, ENV_STAB_EST2_FX ), Mult_32_16( st->log_energy_diff_lt_fx, ENV_STAB_EST3_FX ) ) ) ); /*Q12*/ + + st->hHQ_core->mem_env_delta = extract_l( L_min( MAX16B, tmp_fx ) ); /* Convert to Q12 and handle saturation */ + move16(); + test(); + IF( NE_16( st->last_core, TCX_20_CORE ) && NE_16( st->last_core, TCX_10_CORE ) ) + { + set16_fx( st->hHQ_core->old_out_fx, 0, output_frame ); + set32_fx( st->hHQ_core->old_outLB_fx, 0, L_FRAME16k ); + set16_fx( st->hHQ_core->old_out_LB_fx, 0, L_FRAME16k ); + } + + st->hHQ_core->no_att_hangover = 0; + move16(); + st->hHQ_core->energy_lt_fx = 2457600; /*300.0f Q13*/ + move32(); + set16_fx( st->hHQ_core->old_is_transient, 0, 3 ); + set16_fx( st->hHQ_core->prev_noise_level_fx, 0, 2 ); + st->hHQ_core->prev_R = 0; + move16(); + set16_fx( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 ); + st->hHQ_core->prev_hqswb_clas = HQ_NORMAL; + st->hHQ_core->prev_ni_ratio_fx = 16384; /*Q15*/ + move16(); + move16(); + set16_fx( st->hHQ_core->prev_En_sb_fx, 0, NB_SWB_SUBBANDS ); + } + ELSE + { + set16_fx( st->hHQ_core->old_out_fx, 0, output_frame ); + set32_fx( st->hHQ_core->old_outLB_fx, 0, L_FRAME16k ); + } + } + + /* handle switching cases where preecho_sb was not called in the last frame (memory not up to date) */ + IF( st->hHQ_core != NULL ) + { + st->hHQ_core->pastpre = sub( st->hHQ_core->pastpre, 1 ); + move16(); + IF( st->hHQ_core->pastpre < 0 ) + { + reset_preecho_dec_fx( st->hHQ_core ); + } + } + test(); + IF( st->core_brate == FRAME_NO_DATA ) + { + st->VAD = 0; + st->m_frame_type = ZERO_FRAME; + } + ELSE IF( EQ_32( st->core_brate, SID_2k40 ) || EQ_32( st->core_brate, SID_1k75 ) ) + { + st->VAD = 0; + st->m_frame_type = SID_FRAME; + } + ELSE + { + st->VAD = 1; + st->m_frame_type = ACTIVE_FRAME; + } + + move16(); + move16(); + /*switch on CNA on active frames*/ + IF( ( st->element_mode == EVS_MONO ) ) /* for IVAS modes, st->flag_cna is set earlier */ + { + test(); + test(); + test(); + test(); + test(); + test(); + IF( st->VAD && ( ( NE_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, CNA_MAX_BRATE ) ) || ( EQ_16( st->core, AMR_WB_CORE ) && LE_32( st->total_brate, ACELP_8k85 ) ) ) ) + { + st->flag_cna = 1; + move16(); + } + ELSE IF( st->VAD || ( EQ_16( st->cng_type, FD_CNG ) && EQ_16( st->L_frame, L_FRAME16k ) ) ) + { + st->flag_cna = 0; + move16(); + } + } + + if ( EQ_16( st->core, AMR_WB_CORE ) ) + { + st->cng_type = LP_CNG; + move16(); + } + + /* Reconfigure CNG */ + test(); + test(); + test(); + test(); + IF( st->hFdCngDec && ( NE_16( st->last_L_frame, st->L_frame ) || NE_16( st->hFdCngDec->hFdCngCom->frameSize, st->L_frame ) || ( st->ini_frame == 0 ) || NE_16( st->bwidth, st->last_bwidth ) ) ) + { + /* || st->last_core == AMR_WB_CORE || st->last_codec_mode == MODE2)){*/ + IF( NE_16( st->core, AMR_WB_CORE ) ) + { + test(); + IF( EQ_16( st->rf_flag, 1 ) && EQ_32( st->total_brate, ACELP_13k20 ) ) + { + configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, ACELP_9k60, st->L_frame, st->last_L_frame, st->element_mode ); + } + ELSE + { + configureFdCngDec_ivas_fx( st->hFdCngDec, st->bwidth, st->total_brate, st->L_frame, st->last_L_frame, st->element_mode ); + } + } + ELSE + { + configureFdCngDec_ivas_fx( st->hFdCngDec, WB, ACELP_8k00, st->L_frame, st->last_L_frame, st->element_mode ); + + if ( st->VAD ) + { + st->hFdCngDec->hFdCngCom->CngBitrate = st->total_brate; + move32(); + } + } + test(); + test(); + IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->L_frame, L_FRAME16k ) && LE_16( st->last_L_frame, L_FRAME16k ) ) + { + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame ); + } + + L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth2 ); + + test(); + IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) + { + L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth ); + + IF( EQ_16( st->L_frame, L_FRAME ) ) + { + FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) + { + st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); + move32(); + } + } + ELSE + { + FOR( i = 0; i < ( st->L_frame * 2 ); i++ ) + { + st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); + move32(); + } + } + } + } + } + + return error; +} +/*---------------------------------------------------------------------* + * core_switching_hq_prepare_dec() + * + * Preprocessing in the first HQ frame after ACELP frame + * Modify bit allocation for HQ core by removing ACELP subframe budget + *---------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------* + * bandwidth_switching_detect() + * + * Classification for band-width switching + *---------------------------------------------------------------------*/ + +void bandwidth_switching_detect_ivas_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ +) +{ + test(); + test(); + IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + { + /* there is no BWE in TD stereo secondary channel and in MDCT stereo, IGF is part of the core decoding -> no BW switching -> reset BWS counters */ + st_fx->prev_bws_cnt = 0; + st_fx->bws_cnt = 0; + st_fx->bws_cnt1 = 0; + move16(); + move16(); + move16(); + + return; + } + /* update band-width switching counter */ + test(); + test(); + test(); + test(); + IF( GE_16( st_fx->bws_cnt1, N_NS2W_FRAMES ) ) + { + st_fx->bws_cnt1 = 0; + move16(); + } + ELSE IF( GT_32( st_fx->total_brate, ACELP_9k60 ) && LT_32( st_fx->last_core_brate, ACELP_9k60 ) && EQ_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) && ( st_fx->last_low_rate_mode == 0 ) ) + { + st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); + move16(); + } + ELSE IF( st_fx->bws_cnt1 > 0 ) + { + IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) ) + { + st_fx->bws_cnt = sub( shl( sub( N_NS2W_FRAMES, st_fx->bws_cnt1 ), 1 ), 1 ); + move16(); + } + ELSE + { + st_fx->bws_cnt = 0; + move16(); + } + + IF( LT_16( st_fx->bwidth, st_fx->last_bwidth ) ) + { + st_fx->bws_cnt1 = 0; + move16(); + } + ELSE + { + IF( EQ_16( st_fx->bwidth, SWB ) ) + { + st_fx->bws_cnt1 = add( st_fx->bws_cnt1, 1 ); + move16(); + } + ELSE + { + st_fx->bws_cnt1 = 0; + move16(); + } + } + } + + /* update band-width switching counter */ + test(); + test(); + test(); + IF( GE_16( st_fx->bws_cnt, N_WS2N_FRAMES ) ) + { + st_fx->bws_cnt = 0; + move16(); + } + ELSE IF( LT_32( st_fx->total_brate, ACELP_9k60 ) && GT_32( st_fx->last_core_brate, ACELP_9k60 ) && LT_16( st_fx->bwidth, st_fx->last_bwidth ) && EQ_16( st_fx->bwidth, WB ) ) + { + st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); + move16(); + } + ELSE IF( st_fx->bws_cnt > 0 ) + { + IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) ) + { + st_fx->bws_cnt1 = shr( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 1 ); + move16(); + } + ELSE + { + st_fx->bws_cnt1 = 0; + move16(); + } + + IF( GT_16( st_fx->bwidth, st_fx->last_bwidth ) ) + { + st_fx->bws_cnt = 0; + move16(); + } + ELSE + { + IF( EQ_16( st_fx->bwidth, WB ) ) + { + st_fx->bws_cnt = add( st_fx->bws_cnt, 1 ); + move16(); + } + ELSE + { + st_fx->bws_cnt = 0; + move16(); + } + } + } + + return; +} + + +/*---------------------------------------------------------------------* + * bw_switching_pre_proc() + * + * Band-width switching pre-processing + *---------------------------------------------------------------------*/ +void ivas_bw_switching_pre_proc_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 nchan_out /* i : number of output channels */, + Word32 *old_syn_12k8_16k_fx, + Word16 Q, + Word16 Q_audio ) +{ + Word16 i; + Word32 syn_dct_fx[L_FRAME]; + + + Flag Overflow = 0; + move32(); + + IF( st->element_mode > EVS_MONO ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) && st->hBWE_FD != NULL && !( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) ) + { + /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ + Word16 old_syn_12k8_16k_tmp_16fx[L_FRAME16k]; + Copy_Scale_sig_32_16( old_syn_12k8_16k_fx, old_syn_12k8_16k_tmp_16fx, st->L_frame, sub( -1, Q ) ); + st->tilt_wb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_syn_12k8_16k_tmp_16fx, -1, st->L_frame ), sub( Q, 8 ) ) ); // Q24+(Q-8) - 16 + move16(); + } + + return; + } + + + test(); + test(); + IF( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) + { + /*----------------------------------------------------------------------* + * Calculate tilt of the ACELP core synthesis + *----------------------------------------------------------------------*/ + + st->tilt_wb_fx = ivas_calc_tilt_bwe_fx( old_syn_12k8_16k_fx, Q, st->L_frame ); + move16(); + /*-------------------------------------------------------------------------------* + * Calculate frequency energy of 0~3.2kHz and 3.2~6.4kHz the ACELP core synthesis + *-------------------------------------------------------------------------------*/ + edct_fx( old_syn_12k8_16k_fx, syn_dct_fx, L_FRAME, &Q ); + Word64 W_tmp = 0; + move64(); + Word32 tmp; + Word16 shift; + FOR( i = 0; i < L_FRAME / 2; i++ ) + { + W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); + } + shift = W_norm( W_tmp ); + W_tmp = W_shl( W_tmp, shift ); + tmp = W_extract_h( W_tmp ); + tmp = L_shr( tmp, 8 ); + + tmp = getSqrtWord32( tmp ); + st->enerLL_fx = tmp; + move32(); + st->enerLL_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); + move16(); + W_tmp = 0; + move64(); + FOR( ; i < L_FRAME; i++ ) + { + W_tmp = W_add( W_tmp, W_shr( W_mult0_32_32( syn_dct_fx[i], syn_dct_fx[i] ), Q ) ); + } + shift = W_norm( W_tmp ); + W_tmp = W_shl( W_tmp, shift ); + tmp = W_extract_h( W_tmp ); // Q = Q + shift - 32 + tmp = L_shr( tmp, 7 ); // divide by 128 + tmp = getSqrtWord32( tmp ); + st->enerLH_fx = tmp; + move32(); + st->enerLH_fx_Q = shr( sub( add( Q, shift ), 32 ), 1 ); + move16(); + } + ELSE + { + IF( st->hHQ_core->old_is_transient[0] ) + { + Word32 tmp, L_tmp = 0; + move32(); + FOR( i = 0; i < 32; i++ ) + { + L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); + } + tmp = L_shr( L_tmp, 5 ); // divide by 32 + tmp = getSqrtWord32( tmp ); + st->enerLL_fx = tmp; + move32(); + st->enerLL_fx_Q = Q_audio; + move16(); + + L_tmp = 0; + move32(); + FOR( ; i < 64; i++ ) + { + L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); + } + + tmp = L_shr( L_tmp, 5 ); // divide by 32 + tmp = getSqrtWord32( tmp ); + st->enerLH_fx = tmp; + move32(); + st->enerLH_fx_Q = Q_audio; + move16(); + } + ELSE + { + Word32 tmp, L_tmp = 0; + move32(); + FOR( i = 0; i < L_FRAME / 2; i++ ) + { + L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); + } + tmp = L_shr( L_tmp, 5 ); // divide by 32 + tmp = getSqrtWord32( tmp ); + st->enerLL_fx = tmp; + move32(); + st->enerLL_fx_Q = Q_audio; + move16(); + + L_tmp = 0; + move32(); + FOR( ; i < L_FRAME; i++ ) + { + L_tmp = L_mac0_o( L_tmp, st->t_audio_q_fx[i], st->t_audio_q_fx[i], &Overflow ); + } + tmp = L_shr( L_tmp, 5 ); // divide by 32 + tmp = getSqrtWord32( tmp ); + st->enerLL_fx = tmp; + move32(); + st->enerLL_fx_Q = Q_audio; + move16(); + } + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->last_bwidth, 0 ) && LE_16( st->extl, SWB_CNG ) ) + { + + st->prev_ener_shb_fx = 0; + move16(); + IF( st->hBWE_FD != NULL ) + { + set16_fx( st->prev_SWB_fenv_fx, 0, SWB_FENV ); + } + } + ELSE IF( ( ( ( st->core == ACELP_CORE ) && ( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) || ( EQ_16( st->core, st->last_core ) && NE_16( st->extl, st->last_extl ) ) ) && GE_16( st->last_bwidth, SWB ) ) + { + st->attenu_fx = 3277; // 0.1f in Q15 + move16(); + } + + test(); + test(); + test(); + test(); + test(); + if ( EQ_16( st->last_core, HQ_CORE ) || ( ( st->last_core == ACELP_CORE ) && !( EQ_16( st->last_extl, WB_TBE ) || EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) && GT_32( st->core_brate, ACELP_8k00 ) ) ) + { + st->prev_fractive = 0; + move16(); + } + + return; +} \ No newline at end of file diff --git a/lib_dec/dec_prm.c b/lib_dec/dec_prm.c deleted file mode 100644 index 7b4567f7a..000000000 --- a/lib_dec/dec_prm.c +++ /dev/null @@ -1,328 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * getTCXMode_ivas() - * - * get TCX mode - *--------------------------------------------------------------------*/ -void getTCXMode_ivas_fx( - Decoder_State *st, /* i/o: decoder memory state */ - Decoder_State *st0, /* i : bitstream */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -) -{ - UWord16 ind; - - IF( st->tcxonly ) - { - /* get core */ - ind = get_next_indice_fx( st0, 1 ); /* Store decoder memory of last_core */ - st->core = add( ind, TCX_20_CORE ); - move16(); - /* get class */ - ind = get_next_indice_fx( st0, 2 ); - - st->clas_dec = ONSET; - move16(); - IF( ind == 0 ) - { - st->clas_dec = UNVOICED_CLAS; - move16(); - } - ELSE IF( EQ_16( ind, 1 ) ) - { - IF( GE_16( st->last_good, VOICED_TRANSITION ) ) - { - st->clas_dec = VOICED_TRANSITION; - move16(); - } - ELSE - { - st->clas_dec = UNVOICED_TRANSITION; - move16(); - } - } - ELSE IF( EQ_16( ind, 2 ) ) - { - st->clas_dec = VOICED_CLAS; - move16(); - } - - st->coder_type = INACTIVE; - move16(); - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag ) - { - st->VAD = get_next_indice_fx( st0, 1 ); - move16(); - } - ELSE - { - st->VAD = 0; - move16(); - } - } - ELSE - { - IF( EQ_16( st->mdct_sw, MODE1 ) ) - { - /* 2 bits instead of 3 as TCX is already signaled */ - st->core = TCX_20_CORE; - move16(); - st->hTcxCfg->coder_type = get_next_indice_fx( st0, 2 ); - move16(); - st->coder_type = st->hTcxCfg->coder_type; - move16(); - } - ELSE - { - IF( EQ_16( st->mdct_sw_enable, MODE2 ) ) - { - IF( get_next_indice_1_fx( st0 ) ) - { - ind = get_next_indice_fx( st0, 3 ); - assert( !( ind & 4 ) || !"HQ_CORE encountered in dec_prm_ivas" ); - st->core = TCX_20_CORE; - move16(); - st->hTcxCfg->coder_type = ind; - move16(); - st->coder_type = st->hTcxCfg->coder_type; - move16(); - } - ELSE /* ACELP */ - { - st->core = ACELP_CORE; - move16(); - st->coder_type = get_next_indice_fx( st0, 2 ); - move16(); - } - } - ELSE - { - IF( EQ_16( st->rf_flag, 1 ) ) - { - IF( !st->use_partial_copy ) - { - ind = get_next_indice_fx( st0, 1 ); - IF( ind == 0 ) - { - st->core = ACELP_CORE; - move16(); - } - ELSE - { - st->core = TCX_20_CORE; - move16(); - st->hTcxCfg->coder_type = st->coder_type; - move16(); - } - } - } - ELSE - { - ind = get_next_indice_fx( st, 3 ); - IF( LT_16( ind, ACELP_MODE_MAX ) ) - { - st->core = ACELP_CORE; - move16(); - st->coder_type = ind; - move16(); - } - ELSE - { - st->core = TCX_20_CORE; - move16(); - st->hTcxCfg->coder_type = sub( ind, ACELP_MODE_MAX ); - move16(); - st->coder_type = st->hTcxCfg->coder_type; - move16(); - } - } - } - } - - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - test(); - IF( st->igf && EQ_16( st->core, ACELP_CORE ) ) - { - st->bits_frame_core = sub( st->bits_frame_core, get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_flag ) ); - move16(); - } - - IF( st->rf_flag ) - { - st->bits_frame_core = sub( st->bits_frame_core, add( st->rf_target_bits, 1 ) ); /* +1 as flag-bit not considered in rf_target_bits */ - move16(); - } - } - - /* Inactive frame detection on non-DTX mode */ - IF( EQ_16( st->coder_type, INACTIVE ) ) - { - st->VAD = 0; - move16(); - } - ELSE - { - st->VAD = 1; - move16(); - } - } - - /*Core extended mode mapping for correct PLC classification*/ - st->core_ext_mode = st->coder_type; - move16(); - if ( EQ_16( st->coder_type, INACTIVE ) ) - { - st->core_ext_mode = UNVOICED; - move16(); - } - - return; -} - -/*-------------------------------------------------------------------* - * getTCXWindowing_ivas() - * - * get TCX transform type for each subframe - *--------------------------------------------------------------------*/ -void getTCXWindowing_ivas_fx( - const Word16 core, /* i : current core */ - const Word16 last_core, /* i : last frame core */ - const Word16 element_mode, /* i : element mode */ - TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ - Decoder_State *st0 /* i : bitstream */ -) -{ - Word16 overlap_code; - - /* Set the last overlap mode based on the previous and current frame type and coded overlap mode */ - test(); - test(); - test(); - IF( EQ_16( last_core, ACELP_CORE ) || EQ_16( last_core, AMR_WB_CORE ) ) - { - hTcxCfg->tcx_last_overlap_mode = TRANSITION_OVERLAP; - move16(); - } - ELSE IF( EQ_16( core, TCX_10_CORE ) && EQ_16( hTcxCfg->tcx_curr_overlap_mode, ALDO_WINDOW ) ) - { - hTcxCfg->tcx_last_overlap_mode = FULL_OVERLAP; - move16(); - } - ELSE IF( NE_16( core, TCX_10_CORE ) && EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) - { - hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; - move16(); - } - ELSE - { - hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; - move16(); - } - - /* Set the current overlap mode based on the current frame type and coded overlap mode */ - hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; - move16(); - - IF( NE_16( core, ACELP_CORE ) ) - { - overlap_code = 0; - move16(); - IF( get_next_indice_fx( st0, 1 ) ) - { - overlap_code = add( 2, get_next_indice_fx( st0, 1 ) ); - } - - assert( MIN_OVERLAP == 2 && HALF_OVERLAP == 3 ); - hTcxCfg->tcx_curr_overlap_mode = overlap_code; - move16(); - /*TCX10 : always symmetric windows*/ - test(); - test(); - test(); - IF( EQ_16( core, TCX_20_CORE ) && ( overlap_code == 0 ) && NE_16( last_core, ACELP_CORE ) && NE_16( last_core, AMR_WB_CORE ) ) - { - hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; - move16(); - } - } - - test(); - IF( NE_16( element_mode, EVS_MONO ) && EQ_16( core, TCX_10_CORE ) ) - { - /* also read last overlap */ - overlap_code = 0; - move16(); - - IF( get_next_indice_fx( st0, 1 ) ) - { - overlap_code = add( 2, get_next_indice_fx( st0, 1 ) ); - } - - hTcxCfg->tcx_last_overlap_mode = overlap_code; - move16(); - } - - return; -} - -/*-------------------------------------------------------------------* - * getLPCparam_ivas() - * - * get LPC parameters - *--------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------* - * Function dec_prm_ivas() * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * - * SQ is used for TCX modes - * - * decode parameters according to selected mode * - *-----------------------------------------------------------------*/ diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 73edd3b3b..77fd7d421 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -1742,3 +1742,273 @@ void dec_prm_fx( return; } + + +/*-------------------------------------------------------------------* + * getTCXMode_ivas() + * + * get TCX mode + *--------------------------------------------------------------------*/ +void getTCXMode_ivas_fx( + Decoder_State *st, /* i/o: decoder memory state */ + Decoder_State *st0, /* i : bitstream */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +) +{ + UWord16 ind; + + IF( st->tcxonly ) + { + /* get core */ + ind = get_next_indice_fx( st0, 1 ); /* Store decoder memory of last_core */ + st->core = add( ind, TCX_20_CORE ); + move16(); + /* get class */ + ind = get_next_indice_fx( st0, 2 ); + + st->clas_dec = ONSET; + move16(); + IF( ind == 0 ) + { + st->clas_dec = UNVOICED_CLAS; + move16(); + } + ELSE IF( EQ_16( ind, 1 ) ) + { + IF( GE_16( st->last_good, VOICED_TRANSITION ) ) + { + st->clas_dec = VOICED_TRANSITION; + move16(); + } + ELSE + { + st->clas_dec = UNVOICED_TRANSITION; + move16(); + } + } + ELSE IF( EQ_16( ind, 2 ) ) + { + st->clas_dec = VOICED_CLAS; + move16(); + } + + st->coder_type = INACTIVE; + move16(); + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && !MCT_flag ) + { + st->VAD = get_next_indice_fx( st0, 1 ); + move16(); + } + ELSE + { + st->VAD = 0; + move16(); + } + } + ELSE + { + IF( EQ_16( st->mdct_sw, MODE1 ) ) + { + /* 2 bits instead of 3 as TCX is already signaled */ + st->core = TCX_20_CORE; + move16(); + st->hTcxCfg->coder_type = get_next_indice_fx( st0, 2 ); + move16(); + st->coder_type = st->hTcxCfg->coder_type; + move16(); + } + ELSE + { + IF( EQ_16( st->mdct_sw_enable, MODE2 ) ) + { + IF( get_next_indice_1_fx( st0 ) ) + { + ind = get_next_indice_fx( st0, 3 ); + assert( !( ind & 4 ) || !"HQ_CORE encountered in dec_prm_ivas" ); + st->core = TCX_20_CORE; + move16(); + st->hTcxCfg->coder_type = ind; + move16(); + st->coder_type = st->hTcxCfg->coder_type; + move16(); + } + ELSE /* ACELP */ + { + st->core = ACELP_CORE; + move16(); + st->coder_type = get_next_indice_fx( st0, 2 ); + move16(); + } + } + ELSE + { + IF( EQ_16( st->rf_flag, 1 ) ) + { + IF( !st->use_partial_copy ) + { + ind = get_next_indice_fx( st0, 1 ); + IF( ind == 0 ) + { + st->core = ACELP_CORE; + move16(); + } + ELSE + { + st->core = TCX_20_CORE; + move16(); + st->hTcxCfg->coder_type = st->coder_type; + move16(); + } + } + } + ELSE + { + ind = get_next_indice_fx( st, 3 ); + IF( LT_16( ind, ACELP_MODE_MAX ) ) + { + st->core = ACELP_CORE; + move16(); + st->coder_type = ind; + move16(); + } + ELSE + { + st->core = TCX_20_CORE; + move16(); + st->hTcxCfg->coder_type = sub( ind, ACELP_MODE_MAX ); + move16(); + st->coder_type = st->hTcxCfg->coder_type; + move16(); + } + } + } + } + + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + test(); + IF( st->igf && EQ_16( st->core, ACELP_CORE ) ) + { + st->bits_frame_core = sub( st->bits_frame_core, get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_flag ) ); + move16(); + } + + IF( st->rf_flag ) + { + st->bits_frame_core = sub( st->bits_frame_core, add( st->rf_target_bits, 1 ) ); /* +1 as flag-bit not considered in rf_target_bits */ + move16(); + } + } + + /* Inactive frame detection on non-DTX mode */ + IF( EQ_16( st->coder_type, INACTIVE ) ) + { + st->VAD = 0; + move16(); + } + ELSE + { + st->VAD = 1; + move16(); + } + } + + /*Core extended mode mapping for correct PLC classification*/ + st->core_ext_mode = st->coder_type; + move16(); + if ( EQ_16( st->coder_type, INACTIVE ) ) + { + st->core_ext_mode = UNVOICED; + move16(); + } + + return; +} + +/*-------------------------------------------------------------------* + * getTCXWindowing_ivas() + * + * get TCX transform type for each subframe + *--------------------------------------------------------------------*/ +void getTCXWindowing_ivas_fx( + const Word16 core, /* i : current core */ + const Word16 last_core, /* i : last frame core */ + const Word16 element_mode, /* i : element mode */ + TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ + Decoder_State *st0 /* i : bitstream */ +) +{ + Word16 overlap_code; + + /* Set the last overlap mode based on the previous and current frame type and coded overlap mode */ + test(); + test(); + test(); + IF( EQ_16( last_core, ACELP_CORE ) || EQ_16( last_core, AMR_WB_CORE ) ) + { + hTcxCfg->tcx_last_overlap_mode = TRANSITION_OVERLAP; + move16(); + } + ELSE IF( EQ_16( core, TCX_10_CORE ) && EQ_16( hTcxCfg->tcx_curr_overlap_mode, ALDO_WINDOW ) ) + { + hTcxCfg->tcx_last_overlap_mode = FULL_OVERLAP; + move16(); + } + ELSE IF( NE_16( core, TCX_10_CORE ) && EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) + { + hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; + move16(); + } + ELSE + { + hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; + move16(); + } + + /* Set the current overlap mode based on the current frame type and coded overlap mode */ + hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; + move16(); + + IF( NE_16( core, ACELP_CORE ) ) + { + overlap_code = 0; + move16(); + IF( get_next_indice_fx( st0, 1 ) ) + { + overlap_code = add( 2, get_next_indice_fx( st0, 1 ) ); + } + + assert( MIN_OVERLAP == 2 && HALF_OVERLAP == 3 ); + hTcxCfg->tcx_curr_overlap_mode = overlap_code; + move16(); + /*TCX10 : always symmetric windows*/ + test(); + test(); + test(); + IF( EQ_16( core, TCX_20_CORE ) && ( overlap_code == 0 ) && NE_16( last_core, ACELP_CORE ) && NE_16( last_core, AMR_WB_CORE ) ) + { + hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; + move16(); + } + } + + test(); + IF( NE_16( element_mode, EVS_MONO ) && EQ_16( core, TCX_10_CORE ) ) + { + /* also read last overlap */ + overlap_code = 0; + move16(); + + IF( get_next_indice_fx( st0, 1 ) ) + { + overlap_code = add( 2, get_next_indice_fx( st0, 1 ) ); + } + + hTcxCfg->tcx_last_overlap_mode = overlap_code; + move16(); + } + + return; +} + diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c deleted file mode 100644 index aca84d9d9..000000000 --- a/lib_dec/dec_tcx.c +++ /dev/null @@ -1,508 +0,0 @@ - -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "prot.h" -#include "ivas_prot.h" -#include "prot_fx.h" -#include -#include "options.h" -#include -#include "stat_com.h" -#include "cnst.h" -#include "wmc_auto.h" -#include "ivas_rom_com.h" -#include "ivas_prot_fx.h" -#include "debug.h" - -/*-------------------------------------------------------------------* - * decoder_tcx_post() - * - * - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * decoder_tcx_tns() - * - * TCX: TNS application - *-------------------------------------------------------------------*/ - -void decoder_tcx_tns_fx( - Decoder_State *st, /* i/o: coder memory state */ - const Word16 L_frame_glob, /* i : frame length */ - const Word16 L_spec, - const Word16 L_frame, - const Word16 L_frameTCX, - Word32 x_fx[N_MAX], // Qx - const Word16 fUseTns, /* i : flag that is set if TNS data is present */ - STnsData *tnsData, - const Word16 bfi, /* i : Bad frame indicator */ - const Word16 frame_cnt, /* i : frame counter in the super frame */ - const Word16 whitenedDomain, - Word16 *length ) -{ - Word16 index, isTCX5, L, tmp; - TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; - - index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */ - move16(); - - isTCX5 = 0; - move16(); - L = L_frameTCX; - move16(); - tmp = L; - move16(); - - test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) ) - { - test(); - test(); - IF( NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) ) - { - /* fix sub-window overlap */ - hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; - move16(); - } - - test(); - test(); - test(); - IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) ) - { - L = L_spec; - move16(); - tmp = L; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) || - ( EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) && EQ_16( frame_cnt, 0 ) && EQ_16( index, 0 ) ) ) ) || - ( NE_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) && - NE_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) ) ) - { - isTCX5 = 1; - move16(); - - tcx5SpectrumDeinterleaving_fx( shr( L, 1 ), x_fx ); - } - } - - /*-----------------------------------------------------------* - * Temporal Noise Shaping Synthesis * - *-----------------------------------------------------------*/ - - - test(); - test(); - test(); - IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) ) - { - /* Apply TNS to get the reconstructed signal */ - SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) ); - - test(); - test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) ) - { - tcx5TnsGrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx ); - } - - ApplyTnsFilter( hTcxCfg->pCurrentTnsConfig, tnsData, x_fx, 0 ); - - test(); - test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) ) - { - test(); - IF( EQ_16( st->element_mode, EVS_MONO ) || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ - { - tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); - tmp = L_frameTCX; - move16(); - } - ELSE - { - tcx5TnsUngrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); - } - } - } - test(); - IF( NE_16( whitenedDomain, 0 ) && NE_16( isTCX5, 0 ) ) - { - tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx ); - } - - /* restore index */ - test(); - test(); - test(); - test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) ) - { - /* restore sub-window overlap */ - hTcxCfg->tcx_last_overlap_mode = index; - move16(); - } - - if ( length != NULL ) - { - *length = tmp; - move16(); - } - - return; -} - - -void decoder_tcx_imdct_fx( - Decoder_State *st, /* i/o: coder memory state */ - const Word16 L_frame_glob, /* i : frame length */ - const Word16 L_frameTCX_glob, - const Word16 L_spec, - const Word16 tcx_offset, - const Word16 tcx_offsetFB, - const Word16 L_frame, - const Word16 L_frameTCX, - const Word16 left_rect, - Word32 x_fx[N_MAX], // Q(11) - Word16 q_x, - Word16 xn_buf_fx[], // Q(-2) - Word16 q_win, - const UWord16 kernelType, /* i : TCX transform kernel type */ - const Word16 fUseTns, /* i : flag that is set if TNS data is present */ - Word16 synth_fx[], // Q(-2) /* i/o: synth[-M..L_frame] */ - Word16 synthFB_fx[], // Q(-2) - const Word16 bfi, /* i : Bad frame indicator */ - const Word16 frame_cnt, /* i : frame counter in the super frame */ - const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -) -{ - Word16 j, L, overlap, curr_order, startLine, endLine, isTCX5; - Word16 overlapFB; - Word32 x_tmp_fx[L_FRAME_PLUS]; - Word32 xn_bufFB_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX] = { 0 }; - Word16 xn_bufFB_fx_16[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; - Word16 acelp_zir_fx[L_FRAME_MAX / 2]; - Word32 x_itf_fx[N_MAX_TCX - IGF_START_MN]; - Word16 index, proc = 0; - TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; - TCX_DEC_HANDLE hTcxDec = st->hTcxDec; - TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; - Word16 predictionGain_fx; - Word16 A_itf_fx[ITF_MAX_FILTER_ORDER + 1]; // q_a_itf - Word16 q_a_itf = 15; - Word16 x_e = sub( 31, q_x ); - move16(); - Word16 shift_q = sub( q_x, q_win ); - - /*-----------------------------------------------------------------* - * Initializations - *-----------------------------------------------------------------*/ - - /* Init lengths */ - overlap = hTcxCfg->tcx_mdct_window_length; - move16(); - overlapFB = hTcxCfg->tcx_mdct_window_lengthFB; - move16(); - - index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */ - move16(); - test(); - test(); - test(); - test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && ( st->tcxonly != 0 ) && ( frame_cnt != 0 ) && ( bfi == 0 ) && ( st->last_core != ACELP_CORE ) ) - { - /* fix sub-window overlap */ - hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; - move16(); - } - - IF( st->igf != 0 ) - { - proc = st->hIGFDec->flatteningTrigger; - move16(); - - test(); - IF( proc && fUseTns != 0 ) - { - proc = 0; - move16(); - } - - IF( proc ) - { - - startLine = st->hIGFDec->infoIGFStartLine; - move16(); - endLine = st->hIGFDec->infoIGFStopLine; - move16(); - curr_order = 0; - move16(); - predictionGain_fx = 0; - move16(); - L = L_frameTCX; - move16(); - isTCX5 = 0; - move16(); - - /* interleave again for ITF */ - test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly ) - { - test(); - test(); - test(); - IF( ( hTcxCfg->fIsTNSAllowed && ( fUseTns != 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) ) - { - L = L_spec; - move16(); - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( bfi == 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) || - ( ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) && ( frame_cnt == 0 ) && ( index == 0 ) ) ) ) || - ( ( bfi != 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) && - ( hTcxCfg->tcx_curr_overlap_mode != FULL_OVERLAP ) ) ) ) - { - isTCX5 = 1; - move16(); - - tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx ); - } - } - - FOR( j = startLine; j < endLine; j++ ) - { - IF( EQ_16( st->hIGFDec->flag_sparse[j - IGF_START_MN], 2 ) ) - { - x_itf_fx[j - IGF_START_MN] = x_fx[j]; // q_x - move32(); - x_fx[j] = st->hIGFDec->virtualSpec_fx[j - IGF_START_MN]; - move32(); - } - } - - ITF_Detect_fx( x_fx + IGF_START_MN, startLine, endLine, 8 /*maxOrder*/, A_itf_fx, &q_a_itf, &predictionGain_fx, &curr_order, shl( x_e, 1 ) ); - - ITF_Apply_fx( x_fx, startLine, endLine, A_itf_fx, q_a_itf, curr_order ); - - FOR( j = startLine; j < endLine; j++ ) - { - IF( EQ_16( st->hIGFDec->flag_sparse[j - IGF_START_MN], 2 ) ) - { - x_fx[j] = x_itf_fx[j - IGF_START_MN]; // q_x - move32(); - } - } - - /* deinterleave */ - IF( NE_16( isTCX5, 0 ) ) - { - tcx5SpectrumDeinterleaving_fx( shr( L, 1 ), x_fx ); - } - } - } - - /*-----------------------------------------------------------* - * Prepare OLA buffer after waveadjustment. * - * Compute inverse MDCT of x[]. * - *-----------------------------------------------------------*/ - - - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - Word16 copy_len = s_min( L_FRAME48k, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); - set32_fx( x_tmp_fx, 0, L_FRAME_PLUS ); - Copy32( x_fx, x_tmp_fx, copy_len ); // q_x - Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x - } - ELSE IF( ( st->element_mode == EVS_MONO ) ) - { - Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x - } - ELSE - { - Word16 copy_len = s_max( L_spec, s_max( L_frame, L_frameTCX ) ); - Copy32( x_fx, x_tmp_fx, copy_len ); // q_x - Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x - } - - IF( ( st->igf != 0 ) ) - { - set32_fx( xn_bufFB_fx + st->hIGFDec->infoIGFStartLine, 0, L_frameTCX - st->hIGFDec->infoIGFStartLine ); - } - - test(); - IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && !sba_dirac_stereo_flag ) - { - - IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, - hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, - kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); - } - - /* Generate additional comfort noise to mask potential coding artefacts */ - test(); - test(); - test(); - IF( ( st->flag_cna != 0 ) && NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->cna_dirac_flag == 0 ) ) - { - generate_masking_noise_mdct_ivas_fx( x_fx, &x_e, st->hFdCngDec->hFdCngCom ); - FOR( Word16 ind = 0; ind < L_frame; ind++ ) - { - x_fx[ind] = L_shr( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x - } - } - - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( sba_dirac_stereo_flag != 0 ) ) - { - Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x - - IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, - kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); - } - - FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) - { - xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x - move16(); - } - - Word16 ratio_e; - Word16 ratio = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &ratio_e ); // Q = 15-ratio_e. * FSCALE_DENOM is (1 << 9) - ratio = shr( ratio, sub( 6, ratio_e ) ); - - IF( st->element_mode != EVS_MONO ) - { - IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, - hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); - } - ELSE - { - - IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); - } - FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) - { - xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // Q_x - } - - IF( ( bfi == 0 ) ) - { - Word16 res_m, res_e = 0; - move16(); - st->second_last_tns_active = st->last_tns_active; - move16(); - st->last_tns_active = hTcxCfg->fIsTNSAllowed & fUseTns; - move16(); - hTcxDec->tcxltp_third_last_pitch = hTcxDec->tcxltp_second_last_pitch; - move32(); - hTcxDec->tcxltp_second_last_pitch = st->old_fpitch; - move32(); - res_m = BASOP_Util_Divide1616_Scale( hTcxLtpDec->tcxltp_pitch_fr, st->pit_res_max, &res_e ); - st->old_fpitch = L_add( L_shl( hTcxLtpDec->tcxltp_pitch_int, 16 ), L_shl( res_m, add( res_e, 1 ) ) ); - - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - // Using sat as a single instruction shifts and extracts - st->old_fpitch = W_shl_sat_l( W_mult0_32_32( st->old_fpitch, L_frame_glob ), -8 ); // Divide by 256 ==> SHR by 8 - move32(); - } - - IF( GT_16( st->element_mode, EVS_MONO ) ) - { - res_m = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &res_e ); - st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e ); - move32(); - } - ELSE - { - res_m = BASOP_Util_Divide1616_Scale( L_frameTCX, L_frame, &res_e ); - st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e ); - move32(); - } - } - - /* Update old_syn_overl */ - IF( hTcxCfg->last_aldo == 0 ) - { - Copy( xn_buf_fx + L_frame, hTcxDec->syn_Overl, overlap ); // Q(-2) - FOR( Word16 ind = 0; ind < overlapFB; ind++ ) - { - hTcxDec->syn_OverlFB[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ); // q_x - } - } - - /* Output */ - Copy( xn_buf_fx + sub( shr( overlap, 1 ), tcx_offset ), synth_fx, L_frame_glob ); // Q(-2) - FOR( Word16 ind = 0; ind < L_frameTCX_glob; ind++ ) - { - synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_x - } - - - return; -} - -/*-------------------------------------------------------------------* - * init_tcx_info() - * - * Initialize lengths for TCX processing, update IGF subframe info - *-------------------------------------------------------------------*/ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index a0556437d..4d97367ef 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -4856,3 +4856,450 @@ void decoder_tcx_noiseshaping_igf_fx( return; } + + +/*-------------------------------------------------------------------* + * decoder_tcx_tns() + * + * TCX: TNS application + *-------------------------------------------------------------------*/ + +void decoder_tcx_tns_fx( + Decoder_State *st, /* i/o: coder memory state */ + const Word16 L_frame_glob, /* i : frame length */ + const Word16 L_spec, + const Word16 L_frame, + const Word16 L_frameTCX, + Word32 x_fx[N_MAX], // Qx + const Word16 fUseTns, /* i : flag that is set if TNS data is present */ + STnsData *tnsData, + const Word16 bfi, /* i : Bad frame indicator */ + const Word16 frame_cnt, /* i : frame counter in the super frame */ + const Word16 whitenedDomain, + Word16 *length ) +{ + Word16 index, isTCX5, L, tmp; + TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; + + index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */ + move16(); + + isTCX5 = 0; + move16(); + L = L_frameTCX; + move16(); + tmp = L; + move16(); + + test(); + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) ) + { + test(); + test(); + IF( NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) ) + { + /* fix sub-window overlap */ + hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; + move16(); + } + + test(); + test(); + test(); + IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) ) + { + L = L_spec; + move16(); + tmp = L; + move16(); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) || + ( EQ_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) && EQ_16( frame_cnt, 0 ) && EQ_16( index, 0 ) ) ) ) || + ( NE_16( bfi, 0 ) && ( NE_16( hTcxCfg->tcx_last_overlap_mode, FULL_OVERLAP ) && + NE_16( hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) ) ) + { + isTCX5 = 1; + move16(); + + tcx5SpectrumDeinterleaving_fx( shr( L, 1 ), x_fx ); + } + } + + /*-----------------------------------------------------------* + * Temporal Noise Shaping Synthesis * + *-----------------------------------------------------------*/ + + + test(); + test(); + test(); + IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) ) + { + /* Apply TNS to get the reconstructed signal */ + SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) ); + + test(); + test(); + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) ) + { + tcx5TnsGrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx ); + } + + ApplyTnsFilter( hTcxCfg->pCurrentTnsConfig, tnsData, x_fx, 0 ); + + test(); + test(); + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) ) + { + test(); + IF( EQ_16( st->element_mode, EVS_MONO ) || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ + { + tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); + tmp = L_frameTCX; + move16(); + } + ELSE + { + tcx5TnsUngrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); + } + } + } + test(); + IF( NE_16( whitenedDomain, 0 ) && NE_16( isTCX5, 0 ) ) + { + tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx ); + } + + /* restore index */ + test(); + test(); + test(); + test(); + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) ) + { + /* restore sub-window overlap */ + hTcxCfg->tcx_last_overlap_mode = index; + move16(); + } + + if ( length != NULL ) + { + *length = tmp; + move16(); + } + + return; +} + + +void decoder_tcx_imdct_fx( + Decoder_State *st, /* i/o: coder memory state */ + const Word16 L_frame_glob, /* i : frame length */ + const Word16 L_frameTCX_glob, + const Word16 L_spec, + const Word16 tcx_offset, + const Word16 tcx_offsetFB, + const Word16 L_frame, + const Word16 L_frameTCX, + const Word16 left_rect, + Word32 x_fx[N_MAX], // Q(11) + Word16 q_x, + Word16 xn_buf_fx[], // Q(-2) + Word16 q_win, + const UWord16 kernelType, /* i : TCX transform kernel type */ + const Word16 fUseTns, /* i : flag that is set if TNS data is present */ + Word16 synth_fx[], // Q(-2) /* i/o: synth[-M..L_frame] */ + Word16 synthFB_fx[], // Q(-2) + const Word16 bfi, /* i : Bad frame indicator */ + const Word16 frame_cnt, /* i : frame counter in the super frame */ + const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ +) +{ + Word16 j, L, overlap, curr_order, startLine, endLine, isTCX5; + Word16 overlapFB; + Word32 x_tmp_fx[L_FRAME_PLUS]; + Word32 xn_bufFB_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX] = { 0 }; + Word16 xn_bufFB_fx_16[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; + Word16 acelp_zir_fx[L_FRAME_MAX / 2]; + Word32 x_itf_fx[N_MAX_TCX - IGF_START_MN]; + Word16 index, proc = 0; + TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; + TCX_DEC_HANDLE hTcxDec = st->hTcxDec; + TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; + Word16 predictionGain_fx; + Word16 A_itf_fx[ITF_MAX_FILTER_ORDER + 1]; // q_a_itf + Word16 q_a_itf = 15; + Word16 x_e = sub( 31, q_x ); + move16(); + Word16 shift_q = sub( q_x, q_win ); + + /*-----------------------------------------------------------------* + * Initializations + *-----------------------------------------------------------------*/ + + /* Init lengths */ + overlap = hTcxCfg->tcx_mdct_window_length; + move16(); + overlapFB = hTcxCfg->tcx_mdct_window_lengthFB; + move16(); + + index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */ + move16(); + test(); + test(); + test(); + test(); + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && ( st->tcxonly != 0 ) && ( frame_cnt != 0 ) && ( bfi == 0 ) && ( st->last_core != ACELP_CORE ) ) + { + /* fix sub-window overlap */ + hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; + move16(); + } + + IF( st->igf != 0 ) + { + proc = st->hIGFDec->flatteningTrigger; + move16(); + + test(); + IF( proc && fUseTns != 0 ) + { + proc = 0; + move16(); + } + + IF( proc ) + { + + startLine = st->hIGFDec->infoIGFStartLine; + move16(); + endLine = st->hIGFDec->infoIGFStopLine; + move16(); + curr_order = 0; + move16(); + predictionGain_fx = 0; + move16(); + L = L_frameTCX; + move16(); + isTCX5 = 0; + move16(); + + /* interleave again for ITF */ + test(); + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly ) + { + test(); + test(); + test(); + IF( ( hTcxCfg->fIsTNSAllowed && ( fUseTns != 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) ) + { + L = L_spec; + move16(); + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( bfi == 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) || + ( ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) && ( frame_cnt == 0 ) && ( index == 0 ) ) ) ) || + ( ( bfi != 0 ) && ( ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) && + ( hTcxCfg->tcx_curr_overlap_mode != FULL_OVERLAP ) ) ) ) + { + isTCX5 = 1; + move16(); + + tcx5SpectrumInterleaving_fx( shr( L, 1 ), x_fx ); + } + } + + FOR( j = startLine; j < endLine; j++ ) + { + IF( EQ_16( st->hIGFDec->flag_sparse[j - IGF_START_MN], 2 ) ) + { + x_itf_fx[j - IGF_START_MN] = x_fx[j]; // q_x + move32(); + x_fx[j] = st->hIGFDec->virtualSpec_fx[j - IGF_START_MN]; + move32(); + } + } + + ITF_Detect_fx( x_fx + IGF_START_MN, startLine, endLine, 8 /*maxOrder*/, A_itf_fx, &q_a_itf, &predictionGain_fx, &curr_order, shl( x_e, 1 ) ); + + ITF_Apply_fx( x_fx, startLine, endLine, A_itf_fx, q_a_itf, curr_order ); + + FOR( j = startLine; j < endLine; j++ ) + { + IF( EQ_16( st->hIGFDec->flag_sparse[j - IGF_START_MN], 2 ) ) + { + x_fx[j] = x_itf_fx[j - IGF_START_MN]; // q_x + move32(); + } + } + + /* deinterleave */ + IF( NE_16( isTCX5, 0 ) ) + { + tcx5SpectrumDeinterleaving_fx( shr( L, 1 ), x_fx ); + } + } + } + + /*-----------------------------------------------------------* + * Prepare OLA buffer after waveadjustment. * + * Compute inverse MDCT of x[]. * + *-----------------------------------------------------------*/ + + + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + Word16 copy_len = s_min( L_FRAME48k, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); + set32_fx( x_tmp_fx, 0, L_FRAME_PLUS ); + Copy32( x_fx, x_tmp_fx, copy_len ); // q_x + Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x + } + ELSE IF( ( st->element_mode == EVS_MONO ) ) + { + Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x + } + ELSE + { + Word16 copy_len = s_max( L_spec, s_max( L_frame, L_frameTCX ) ); + Copy32( x_fx, x_tmp_fx, copy_len ); // q_x + Copy32( x_fx, xn_bufFB_fx, copy_len ); // q_x + } + + IF( ( st->igf != 0 ) ) + { + set32_fx( xn_bufFB_fx + st->hIGFDec->infoIGFStartLine, 0, L_frameTCX - st->hIGFDec->infoIGFStartLine ); + } + + test(); + IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && !sba_dirac_stereo_flag ) + { + + IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, + hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); + } + + /* Generate additional comfort noise to mask potential coding artefacts */ + test(); + test(); + test(); + IF( ( st->flag_cna != 0 ) && NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->cna_dirac_flag == 0 ) ) + { + generate_masking_noise_mdct_ivas_fx( x_fx, &x_e, st->hFdCngDec->hFdCngCom ); + FOR( Word16 ind = 0; ind < L_frame; ind++ ) + { + x_fx[ind] = L_shr( x_fx[ind], sub( 31, add( x_e, q_x ) ) ); // q_x + } + } + + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( sba_dirac_stereo_flag != 0 ) ) + { + Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x + + IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); + } + + FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) + { + xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x + move16(); + } + + Word16 ratio_e; + Word16 ratio = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &ratio_e ); // Q = 15-ratio_e. * FSCALE_DENOM is (1 << 9) + ratio = shr( ratio, sub( 6, ratio_e ) ); + + IF( st->element_mode != EVS_MONO ) + { + IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, + hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); + } + ELSE + { + + IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); + } + FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) + { + xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // Q_x + } + + IF( ( bfi == 0 ) ) + { + Word16 res_m, res_e = 0; + move16(); + st->second_last_tns_active = st->last_tns_active; + move16(); + st->last_tns_active = hTcxCfg->fIsTNSAllowed & fUseTns; + move16(); + hTcxDec->tcxltp_third_last_pitch = hTcxDec->tcxltp_second_last_pitch; + move32(); + hTcxDec->tcxltp_second_last_pitch = st->old_fpitch; + move32(); + res_m = BASOP_Util_Divide1616_Scale( hTcxLtpDec->tcxltp_pitch_fr, st->pit_res_max, &res_e ); + st->old_fpitch = L_add( L_shl( hTcxLtpDec->tcxltp_pitch_int, 16 ), L_shl( res_m, add( res_e, 1 ) ) ); + + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + // Using sat as a single instruction shifts and extracts + st->old_fpitch = W_shl_sat_l( W_mult0_32_32( st->old_fpitch, L_frame_glob ), -8 ); // Divide by 256 ==> SHR by 8 + move32(); + } + + IF( GT_16( st->element_mode, EVS_MONO ) ) + { + res_m = BASOP_Util_Divide1616_Scale( L_frameTCX_glob, L_frame_glob, &res_e ); + st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e ); + move32(); + } + ELSE + { + res_m = BASOP_Util_Divide1616_Scale( L_frameTCX, L_frame, &res_e ); + st->old_fpitchFB = L_shl( Mpy_32_16_1( st->old_fpitch, res_m ), res_e ); + move32(); + } + } + + /* Update old_syn_overl */ + IF( hTcxCfg->last_aldo == 0 ) + { + Copy( xn_buf_fx + L_frame, hTcxDec->syn_Overl, overlap ); // Q(-2) + FOR( Word16 ind = 0; ind < overlapFB; ind++ ) + { + hTcxDec->syn_OverlFB[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ); // q_x + } + } + + /* Output */ + Copy( xn_buf_fx + sub( shr( overlap, 1 ), tcx_offset ), synth_fx, L_frame_glob ); // Q(-2) + FOR( Word16 ind = 0; ind < L_frameTCX_glob; ind++ ) + { + synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_x + } + + + return; +} + diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c deleted file mode 100644 index dd3adb247..000000000 --- a/lib_dec/fd_cng_dec.c +++ /dev/null @@ -1,1393 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "ivas_prot.h" -#include "rom_com.h" -#include "wmc_auto.h" -#include "ivas_prot.h" -#include "ivas_rom_dec.h" -#include "ivas_rom_com_fx.h" -#include "prot_fx.h" -#include "ivas_prot_fx.h" -#include "basop_util.h" -#include "rom_basop_util.h" - -/*------------------------------------------------------------------- - * Local constants - *-------------------------------------------------------------------*/ - -#define DELTA_MASKING_NOISE_Q15 0 -#define CNA_ACT_DN_LARGE_PARTITION 50 /* index of the first larger partition */ -#define FIRST_CNA_NOISE_UPD_FRAMES 5 /* minimum number of CN initialization frames */ -#define LOG_10_BASE_2 1783446566 /* Q29 */ -#define GAIN_Q_OFFSET_IVAS_FX 45 -#define LOG_10_BASE_2_BY_10_Q31 713378606 -#define TWO_BY_THREE_Q31 1431655765 -#define ONE_BY_FRAMES_PER_SEC_Q15 656 -#define NB_LAST_BAND_SCALE_Q31 1717986918 -#define SWB_13k2_LAST_BAND_SCALE_Q31 1717986918 - -/*------------------------------------------------------------------- - * Local fucntions declarations - *-------------------------------------------------------------------*/ - -/*------------------------------------------------------------------- - * createFdCngDec() - * - * Create an instance of type FD_CNG - *-------------------------------------------------------------------*/ - - -/*------------------------------------------------------------------- - * initFdCngDec() - * - * Initialize an instance of type FD_CNG - *-------------------------------------------------------------------*/ -void configureFdCngDec_ivas_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ - const Word16 bwidth, /*Q0*/ - const Word32 total_brate, /*Q0*/ - const Word16 L_frame, /*Q0*/ - const Word16 last_L_frame, /*Q0*/ - const Word16 element_mode /*Q0*/ ) -{ - Word16 j, stopBandFR; - HANDLE_FD_CNG_COM hsCom = hFdCngDec->hFdCngCom; - - hsCom->CngBandwidth = bwidth; /*Q0*/ - move16(); - if ( EQ_16( hsCom->CngBandwidth, FB ) ) - { - hsCom->CngBandwidth = SWB; - move16(); - } - test(); - IF( NE_32( total_brate, FRAME_NO_DATA ) && NE_32( total_brate, SID_2k40 ) ) - { - hsCom->CngBitrate = total_brate; /*Q0*/ - move32(); - } - ELSE IF( EQ_32( hsCom->CngBitrate, -1 ) ) - { - /* set minimum active CBR bitrate IF CngBitrate is uninitialized */ - IF( element_mode > EVS_MONO ) - { - hsCom->CngBitrate = IVAS_13k2; - move32(); - } - ELSE - { - hsCom->CngBitrate = ACELP_7k20; - move32(); - } - } - - /* FD-CNG config for MDCT-Stereo is always the same (since for > 48 kbps only) */ - /* This may need adjustment in the future IF 2TC DTX for some mode uses MDCT-Stereo DTX for lower bitrates too */ - if ( EQ_16( element_mode, IVAS_CPE_MDCT ) ) - { - hsCom->CngBitrate = IVAS_48k; - move32(); - } - hsCom->numSlots = 16; - move32(); - - /* NB configuration */ - IF( EQ_16( bwidth, NB ) ) - { - hsCom->FdCngSetup = FdCngSetup_nb; - hsCom->numCoreBands = 16; - move16(); - hsCom->regularStopBand = 16; - move16(); - } - - /* WB configuration */ - ELSE IF( EQ_16( bwidth, WB ) ) - { - /* FFT 6.4kHz, no CLDFB */ - test(); - test(); - IF( LE_32( hsCom->CngBitrate, ACELP_8k00 ) && EQ_16( L_frame, L_FRAME ) ) - { - hsCom->FdCngSetup = FdCngSetup_wb1; - hsCom->numCoreBands = 16; - move16(); - hsCom->regularStopBand = 16; - move16(); - } - /* FFT 6.4kHz, CLDFB 8.0kHz */ - ELSE IF( LE_32( hsCom->CngBitrate, ACELP_13k20 ) || EQ_16( L_frame, L_FRAME ) ) - { - hsCom->FdCngSetup = FdCngSetup_wb2; - hsCom->numCoreBands = 16; - move16(); - hsCom->regularStopBand = 20; - move16(); - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - hsCom->FdCngSetup = FdCngSetup_wb2; - hsCom->numCoreBands = 20; - move16(); - hsCom->regularStopBand = 20; - move16(); - hsCom->FdCngSetup.fftlen = 640; - move16(); - hsCom->FdCngSetup.stopFFTbin = 256; - move16(); - } - } - /* FFT 8.0kHz, no CLDFB */ - ELSE - { - hsCom->FdCngSetup = FdCngSetup_wb3; - hsCom->numCoreBands = 20; - move16(); - hsCom->regularStopBand = 20; - move16(); - } - } - - /* SWB/FB configuration */ - ELSE - { - /* FFT 6.4kHz, CLDFB 14kHz */ - IF( EQ_16( L_frame, L_FRAME ) ) - { - hsCom->FdCngSetup = FdCngSetup_swb1; - hsCom->numCoreBands = 16; - move16(); - hsCom->regularStopBand = 35; - move16(); - } - /* FFT 8.0kHz, CLDFB 16kHz */ - ELSE - { - hsCom->FdCngSetup = FdCngSetup_swb2; - hsCom->numCoreBands = 20; - move16(); - hsCom->regularStopBand = 40; - move16(); - test(); - if ( EQ_16( last_L_frame, L_FRAME ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) - { - hsCom->regularStopBand = 35; - move16(); - } - } - } - - - hsCom->fftlen = hsCom->FdCngSetup.fftlen; - move16(); - hsCom->stopFFTbin = hsCom->FdCngSetup.stopFFTbin; - move16(); - - /* Configure the SID quantizer and the Comfort Noise Generator */ - - hsCom->startBand = 2; - move16(); - hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[( hsCom->FdCngSetup.numPartitions - 1 )], 1 ); /*Q0*/ - initPartitions( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_norm, &hsCom->psize_norm_exp, hsCom->psize_inv, 0 ); - - IF( EQ_16( hsCom->stopFFTbin, 160 ) ) - { - hsCom->nFFTpart = 17; - move16(); - } - ELSE IF( EQ_16( hsCom->stopFFTbin, 256 ) ) - { - hsCom->nFFTpart = 20; - move16(); - } - ELSE - { - hsCom->nFFTpart = 21; - move16(); - } - hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart ); /*Q0*/ - move16(); - FOR( j = 0; j < hsCom->nCLDFBpart; j++ ) - { - hsCom->CLDFBpart[j] = sub( hsCom->part[( j + hsCom->nFFTpart )], sub( hsCom->stopFFTbin, hsCom->startBand ) ); /*Q0*/ - move16(); - hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[( j + hsCom->nFFTpart )]; - move16(); - } - - stopBandFR = 40; //(Word16)floor(1000.f /*Hz*/ / 25.f /*Hz/Bin*/); - move16(); - if ( GT_16( stopBandFR, hsCom->stopFFTbin ) ) - { - stopBandFR = hsCom->stopFFTbin; /*Q0*/ - move16(); - } - - initPartitions( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions, hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping, hFdCngDec->psize_shaping, hFdCngDec->psize_shaping_norm, &hFdCngDec->psize_shaping_norm_exp, hFdCngDec->psize_inv_shaping, stopBandFR ); - - hFdCngDec->nFFTpart_shaping = hFdCngDec->npart_shaping; /*Q0*/ - move16(); - - BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) ); - BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) ); - - SWITCH( hsCom->fftlen ) - { - case 512: - hsCom->olapWinAna_fx = olapWinAna512_fx; /*Q30*/ - hsCom->fftSineTab_fx = NULL; - hsCom->olapWinSyn_fx = olapWinSyn256_fx; /*Q15*/ - hsCom->fftlenShift = 8; - move16(); - hsCom->fftlenFac = 32767 /*1.0 Q15*/; - move16(); - BREAK; - case 640: - hsCom->olapWinAna_fx = olapWinAna640_fx; /*Q30*/ - hsCom->fftSineTab_fx = fftSineTab640_fx; /*Q15*/ - hsCom->olapWinSyn_fx = olapWinSyn320_fx; /*Q15*/ - hsCom->fftlenShift = 9; - move16(); - hsCom->fftlenFac = 20480 /*0.625 Q15*/; - move16(); - BREAK; - default: - assert( !"Unsupported FFT length for FD-based CNG" ); - BREAK; - } - BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) ); - BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) ); - hsCom->frameSize = shr( hsCom->fftlen, 1 ); - - return; -} - -/*------------------------------------------------------------------- - * deleteFdCngDec() - * - * Delete the instance of type FD_CNG - *-------------------------------------------------------------------*/ - - -/*------------------------------------------------------------------- - * ApplyFdCng() - * - * Apply the CLDFB-based CNG at the decoder - *-------------------------------------------------------------------*/ - -/*------------------------------------------------------------------- - * FdCng_decodeSID() - * - * Decode the FD-CNG bitstream - *-------------------------------------------------------------------*/ - - -/*------------------------------------------------------------------- - * FdCng_decodeSID_ivas_fx() - * - * Decode the FD-CNG bitstream - *-------------------------------------------------------------------*/ - -void FdCng_decodeSID_ivas_fx( - Decoder_State *st /* i/o: decoder state structure */ -) -{ - Word16 N; - Word32 *sidNoiseEst; - Word32 gain; - Word16 i, index; - Word32 v[32]; - Word16 indices[32]; - HANDLE_FD_CNG_COM hFdCngCom; - Word32 *invTrfMatrix_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word16 tmp16; - - IF( st->element_mode == EVS_MONO ) - { - tmp16 = GAIN_Q_OFFSET_EVS_FX_Q0; - move16(); - } - ELSE - { - tmp16 = GAIN_Q_OFFSET_IVAS_FX_Q0; - move16(); - } - - const Word16 gain_q_offset = tmp16; /* Q0 */ - move16(); - - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /*Q31*/ - - hFdCngCom = ( st->hFdCngDec )->hFdCngCom; - - sidNoiseEst = hFdCngCom->sidNoiseEst; /*Q16*/ - - N = hFdCngCom->npart; /*Q0*/ - move16(); - gain = 0; - move32(); - hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); - move16(); - - /* Read bitstream */ - FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) - { - indices[i] = get_next_indice_fx( st, bits_37bits[i] ); /*Q0*/ - move16(); - } - - index = get_next_indice_fx( st, 7 ); - - /* MSVQ decoder */ - - IF( st->element_mode != EVS_MONO ) - { - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 ); - } - ELSE - { /* Legacy EVS_MONO MSVQ tables */ - msvq_dec_fx( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL, 7 ); - } - - - /* Decode gain */ - // gain = ((float)index - gain_q_offset) / 1.5f; - gain = L_mult0( sub( index, gain_q_offset ), 21845 ); // Q15 - - /* Apply gain and undo log */ - Word16 res_exp[NPART]; - Word16 max_res_exp = 0; - move16(); - FOR( i = 0; i < N; i++ ) - { - sidNoiseEst[i] = BASOP_util_Pow2( Mpy_32_32( L_add( v[i], gain ), LOG_10_BASE_2_BY_10_Q31 ), Q16, &res_exp[i] ); /*Q31 - res_exp[i]*/ - move32(); - if ( LT_16( max_res_exp, res_exp[i] ) ) - { - max_res_exp = res_exp[i]; - move16(); - } - } - - FOR( i = 0; i < N; i++ ) - { - sidNoiseEst[i] = L_shr( sidNoiseEst[i], sub( max_res_exp, res_exp[i] ) ); /*Q31 - max_res_exp*/ - move32(); - } - - hFdCngCom->sidNoiseEstExp = max_res_exp; - move16(); - - /* NB last band energy compensation */ - - IF( hFdCngCom->CngBandwidth == NB ) - { - sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], NB_LAST_BAND_SCALE ); /*Q31 - max_res_exp*/ - move32(); - } - - test(); - IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) - { - sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], SWB_13k2_LAST_BAND_SCALE ); /*Q31 - max_res_exp*/ - move32(); - } - - scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); - hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; - move16(); - - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, st->preemph_fac ); - - return; -} - -/*------------------------------------------------------------------- - * noisy_speech_detection() - * - * - *-------------------------------------------------------------------*/ - -/*------------------------------------------------------------------- - * generate_comfort_noise_dec() - * - * Generate the comfort noise based on the target noise level - *-------------------------------------------------------------------*/ - -/*------------------------------------------------------------------- - * generate_masking_noise() - * - * Generate additional comfort noise (kind of noise filling) - *-------------------------------------------------------------------*/ - -/*------------------------------------------------------------------- - * generate_masking_noise_ivas_fx() - * - * Generate additional comfort noise (kind of noise filling) - *-------------------------------------------------------------------*/ - -void generate_masking_noise_ivas_fx( - Word32 *timeDomainBuffer, /* i/o: time-domain signal Q31 - *exp_out*/ - Word16 *exp_out, /* o : time-domain signal exp */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 length, /* i : frame size Q0*/ - const Word16 core, /* i : core Q0*/ - const Word16 return_noise, /* i : noise is returned instead of added Q0*/ - const Word16 secondary, /* i : flag to indicate secondary noise generation Q0*/ - const Word16 element_mode, /* i : element mode Q0*/ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 nchan_out /* i : number of output channels Q0*/ -) -{ - Word32 *cngNoiseLevel_fx = hFdCngCom->cngNoiseLevel; - Word32 *ptr_level_fx = cngNoiseLevel_fx; - Word32 *fftBuffer_fx = hFdCngCom->fftBuffer; - Word16 i; - Word32 maskingNoise_fx[L_FRAME16k]; - Word32 *ptr_r_fx; - Word32 *ptr_i_fx; - Word16 startBand; - Word16 *seed = &( hFdCngCom->seed ); - Word32 scale_fx; - Word16 shift; - scale_fx = 0x40000000; // 1.0 in Q30 - move32(); - startBand = hFdCngCom->startBand; /*Q0*/ - move16(); - shift = getScaleFactor32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); - if ( LT_16( sub( hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) - { - shift = sub( hFdCngCom->cngNoiseLevelExp, 4 ); /*Q0*/ - } - scale_sig32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); /*hFdCngCom->cngNoiseLevelExp*/ - hFdCngCom->cngNoiseLevelExp = sub( hFdCngCom->cngNoiseLevelExp, shift ); - move16(); - - /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ - *exp_out = Q15; - move16(); - IF( GT_16( hFdCngCom->likelihood_noisy_speech, DELTA_MASKING_NOISE_Q15 ) ) - { - IF( NE_16( core, AMR_WB_CORE ) ) - { - /* Compute additional CN level */ - FOR( i = 0; i < SIZE_SCALE_TABLE_CN; i++ ) - { - test(); - test(); - if ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_only[i].bwmode ) && - GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateFrom ) && - LT_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateTo ) ) - { - BREAK; - } - } - - scale_fx = L_deposit_h( scaleTable_cn_only[i].scale_ivas ); /* Q30 */ - } - ELSE - { - /* Compute additional CN level */ - FOR( i = 0; i < SIZE_SCALE_TABLE_CN_AMRWB; i++ ) - { - if ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only_amrwbio[i][0] ) ) - { - BREAK; - } - } - - IF( LT_16( i, SIZE_SCALE_TABLE_CN_AMRWB ) ) - { - scale_fx = L_deposit_h( scaleTable_cn_only_amrwbio[i][1] ); /* Q30 */ - } - ELSE - { - scale_fx = 0; - move32(); - } - } - - /* Exclude clean speech */ - scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech ); // Q30 - - /* Generate Gaussian random noise in real and imaginary parts of the FFT bins - Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */ - IF( startBand == 0 ) - { - rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out ); // Q15 - ptr_r_fx = fftBuffer_fx + 2; /*Q31 - hFdCngCom->fftBuffer_exp*/ - Word16 exp1; - exp1 = add( hFdCngCom->cngNoiseLevelExp, 1 ); - Word32 mpy1; - mpy1 = Sqrt32( Mpy_32_32( scale_fx, *ptr_level_fx ), &exp1 ); /*Q31 - exp1*/ - mpy1 = L_shl( mpy1, exp1 ); // Q31 - fftBuffer_fx[0] = Mpy_32_32( fftBuffer_fx[0], mpy1 ); /* DC component in FFT */ // Q = Q15 - ptr_level_fx++; - } - ELSE - { - fftBuffer_fx[0] = 0; - move32(); - set32_fx( fftBuffer_fx + 2, 0, shl( sub( startBand, 1 ), 1 ) ); - ptr_r_fx = fftBuffer_fx + shl( startBand, 1 ); /*Q31 - hFdCngCom->fftBuffer_exp*/ - } - ptr_i_fx = ptr_r_fx + 1; - FOR( ; ptr_level_fx < cngNoiseLevel_fx + hFdCngCom->stopFFTbin - startBand; ptr_level_fx++ ) - { - /* Real part in FFT bins */ - rand_gauss_fx( ptr_r_fx, seed, *exp_out ); // Q15 - Word16 exp2; - exp2 = add( hFdCngCom->cngNoiseLevelExp, 1 ); - Word32 mpy2; - mpy2 = Sqrt32( L_shr( Mpy_32_32( scale_fx, *ptr_level_fx ), 1 ), &exp2 ); /*Q31 - exp2*/ - ( *ptr_r_fx ) = L_shl( Mpy_32_32( *ptr_r_fx, mpy2 ), exp2 ); // Q = Q15 - move32(); - ptr_r_fx += 2; - - /* Imaginary part in FFT bins */ - rand_gauss_fx( ptr_i_fx, seed, *exp_out ); // Q15 - ( *ptr_i_fx ) = L_shl( Mpy_32_32( *ptr_i_fx, mpy2 ), exp2 ); // Q = Q15 - ptr_i_fx += 2; - } - - /* Remaining FFT bins are set to zero */ - set32_fx( fftBuffer_fx + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); - /* Nyquist frequency is discarded */ - fftBuffer_fx[1] = 0; - move32(); - } - ELSE - { - /* very low level case - update random seeds and reset FFT buffer; don't fully skip SynthesisSTFT_flt(), because of the buffer updates done there... */ - generate_masking_noise_update_seed_fx( hFdCngCom ); - - set32_fx( fftBuffer_fx, 0, hFdCngCom->fftlen ); - } - - /* Perform STFT synthesis */ - IF( secondary ) - { - SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); - } - ELSE - { - SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); - } - *exp_out = sub( *exp_out, Q9 ); - move16(); - - /* Add some comfort noise on top of decoded signal */ - IF( return_noise ) - { - Copy32( maskingNoise_fx, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/ - } - ELSE - { - v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/ - } - - return; -} - -/*------------------------------------------------------------------- - * generate_masking_noise_update_seed() - * - * Update seed for scenarios where generate_masking_noise() is - * not called based on signal statistics - *-------------------------------------------------------------------*/ - - -/*------------------------------------------------------------------- - * generate_stereo_masking_noise_fx() - * - * Generate additional comfort noise (kind of noise filling) - *-------------------------------------------------------------------*/ - -void generate_stereo_masking_noise_fx( - Word16 *syn, /* i/o: time-domain signal Q_syn*/ - Word16 Q_syn, - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel Q0*/ - const Word16 fadeOut, /* i : only fade out of previous state Q0*/ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const Word16 nchan_out /* i : number of output channels Q0*/ -) -{ - HANDLE_FD_CNG_COM hFdCngCom; - Word32 gamma_fx, scale_fx /*, SP_ratio_fx needs to be integrated*/; - Word32 Np_fx[L_FRAME16k]; - Word32 Ns_fx[L_FRAME16k]; - Word32 N1_fx[L_FRAME16k]; - Word32 N2_fx[L_FRAME16k]; - Word16 N1_fx_exp, N2_fx_exp; - Word16 i; - - IF( st->idchan == 0 ) - { - hFdCngCom = st->hFdCngDec->hFdCngCom; -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ -#else - Copy_Scale_sig_16_32_DEPREC( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ -#endif - Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); /*st->Q_syn*/ - - set32_fx( &Np_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); - set32_fx( &Ns_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); - - IF( !fadeOut ) - { -#ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/ -#else - Copy_Scale_sig_16_32_DEPREC( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/ -#endif - generate_masking_noise_ivas_fx( N1_fx, &N1_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out ); // N1_fx Q6 - /* Generate masking noise for secondary channel */ - IF( flag_sec_CNA ) - { - generate_masking_noise_ivas_fx( N2_fx, &N2_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out ); // N2_fx Q6 - gamma_fx = L_shr( Mpy_32_32( hStereoCng->c_PS_LT_fx, hStereoCng->c_PS_LT_fx ), 1 ); /*Q30*/ - scale_fx = ONE_IN_Q30; - move32(); - IF( LT_32( gamma_fx, 966367642 /* 0.9 in Q30 */ ) ) - { - Word16 exp_gamma; - exp_gamma = 0; - move16(); - Word16 divisor1; - divisor1 = Inv16( (Word16) L_shr( L_sub( ONE_IN_Q30, gamma_fx ), Q15 ), &exp_gamma ); // Q15-exp_gamma - gamma_fx = L_shl( Mpy_32_16_1( gamma_fx, divisor1 ), exp_gamma ); // Q30 - Word16 exp_gamma1, exp_gamma2, exp_gamma3; - exp_gamma1 = Q1; - exp_gamma2 = Q1; - exp_gamma3 = Q1; - move16(); - move16(); - move16(); - gamma_fx = Sqrt32( L_add( gamma_fx, ONE_IN_Q30 ), &exp_gamma1 ); /*Q31 - exp_gamma1*/ - Word32 temp; - temp = Sqrt32( gamma_fx, &exp_gamma2 ); // Q31-exp_gamma1 - gamma_fx = L_sub( gamma_fx, L_shl( temp, sub( exp_gamma2, exp_gamma1 ) ) ); // Q31-exp_gamma1 - gamma_fx = L_shl( gamma_fx, sub( exp_gamma1, Q1 ) ); // Q30 - Word32 divisor2; - divisor2 = Sqrt32( L_add( ONE_IN_Q30, L_shl( Mpy_32_32( gamma_fx, gamma_fx ), Q1 ) ), &exp_gamma3 ); // Q31 - exp_gamma3 - scale_fx = L_shl( divide3232( ONE_IN_Q30, divisor2 ), add( Q15, exp_gamma3 ) ); // Q30 - } - ELSE - { - gamma_fx = 0; - move16(); - } - - FOR( i = 0; i < 2 * hFdCngCom->frameSize / 4; i++ ) - { - Np_fx[i] = L_add( Np_fx[i], - Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ) ); // Q6 - move32(); - Word32 add2; - add2 = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 - if ( hStereoCng->c_PS_LT_fx < 0 ) - { - add2 = L_negate( add2 ); /*Q6*/ - } - Ns_fx[i] = L_add( Ns_fx[i], add2 ); /*Q6*/ - move32(); - } - FOR( ; i < hFdCngCom->frameSize; i++ ) - { - Np_fx[i] = Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 - move32(); - Ns_fx[i] = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 - move32(); - IF( hStereoCng->c_PS_LT_fx < 0 ) - { - Ns_fx[i] = L_negate( Ns_fx[i] ); - move32(); - } - } - /* Below code to be converted */ - Word32 scale_fx_tmp = Mpy_32_32( scale_fx, L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ) ); // Q21 - FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ ) - { - hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp, - L_add( L_shr( hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )], Q15 ), - Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ) ) ), - Q14 ); // Q_olap - move16(); - hStereoCng->olapBufferSynth22_fx[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp, - L_sub( L_shr( hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )], Q15 ), - Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ) ) ), - Q14 ); // Q_olap - move16(); - } - } - ELSE - { - FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ ) - { - Np_fx[i] = L_add( Np_fx[i], N1_fx[i] ); // Q6 - move32(); - } - Copy32( &N1_fx[( hFdCngCom->frameSize / 2 )], &Np_fx[( hFdCngCom->frameSize / 2 )], shr( hFdCngCom->frameSize, 1 ) ); /*Q6*/ - scale_fx = L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ); // Q21 - FOR( i = 0; i < hFdCngCom->frameSize; i++ ) - { - hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_16_1( scale_fx, hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ), Q6 ); // Q_olap - move16(); - } - } - - Copy_Scale_sig_32_16( hStereoCng->olapBufferSynth22_32fx, hStereoCng->olapBufferSynth22_fx, hFdCngCom->fftlen, sub( st->Q_syn, 15 ) ); /*st->Q_syn*/ - } - ELSE - { - set16_fx( hFdCngCom->olapBufferSynth2, 0, shr( hFdCngCom->frameSize, 1 ) ); - set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( hFdCngCom->frameSize, 1 ) ); - } - IF( flag_sec_CNA ) - { - Copy_Scale_sig_32_16( Ns_fx, hStereoCng->maskingNoiseS_fx, hFdCngCom->frameSize, 0 ); // Q6 - hStereoCng->enableSecCNA = 1; - move16(); - } - ELSE - { - set16_fx( hStereoCng->olapBufferSynth22_fx, 0, hFdCngCom->frameSize ); - } - - /* add masking noise */ - FOR( i = 0; i < hFdCngCom->frameSize; i++ ) - { - syn[i] = add( syn[i], (Word16) L_shr( Np_fx[i], sub( Q16 + Q6, Q_syn ) ) ); // Q_syn - move16(); - } - } - ELSE IF( hStereoCng->enableSecCNA ) - { - Word16 SP_ratio_fx; - SP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /* Use long-term SP ratio based on L/R synthesis Q15*/ - Word16 prevSP_ratio_fx; - prevSP_ratio_fx = hStereoTD->prevSP_ratio_fx; /* Use long-term SP ratio based on L/R synthesis Q15*/ - move16(); - /* scale and add masking noise */ - FOR( i = 0; i < shr( *hStereoCng->frameSize, 2 ); i++ ) - { - Word16 s; - Word16 scale_fx_tmp; - scale_fx_tmp = BASOP_Util_Divide3216_Scale( L_add( L_mult0( prevSP_ratio_fx, sub( shr( *hStereoCng->frameSize, 2 ), i ) ), L_mult0( SP_ratio_fx, i ) ), shr( *hStereoCng->frameSize, 2 ), &s ); // Q15 - scale_fx_tmp = shl( scale_fx_tmp, s ); - syn[i] = add( syn[i], mult( scale_fx_tmp, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/ - move16(); - } - FOR( ; i < *hStereoCng->frameSize / 2; i++ ) - { - syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/ - move16(); - } - FOR( ; i < *hStereoCng->frameSize; i++ ) - { - syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/ - move16(); - } - hStereoTD->prevSP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /*Q15*/ - move16(); - } - - return; -} -void generate_masking_noise_lb_dirac_fx( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - Word32 *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA Q11*/ - const Word16 nCldfbTs, /* i : number of CLDFB slots that will be rendered Q0*/ - const Word16 cna_flag /* i : CNA flag for LB and HB Q0*/ -) -{ - Word16 i; - Word32 *cngNoiseLevel = hFdCngCom->cngNoiseLevel; /*hFdCngCom->cngNoiseLevelExp*/ - Word32 *fftBuffer = hFdCngCom->fftBuffer; /*hFdCngCom->fftBuffer_exp*/ - Word32 *ptr_r; - Word32 *ptr_i; - Word32 *ptr_level; - Word16 *seed = &( hFdCngCom->seed ); - Word32 scale; - Word16 n_samples_out, n_samples_start, n_samples_out_loop; - - push_wmops( "fd_cng_dirac" ); - - /* Init */ - scale = 0; - move32(); - n_samples_out = i_mult( shr( hFdCngCom->frameSize, 4 ), nCldfbTs ); - n_samples_start = 0; - move16(); - Word16 exp_out = Q11; - move16(); - /*LB CLDFB - CNA from STFT*/ - IF( cna_flag ) - { - /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ - IF( GT_16( hFdCngCom->likelihood_noisy_speech, DELTA_MASKING_NOISE_Q15 ) ) - { - /* Compute additional CN level */ - FOR( i = 0; i < 15; i++ ) - { - test(); - test(); - if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) && - GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) && - LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) - { - BREAK; - } - } - - scale = L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ); /* Q30 */ - scale = Mpy_32_16_1( scale, hFdCngCom->likelihood_noisy_speech ); /* Q30 */ - } - } - - /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/ - test(); - IF( cna_flag && tdBuffer != NULL ) - { - WHILE( n_samples_out > 0 ) - { - n_samples_out_loop = s_min( hFdCngCom->frameSize, n_samples_out ); - IF( scale != 0 ) - { - /*Generate LF comfort noise only at first slot, for the whole frame*/ - ptr_level = cngNoiseLevel; /*hFdCngCom->cngNoiseLevelExp*/ - - /* Generate Gaussian random noise in real and imaginary parts of the FFT bins - Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */ - IF( EQ_16( hFdCngCom->startBand, 0 ) ) - { - rand_gauss_fx( &fftBuffer[0], seed, exp_out ); - ptr_r = fftBuffer + 2; /*hFdCngCom->fftBuffer_exp*/ - - Word16 exp2 = sub( 31, hFdCngCom->cngNoiseLevelExp ); - Word32 sqr = Sqrt32( L_shr( Mpy_32_32( scale, *ptr_level ), 1 ), &exp2 ); /* DC component in FFT Q31 - exp2*/ - sqr = L_shl( sqr, exp2 ); /*Q31*/ - fftBuffer[0] = Mpy_32_32( fftBuffer[0], sqr ); /* DC component in FFT Q31 - hFdCngCom->fftBuffer_exp*/ - move32(); - ptr_level++; - } - ELSE - { - fftBuffer[0] = 0; - move32(); - set32_fx( fftBuffer + 2, 0, shl( sub( hFdCngCom->startBand, 1 ), 1 ) ); - ptr_r = fftBuffer + shl( hFdCngCom->startBand, 1 ); /*hFdCngCom->fftBuffer_exp*/ - } - ptr_i = ptr_r + 1; /*hFdCngCom->fftBuffer_exp*/ - - FOR( ; ptr_level < cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); ptr_level++ ) - { - rand_gauss_fx( ptr_r, seed, exp_out ); - Word16 exp2 = hFdCngCom->cngNoiseLevelExp; - Word32 mpy2 = Sqrt32( Mpy_32_32( scale, *ptr_level ), &exp2 ); /*Q31 - exp2*/ - ( *ptr_r ) = L_shl( Mpy_32_32( *ptr_r, mpy2 ), exp2 ); /*Q31 - hFdCngCom->fftBuffer_exp*/ - move32(); - ptr_r += 2; - - /* Imaginary part in FFT bins */ - rand_gauss_fx( ptr_i, seed, exp_out ); - ( *ptr_i ) = L_shl( Mpy_32_32( *ptr_i, mpy2 ), exp2 ); /*Q31 - hFdCngCom->fftBuffer_exp*/ - move32(); - ptr_i += 2; - } - /* Remaining FFT bins are set to zero */ - set32_fx( fftBuffer + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); - /* Nyquist frequency is discarded */ - fftBuffer[1] = 0; - move32(); - - /* Perform STFT synthesis */ - SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); - scale_sig32( tdBuffer + n_samples_start, n_samples_out_loop, Q9 ); // Q2 -> Q11 - } - - ELSE - { - /* very low level case - update random seeds */ - generate_masking_noise_update_seed_fx( hFdCngCom ); - - set32_fx( fftBuffer, 0, hFdCngCom->fftlen ); - /* Perform STFT synthesis */ - SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); - } - hFdCngCom->fftBuffer_exp = 31 - 11; - move16(); - n_samples_out = sub( n_samples_out, hFdCngCom->frameSize ); - n_samples_start = add( n_samples_start, hFdCngCom->frameSize ); - } - } - - pop_wmops(); - - return; -} -void generate_masking_noise_dirac_ivas_fx( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA q_input*/ - Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer q_cldfb*/ - Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer q_cldfb*/ - const Word16 slot_index, /* i : CLDFB slot index Q0*/ - const Word16 cna_flag, /* i : CNA flag for LB and HB Q0*/ - const Word16 fd_cng_flag, /* i : FD-CNG flag for HB Q0*/ - Word16 q_input, - Word16 *q_cldfb ) -{ - Word16 i; - Word32 *ptr_level_fx; - Word16 *seed = &( hFdCngCom->seed ); - Word32 scale_fx; - Word16 q_scale, q_shift, q_ptr_level; - - push_wmops( "fd_cng_dirac" ); - - /* Init */ - scale_fx = 0; - move32(); - - /* Resample CLDFB memories if necessary*/ - IF( NE_16( i_mult( h_cldfb->no_channels, h_cldfb->no_col ), hFdCngCom->frameSize ) ) - { - resampleCldfb_ivas_fx( h_cldfb, hFdCngCom->frameSize * FRAMES_PER_SEC ); - } - - set32_fx( Cldfb_RealBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_ImagBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX ); - - /*LB CLDFB - CNA from STFT*/ - IF( cna_flag != 0 ) - { - /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ - IF( hFdCngCom->likelihood_noisy_speech > 0 ) - { - /* Compute additional CN level */ - FOR( i = 0; i < 15; i++ ) - { - test(); - test(); - if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) && - ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) ) && - ( LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) ) - { - BREAK; - } - } - - scale_fx = L_shr( L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ), Q3 ); /* Q27 */ - scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech ); - } - } - /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/ - IF( cna_flag && tdBuffer_fx != NULL ) - { - *q_cldfb = q_input; - move16(); - IF( scale_fx != 0 ) - { - /* LF CLDFB*/ - cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[( hFdCngCom->numCoreBands * slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb ); - } - ELSE - { - /* LB ana CLDFB*/ - cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[( hFdCngCom->numCoreBands * slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb ); - } - } - - /*HF CLDFB - CNA and/or FD-CNG*/ - if ( fd_cng_flag ) - { - scale_fx = L_add( scale_fx, ONE_IN_Q27 ); // 1 in Q27 - } - IF( scale_fx != 0 ) - { - q_scale = 27; - move16(); - q_shift = norm_l( scale_fx ); - scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/ - q_scale = add( q_scale, q_shift ); - scale_fx = Mpy_32_32( scale_fx, Mpy_32_16_1( L_mult( h_cldfb->scale, h_cldfb->scale ), CLDFB_SCALING ) ); // Q = q_scale + 2 * Q8 - 34 - q_scale = sub( add( q_scale, 2 * Q8 ), 31 ); - ptr_level_fx = hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); /*Q31 - hFdCngCom->cngNoiseLevelExp*/ - q_ptr_level = sub( 31, hFdCngCom->cngNoiseLevelExp ); - - FOR( i = hFdCngCom->numCoreBands; i < hFdCngCom->regularStopBand; i++ ) - { - Word32 num; - Word16 exp, q_num; - q_shift = norm_l( scale_fx ); - scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/ - q_scale = add( q_scale, q_shift ); - num = Mpy_32_32( scale_fx, *ptr_level_fx ); /*q_num*/ - q_num = sub( add( q_scale, q_ptr_level ), 31 ); - exp = sub( 31, q_num ); - num = Sqrt32( num, &exp ); /*Q31 - exp*/ - /* Real part in CLDFB band */ - rand_gauss_fx( &Cldfb_RealBuffer_fx[i], seed, *q_cldfb ); - Cldfb_RealBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_RealBuffer_fx[i], num ), exp ); - move32(); - /* Imaginary part in CLDFB band */ - rand_gauss_fx( &Cldfb_ImagBuffer_fx[i], seed, *q_cldfb ); - Cldfb_ImagBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_ImagBuffer_fx[i], num ), exp ); - move32(); - - ptr_level_fx++; - } - } - - pop_wmops(); - - return; -} - - -/*------------------------------------------------------------------- - * FdCngDecodeMDCTStereoSID() - * - * Decode FD-Cng parameters for CNG in MDCT-Stereo mode from the bitstream - * - *-------------------------------------------------------------------*/ - -void FdCngDecodeMDCTStereoSID_fx( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -) -{ - DEC_CORE_HANDLE sts[CPE_CHANNELS]; - HANDLE_FD_CNG_COM hFdCngCom; - Word32 *ms_ptr_fx[CPE_CHANNELS]; - Word32 *lr_ptr_fx[CPE_CHANNELS]; - Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; - Word32 gain_fx[CPE_CHANNELS]; - Word16 indices[FD_CNG_stages_37bits]; - Word16 N, i, ch, p, stages; - Word16 is_out_ms; - Word32 *invTrfMatrix_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word16 shift, exp_diff, max_exp_idx; - Word16 exp_arr[NPART]; - Word32 tmp32, tmp32_arr[NPART]; - - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31 - - is_out_ms = 0; - move16(); - if ( hCPE->hCoreCoder[0]->cng_sba_flag ) - { - is_out_ms = 1; - move16(); - } - - N = 0; /* to avoid compilation warning */ - move16(); - - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; /*Q20*/ - lr_ptr_fx[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; /*Q18*/ - } - - /* decode noise shapes and gains */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - hFdCngCom = ( sts[ch]->hFdCngDec )->hFdCngCom; - N = hFdCngCom->npart; - move16(); - hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); /*Q0*/ - move16(); - - IF( ch ) - { - stages = FD_CNG_JOINT_stages_25bits; - move16(); - } - ELSE - { - stages = FD_CNG_stages_37bits; - move16(); - } - - /* read bitstream */ - FOR( i = 0; i < stages; i++ ) - { - indices[i] = get_next_indice_fx( sts[ch], bits_37bits[i] ); /*Q0*/ - move16(); - } - { - gain_fx[ch] = Mpy_32_32( L_shl( L_sub( get_next_indice_fx( sts[ch], 7 ), GAIN_Q_OFFSET_IVAS_FX ), Q20 ), TWO_BY_THREE_Q31 /* 2/3 in Q31 */ ); // Q20 - move32(); - } - - /* MSVQ decoder */ - shift = find_guarded_bits_fx( N ); - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, ms_ptr_fx[ch], NULL, 7 ); // Q20 - shift - - Scale_sig32( ms_ptr_fx[ch], N, shift ); // Q20 - } - - dtx_read_padding_bits_fx( sts[1], mult( sub( IVAS_SID_5k2, 4400 ), ONE_BY_FRAMES_PER_SEC_Q15 ) ); - - IF( sts[0]->hFdCngDec->hFdCngCom->no_side_flag ) - { - set32_fx( ms_ptr_fx[1], 0, NPART ); - } - - IF( EQ_16( is_out_ms, 0 ) ) - { - inverseMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 ); - } - - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - max_exp_idx = 0; - move16(); - hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom; - FOR( p = 0; p < N; p++ ) - { - tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20 - tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); /*Q31 - exp_arr[p]*/ - move32(); - if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) ) - { - max_exp_idx = p; /*Q0*/ - move16(); - } - } - - // Bringing in same exponent - FOR( p = 0; p < N; p++ ) - { - lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); /*Q31 - exp_arr[max_exp_idx]*/ - move32(); - } - - hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx]; - move16(); - - scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); - - hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; - move16(); - - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); - } - - test(); - IF( EQ_16( hCPE->nchan_out, 1 ) && LE_32( hCPE->last_element_brate, IVAS_SID_5k2 ) ) - { - /* create proper M noise shape in channel zero after gains have been applied */ - exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp ); - move16(); - FOR( p = 0; p < N; p++ ) - { - IF( GT_16( exp_diff, 0 ) ) - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) ); /*Q18*/ - move32(); - } - ELSE - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], sub( 1, exp_diff ) ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); /*Q18*/ - move32(); - } - } - IF( LT_16( exp_diff, 0 ) ) - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) ); - move16(); - } - } - - return; -} - - -/*------------------------------------------------------------------- - * FdCngDecodeDiracMDCTStereoSID_fx() - * - * Decode FD-CNG parameters for CNG in 2TC DirAC mode from the bitstream - *-------------------------------------------------------------------*/ - -void FdCngDecodeDiracMDCTStereoSID_fx( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -) -{ - DEC_CORE_HANDLE sts[CPE_CHANNELS]; - HANDLE_FD_CNG_COM hFdCngCom; - Word32 *ms_ptr_fx[CPE_CHANNELS]; - Word32 *lr_ptr_fx[CPE_CHANNELS]; - Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; - Word32 gain_fx[CPE_CHANNELS]; - Word16 indices[FD_CNG_stages_37bits]; - Word16 N, i, ch, p; - Word32 *invTrfMatrix_fx; - Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - Word16 shift, exp_diff, max_exp_idx; - Word16 exp_arr[NPART]; - Word32 tmp32, tmp32_arr[NPART]; - - invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ - create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31 - - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; /*Q20*/ - lr_ptr_fx[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; /*Q20*/ - ( sts[ch]->hFdCngDec )->hFdCngCom->sid_frame_counter++; /*Q18*/ - } - - /* decode noise shapes and gains */ - hFdCngCom = ( sts[0]->hFdCngDec )->hFdCngCom; - N = hFdCngCom->npart; /*Q0*/ - move16(); - - /* read bitstream */ - FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) - { - indices[i] = get_next_indice_fx( sts[0], bits_37bits[i] ); /*Q0*/ - move16(); - } - gain_fx[0] = Mpy_32_32( L_shl( L_sub( get_next_indice_fx( sts[0], 7 ), GAIN_Q_OFFSET_IVAS_FX ), Q20 ), TWO_BY_THREE_Q31 /* 2/3 in Q31 */ ); // Q20 - move32(); - - gain_fx[1] = gain_fx[0]; /*Q20*/ - move32(); - - /* MSVQ decoder */ - shift = find_guarded_bits_fx( N ); - msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, ms_ptr_fx[0], NULL, 7 ); // Q20 - shift - - Scale_sig32( ms_ptr_fx[0], N, shift ); // Q20 - - Copy32( ms_ptr_fx[0], ms_ptr_fx[1], N ); /*Q20*/ - - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - max_exp_idx = 0; - move16(); - hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom; - - FOR( p = 0; p < N; p++ ) - { - tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20 - tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); /*Q31 - exp_arr[p]*/ - move32(); - if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) ) - { - max_exp_idx = p; /*Q0*/ - move16(); - } - } - - // Bringing in same exponent - FOR( p = 0; p < N; p++ ) - { - lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); /*Q20*/ - move32(); - } - - hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx]; /*Q0*/ - move16(); - - /* NB last band energy compensation */ - test(); - IF( hFdCngCom->CngBandwidth == NB ) - { - lr_ptr_fx[ch][( N - 1 )] = Mpy_32_32( lr_ptr_fx[ch][( N - 1 )], NB_LAST_BAND_SCALE_Q31 ); /*Q20*/ - move32(); - } - ELSE IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) - { - lr_ptr_fx[ch][( N - 1 )] = Mpy_32_32( lr_ptr_fx[ch][( N - 1 )], SWB_13k2_LAST_BAND_SCALE_Q31 ); /*Q20*/ - move32(); - } - - scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); - - hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; - move16(); - - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); - } - sts[0]->hFdCngDec->hFdCngCom->coherence_fx = 0; - move16(); - sts[1]->hFdCngDec->hFdCngCom->coherence_fx = 0; - move16(); - - IF( EQ_16( hCPE->nchan_out, 1 ) ) - { - /* create proper M noise shape in channel zero after gains have been applied */ - exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp ); - FOR( p = 0; p < N; p++ ) - { - IF( exp_diff > 0 ) - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) ); /*Q18*/ - move32(); - } - ELSE - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], sub( 1, exp_diff ) ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); /*Q18*/ - move32(); - } - } - IF( exp_diff < 0 ) - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) ); - move16(); - } - } - - return; -} diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 8a902448f..f788144fa 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -24,6 +24,14 @@ #define ST_PERIODOG_FACT_Q15 29491 /* 0.9 in Q15, short-term filter factor for periodogram */ #define CNA_ACT_DN_FACT_Q15 22938 /* 0.7 in Q15, downward updating factor for CNA during active frames */ #define FIRST_CNA_NOISE_UPD_FRAMES 5 /* minimum number of CN initialization frames */ +#define DELTA_MASKING_NOISE_Q15 0 +#define LOG_10_BASE_2 1783446566 /* Q29 */ +#define GAIN_Q_OFFSET_IVAS_FX 45 +#define LOG_10_BASE_2_BY_10_Q31 713378606 +#define TWO_BY_THREE_Q31 1431655765 +#define ONE_BY_FRAMES_PER_SEC_Q15 656 +#define NB_LAST_BAND_SCALE_Q31 1717986918 +#define SWB_13k2_LAST_BAND_SCALE_Q31 1717986918 /******************************** * External tables * @@ -5025,6 +5033,1278 @@ void generate_masking_noise_mdct_ivas_fx( return; } + +/*------------------------------------------------------------------- + * initFdCngDec() + * + * Initialize an instance of type FD_CNG + *-------------------------------------------------------------------*/ +void configureFdCngDec_ivas_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bwidth, /*Q0*/ + const Word32 total_brate, /*Q0*/ + const Word16 L_frame, /*Q0*/ + const Word16 last_L_frame, /*Q0*/ + const Word16 element_mode /*Q0*/ ) +{ + Word16 j, stopBandFR; + HANDLE_FD_CNG_COM hsCom = hFdCngDec->hFdCngCom; + + hsCom->CngBandwidth = bwidth; /*Q0*/ + move16(); + if ( EQ_16( hsCom->CngBandwidth, FB ) ) + { + hsCom->CngBandwidth = SWB; + move16(); + } + test(); + IF( NE_32( total_brate, FRAME_NO_DATA ) && NE_32( total_brate, SID_2k40 ) ) + { + hsCom->CngBitrate = total_brate; /*Q0*/ + move32(); + } + ELSE IF( EQ_32( hsCom->CngBitrate, -1 ) ) + { + /* set minimum active CBR bitrate IF CngBitrate is uninitialized */ + IF( element_mode > EVS_MONO ) + { + hsCom->CngBitrate = IVAS_13k2; + move32(); + } + ELSE + { + hsCom->CngBitrate = ACELP_7k20; + move32(); + } + } + + /* FD-CNG config for MDCT-Stereo is always the same (since for > 48 kbps only) */ + /* This may need adjustment in the future IF 2TC DTX for some mode uses MDCT-Stereo DTX for lower bitrates too */ + if ( EQ_16( element_mode, IVAS_CPE_MDCT ) ) + { + hsCom->CngBitrate = IVAS_48k; + move32(); + } + hsCom->numSlots = 16; + move32(); + + /* NB configuration */ + IF( EQ_16( bwidth, NB ) ) + { + hsCom->FdCngSetup = FdCngSetup_nb; + hsCom->numCoreBands = 16; + move16(); + hsCom->regularStopBand = 16; + move16(); + } + + /* WB configuration */ + ELSE IF( EQ_16( bwidth, WB ) ) + { + /* FFT 6.4kHz, no CLDFB */ + test(); + test(); + IF( LE_32( hsCom->CngBitrate, ACELP_8k00 ) && EQ_16( L_frame, L_FRAME ) ) + { + hsCom->FdCngSetup = FdCngSetup_wb1; + hsCom->numCoreBands = 16; + move16(); + hsCom->regularStopBand = 16; + move16(); + } + /* FFT 6.4kHz, CLDFB 8.0kHz */ + ELSE IF( LE_32( hsCom->CngBitrate, ACELP_13k20 ) || EQ_16( L_frame, L_FRAME ) ) + { + hsCom->FdCngSetup = FdCngSetup_wb2; + hsCom->numCoreBands = 16; + move16(); + hsCom->regularStopBand = 20; + move16(); + IF( EQ_16( L_frame, L_FRAME16k ) ) + { + hsCom->FdCngSetup = FdCngSetup_wb2; + hsCom->numCoreBands = 20; + move16(); + hsCom->regularStopBand = 20; + move16(); + hsCom->FdCngSetup.fftlen = 640; + move16(); + hsCom->FdCngSetup.stopFFTbin = 256; + move16(); + } + } + /* FFT 8.0kHz, no CLDFB */ + ELSE + { + hsCom->FdCngSetup = FdCngSetup_wb3; + hsCom->numCoreBands = 20; + move16(); + hsCom->regularStopBand = 20; + move16(); + } + } + + /* SWB/FB configuration */ + ELSE + { + /* FFT 6.4kHz, CLDFB 14kHz */ + IF( EQ_16( L_frame, L_FRAME ) ) + { + hsCom->FdCngSetup = FdCngSetup_swb1; + hsCom->numCoreBands = 16; + move16(); + hsCom->regularStopBand = 35; + move16(); + } + /* FFT 8.0kHz, CLDFB 16kHz */ + ELSE + { + hsCom->FdCngSetup = FdCngSetup_swb2; + hsCom->numCoreBands = 20; + move16(); + hsCom->regularStopBand = 40; + move16(); + test(); + if ( EQ_16( last_L_frame, L_FRAME ) && EQ_16( element_mode, IVAS_CPE_DFT ) ) + { + hsCom->regularStopBand = 35; + move16(); + } + } + } + + + hsCom->fftlen = hsCom->FdCngSetup.fftlen; + move16(); + hsCom->stopFFTbin = hsCom->FdCngSetup.stopFFTbin; + move16(); + + /* Configure the SID quantizer and the Comfort Noise Generator */ + + hsCom->startBand = 2; + move16(); + hsCom->stopBand = add( hsCom->FdCngSetup.sidPartitions[( hsCom->FdCngSetup.numPartitions - 1 )], 1 ); /*Q0*/ + initPartitions( hsCom->FdCngSetup.sidPartitions, hsCom->FdCngSetup.numPartitions, hsCom->startBand, hsCom->stopBand, hsCom->part, &hsCom->npart, hsCom->midband, hsCom->psize, hsCom->psize_norm, &hsCom->psize_norm_exp, hsCom->psize_inv, 0 ); + + IF( EQ_16( hsCom->stopFFTbin, 160 ) ) + { + hsCom->nFFTpart = 17; + move16(); + } + ELSE IF( EQ_16( hsCom->stopFFTbin, 256 ) ) + { + hsCom->nFFTpart = 20; + move16(); + } + ELSE + { + hsCom->nFFTpart = 21; + move16(); + } + hsCom->nCLDFBpart = sub( hsCom->npart, hsCom->nFFTpart ); /*Q0*/ + move16(); + FOR( j = 0; j < hsCom->nCLDFBpart; j++ ) + { + hsCom->CLDFBpart[j] = sub( hsCom->part[( j + hsCom->nFFTpart )], sub( hsCom->stopFFTbin, hsCom->startBand ) ); /*Q0*/ + move16(); + hsCom->CLDFBpsize_inv[j] = hsCom->psize_inv[( j + hsCom->nFFTpart )]; + move16(); + } + + stopBandFR = 40; //(Word16)floor(1000.f /*Hz*/ / 25.f /*Hz/Bin*/); + move16(); + if ( GT_16( stopBandFR, hsCom->stopFFTbin ) ) + { + stopBandFR = hsCom->stopFFTbin; /*Q0*/ + move16(); + } + + initPartitions( hsCom->FdCngSetup.shapingPartitions, hsCom->FdCngSetup.numShapingPartitions, hsCom->startBand, hsCom->stopFFTbin, hFdCngDec->part_shaping, &hFdCngDec->npart_shaping, hFdCngDec->midband_shaping, hFdCngDec->psize_shaping, hFdCngDec->psize_shaping_norm, &hFdCngDec->psize_shaping_norm_exp, hFdCngDec->psize_inv_shaping, stopBandFR ); + + hFdCngDec->nFFTpart_shaping = hFdCngDec->npart_shaping; /*Q0*/ + move16(); + + BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) ); + BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) ); + + SWITCH( hsCom->fftlen ) + { + case 512: + hsCom->olapWinAna_fx = olapWinAna512_fx; /*Q30*/ + hsCom->fftSineTab_fx = NULL; + hsCom->olapWinSyn_fx = olapWinSyn256_fx; /*Q15*/ + hsCom->fftlenShift = 8; + move16(); + hsCom->fftlenFac = 32767 /*1.0 Q15*/; + move16(); + BREAK; + case 640: + hsCom->olapWinAna_fx = olapWinAna640_fx; /*Q30*/ + hsCom->fftSineTab_fx = fftSineTab640_fx; /*Q15*/ + hsCom->olapWinSyn_fx = olapWinSyn320_fx; /*Q15*/ + hsCom->fftlenShift = 9; + move16(); + hsCom->fftlenFac = 20480 /*0.625 Q15*/; + move16(); + BREAK; + default: + assert( !"Unsupported FFT length for FD-based CNG" ); + BREAK; + } + BASOP_getTables( &hsCom->olapWinAna, NULL, NULL, shr( hsCom->fftlen, 1 ) ); + BASOP_getTables( &hsCom->olapWinSyn, NULL, NULL, shr( hsCom->fftlen, 2 ) ); + hsCom->frameSize = shr( hsCom->fftlen, 1 ); + + return; +} + +/*------------------------------------------------------------------- + * FdCng_decodeSID_ivas_fx() + * + * Decode the FD-CNG bitstream + *-------------------------------------------------------------------*/ + +void FdCng_decodeSID_ivas_fx( + Decoder_State *st /* i/o: decoder state structure */ +) +{ + Word16 N; + Word32 *sidNoiseEst; + Word32 gain; + Word16 i, index; + Word32 v[32]; + Word16 indices[32]; + HANDLE_FD_CNG_COM hFdCngCom; + Word32 *invTrfMatrix_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + Word16 tmp16; + + IF( st->element_mode == EVS_MONO ) + { + tmp16 = GAIN_Q_OFFSET_EVS_FX_Q0; + move16(); + } + ELSE + { + tmp16 = GAIN_Q_OFFSET_IVAS_FX_Q0; + move16(); + } + + const Word16 gain_q_offset = tmp16; /* Q0 */ + move16(); + + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /*Q31*/ + + hFdCngCom = ( st->hFdCngDec )->hFdCngCom; + + sidNoiseEst = hFdCngCom->sidNoiseEst; /*Q16*/ + + N = hFdCngCom->npart; /*Q0*/ + move16(); + gain = 0; + move32(); + hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); + move16(); + + /* Read bitstream */ + FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) + { + indices[i] = get_next_indice_fx( st, bits_37bits[i] ); /*Q0*/ + move16(); + } + + index = get_next_indice_fx( st, 7 ); + + /* MSVQ decoder */ + + IF( st->element_mode != EVS_MONO ) + { + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, v, NULL, 7 ); + } + ELSE + { /* Legacy EVS_MONO MSVQ tables */ + msvq_dec_fx( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL, 7 ); + } + + + /* Decode gain */ + // gain = ((float)index - gain_q_offset) / 1.5f; + gain = L_mult0( sub( index, gain_q_offset ), 21845 ); // Q15 + + /* Apply gain and undo log */ + Word16 res_exp[NPART]; + Word16 max_res_exp = 0; + move16(); + FOR( i = 0; i < N; i++ ) + { + sidNoiseEst[i] = BASOP_util_Pow2( Mpy_32_32( L_add( v[i], gain ), LOG_10_BASE_2_BY_10_Q31 ), Q16, &res_exp[i] ); /*Q31 - res_exp[i]*/ + move32(); + if ( LT_16( max_res_exp, res_exp[i] ) ) + { + max_res_exp = res_exp[i]; + move16(); + } + } + + FOR( i = 0; i < N; i++ ) + { + sidNoiseEst[i] = L_shr( sidNoiseEst[i], sub( max_res_exp, res_exp[i] ) ); /*Q31 - max_res_exp*/ + move32(); + } + + hFdCngCom->sidNoiseEstExp = max_res_exp; + move16(); + + /* NB last band energy compensation */ + + IF( hFdCngCom->CngBandwidth == NB ) + { + sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], NB_LAST_BAND_SCALE ); /*Q31 - max_res_exp*/ + move32(); + } + + test(); + IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) + { + sidNoiseEst[( N - 1 )] = Mpy_32_16_1( sidNoiseEst[( N - 1 )], SWB_13k2_LAST_BAND_SCALE ); /*Q31 - max_res_exp*/ + move32(); + } + + scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); + hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; + move16(); + + lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, st->preemph_fac ); + + return; +} + +/*------------------------------------------------------------------- + * generate_masking_noise_ivas_fx() + * + * Generate additional comfort noise (kind of noise filling) + *-------------------------------------------------------------------*/ + +void generate_masking_noise_ivas_fx( + Word32 *timeDomainBuffer, /* i/o: time-domain signal Q31 - *exp_out*/ + Word16 *exp_out, /* o : time-domain signal exp */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 length, /* i : frame size Q0*/ + const Word16 core, /* i : core Q0*/ + const Word16 return_noise, /* i : noise is returned instead of added Q0*/ + const Word16 secondary, /* i : flag to indicate secondary noise generation Q0*/ + const Word16 element_mode, /* i : element mode Q0*/ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const Word16 nchan_out /* i : number of output channels Q0*/ +) +{ + Word32 *cngNoiseLevel_fx = hFdCngCom->cngNoiseLevel; + Word32 *ptr_level_fx = cngNoiseLevel_fx; + Word32 *fftBuffer_fx = hFdCngCom->fftBuffer; + Word16 i; + Word32 maskingNoise_fx[L_FRAME16k]; + Word32 *ptr_r_fx; + Word32 *ptr_i_fx; + Word16 startBand; + Word16 *seed = &( hFdCngCom->seed ); + Word32 scale_fx; + Word16 shift; + scale_fx = 0x40000000; // 1.0 in Q30 + move32(); + startBand = hFdCngCom->startBand; /*Q0*/ + move16(); + shift = getScaleFactor32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + if ( LT_16( sub( hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + { + shift = sub( hFdCngCom->cngNoiseLevelExp, 4 ); /*Q0*/ + } + scale_sig32( hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); /*hFdCngCom->cngNoiseLevelExp*/ + hFdCngCom->cngNoiseLevelExp = sub( hFdCngCom->cngNoiseLevelExp, shift ); + move16(); + + /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ + *exp_out = Q15; + move16(); + IF( GT_16( hFdCngCom->likelihood_noisy_speech, DELTA_MASKING_NOISE_Q15 ) ) + { + IF( NE_16( core, AMR_WB_CORE ) ) + { + /* Compute additional CN level */ + FOR( i = 0; i < SIZE_SCALE_TABLE_CN; i++ ) + { + test(); + test(); + if ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_only[i].bwmode ) && + GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateFrom ) && + LT_32( hFdCngCom->CngBitrate, scaleTable_cn_only[i].bitrateTo ) ) + { + BREAK; + } + } + + scale_fx = L_deposit_h( scaleTable_cn_only[i].scale_ivas ); /* Q30 */ + } + ELSE + { + /* Compute additional CN level */ + FOR( i = 0; i < SIZE_SCALE_TABLE_CN_AMRWB; i++ ) + { + if ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_only_amrwbio[i][0] ) ) + { + BREAK; + } + } + + IF( LT_16( i, SIZE_SCALE_TABLE_CN_AMRWB ) ) + { + scale_fx = L_deposit_h( scaleTable_cn_only_amrwbio[i][1] ); /* Q30 */ + } + ELSE + { + scale_fx = 0; + move32(); + } + } + + /* Exclude clean speech */ + scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech ); // Q30 + + /* Generate Gaussian random noise in real and imaginary parts of the FFT bins + Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */ + IF( startBand == 0 ) + { + rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out ); // Q15 + ptr_r_fx = fftBuffer_fx + 2; /*Q31 - hFdCngCom->fftBuffer_exp*/ + Word16 exp1; + exp1 = add( hFdCngCom->cngNoiseLevelExp, 1 ); + Word32 mpy1; + mpy1 = Sqrt32( Mpy_32_32( scale_fx, *ptr_level_fx ), &exp1 ); /*Q31 - exp1*/ + mpy1 = L_shl( mpy1, exp1 ); // Q31 + fftBuffer_fx[0] = Mpy_32_32( fftBuffer_fx[0], mpy1 ); /* DC component in FFT */ // Q = Q15 + ptr_level_fx++; + } + ELSE + { + fftBuffer_fx[0] = 0; + move32(); + set32_fx( fftBuffer_fx + 2, 0, shl( sub( startBand, 1 ), 1 ) ); + ptr_r_fx = fftBuffer_fx + shl( startBand, 1 ); /*Q31 - hFdCngCom->fftBuffer_exp*/ + } + ptr_i_fx = ptr_r_fx + 1; + FOR( ; ptr_level_fx < cngNoiseLevel_fx + hFdCngCom->stopFFTbin - startBand; ptr_level_fx++ ) + { + /* Real part in FFT bins */ + rand_gauss_fx( ptr_r_fx, seed, *exp_out ); // Q15 + Word16 exp2; + exp2 = add( hFdCngCom->cngNoiseLevelExp, 1 ); + Word32 mpy2; + mpy2 = Sqrt32( L_shr( Mpy_32_32( scale_fx, *ptr_level_fx ), 1 ), &exp2 ); /*Q31 - exp2*/ + ( *ptr_r_fx ) = L_shl( Mpy_32_32( *ptr_r_fx, mpy2 ), exp2 ); // Q = Q15 + move32(); + ptr_r_fx += 2; + + /* Imaginary part in FFT bins */ + rand_gauss_fx( ptr_i_fx, seed, *exp_out ); // Q15 + ( *ptr_i_fx ) = L_shl( Mpy_32_32( *ptr_i_fx, mpy2 ), exp2 ); // Q = Q15 + ptr_i_fx += 2; + } + + /* Remaining FFT bins are set to zero */ + set32_fx( fftBuffer_fx + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); + /* Nyquist frequency is discarded */ + fftBuffer_fx[1] = 0; + move32(); + } + ELSE + { + /* very low level case - update random seeds and reset FFT buffer; don't fully skip SynthesisSTFT_flt(), because of the buffer updates done there... */ + generate_masking_noise_update_seed_fx( hFdCngCom ); + + set32_fx( fftBuffer_fx, 0, hFdCngCom->fftlen ); + } + + /* Perform STFT synthesis */ + IF( secondary ) + { + SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); + } + ELSE + { + SynthesisSTFT_fx( fftBuffer_fx, maskingNoise_fx, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, 0, hFdCngCom, element_mode, nchan_out ); + } + *exp_out = sub( *exp_out, Q9 ); + move16(); + + /* Add some comfort noise on top of decoded signal */ + IF( return_noise ) + { + Copy32( maskingNoise_fx, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/ + } + ELSE + { + v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/ + } + + return; +} + +/*------------------------------------------------------------------- + * generate_stereo_masking_noise_fx() + * + * Generate additional comfort noise (kind of noise filling) + *-------------------------------------------------------------------*/ + +void generate_stereo_masking_noise_fx( + Word16 *syn, /* i/o: time-domain signal Q_syn*/ + Word16 Q_syn, + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel Q0*/ + const Word16 fadeOut, /* i : only fade out of previous state Q0*/ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ + const Word16 nchan_out /* i : number of output channels Q0*/ +) +{ + HANDLE_FD_CNG_COM hFdCngCom; + Word32 gamma_fx, scale_fx /*, SP_ratio_fx needs to be integrated*/; + Word32 Np_fx[L_FRAME16k]; + Word32 Ns_fx[L_FRAME16k]; + Word32 N1_fx[L_FRAME16k]; + Word32 N2_fx[L_FRAME16k]; + Word16 N1_fx_exp, N2_fx_exp; + Word16 i; + + IF( st->idchan == 0 ) + { + hFdCngCom = st->hFdCngDec->hFdCngCom; +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ +#else + Copy_Scale_sig_16_32_DEPREC( hStereoCng->olapBufferSynth22_fx, Ns_fx, shr( hFdCngCom->frameSize, 1 ), sub( Q6, st->Q_syn ) ); /*Q6*/ +#endif + Copy32( hFdCngCom->olapBufferSynth2_fx, Np_fx, shr( hFdCngCom->frameSize, 1 ) ); /*st->Q_syn*/ + + set32_fx( &Np_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); + set32_fx( &Ns_fx[( hFdCngCom->frameSize / 2 )], 0, shr( hFdCngCom->frameSize, 1 ) ); + + IF( !fadeOut ) + { +#ifdef FIX_ISSUE_1237 + Copy_Scale_sig_16_32_no_sat( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/ +#else + Copy_Scale_sig_16_32_DEPREC( hStereoCng->olapBufferSynth22_fx, hStereoCng->olapBufferSynth22_32fx, hFdCngCom->fftlen, sub( Q15, st->Q_syn ) ); /*Q15*/ +#endif + generate_masking_noise_ivas_fx( N1_fx, &N1_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out ); // N1_fx Q6 + /* Generate masking noise for secondary channel */ + IF( flag_sec_CNA ) + { + generate_masking_noise_ivas_fx( N2_fx, &N2_fx_exp, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out ); // N2_fx Q6 + gamma_fx = L_shr( Mpy_32_32( hStereoCng->c_PS_LT_fx, hStereoCng->c_PS_LT_fx ), 1 ); /*Q30*/ + scale_fx = ONE_IN_Q30; + move32(); + IF( LT_32( gamma_fx, 966367642 /* 0.9 in Q30 */ ) ) + { + Word16 exp_gamma; + exp_gamma = 0; + move16(); + Word16 divisor1; + divisor1 = Inv16( (Word16) L_shr( L_sub( ONE_IN_Q30, gamma_fx ), Q15 ), &exp_gamma ); // Q15-exp_gamma + gamma_fx = L_shl( Mpy_32_16_1( gamma_fx, divisor1 ), exp_gamma ); // Q30 + Word16 exp_gamma1, exp_gamma2, exp_gamma3; + exp_gamma1 = Q1; + exp_gamma2 = Q1; + exp_gamma3 = Q1; + move16(); + move16(); + move16(); + gamma_fx = Sqrt32( L_add( gamma_fx, ONE_IN_Q30 ), &exp_gamma1 ); /*Q31 - exp_gamma1*/ + Word32 temp; + temp = Sqrt32( gamma_fx, &exp_gamma2 ); // Q31-exp_gamma1 + gamma_fx = L_sub( gamma_fx, L_shl( temp, sub( exp_gamma2, exp_gamma1 ) ) ); // Q31-exp_gamma1 + gamma_fx = L_shl( gamma_fx, sub( exp_gamma1, Q1 ) ); // Q30 + Word32 divisor2; + divisor2 = Sqrt32( L_add( ONE_IN_Q30, L_shl( Mpy_32_32( gamma_fx, gamma_fx ), Q1 ) ), &exp_gamma3 ); // Q31 - exp_gamma3 + scale_fx = L_shl( divide3232( ONE_IN_Q30, divisor2 ), add( Q15, exp_gamma3 ) ); // Q30 + } + ELSE + { + gamma_fx = 0; + move16(); + } + + FOR( i = 0; i < 2 * hFdCngCom->frameSize / 4; i++ ) + { + Np_fx[i] = L_add( Np_fx[i], + Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ) ); // Q6 + move32(); + Word32 add2; + add2 = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 + if ( hStereoCng->c_PS_LT_fx < 0 ) + { + add2 = L_negate( add2 ); /*Q6*/ + } + Ns_fx[i] = L_add( Ns_fx[i], add2 ); /*Q6*/ + move32(); + } + FOR( ; i < hFdCngCom->frameSize; i++ ) + { + Np_fx[i] = Mpy_32_32( scale_fx, L_shl( L_add( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 + move32(); + Ns_fx[i] = Mpy_32_32( scale_fx, L_shl( L_sub( N1_fx[i], Mpy_32_32( gamma_fx, L_shl( N2_fx[i], Q1 ) ) ), Q1 ) ); // Q6 + move32(); + IF( hStereoCng->c_PS_LT_fx < 0 ) + { + Ns_fx[i] = L_negate( Ns_fx[i] ); + move32(); + } + } + /* Below code to be converted */ + Word32 scale_fx_tmp = Mpy_32_32( scale_fx, L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ) ); // Q21 + FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ ) + { + hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp, + L_add( L_shr( hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )], Q15 ), + Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ) ) ), + Q14 ); // Q_olap + move16(); + hStereoCng->olapBufferSynth22_fx[i] = (Word16) L_shr( Mpy_32_32( scale_fx_tmp, + L_sub( L_shr( hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )], Q15 ), + Mpy_32_16_1( gamma_fx, hStereoCng->olapBufferSynth22_fx[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ) ) ), + Q14 ); // Q_olap + move16(); + } + } + ELSE + { + FOR( i = 0; i < shr( hFdCngCom->frameSize, 1 ); i++ ) + { + Np_fx[i] = L_add( Np_fx[i], N1_fx[i] ); // Q6 + move32(); + } + Copy32( &N1_fx[( hFdCngCom->frameSize / 2 )], &Np_fx[( hFdCngCom->frameSize / 2 )], shr( hFdCngCom->frameSize, 1 ) ); /*Q6*/ + scale_fx = L_shl( shr( hFdCngCom->fftlen, 1 ), Q22 ); // Q21 + FOR( i = 0; i < hFdCngCom->frameSize; i++ ) + { + hFdCngCom->olapBufferSynth2[i] = (Word16) L_shr( Mpy_32_16_1( scale_fx, hFdCngCom->olapBufferSynth2[( i + ( 5 * ( hFdCngCom->frameSize / 4 ) ) )] ), Q6 ); // Q_olap + move16(); + } + } + + Copy_Scale_sig_32_16( hStereoCng->olapBufferSynth22_32fx, hStereoCng->olapBufferSynth22_fx, hFdCngCom->fftlen, sub( st->Q_syn, 15 ) ); /*st->Q_syn*/ + } + ELSE + { + set16_fx( hFdCngCom->olapBufferSynth2, 0, shr( hFdCngCom->frameSize, 1 ) ); + set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( hFdCngCom->frameSize, 1 ) ); + } + IF( flag_sec_CNA ) + { + Copy_Scale_sig_32_16( Ns_fx, hStereoCng->maskingNoiseS_fx, hFdCngCom->frameSize, 0 ); // Q6 + hStereoCng->enableSecCNA = 1; + move16(); + } + ELSE + { + set16_fx( hStereoCng->olapBufferSynth22_fx, 0, hFdCngCom->frameSize ); + } + + /* add masking noise */ + FOR( i = 0; i < hFdCngCom->frameSize; i++ ) + { + syn[i] = add( syn[i], (Word16) L_shr( Np_fx[i], sub( Q16 + Q6, Q_syn ) ) ); // Q_syn + move16(); + } + } + ELSE IF( hStereoCng->enableSecCNA ) + { + Word16 SP_ratio_fx; + SP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /* Use long-term SP ratio based on L/R synthesis Q15*/ + Word16 prevSP_ratio_fx; + prevSP_ratio_fx = hStereoTD->prevSP_ratio_fx; /* Use long-term SP ratio based on L/R synthesis Q15*/ + move16(); + /* scale and add masking noise */ + FOR( i = 0; i < shr( *hStereoCng->frameSize, 2 ); i++ ) + { + Word16 s; + Word16 scale_fx_tmp; + scale_fx_tmp = BASOP_Util_Divide3216_Scale( L_add( L_mult0( prevSP_ratio_fx, sub( shr( *hStereoCng->frameSize, 2 ), i ) ), L_mult0( SP_ratio_fx, i ) ), shr( *hStereoCng->frameSize, 2 ), &s ); // Q15 + scale_fx_tmp = shl( scale_fx_tmp, s ); + syn[i] = add( syn[i], mult( scale_fx_tmp, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/ + move16(); + } + FOR( ; i < *hStereoCng->frameSize / 2; i++ ) + { + syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/ + move16(); + } + FOR( ; i < *hStereoCng->frameSize; i++ ) + { + syn[i] = add( syn[i], mult( SP_ratio_fx, shr( hStereoCng->maskingNoiseS_fx[i], sub( Q6, Q_syn ) ) ) ); /*Q_syn*/ + move16(); + } + hStereoTD->prevSP_ratio_fx = extract_h( hStereoTD->SP_ratio_LT_fx ); /*Q15*/ + move16(); + } + + return; +} +void generate_masking_noise_lb_dirac_fx( + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + Word32 *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA Q11*/ + const Word16 nCldfbTs, /* i : number of CLDFB slots that will be rendered Q0*/ + const Word16 cna_flag /* i : CNA flag for LB and HB Q0*/ +) +{ + Word16 i; + Word32 *cngNoiseLevel = hFdCngCom->cngNoiseLevel; /*hFdCngCom->cngNoiseLevelExp*/ + Word32 *fftBuffer = hFdCngCom->fftBuffer; /*hFdCngCom->fftBuffer_exp*/ + Word32 *ptr_r; + Word32 *ptr_i; + Word32 *ptr_level; + Word16 *seed = &( hFdCngCom->seed ); + Word32 scale; + Word16 n_samples_out, n_samples_start, n_samples_out_loop; + + push_wmops( "fd_cng_dirac" ); + + /* Init */ + scale = 0; + move32(); + n_samples_out = i_mult( shr( hFdCngCom->frameSize, 4 ), nCldfbTs ); + n_samples_start = 0; + move16(); + Word16 exp_out = Q11; + move16(); + /*LB CLDFB - CNA from STFT*/ + IF( cna_flag ) + { + /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ + IF( GT_16( hFdCngCom->likelihood_noisy_speech, DELTA_MASKING_NOISE_Q15 ) ) + { + /* Compute additional CN level */ + FOR( i = 0; i < 15; i++ ) + { + test(); + test(); + if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) && + GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) && + LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) + { + BREAK; + } + } + + scale = L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ); /* Q30 */ + scale = Mpy_32_16_1( scale, hFdCngCom->likelihood_noisy_speech ); /* Q30 */ + } + } + + /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/ + test(); + IF( cna_flag && tdBuffer != NULL ) + { + WHILE( n_samples_out > 0 ) + { + n_samples_out_loop = s_min( hFdCngCom->frameSize, n_samples_out ); + IF( scale != 0 ) + { + /*Generate LF comfort noise only at first slot, for the whole frame*/ + ptr_level = cngNoiseLevel; /*hFdCngCom->cngNoiseLevelExp*/ + + /* Generate Gaussian random noise in real and imaginary parts of the FFT bins + Amplitudes are adjusted to the estimated noise level cngNoiseLevel_flt in each bin */ + IF( EQ_16( hFdCngCom->startBand, 0 ) ) + { + rand_gauss_fx( &fftBuffer[0], seed, exp_out ); + ptr_r = fftBuffer + 2; /*hFdCngCom->fftBuffer_exp*/ + + Word16 exp2 = sub( 31, hFdCngCom->cngNoiseLevelExp ); + Word32 sqr = Sqrt32( L_shr( Mpy_32_32( scale, *ptr_level ), 1 ), &exp2 ); /* DC component in FFT Q31 - exp2*/ + sqr = L_shl( sqr, exp2 ); /*Q31*/ + fftBuffer[0] = Mpy_32_32( fftBuffer[0], sqr ); /* DC component in FFT Q31 - hFdCngCom->fftBuffer_exp*/ + move32(); + ptr_level++; + } + ELSE + { + fftBuffer[0] = 0; + move32(); + set32_fx( fftBuffer + 2, 0, shl( sub( hFdCngCom->startBand, 1 ), 1 ) ); + ptr_r = fftBuffer + shl( hFdCngCom->startBand, 1 ); /*hFdCngCom->fftBuffer_exp*/ + } + ptr_i = ptr_r + 1; /*hFdCngCom->fftBuffer_exp*/ + + FOR( ; ptr_level < cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); ptr_level++ ) + { + rand_gauss_fx( ptr_r, seed, exp_out ); + Word16 exp2 = hFdCngCom->cngNoiseLevelExp; + Word32 mpy2 = Sqrt32( Mpy_32_32( scale, *ptr_level ), &exp2 ); /*Q31 - exp2*/ + ( *ptr_r ) = L_shl( Mpy_32_32( *ptr_r, mpy2 ), exp2 ); /*Q31 - hFdCngCom->fftBuffer_exp*/ + move32(); + ptr_r += 2; + + /* Imaginary part in FFT bins */ + rand_gauss_fx( ptr_i, seed, exp_out ); + ( *ptr_i ) = L_shl( Mpy_32_32( *ptr_i, mpy2 ), exp2 ); /*Q31 - hFdCngCom->fftBuffer_exp*/ + move32(); + ptr_i += 2; + } + /* Remaining FFT bins are set to zero */ + set32_fx( fftBuffer + shl( hFdCngCom->stopFFTbin, 1 ), 0, sub( hFdCngCom->fftlen, shl( hFdCngCom->stopFFTbin, 1 ) ) ); + /* Nyquist frequency is discarded */ + fftBuffer[1] = 0; + move32(); + + /* Perform STFT synthesis */ + SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + scale_sig32( tdBuffer + n_samples_start, n_samples_out_loop, Q9 ); // Q2 -> Q11 + } + + ELSE + { + /* very low level case - update random seeds */ + generate_masking_noise_update_seed_fx( hFdCngCom ); + + set32_fx( fftBuffer, 0, hFdCngCom->fftlen ); + /* Perform STFT synthesis */ + SynthesisSTFT_dirac_fx( fftBuffer, tdBuffer + n_samples_start, hFdCngCom->olapBufferSynth2_fx, hFdCngCom->olapWinSyn_fx, n_samples_out_loop, hFdCngCom ); + } + hFdCngCom->fftBuffer_exp = 31 - 11; + move16(); + n_samples_out = sub( n_samples_out, hFdCngCom->frameSize ); + n_samples_start = add( n_samples_start, hFdCngCom->frameSize ); + } + } + + pop_wmops(); + + return; +} +void generate_masking_noise_dirac_ivas_fx( + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA q_input*/ + Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer q_cldfb*/ + Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer q_cldfb*/ + const Word16 slot_index, /* i : CLDFB slot index Q0*/ + const Word16 cna_flag, /* i : CNA flag for LB and HB Q0*/ + const Word16 fd_cng_flag, /* i : FD-CNG flag for HB Q0*/ + Word16 q_input, + Word16 *q_cldfb ) +{ + Word16 i; + Word32 *ptr_level_fx; + Word16 *seed = &( hFdCngCom->seed ); + Word32 scale_fx; + Word16 q_scale, q_shift, q_ptr_level; + + push_wmops( "fd_cng_dirac" ); + + /* Init */ + scale_fx = 0; + move32(); + + /* Resample CLDFB memories if necessary*/ + IF( NE_16( i_mult( h_cldfb->no_channels, h_cldfb->no_col ), hFdCngCom->frameSize ) ) + { + resampleCldfb_ivas_fx( h_cldfb, hFdCngCom->frameSize * FRAMES_PER_SEC ); + } + + set32_fx( Cldfb_RealBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( Cldfb_ImagBuffer_fx, 0, CLDFB_NO_CHANNELS_MAX ); + + /*LB CLDFB - CNA from STFT*/ + IF( cna_flag != 0 ) + { + /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ + IF( hFdCngCom->likelihood_noisy_speech > 0 ) + { + /* Compute additional CN level */ + FOR( i = 0; i < 15; i++ ) + { + test(); + test(); + if ( ( EQ_16( hFdCngCom->CngBandwidth, scaleTable_cn_dirac[i].bwmode ) ) && + ( GE_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateFrom ) ) && + ( LT_32( hFdCngCom->CngBitrate, scaleTable_cn_dirac[i].bitrateTo ) ) ) + { + BREAK; + } + } + + scale_fx = L_shr( L_deposit_h( scaleTable_cn_dirac[i].scale_ivas ), Q3 ); /* Q27 */ + scale_fx = Mpy_32_16_1( scale_fx, hFdCngCom->likelihood_noisy_speech ); + } + } + /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/ + IF( cna_flag && tdBuffer_fx != NULL ) + { + *q_cldfb = q_input; + move16(); + IF( scale_fx != 0 ) + { + /* LF CLDFB*/ + cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[( hFdCngCom->numCoreBands * slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb ); + } + ELSE + { + /* LB ana CLDFB*/ + cldfbAnalysis_ts_fx_fixed_q( &( tdBuffer_fx[( hFdCngCom->numCoreBands * slot_index )] ), Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hFdCngCom->numCoreBands, h_cldfb, q_cldfb ); + } + } + + /*HF CLDFB - CNA and/or FD-CNG*/ + if ( fd_cng_flag ) + { + scale_fx = L_add( scale_fx, ONE_IN_Q27 ); // 1 in Q27 + } + IF( scale_fx != 0 ) + { + q_scale = 27; + move16(); + q_shift = norm_l( scale_fx ); + scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/ + q_scale = add( q_scale, q_shift ); + scale_fx = Mpy_32_32( scale_fx, Mpy_32_16_1( L_mult( h_cldfb->scale, h_cldfb->scale ), CLDFB_SCALING ) ); // Q = q_scale + 2 * Q8 - 34 + q_scale = sub( add( q_scale, 2 * Q8 ), 31 ); + ptr_level_fx = hFdCngCom->cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); /*Q31 - hFdCngCom->cngNoiseLevelExp*/ + q_ptr_level = sub( 31, hFdCngCom->cngNoiseLevelExp ); + + FOR( i = hFdCngCom->numCoreBands; i < hFdCngCom->regularStopBand; i++ ) + { + Word32 num; + Word16 exp, q_num; + q_shift = norm_l( scale_fx ); + scale_fx = L_shl( scale_fx, q_shift ); /*q_scale+q_shift*/ + q_scale = add( q_scale, q_shift ); + num = Mpy_32_32( scale_fx, *ptr_level_fx ); /*q_num*/ + q_num = sub( add( q_scale, q_ptr_level ), 31 ); + exp = sub( 31, q_num ); + num = Sqrt32( num, &exp ); /*Q31 - exp*/ + /* Real part in CLDFB band */ + rand_gauss_fx( &Cldfb_RealBuffer_fx[i], seed, *q_cldfb ); + Cldfb_RealBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_RealBuffer_fx[i], num ), exp ); + move32(); + /* Imaginary part in CLDFB band */ + rand_gauss_fx( &Cldfb_ImagBuffer_fx[i], seed, *q_cldfb ); + Cldfb_ImagBuffer_fx[i] = L_shl( Mpy_32_32( Cldfb_ImagBuffer_fx[i], num ), exp ); + move32(); + + ptr_level_fx++; + } + } + + pop_wmops(); + + return; +} + + +/*------------------------------------------------------------------- + * FdCngDecodeMDCTStereoSID() + * + * Decode FD-Cng parameters for CNG in MDCT-Stereo mode from the bitstream + * + *-------------------------------------------------------------------*/ + +void FdCngDecodeMDCTStereoSID_fx( + CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ +) +{ + DEC_CORE_HANDLE sts[CPE_CHANNELS]; + HANDLE_FD_CNG_COM hFdCngCom; + Word32 *ms_ptr_fx[CPE_CHANNELS]; + Word32 *lr_ptr_fx[CPE_CHANNELS]; + Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; + Word32 gain_fx[CPE_CHANNELS]; + Word16 indices[FD_CNG_stages_37bits]; + Word16 N, i, ch, p, stages; + Word16 is_out_ms; + Word32 *invTrfMatrix_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + Word16 shift, exp_diff, max_exp_idx; + Word16 exp_arr[NPART]; + Word32 tmp32, tmp32_arr[NPART]; + + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31 + + is_out_ms = 0; + move16(); + if ( hCPE->hCoreCoder[0]->cng_sba_flag ) + { + is_out_ms = 1; + move16(); + } + + N = 0; /* to avoid compilation warning */ + move16(); + + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + sts[ch] = hCPE->hCoreCoder[ch]; + ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; /*Q20*/ + lr_ptr_fx[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; /*Q18*/ + } + + /* decode noise shapes and gains */ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + sts[ch] = hCPE->hCoreCoder[ch]; + hFdCngCom = ( sts[ch]->hFdCngDec )->hFdCngCom; + N = hFdCngCom->npart; + move16(); + hFdCngCom->sid_frame_counter = add( hFdCngCom->sid_frame_counter, 1 ); /*Q0*/ + move16(); + + IF( ch ) + { + stages = FD_CNG_JOINT_stages_25bits; + move16(); + } + ELSE + { + stages = FD_CNG_stages_37bits; + move16(); + } + + /* read bitstream */ + FOR( i = 0; i < stages; i++ ) + { + indices[i] = get_next_indice_fx( sts[ch], bits_37bits[i] ); /*Q0*/ + move16(); + } + { + gain_fx[ch] = Mpy_32_32( L_shl( L_sub( get_next_indice_fx( sts[ch], 7 ), GAIN_Q_OFFSET_IVAS_FX ), Q20 ), TWO_BY_THREE_Q31 /* 2/3 in Q31 */ ); // Q20 + move32(); + } + + /* MSVQ decoder */ + shift = find_guarded_bits_fx( N ); + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, ms_ptr_fx[ch], NULL, 7 ); // Q20 - shift + + Scale_sig32( ms_ptr_fx[ch], N, shift ); // Q20 + } + + dtx_read_padding_bits_fx( sts[1], mult( sub( IVAS_SID_5k2, 4400 ), ONE_BY_FRAMES_PER_SEC_Q15 ) ); + + IF( sts[0]->hFdCngDec->hFdCngCom->no_side_flag ) + { + set32_fx( ms_ptr_fx[1], 0, NPART ); + } + + IF( EQ_16( is_out_ms, 0 ) ) + { + inverseMS_fx( N, ms_ptr_fx[0], ms_ptr_fx[1], ONE_IN_Q31 ); + } + + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + max_exp_idx = 0; + move16(); + hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom; + FOR( p = 0; p < N; p++ ) + { + tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20 + tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); /*Q31 - exp_arr[p]*/ + move32(); + if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) ) + { + max_exp_idx = p; /*Q0*/ + move16(); + } + } + + // Bringing in same exponent + FOR( p = 0; p < N; p++ ) + { + lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); /*Q31 - exp_arr[max_exp_idx]*/ + move32(); + } + + hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx]; + move16(); + + scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); + + hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; + move16(); + + lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); + } + + test(); + IF( EQ_16( hCPE->nchan_out, 1 ) && LE_32( hCPE->last_element_brate, IVAS_SID_5k2 ) ) + { + /* create proper M noise shape in channel zero after gains have been applied */ + exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp ); + move16(); + FOR( p = 0; p < N; p++ ) + { + IF( GT_16( exp_diff, 0 ) ) + { + sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) ); /*Q18*/ + move32(); + } + ELSE + { + sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], sub( 1, exp_diff ) ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); /*Q18*/ + move32(); + } + } + IF( LT_16( exp_diff, 0 ) ) + { + sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) ); + move16(); + } + } + + return; +} + + +/*------------------------------------------------------------------- + * FdCngDecodeDiracMDCTStereoSID_fx() + * + * Decode FD-CNG parameters for CNG in 2TC DirAC mode from the bitstream + *-------------------------------------------------------------------*/ + +void FdCngDecodeDiracMDCTStereoSID_fx( + CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ +) +{ + DEC_CORE_HANDLE sts[CPE_CHANNELS]; + HANDLE_FD_CNG_COM hFdCngCom; + Word32 *ms_ptr_fx[CPE_CHANNELS]; + Word32 *lr_ptr_fx[CPE_CHANNELS]; + Word32 logNoiseEst_fx[CPE_CHANNELS][NPART]; + Word32 gain_fx[CPE_CHANNELS]; + Word16 indices[FD_CNG_stages_37bits]; + Word16 N, i, ch, p; + Word32 *invTrfMatrix_fx; + Word32 tmpRAM_fx[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; + Word16 shift, exp_diff, max_exp_idx; + Word16 exp_arr[NPART]; + Word32 tmp32, tmp32_arr[NPART]; + + invTrfMatrix_fx = (Word32 *) tmpRAM_fx; /* dynamically filled */ + create_IDCT_N_Matrix_fx( invTrfMatrix_fx, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, FDCNG_VQ_MAX_LEN * FDCNG_VQ_DCT_MAXTRUNC ); // Q31 + + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + sts[ch] = hCPE->hCoreCoder[ch]; + ms_ptr_fx[ch] = &logNoiseEst_fx[ch][0]; /*Q20*/ + lr_ptr_fx[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; /*Q20*/ + ( sts[ch]->hFdCngDec )->hFdCngCom->sid_frame_counter++; /*Q18*/ + } + + /* decode noise shapes and gains */ + hFdCngCom = ( sts[0]->hFdCngDec )->hFdCngCom; + N = hFdCngCom->npart; /*Q0*/ + move16(); + + /* read bitstream */ + FOR( i = 0; i < FD_CNG_stages_37bits; i++ ) + { + indices[i] = get_next_indice_fx( sts[0], bits_37bits[i] ); /*Q0*/ + move16(); + } + gain_fx[0] = Mpy_32_32( L_shl( L_sub( get_next_indice_fx( sts[0], 7 ), GAIN_Q_OFFSET_IVAS_FX ), Q20 ), TWO_BY_THREE_Q31 /* 2/3 in Q31 */ ); // Q20 + move32(); + + gain_fx[1] = gain_fx[0]; /*Q20*/ + move32(); + + /* MSVQ decoder */ + shift = find_guarded_bits_fx( N ); + msvq_dec_fx( ivas_cdk_37bits_fx, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix_fx, ms_ptr_fx[0], NULL, 7 ); // Q20 - shift + + Scale_sig32( ms_ptr_fx[0], N, shift ); // Q20 + + Copy32( ms_ptr_fx[0], ms_ptr_fx[1], N ); /*Q20*/ + + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + max_exp_idx = 0; + move16(); + hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom; + + FOR( p = 0; p < N; p++ ) + { + tmp32 = L_add( ms_ptr_fx[ch][p], gain_fx[ch] ); // Q20 + tmp32_arr[p] = BASOP_util_Pow2( Mpy_32_32( tmp32, LOG_10_BASE_2_BY_10_Q31 ), Q11, &exp_arr[p] ); /*Q31 - exp_arr[p]*/ + move32(); + if ( LT_16( exp_arr[max_exp_idx], exp_arr[p] ) ) + { + max_exp_idx = p; /*Q0*/ + move16(); + } + } + + // Bringing in same exponent + FOR( p = 0; p < N; p++ ) + { + lr_ptr_fx[ch][p] = L_shl( tmp32_arr[p], sub( exp_arr[p], exp_arr[max_exp_idx] ) ); /*Q20*/ + move32(); + } + + hFdCngCom->sidNoiseEstExp = exp_arr[max_exp_idx]; /*Q0*/ + move16(); + + /* NB last band energy compensation */ + test(); + IF( hFdCngCom->CngBandwidth == NB ) + { + lr_ptr_fx[ch][( N - 1 )] = Mpy_32_32( lr_ptr_fx[ch][( N - 1 )], NB_LAST_BAND_SCALE_Q31 ); /*Q20*/ + move32(); + } + ELSE IF( EQ_16( hFdCngCom->CngBandwidth, SWB ) && LE_32( hFdCngCom->CngBitrate, ACELP_13k20 ) ) + { + lr_ptr_fx[ch][( N - 1 )] = Mpy_32_32( lr_ptr_fx[ch][( N - 1 )], SWB_13k2_LAST_BAND_SCALE_Q31 ); /*Q20*/ + move32(); + } + + scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), hFdCngCom->cngNoiseLevel, 1 ); + + hFdCngCom->cngNoiseLevelExp = hFdCngCom->sidNoiseEstExp; + move16(); + + lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); + } + sts[0]->hFdCngDec->hFdCngCom->coherence_fx = 0; + move16(); + sts[1]->hFdCngDec->hFdCngCom->coherence_fx = 0; + move16(); + + IF( EQ_16( hCPE->nchan_out, 1 ) ) + { + /* create proper M noise shape in channel zero after gains have been applied */ + exp_diff = sub( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, sts[1]->hFdCngDec->hFdCngCom->sidNoiseEstExp ); + FOR( p = 0; p < N; p++ ) + { + IF( exp_diff > 0 ) + { + sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], add( exp_diff, 1 ) ) ); /*Q18*/ + move32(); + } + ELSE + { + sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = L_add( L_shr( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p], sub( 1, exp_diff ) ), L_shr( sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p], 1 ) ); /*Q18*/ + move32(); + } + } + IF( exp_diff < 0 ) + { + sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp = add( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEstExp, negate( exp_diff ) ); + move16(); + } + } + + return; +} + + #ifdef IVAS_CODE_CNG /*------------------------------------------------------------------- diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c deleted file mode 100644 index 2b8091305..000000000 --- a/lib_dec/init_dec.c +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "ivas_cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*----------------------------------------------------------------------* - * init_decoder() - * - * Initialization of static variables for the decoder - *----------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------* - * reset_preecho_dec() - * - * Initialization of static variables for pre-echo - *----------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------* - * destroy_cldfb_decoder_flt() - * - * Free memory which was allocated in init_decoder() - *----------------------------------------------------------------------*/ -void destroy_cldfb_decoder_ivas_fx( - Decoder_State *st /* o : Decoder static variables structure */ -) -{ - /* CLDFB BPF & resampling tools */ - deleteCldfb_ivas_fx( &st->cldfbAna ); /* delete analysis at max. sampling rate 48kHz */ - deleteCldfb_ivas_fx( &st->cldfbBPF ); /* delete analysis BPF at max. internal sampling rate 16kHz */ - deleteCldfb_ivas_fx( &st->cldfbSyn ); /* delete synthesis at output sampling rate */ - deleteCldfb_ivas_fx( &st->cldfbSynHB ); - - deleteFdCngDec_fx( &st->hFdCngDec ); - - return; -} diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index a96774113..caa164df9 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1822,3 +1822,18 @@ void destroy_cldfb_decoder_fx( return; } + +void destroy_cldfb_decoder_ivas_fx( + Decoder_State *st /* o : Decoder static variables structure */ +) +{ + /* CLDFB BPF & resampling tools */ + deleteCldfb_ivas_fx( &st->cldfbAna ); /* delete analysis at max. sampling rate 48kHz */ + deleteCldfb_ivas_fx( &st->cldfbBPF ); /* delete analysis BPF at max. internal sampling rate 16kHz */ + deleteCldfb_ivas_fx( &st->cldfbSyn ); /* delete synthesis at output sampling rate */ + deleteCldfb_ivas_fx( &st->cldfbSynHB ); + + deleteFdCngDec_fx( &st->hFdCngDec ); + + return; +} diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 459dcc4d4..5a948bdfa 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -3787,3 +3787,36 @@ static void ivas_param_mc_bs_decode_parameter_values_fx( return; } + +Word16 param_mc_get_num_cldfb_syntheses_ivas_fx( + Decoder_Struct *st_ivas /* i : Parametric MC handle */ +) +{ + Word16 num_cldfb_syntheses; + + num_cldfb_syntheses = 0; + move16(); + + /* sanity check*/ + IF( st_ivas->hParamMC == NULL ) + { + assert( 0 && "ParamMC handle does not exist!\n" ); + } + + test(); + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + num_cldfb_syntheses = 2; + move16(); + } + ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + { + num_cldfb_syntheses = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); + } + ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) ) + { + num_cldfb_syntheses = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); + } + + return num_cldfb_syntheses; +} diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c deleted file mode 100644 index 0d9ee2710..000000000 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "ivas_prot_fx.h" - -Word16 param_mc_get_num_cldfb_syntheses_ivas_fx( - Decoder_Struct *st_ivas /* i : Parametric MC handle */ -) -{ - Word16 num_cldfb_syntheses; - - num_cldfb_syntheses = 0; - move16(); - - /* sanity check*/ - IF( st_ivas->hParamMC == NULL ) - { - assert( 0 && "ParamMC handle does not exist!\n" ); - } - - test(); - IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - num_cldfb_syntheses = 2; - move16(); - } - ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) - { - num_cldfb_syntheses = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); - } - ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) ) - { - num_cldfb_syntheses = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); - } - - return num_cldfb_syntheses; -} diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c deleted file mode 100644 index 6b80108a8..000000000 --- a/lib_dec/swb_bwe_dec.c +++ /dev/null @@ -1,681 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "rom_com.h" -#include "basop_util.h" -#include "basop_proto_func.h" -#include "wmc_auto.h" - - -static Word16 para_pred_bws_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *signal_wb_fx, /* i : wideband frequency signal Q_syn */ - Word16 *SWB_fenv_fx, /* o : frequency-domain BWE envelope Q1 */ - Word16 Q_syn ) -{ - Word16 i, j, k; - Word16 mode; - Word16 tmp, tmp_den, tmp_num; - Word32 L_tmp, L_tmp_max; - Word16 exp; - Word16 *input_hi_fx; - Word32 *mea; - Word16 peak_fx, mag_fx; - Word32 mean_fx[7], peak_32_fx; - Word32 avrg1_fx, avrg2_fx, min_fx; - Word16 att_fx; - Word16 coder_type = st_fx->coder_type; - move16(); - - mode = NORMAL; - move16(); - - k = 0; - move16(); - input_hi_fx = &signal_wb_fx[SHARP_WIDTH]; /*Q_syn*/ - FOR( i = 0; i < 7; i++ ) - { - peak_fx = 0; - move16(); - mean_fx[i] = 0; - move16(); - FOR( j = 0; j < SHARP_WIDTH; j++ ) - { - mag_fx = abs_s( *input_hi_fx ); /*Q_syn*/ - peak_fx = s_max( peak_fx, mag_fx ); /*Q_syn*/ - mean_fx[i] = L_add( mean_fx[i], L_deposit_l( mag_fx ) ); /*Q_syn*/ - move32(); - input_hi_fx++; - } - - IF( LT_16( Q_syn, 11 ) ) - { - tmp = 1; - move16(); - } - ELSE - { - tmp = 0; - move16(); - if ( GT_16( shr( peak_fx, 3 ), shl( 1, Q_syn ) ) ) - { - tmp = 1; - move16(); - } - } - IF( tmp > 0 ) - { - L_tmp = L_msu0( Mult_32_16( L_shl( mean_fx[i], 10 ) /*Q_syn + 10*/, 18432 /*4.5f Q12*/ ), peak_fx /*Q_syn*/, 4544 /*35.5 (SHARP_WIDTH + 3.5f)Q7*/ ); - if ( L_tmp < 0 ) - { - k = add( k, 1 ); - } - } - } - - avrg1_fx = L_deposit_l( 0 ); - avrg2_fx = L_deposit_l( 0 ); - FOR( i = 1; i < 4; i++ ) - { - avrg1_fx = L_add( avrg1_fx, mean_fx[i] ); /*Q_syn*/ - avrg2_fx = L_add( avrg2_fx, mean_fx[i + 3] ); /*Q_syn*/ - } - avrg1_fx = Mult_32_16( avrg1_fx, 10923 /* 1/3 -> Q15 -> 10923 */ ); /*Q_syn + Q15 - 15*/ - avrg2_fx = Mult_32_16( avrg2_fx, 10923 /* 1/3 -> Q15 -> 10923 */ ); /*Q_syn + Q15 - 15*/ - - min_fx = L_add( 2147483647, 0 ); /*2^31 */ - peak_32_fx = L_deposit_l( 0 ); - FOR( i = 4; i < 7; i++ ) - { - IF( GT_32( mean_fx[i], L_shl( avrg2_fx, 1 ) ) ) - { - exp = norm_l( mean_fx[i] ); - IF( LT_16( exp, 16 ) ) - { - tmp_den = extract_l( L_shr( mean_fx[i], sub( 16, exp ) ) ); /*Qsyn - 16 + exp */ - tmp_num = extract_l( L_shr( avrg2_fx, sub( 15, exp ) ) ); /*Qsyn - 16 + exp */ - } - ELSE - { - tmp_den = extract_l( mean_fx[i] ); - tmp_num = extract_l( L_shl( avrg2_fx, 1 ) ); - } - - tmp_den = div_s( 1, tmp_den ); - - tmp = i_mult( tmp_num, tmp_den ); /*Q15 */ - - mean_fx[i] = Mult_32_16( mean_fx[i], tmp ); /*Q_syn + Q15 - 15*/ - move32(); - } - min_fx = L_min( min_fx, mean_fx[i] ); - peak_32_fx = L_max( peak_32_fx, mean_fx[i] ); - } - - IF( GT_16( st_fx->tilt_wb_fx, 16384 /*8 in Q11*/ ) ) - { - IF( GT_16( st_fx->tilt_wb_fx, 30720 /*15.0f in Q11*/ ) ) - { - min_fx = peak_32_fx; - move32(); - } - ELSE - { - tmp = extract_l( L_shr( L_mult0( st_fx->tilt_wb_fx, 17476 ), 14 ) ); /*Q15 */ - min_fx = Mult_32_16( peak_32_fx, tmp ); - } - } - - test(); - IF( peak_32_fx == 0 || min_fx == 0 ) - { - set16_fx( SWB_fenv_fx, 0, SWB_FENV ); - } - ELSE - { - exp = norm_l( peak_32_fx ); - IF( LT_16( exp, 16 ) ) - { - tmp_den = extract_l( L_shr( peak_32_fx, sub( 16, exp ) ) ); /*Qsyn - 16 + exp */ - tmp = div_s( 16384, tmp_den ); /*Q15+14 - (Qsyn - 16 + exp) */ - tmp_num = extract_l( L_shr( min_fx, sub( 16, exp ) ) ); /*Qsyn - 16 + exp */ - tmp = extract_l( L_shr( L_mult0( tmp_num, tmp ), 14 ) ); /*Q15 */ - } - ELSE - { - tmp_den = extract_l( peak_32_fx ); /*Qsyn */ - exp = norm_s( tmp_den ); - tmp = div_s( shl( 1, sub( 14, exp ) ), tmp_den ); /*Q 29-exp - Qsyn */ - tmp_num = extract_l( min_fx ); /*Qsyn */ - tmp = extract_l( L_shr( L_mult0( tmp_num, tmp ), sub( 14, exp ) ) ); /*Q15 */ - } - - j = 0; - move16(); - mea = &mean_fx[4]; - L_tmp_max = L_shl( 32767, add( Q_syn, 5 ) ); - FOR( i = 0; i < SWB_FENV; i++ ) - { - if ( EQ_16( j, 5 ) ) - { - mea++; - j = 0; - move16(); - } - j = add( j, 1 ); - L_tmp = L_min( Mult_32_16( *mea, tmp ), L_tmp_max ); - SWB_fenv_fx[i] = extract_l( L_shr( L_tmp, add( Q_syn, 5 ) ) ); - move16(); - } - } - - j = 0; - move16(); - FOR( i = SWB_FENV / 2; i < SWB_FENV; i++ ) - { - tmp = sub( 32767, i_mult( j, 2341 ) ); - SWB_fenv_fx[i] = mult_r( SWB_fenv_fx[i], tmp ); - move16(); - j = add( j, 1 ); - } - - IF( GT_32( avrg1_fx, L_shl( avrg2_fx, 3 ) ) ) - { - FOR( i = 0; i < SWB_FENV; i++ ) - { - SWB_fenv_fx[i] = shr( SWB_fenv_fx[i], 1 ); - move16(); - } - } - - test(); - test(); - test(); - test(); - test(); - IF( NE_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->last_codec_mode, MODE1 ) && - ( GT_32( st_fx->enerLH_fx, L_shr( st_fx->prev_enerLH_fx, 1 ) ) && LT_32( L_shr( st_fx->enerLH_fx, 1 ), st_fx->prev_enerLH_fx ) ) && - ( GT_32( st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx, 1 ) ) && LT_32( L_shr( st_fx->enerLL_fx, 1 ), st_fx->prev_enerLL_fx ) ) ) - { - FOR( i = 0; i < SWB_FENV; i++ ) - { - test(); - IF( NE_16( st_fx->prev_coder_type, coder_type ) && GT_16( mult_r( SWB_fenv_fx[i], 16384 /*1/2.0f in Q15*/ ), st_fx->prev_SWB_fenv_fx[i] ) ) - { - SWB_fenv_fx[i] = round_fx( L_mac( L_mult( SWB_fenv_fx[i], 3277 /*0.1f in Q15*/ ), st_fx->prev_SWB_fenv_fx[i], 29491 /*0.9f in Q15*/ ) ); - move16(); - } - ELSE - { - SWB_fenv_fx[i] = round_fx( L_mac( L_mult( SWB_fenv_fx[i], st_fx->attenu_fx ), st_fx->prev_SWB_fenv_fx[i], sub( 32767 /*1.0f in Q15*/, st_fx->attenu_fx ) ) ); - move16(); - } - } - - IF( LT_16( st_fx->attenu_fx, 29491 /*0.9f in Q15*/ ) ) - { - st_fx->attenu_fx = add( st_fx->attenu_fx, 1638 /*0.05f in Q15*/ ); - move16(); - } - } - ELSE - { - test(); - test(); - test(); - test(); - IF( NE_32( st_fx->core_brate, st_fx->last_core_brate ) || ( GT_32( st_fx->enerLH_fx, L_shr( st_fx->prev_enerLH_fx, 1 ) ) && LT_32( L_shr( st_fx->enerLH_fx, 1 ), st_fx->prev_enerLH_fx ) ) || - ( GT_32( st_fx->enerLL_fx, L_shr( st_fx->prev_enerLL_fx, 1 ) ) && LT_32( L_shr( st_fx->enerLL_fx, 1 ), st_fx->prev_enerLL_fx ) ) ) - { - FOR( i = 0; i < SWB_FENV; i++ ) - { - if ( GT_16( mult_r( SWB_fenv_fx[i], 16384 /*0.5f in Q15*/ ), st_fx->prev_SWB_fenv_fx[i] ) ) - { - SWB_fenv_fx[i] = st_fx->prev_SWB_fenv_fx[i]; - move16(); - } - } - } - - FOR( i = 0; i < SWB_FENV; i++ ) - { - SWB_fenv_fx[i] = round_fx( L_mac( L_mult( SWB_fenv_fx[i], 29491 /*0.9f in Q15*/ ), st_fx->prev_SWB_fenv_fx[i], 3277 /*0.1f in Q15*/ ) ); - move16(); - } - st_fx->attenu_fx = 3277; /*Q15*/ - move16(); - } - - if ( GT_16( k, 3 ) ) - { - mode = HARMONIC; - move16(); - } - - - att_fx = i_mult( sub( N_WS2N_FRAMES, st_fx->bws_cnt ), 819 ); /*15 */ - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - FOR( i = 0; i < 4; i++ ) - { - SWB_fenv_fx[i] = mult_r( SWB_fenv_fx[i], att_fx ); - move16(); /*Q1 */ - } - } - - FOR( i = 4; i < SWB_FENV; i++ ) - { - SWB_fenv_fx[i] = mult_r( SWB_fenv_fx[i], att_fx ); - move16(); /*Q1 */ - } - - return mode; -} - - -/*-------------------------------------------------------------------* - * WB_BWE_gain_deq() - * - * Decoding of WB parameters - *-------------------------------------------------------------------*/ - - -Word16 swb_bwe_dec_fx32( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 output_fx[], /* i : synthesis @internal Fs : Q11 */ - Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis : Q11 */ - Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis : Q_syn_hb */ - Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - Word16 output_frame /* i : frame length */ -) -{ - Word16 L; - Word16 mode; - Word16 idxGain; - Word16 i, j, l_subfr; - Word16 fb_band_begin; - Word16 frica_flag = 0; - move16(); - Word16 ener_adjust_quan_fx; - Word16 fb_ener_adjust_fx = 0; - move16(); - Word16 scl, new_input_fx_exp, ysynth_frame_size; - Word16 Q_syn, Q_syn_hb, tmp, tmp2, q_tmp, Qsynth_fx16; - - Word16 ysynth_fx[L_FRAME48k]; - Word16 SWB_fenv_fx[SWB_FENV]; - Word16 SWB_tenv_fx[SWB_TENV]; - Word16 synth_fx16[L_FRAME48k]; - Word16 hb_synth_fx16[L_FRAME48k]; - - Word32 L_tmp; - Word32 yerror_fx[L_FRAME48k]; - Word32 ysynth_fx32[L_FRAME48k]; - Word32 SWB_tenv_tmp_fx[SWB_TENV]; - Word32 wtda_synth_fx[2 * L_FRAME48k]; - - FD_BWE_DEC_HANDLE hBWE_FD; - hBWE_FD = st_fx->hBWE_FD; - - /*---------------------------------------------------------------------* - * SWB BWE decoding - *---------------------------------------------------------------------*/ - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) - { - /* todo - wtda() does not support L_FRAME length; thus temporarily resample the signal */ - /* todo - delay output[] by 1.25ms ? */ - L_lerp_fx_q11( output_fx, ysynth_fx32, L_FRAME16k, st_fx->L_frame ); - - /* windowing of the ACELP core synthesis */ - wtda_fx32( ysynth_fx32, wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx32, ALDO_WINDOW, ALDO_WINDOW, /*st_fx->L_frame*/ L_FRAME16k ); - - /* DCT of the ACELP core synthesis */ - new_input_fx_exp = 11; - move16(); - direct_transform_fx( wtda_synth_fx, ysynth_fx32, 0, /*st_fx->L_frame*/ L_FRAME16k, &new_input_fx_exp, st_fx->element_mode ); - ysynth_frame_size = L_FRAME16k; - move16(); - } - ELSE - { - /* windowing of the ACELP core synthesis */ - wtda_fx32( synth_fx, wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx32, ALDO_WINDOW, ALDO_WINDOW, output_frame ); - - /* DCT of the ACELP core synthesis */ - new_input_fx_exp = 11; - move16(); - direct_transform_fx( wtda_synth_fx, ysynth_fx32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode ); - ysynth_frame_size = output_frame; - move16(); - } - - /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ - scl = sub( 16 + 11, new_input_fx_exp ); - /* Possible to Upscale? */ - IF( scl > 0 ) - { - /* Yes */ - /* Calc Room to Upscale */ - Q_syn = sub( Find_Max_Norm32( ysynth_fx32, ysynth_frame_size ), 3 ); - /* Stay within MAX_Q_NEW_INPUT */ - scl = s_min( Q_syn, scl ); - } - /*Don't upscale if already in 15 bits*/ - IF( GT_16( scl, 15 ) ) - { - FOR( i = 0; i < ysynth_frame_size; i++ ) - { - ysynth_fx[i] = extract_l( ysynth_fx32[i] ); - move16(); - } - Q_syn = new_input_fx_exp; - move16(); - } - ELSE - { - Copy_Scale_sig32_16( ysynth_fx32, ysynth_fx, ysynth_frame_size, scl ); - Q_syn = add( sub( new_input_fx_exp, 16 ), scl ); - } - - IF( !st_fx->bfi ) - { - IF( st_fx->bws_cnt > 0 ) - { - /* estimate parameters */ - mode = para_pred_bws_fx( st_fx, ysynth_fx, SWB_fenv_fx, Q_syn ); - } - ELSE - { - /* de-quantization */ - mode = swb_bwe_gain_deq_fx( st_fx, ACELP_CORE, SWB_tenv_fx, SWB_fenv_fx, 0, -1 ); - } - - L = SWB_FENV; - move16(); - if ( EQ_16( mode, TRANSIENT ) ) - { - L = SWB_FENV_TRANS; - move16(); - } - - L_tmp = 0; - move32(); - FOR( i = 0; i < L; i++ ) - { - L_tmp = L_add( L_tmp, L_deposit_l( SWB_fenv_fx[i] ) ); - } - q_tmp = norm_s( L ); - tmp = div_s( shl( 1, sub( 14, q_tmp ) ), L ); /*Q(29-q_tmp) */ - L_tmp = Mpy_32_16_1( L_tmp, tmp ); /*Q(1+29-q_tmp+1-16)->Q(15-q_tmp) */ - st_fx->prev_ener_shb_fx = round_fx( L_shl( L_tmp, add( q_tmp, 2 ) ) ); /*Q1 */ - move16(); - } - ELSE - { - /* SHB FEC */ - - IF( NE_16( hBWE_FD->prev_mode, TRANSIENT ) ) - { - mode = hBWE_FD->prev_mode; - move16(); - } - ELSE - { - mode = NORMAL; - move16(); - } - - Copy( st_fx->prev_SWB_fenv_fx, SWB_fenv_fx, SWB_FENV ); - } - - /* reconstruction of MDCT spectrum of the error signal */ - set32_fx( yerror_fx, 0, output_frame ); - - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl ); - } - ELSE - { - SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl ); - } - - test(); - IF( EQ_16( hBWE_FD->prev_frica_flag, 1 ) && frica_flag == 0 ) - { - FOR( i = 0; i < L_SUBFR; i++ ) - { - tmp = sub( 32767, extract_l( L_mult0( i, 512 ) ) ); /*Q15 */ - hBWE_FD->mem_imdct_fx[i] = mult_r( hBWE_FD->mem_imdct_fx[i], tmp ); - move16(); - } - - FOR( ; i < output_frame; i++ ) - { - hBWE_FD->mem_imdct_fx[i] = 0; - move16(); - } - } - - /* decode information */ - IF( EQ_16( st_fx->extl, FB_BWE ) ) - { - IF( !st_fx->bfi ) - { - idxGain = (Word16) get_next_indice_fx( st_fx, NUM_BITS_FB_FRAMEGAIN ); - fb_ener_adjust_fx = usdequant_fx( idxGain, FB_GAIN_QLOW_FX, FB_GAIN_QDELTA_FX ); /*Q15 */ - } - ELSE IF( st_fx->bfi ) - { - fb_ener_adjust_fx = st_fx->prev_fb_ener_adjust_fx; - move16(); - } - - st_fx->prev_fb_ener_adjust_fx = fb_ener_adjust_fx; - move16(); - IF( EQ_16( mode, TRANSIENT ) ) - { - ener_adjust_quan_fx = shr( fb_ener_adjust_fx, 2 ); - } - ELSE - { - IF( SWB_fenv_fx[7] != 0 ) - { - tmp = div_s( 1, SWB_fenv_fx[7] ); - ener_adjust_quan_fx = s_min( shr( i_mult_sat( SWB_fenv_fx[13], tmp ), 2 ), 32767 ); - } - ELSE - { - ener_adjust_quan_fx = 0; - move16(); - } - } - - fb_band_begin = FB_BAND_BEGIN; - move16(); - if ( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - fb_band_begin = FB_BAND_BEGIN_12k8; - move16(); - } - - j = 0; - move16(); - FOR( i = fb_band_begin; i < add( fb_band_begin, DE_OFFSET1 ); i++ ) - { - tmp = sub( 32767, i_mult( j, 1024 ) ); - tmp = mult_r( tmp, ener_adjust_quan_fx ); /*Q13*/ - - tmp2 = i_mult( j, 256 ); /*Q13*/ - tmp2 = mult_r( tmp2, fb_ener_adjust_fx ); /*Q13*/ - - tmp = add( tmp, tmp2 ); /*Q13*/ - yerror_fx[i] = L_shl( Mpy_32_16_1( yerror_fx[i - FB_BAND_WIDTH], tmp ), 2 ); /*15+Q_syn */ - move32(); - j = add( j, 1 ); - } - FOR( ; i < FB_BAND_END; i++ ) - { - yerror_fx[i] = Mpy_32_16_1( yerror_fx[i - FB_BAND_WIDTH], fb_ener_adjust_fx ); /*15+Q_syn */ - move32(); - } - } - - /* iDCT of the error signal */ - Q_syn_hb = add( Q_syn, 15 ); - Inverse_Transform( yerror_fx, &Q_syn_hb, wtda_synth_fx, 0, output_frame, -1, st_fx->element_mode ); - - /* inverse windowing of the error signal */ - window_ola_fx( wtda_synth_fx, hb_synth_fx16, &Q_syn_hb, hBWE_FD->mem_imdct_fx, &hBWE_FD->mem_imdct_exp_fx, output_frame, ALDO_WINDOW, ALDO_WINDOW, 0, 0, 0 ); - l_subfr = mult( output_frame, 8192 ); - - test(); - IF( EQ_16( mode, TRANSIENT ) ) - { - FOR( i = 0; i < SWB_TENV; i++ ) - { - SWB_tenv_tmp_fx[i] = L_mult0( SWB_tenv_fx[i] /*Q0*/, 26214 /*0.8f Q15*/ ); // Q15 - move32(); - } - - /* time envelope shaping when the current frame is TRANSIENT frame */ - time_envelop_shaping_ivas_fx( hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb ); - - Q_syn_hb = sub( Q_syn_hb, 3 ); - - hBWE_FD->prev_td_energy_fx = SWB_tenv_fx[3]; - move16(); - } - ELSE IF( EQ_16( frica_flag, 1 ) && hBWE_FD->prev_frica_flag == 0 ) - { - Qsynth_fx16 = Find_Max_Norm32( synth_fx, output_frame ); - Qsynth_fx16 = sub( Qsynth_fx16, shr( add( sub( 15, norm_s( l_subfr ) ), 1 ), 1 ) ); - Copy_Scale_sig32_16( synth_fx, synth_fx16, output_frame, Qsynth_fx16 ); - Qsynth_fx16 = add( 11 - 16, Qsynth_fx16 ); - - /* IVAS_fmToDo: synth[] is @internal_Fs!!! */ - time_reduce_pre_echo_fx( synth_fx16, hb_synth_fx16, hBWE_FD->prev_td_energy_fx, l_subfr, Qsynth_fx16, Q_syn_hb ); - } - ELSE - { - tmp = i_mult2( 3, l_subfr ); - L_tmp = L_deposit_l( 0 ); - - FOR( i = 0; i < l_subfr; i++ ) - { - L_tmp = L_mac0_sat( L_tmp, hb_synth_fx16[add( tmp, i )], hb_synth_fx16[add( tmp, i )] ); /*(2*Q_syn_hb) */ - } - - L_tmp = Mult_32_16( L_tmp, div_s( 1, l_subfr ) ); /*(2*Q_syn_hb) */ - hBWE_FD->prev_td_energy_fx = 0; - move16(); - - IF( L_tmp != 0 ) - { - q_tmp = norm_l( L_tmp ); - tmp = extract_h( L_shl( L_tmp, q_tmp ) ); - q_tmp = sub( q_tmp, sub( 30, shl( Q_syn_hb, 1 ) ) ); - - tmp = div_s( 16384, tmp ); - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &q_tmp ); /*Q(31-exp) */ - hBWE_FD->prev_td_energy_fx = round_fx( L_shl( L_tmp, sub( q_tmp, 15 ) ) ); /*Q0 */ - move16(); - } - } - - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) - { - Qsynth_fx16 = add( 16 - 11, Q_syn_hb ); - Copy_Scale_sig32_16( synth_fx, synth_fx16, output_frame, Qsynth_fx16 ); - - /* add HB synth from hf_synth() */ - v_add_16( hb_synth_fx16, synth_fx16, hb_synth_fx16, output_frame ); - } - - hBWE_FD->prev_mode = mode; - move16(); - hBWE_FD->prev_frica_flag = frica_flag; - move16(); - - FOR( i = 0; i < output_frame; i++ ) - { - hb_synth_fx[i] = L_deposit_l( hb_synth_fx16[i] ); // Q_syn_hb - move32(); - } - - return Q_syn_hb; -} - - -void fd_bwe_dec_init_fx( - FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ -) -{ - set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, L_FRAME48k ); - set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - hBWE_FD->prev_mode = NORMAL; - move16(); - hBWE_FD->prev_Energy_fx = 0; - move16(); - hBWE_FD->prev_L_swb_norm = 8; - move16(); - hBWE_FD->Seed = 21211; - move16(); - hBWE_FD->prev_frica_flag = 0; - move16(); - set16_fx( hBWE_FD->mem_imdct_fx, 0, L_FRAME48k ); - hBWE_FD->prev_td_energy_fx = 0; - move16(); - hBWE_FD->prev_weight_fx = 0; - move16(); - hBWE_FD->prev_flag = 0; - move16(); - hBWE_FD->prev_Energy_wb_fx = 0; - move32(); - hBWE_FD->mem_deemph_old_syn_fx = 0; - move16(); - - return; -} diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 9552bbf2f..23c4c3e8a 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -1266,3 +1266,372 @@ void fd_bwe_dec_init( return; } + +/*-------------------------------------------------------------------* + * WB_BWE_gain_deq() + * + * Decoding of WB parameters + *-------------------------------------------------------------------*/ + + +Word16 swb_bwe_dec_fx32( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 output_fx[], /* i : synthesis @internal Fs : Q11 */ + Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis : Q11 */ + Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis : Q_syn_hb */ + Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + Word16 output_frame /* i : frame length */ +) +{ + Word16 L; + Word16 mode; + Word16 idxGain; + Word16 i, j, l_subfr; + Word16 fb_band_begin; + Word16 frica_flag = 0; + move16(); + Word16 ener_adjust_quan_fx; + Word16 fb_ener_adjust_fx = 0; + move16(); + Word16 scl, new_input_fx_exp, ysynth_frame_size; + Word16 Q_syn, Q_syn_hb, tmp, tmp2, q_tmp, Qsynth_fx16; + + Word16 ysynth_fx[L_FRAME48k]; + Word16 SWB_fenv_fx[SWB_FENV]; + Word16 SWB_tenv_fx[SWB_TENV]; + Word16 synth_fx16[L_FRAME48k]; + Word16 hb_synth_fx16[L_FRAME48k]; + + Word32 L_tmp; + Word32 yerror_fx[L_FRAME48k]; + Word32 ysynth_fx32[L_FRAME48k]; + Word32 SWB_tenv_tmp_fx[SWB_TENV]; + Word32 wtda_synth_fx[2 * L_FRAME48k]; + + FD_BWE_DEC_HANDLE hBWE_FD; + hBWE_FD = st_fx->hBWE_FD; + + /*---------------------------------------------------------------------* + * SWB BWE decoding + *---------------------------------------------------------------------*/ + test(); + IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) + { + /* todo - wtda() does not support L_FRAME length; thus temporarily resample the signal */ + /* todo - delay output[] by 1.25ms ? */ + L_lerp_fx_q11( output_fx, ysynth_fx32, L_FRAME16k, st_fx->L_frame ); + + /* windowing of the ACELP core synthesis */ + wtda_fx32( ysynth_fx32, wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx32, ALDO_WINDOW, ALDO_WINDOW, /*st_fx->L_frame*/ L_FRAME16k ); + + /* DCT of the ACELP core synthesis */ + new_input_fx_exp = 11; + move16(); + direct_transform_fx( wtda_synth_fx, ysynth_fx32, 0, /*st_fx->L_frame*/ L_FRAME16k, &new_input_fx_exp, st_fx->element_mode ); + ysynth_frame_size = L_FRAME16k; + move16(); + } + ELSE + { + /* windowing of the ACELP core synthesis */ + wtda_fx32( synth_fx, wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx32, ALDO_WINDOW, ALDO_WINDOW, output_frame ); + + /* DCT of the ACELP core synthesis */ + new_input_fx_exp = 11; + move16(); + direct_transform_fx( wtda_synth_fx, ysynth_fx32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode ); + ysynth_frame_size = output_frame; + move16(); + } + + /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ + scl = sub( 16 + 11, new_input_fx_exp ); + /* Possible to Upscale? */ + IF( scl > 0 ) + { + /* Yes */ + /* Calc Room to Upscale */ + Q_syn = sub( Find_Max_Norm32( ysynth_fx32, ysynth_frame_size ), 3 ); + /* Stay within MAX_Q_NEW_INPUT */ + scl = s_min( Q_syn, scl ); + } + /*Don't upscale if already in 15 bits*/ + IF( GT_16( scl, 15 ) ) + { + FOR( i = 0; i < ysynth_frame_size; i++ ) + { + ysynth_fx[i] = extract_l( ysynth_fx32[i] ); + move16(); + } + Q_syn = new_input_fx_exp; + move16(); + } + ELSE + { + Copy_Scale_sig32_16( ysynth_fx32, ysynth_fx, ysynth_frame_size, scl ); + Q_syn = add( sub( new_input_fx_exp, 16 ), scl ); + } + + IF( !st_fx->bfi ) + { + IF( st_fx->bws_cnt > 0 ) + { + /* estimate parameters */ + mode = para_pred_bws_fx( st_fx, ysynth_fx, SWB_fenv_fx, Q_syn ); + } + ELSE + { + /* de-quantization */ + mode = swb_bwe_gain_deq_fx( st_fx, ACELP_CORE, SWB_tenv_fx, SWB_fenv_fx, 0, -1 ); + } + + L = SWB_FENV; + move16(); + if ( EQ_16( mode, TRANSIENT ) ) + { + L = SWB_FENV_TRANS; + move16(); + } + + L_tmp = 0; + move32(); + FOR( i = 0; i < L; i++ ) + { + L_tmp = L_add( L_tmp, L_deposit_l( SWB_fenv_fx[i] ) ); + } + q_tmp = norm_s( L ); + tmp = div_s( shl( 1, sub( 14, q_tmp ) ), L ); /*Q(29-q_tmp) */ + L_tmp = Mpy_32_16_1( L_tmp, tmp ); /*Q(1+29-q_tmp+1-16)->Q(15-q_tmp) */ + st_fx->prev_ener_shb_fx = round_fx( L_shl( L_tmp, add( q_tmp, 2 ) ) ); /*Q1 */ + move16(); + } + ELSE + { + /* SHB FEC */ + + IF( NE_16( hBWE_FD->prev_mode, TRANSIENT ) ) + { + mode = hBWE_FD->prev_mode; + move16(); + } + ELSE + { + mode = NORMAL; + move16(); + } + + Copy( st_fx->prev_SWB_fenv_fx, SWB_fenv_fx, SWB_FENV ); + } + + /* reconstruction of MDCT spectrum of the error signal */ + set32_fx( yerror_fx, 0, output_frame ); + + IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) + { + SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl ); + } + ELSE + { + SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl ); + } + + test(); + IF( EQ_16( hBWE_FD->prev_frica_flag, 1 ) && frica_flag == 0 ) + { + FOR( i = 0; i < L_SUBFR; i++ ) + { + tmp = sub( 32767, extract_l( L_mult0( i, 512 ) ) ); /*Q15 */ + hBWE_FD->mem_imdct_fx[i] = mult_r( hBWE_FD->mem_imdct_fx[i], tmp ); + move16(); + } + + FOR( ; i < output_frame; i++ ) + { + hBWE_FD->mem_imdct_fx[i] = 0; + move16(); + } + } + + /* decode information */ + IF( EQ_16( st_fx->extl, FB_BWE ) ) + { + IF( !st_fx->bfi ) + { + idxGain = (Word16) get_next_indice_fx( st_fx, NUM_BITS_FB_FRAMEGAIN ); + fb_ener_adjust_fx = usdequant_fx( idxGain, FB_GAIN_QLOW_FX, FB_GAIN_QDELTA_FX ); /*Q15 */ + } + ELSE IF( st_fx->bfi ) + { + fb_ener_adjust_fx = st_fx->prev_fb_ener_adjust_fx; + move16(); + } + + st_fx->prev_fb_ener_adjust_fx = fb_ener_adjust_fx; + move16(); + IF( EQ_16( mode, TRANSIENT ) ) + { + ener_adjust_quan_fx = shr( fb_ener_adjust_fx, 2 ); + } + ELSE + { + IF( SWB_fenv_fx[7] != 0 ) + { + tmp = div_s( 1, SWB_fenv_fx[7] ); + ener_adjust_quan_fx = s_min( shr( i_mult_sat( SWB_fenv_fx[13], tmp ), 2 ), 32767 ); + } + ELSE + { + ener_adjust_quan_fx = 0; + move16(); + } + } + + fb_band_begin = FB_BAND_BEGIN; + move16(); + if ( EQ_16( st_fx->L_frame, L_FRAME ) ) + { + fb_band_begin = FB_BAND_BEGIN_12k8; + move16(); + } + + j = 0; + move16(); + FOR( i = fb_band_begin; i < add( fb_band_begin, DE_OFFSET1 ); i++ ) + { + tmp = sub( 32767, i_mult( j, 1024 ) ); + tmp = mult_r( tmp, ener_adjust_quan_fx ); /*Q13*/ + + tmp2 = i_mult( j, 256 ); /*Q13*/ + tmp2 = mult_r( tmp2, fb_ener_adjust_fx ); /*Q13*/ + + tmp = add( tmp, tmp2 ); /*Q13*/ + yerror_fx[i] = L_shl( Mpy_32_16_1( yerror_fx[i - FB_BAND_WIDTH], tmp ), 2 ); /*15+Q_syn */ + move32(); + j = add( j, 1 ); + } + FOR( ; i < FB_BAND_END; i++ ) + { + yerror_fx[i] = Mpy_32_16_1( yerror_fx[i - FB_BAND_WIDTH], fb_ener_adjust_fx ); /*15+Q_syn */ + move32(); + } + } + + /* iDCT of the error signal */ + Q_syn_hb = add( Q_syn, 15 ); + Inverse_Transform( yerror_fx, &Q_syn_hb, wtda_synth_fx, 0, output_frame, -1, st_fx->element_mode ); + + /* inverse windowing of the error signal */ + window_ola_fx( wtda_synth_fx, hb_synth_fx16, &Q_syn_hb, hBWE_FD->mem_imdct_fx, &hBWE_FD->mem_imdct_exp_fx, output_frame, ALDO_WINDOW, ALDO_WINDOW, 0, 0, 0 ); + l_subfr = mult( output_frame, 8192 ); + + test(); + IF( EQ_16( mode, TRANSIENT ) ) + { + FOR( i = 0; i < SWB_TENV; i++ ) + { + SWB_tenv_tmp_fx[i] = L_mult0( SWB_tenv_fx[i] /*Q0*/, 26214 /*0.8f Q15*/ ); // Q15 + move32(); + } + + /* time envelope shaping when the current frame is TRANSIENT frame */ + time_envelop_shaping_ivas_fx( hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb ); + + Q_syn_hb = sub( Q_syn_hb, 3 ); + + hBWE_FD->prev_td_energy_fx = SWB_tenv_fx[3]; + move16(); + } + ELSE IF( EQ_16( frica_flag, 1 ) && hBWE_FD->prev_frica_flag == 0 ) + { + Qsynth_fx16 = Find_Max_Norm32( synth_fx, output_frame ); + Qsynth_fx16 = sub( Qsynth_fx16, shr( add( sub( 15, norm_s( l_subfr ) ), 1 ), 1 ) ); + Copy_Scale_sig32_16( synth_fx, synth_fx16, output_frame, Qsynth_fx16 ); + Qsynth_fx16 = add( 11 - 16, Qsynth_fx16 ); + + /* IVAS_fmToDo: synth[] is @internal_Fs!!! */ + time_reduce_pre_echo_fx( synth_fx16, hb_synth_fx16, hBWE_FD->prev_td_energy_fx, l_subfr, Qsynth_fx16, Q_syn_hb ); + } + ELSE + { + tmp = i_mult2( 3, l_subfr ); + L_tmp = L_deposit_l( 0 ); + + FOR( i = 0; i < l_subfr; i++ ) + { + L_tmp = L_mac0_sat( L_tmp, hb_synth_fx16[add( tmp, i )], hb_synth_fx16[add( tmp, i )] ); /*(2*Q_syn_hb) */ + } + + L_tmp = Mult_32_16( L_tmp, div_s( 1, l_subfr ) ); /*(2*Q_syn_hb) */ + hBWE_FD->prev_td_energy_fx = 0; + move16(); + + IF( L_tmp != 0 ) + { + q_tmp = norm_l( L_tmp ); + tmp = extract_h( L_shl( L_tmp, q_tmp ) ); + q_tmp = sub( q_tmp, sub( 30, shl( Q_syn_hb, 1 ) ) ); + + tmp = div_s( 16384, tmp ); + L_tmp = L_deposit_h( tmp ); + L_tmp = Isqrt_lc( L_tmp, &q_tmp ); /*Q(31-exp) */ + hBWE_FD->prev_td_energy_fx = round_fx( L_shl( L_tmp, sub( q_tmp, 15 ) ) ); /*Q0 */ + move16(); + } + } + + test(); + IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) + { + Qsynth_fx16 = add( 16 - 11, Q_syn_hb ); + Copy_Scale_sig32_16( synth_fx, synth_fx16, output_frame, Qsynth_fx16 ); + + /* add HB synth from hf_synth() */ + v_add_16( hb_synth_fx16, synth_fx16, hb_synth_fx16, output_frame ); + } + + hBWE_FD->prev_mode = mode; + move16(); + hBWE_FD->prev_frica_flag = frica_flag; + move16(); + + FOR( i = 0; i < output_frame; i++ ) + { + hb_synth_fx[i] = L_deposit_l( hb_synth_fx16[i] ); // Q_syn_hb + move32(); + } + + return Q_syn_hb; +} + + +void fd_bwe_dec_init_fx( + FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ +) +{ + set16_fx( hBWE_FD->L_old_wtda_swb_fx, 0, L_FRAME48k ); + set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); + hBWE_FD->prev_mode = NORMAL; + move16(); + hBWE_FD->prev_Energy_fx = 0; + move16(); + hBWE_FD->prev_L_swb_norm = 8; + move16(); + hBWE_FD->Seed = 21211; + move16(); + hBWE_FD->prev_frica_flag = 0; + move16(); + set16_fx( hBWE_FD->mem_imdct_fx, 0, L_FRAME48k ); + hBWE_FD->prev_td_energy_fx = 0; + move16(); + hBWE_FD->prev_weight_fx = 0; + move16(); + hBWE_FD->prev_flag = 0; + move16(); + hBWE_FD->prev_Energy_wb_fx = 0; + move32(); + hBWE_FD->mem_deemph_old_syn_fx = 0; + move16(); + + return; +} + diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c deleted file mode 100644 index 80dfad505..000000000 --- a/lib_dec/swb_tbe_dec.c +++ /dev/null @@ -1,2478 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "rom_com.h" -#include "rom_dec.h" -#include "wmc_auto.h" -#include "ivas_prot.h" -#include "ivas_prot_fx.h" - -/*-----------------------------------------------------------------* - * Local function prototypes - *-----------------------------------------------------------------*/ - - -void find_max_mem_dec_m3( - Decoder_State *st, - Word16 *n_mem3 ); - -/*-------------------------------------------------------------------* - * ResetSHBbuffer_Dec() - * - * - *-------------------------------------------------------------------*/ - -static void calc_tilt_bwe_fx_loc( - const Word32 *sp_fx, /* i : input signal : Q11 */ - Word32 *tilt_fx, /* o : signal tilt : tilt_fx_q */ - Word16 *tilt_fx_q, /* o : signal tilt */ - const Word16 N /* i : signal length : Q0 */ -) -{ - Word16 i; - Word64 r0_fx, r1_fx; - - r0_fx = EPSILON_FX_SMALL; - move64(); - FOR( i = 0; i < N; i++ ) - { - r0_fx = W_add( r0_fx, W_shr( W_mult_32_32( sp_fx[i], sp_fx[i] ), 1 ) ); /*Q11*2 - 1*/ - } - r1_fx = W_deposit32_l( abs( L_sub( sp_fx[1], sp_fx[0] ) ) ); /*Q11*/ - FOR( i = 2; i < N; i++ ) - { - IF( W_mult_32_32( L_sub( sp_fx[i], sp_fx[i - 1] ) /*Q11*/, L_sub( sp_fx[i - 1], sp_fx[i - 2] ) /*Q11*/ ) /*Q11 * 2 - 1*/ < 0 ) - { - r1_fx = W_add( r1_fx, W_deposit32_l( abs( L_sub( sp_fx[i], sp_fx[i - 1] ) ) ) ); /*Q11*/ - } - } - Word16 headroom_left_r0 = W_norm( r0_fx ); - Word16 headroom_left_r1 = W_norm( r1_fx ); - Word16 r0_q = 0, r1_q = 0; - move16(); - move16(); - IF( LT_16( headroom_left_r0, 32 ) ) - { - r0_fx = W_shr( r0_fx, sub( 32, headroom_left_r0 ) ); - r0_q = sub( 31, sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_r0 ) ) ); - } - ELSE - { - r0_q = 31 - ( 2 * OUTPUT_Q ); - move16(); - } - - IF( LT_16( headroom_left_r1, 32 ) ) - { - r1_fx = W_shr( r1_fx, sub( 32, headroom_left_r1 ) ); - r1_q = sub( OUTPUT_Q, sub( 32, headroom_left_r1 ) ); - } - ELSE - { - r1_q = OUTPUT_Q; - move16(); - } - Word32 temp_r0_inv = ISqrt32( W_extract_l( r0_fx ), &r0_q ); - Word32 res = Mpy_32_32( W_extract_l( r1_fx ), temp_r0_inv ); - // Word16 res_q = r1_q + ( r0_q < 0 ? ( 31 + ( -1 * r0_q ) ) : r0_q ) - 31; - Word16 res_q; - IF( r0_q < 0 ) - { - res_q = add( r1_q, sub( add( 31, -r0_q ), 31 ) ); - } - ELSE - { - res_q = add( r1_q, sub( r0_q, 31 ) ); - } - Word16 norm_res = norm_l( res ); - IF( norm_res > 0 ) - { - *tilt_fx = L_shl_sat( res, norm_res ); - move32(); - *tilt_fx_q = add( res_q, norm_res ); - move16(); - } - ELSE - { - *tilt_fx = res; - move32(); - *tilt_fx_q = res_q; - move16(); - } - return; -} - -/*-------------------------------------------------------------------* - * swb_tbe_dec() - * - * SWB TBE decoder, 6 - 14 kHz (or 7.5 - 15.5 kHz) band decoding module - *-------------------------------------------------------------------*/ -static void rescale_genSHB_mem_dec( - Decoder_State *st_fx, - Word16 sf /*Q0*/ -) -{ - Word16 i; - TD_BWE_DEC_HANDLE hBWE_TD; - hBWE_TD = st_fx->hBWE_TD; - - FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) - { - hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf ); - move16(); - } - - FOR( i = 0; i < 7; i++ ) - { - hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i] = shl( hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i], sf ); - move16(); - } - - /* -- Apply memory scaling for 13.2 and 16.4k bps using sf ----*/ - IF( LT_32( st_fx->total_brate, ACELP_24k40 ) ) - { - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - hBWE_TD->state_lpc_syn_fx[i] = shl_sat( hBWE_TD->state_lpc_syn_fx[i], sf ); - move16(); - } - - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - hBWE_TD->state_syn_shbexc_fx[i] = shl_sat( hBWE_TD->state_syn_shbexc_fx[i], sf ); - move16(); - } - } - - hBWE_TD->mem_csfilt_fx[0] = L_shl( hBWE_TD->mem_csfilt_fx[0], sf ); - move32(); - - hBWE_TD->tbe_demph_fx = shl_r( hBWE_TD->tbe_demph_fx, sf ); - move16(); - hBWE_TD->tbe_premph_fx = shl_r( hBWE_TD->tbe_premph_fx, sf ); - move16(); -} - -static void gradientGainShape( - Decoder_State *st_fx, - Word16 *GainShape_fx, /*Q15*/ - Word32 *GainFrame_fx /* Q18 */ ) -{ - Word16 i, j, tmp; - Word16 GainShapeTemp[NUM_SHB_SUBFR / 4]; - Word16 GainGrad0[3]; - Word16 GainGrad1[3]; - Word16 GainGradFEC[4]; - TD_BWE_DEC_HANDLE hBWE_TD; - hBWE_TD = st_fx->hBWE_TD; - - - /* the previous frame gainshape gradient and the gainshape gradient pattern for the current frame */ - FOR( j = 0; j < 3; j++ ) - { - GainGrad0[j] = sub( shr( st_fx->GainShape_Delay[j + 1], 1 ), shr( st_fx->GainShape_Delay[j], 1 ) ); - move16(); /* Q14 */ - GainGrad1[j] = sub( shr( st_fx->GainShape_Delay[j + 5], 1 ), shr( st_fx->GainShape_Delay[j + 4], 1 ) ); - move16(); /* Q14 */ - GainGradFEC[j + 1] = add( mult_r( GainGrad0[j], 13107 /*0.4f in Q15*/ ), mult_r( GainGrad1[j], 19660 /*0.6f in Q15*/ ) ); - move16(); /* Q14 */ - } - - /* gradient for the first gainshape */ - test(); - test(); - test(); - IF( ( ( GT_16( shr( GainGrad1[2], 1 ), GainGrad1[1] ) ) && ( GT_16( shr( GainGrad1[1], 1 ), GainGrad1[0] ) ) ) || - ( ( LT_16( shr( GainGrad1[2], 1 ), GainGrad1[1] ) ) && ( LT_16( shr( GainGrad1[1], 1 ), GainGrad1[0] ) ) ) ) - { - GainGradFEC[0] = add( mult_r( GainGrad1[1], 3277 /*0.1f in Q15*/ ), mult_r( GainGrad1[2], 29490 /*0.9f in Q15*/ ) ); - move16(); /* Q14 */ - } - ELSE - { - GainGradFEC[0] = add( mult_r( GainGrad1[0], 6553 /*0.2f in Q15*/ ), mult_r( GainGrad1[1], 9830 /*0.3f in Q15*/ ) ); - move16(); - GainGradFEC[0] = add( GainGradFEC[0], mult_r( GainGrad1[2], 16384 /*0.5f in Q15*/ ) ); - move16(); /* Q14 */ - } - - /* get the first gainshape template */ - test(); - test(); - IF( ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) ) && ( GainGradFEC[0] > 0 ) ) - { - GainShapeTemp[0] = add( shr( st_fx->GainShape_Delay[7], 1 ), GainGradFEC[0] ); - move16(); - } - ELSE IF( GainGradFEC[0] > 0 ) - { - GainShapeTemp[0] = add( shr( st_fx->GainShape_Delay[7], 1 ), mult_r( GainGradFEC[0], 16384 /*0.5f in Q15*/ ) ); - move16(); /* Q14 */ - } - ELSE - { - GainShapeTemp[0] = shr( st_fx->GainShape_Delay[7], 1 ); - move16(); /* Q14 */ - } - - /*Get the second the third and the fourth gainshape template*/ - - tmp = shr( GainGrad1[2], 3 ); /* GainGrad1[2]/8 */ - tmp = mult_r( tmp, 26214 ); /* 0.8 in Q15 tmp*(8/10) */ - - test(); - IF( ( GT_16( tmp, GainGrad1[1] ) ) && ( GainGrad1[1] > 0 ) ) - { - FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ ) - { - GainShapeTemp[i] = add( GainShapeTemp[i - 1], mult_r( GainGradFEC[i], 26214 /*0.8f in Q15*/ ) ); - move16(); /* GainShapeTemp[i-1] + 0.8* GainShapeTemp[i] */ - GainShapeTemp[i] = s_max( GainShapeTemp[i], 328 /*0.01f Q15*/ ); - move16(); - } - } - ELSE - { - test(); - IF( ( GT_16( tmp, GainGrad1[1] ) ) && ( GainGrad1[1] < 0 ) ) - { - FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ ) - { - GainShapeTemp[i] = add( GainShapeTemp[i - 1], mult_r( GainGradFEC[i], 6553 /*0.2f in Q15*/ ) ); - move16(); /* GainShapeTemp[i-1] + 0.8* GainShapeTemp[i] */ - GainShapeTemp[i] = s_max( GainShapeTemp[i], 328 /*0.01f Q15*/ ); - move16(); /* Q14 */ - } - } - ELSE - { - FOR( i = 1; i < NUM_SHB_SUBFR / 4; i++ ) - { - GainShapeTemp[i] = add( GainShapeTemp[i - 1], GainGradFEC[i] ); - move16(); - GainShapeTemp[i] = s_max( GainShapeTemp[i], 328 /*0.01f Q15*/ ); - move16(); - } - } - } - - /* Get the gainshape and gain frame for the current frame*/ - test(); - test(); - test(); - IF( ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) ) && EQ_16( st_fx->nbLostCmpt, 1 ) ) - { - FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - tmp = mult_r( GainShapeTemp[i], 19660 /*0.6f Q15*/ ); /* GainShapeTemp[i]*0.6 */ - - IF( GT_16( 8192, tmp ) ) - { - GainShape_fx[i * 4 + j] = shl( tmp, 2 ); /*Q15*/ - move16(); /* (GainShapeTemp[i]*0.6)>>1 */ - } - ELSE - { - GainShape_fx[i * 4 + j] = 32767; /*Q15*/ - move16(); /* Clipping here to avoid the a huge change of the code due to gain shape change */ - } - } - } - hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 31129 ); - move16(); - } - ELSE IF( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) ) - { - FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - IF( LT_16( GainShapeTemp[i], 16384 ) ) - { - GainShape_fx[i * 4 + j] = shl( GainShapeTemp[i], 1 ); /*Q15*/ - move16(); - } - ELSE - { - GainShape_fx[i * 4 + j] = 32767; // 1.0f in Q15 - move16(); - } - } - } - hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 31129 /*0.95f in Q15*/ ); /*Q15*/ - move16(); - } - ELSE IF( GT_16( st_fx->nbLostCmpt, 1 ) ) - { - FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - GainShape_fx[i * 4 + j] = GainShapeTemp[i]; /*Q15*/ - move16(); - } - } - hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 16384 /*0.5f in Q15*/ ); /*Q15*/ - move16(); - } - ELSE - { - FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - IF( LT_16( GainShapeTemp[i], 16384 ) ) - { - GainShape_fx[i * 4 + j] = shl( GainShapeTemp[i], 1 ); /*Q15*/ - move16(); - } - ELSE - { - GainShape_fx[i * 4 + j] = 32767; /*Q15*/ - move16(); - } - } - } - hBWE_TD->GainAttn_fx = mult_r( hBWE_TD->GainAttn_fx, 27852 /*0.85f in Q15*/ ); /*Q15*/ - move16(); - } - - *GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, hBWE_TD->GainAttn_fx ); /* Q18 */ - move32(); -} - -static void find_max_mem_dec( - Decoder_State *st_fx, - Word16 *n_mem, - Word16 *n_mem2, - Word16 *n_mem3 ) -{ - Word16 i; - Word16 n_mem_32; - Word16 max = 0; - move16(); - Word32 Lmax = 0; - move32(); - Word16 tempQ15, max2 = 0; - move16(); - Word16 max3; - Word32 tempQ32, Lmax3; - TD_BWE_DEC_HANDLE hBWE_TD; - hBWE_TD = st_fx->hBWE_TD; - - /* old BWE exc max */ - FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) - { - tempQ15 = abs_s( hBWE_TD->old_bwe_exc_extended_fx[i] ); - max = s_max( max, tempQ15 ); - } - - /* decimate all-pass steep memory */ - FOR( i = 0; i < 7; i++ ) - { - tempQ15 = abs_s( hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i] ); - max = s_max( max, tempQ15 ); - } - - /* -- keep norm of state_lpc_syn_fx, state_syn_shbexc_fx, - and mem_stp_swb_fx separately for 24.4 and 32kbps ----*/ - /* findMaxMem2() inside tbe com */ - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - tempQ15 = abs_s( hBWE_TD->state_lpc_syn_fx[i] ); - max2 = s_max( max2, tempQ15 ); - } - - /* findMaxMem2() inside tbe com */ - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - tempQ15 = abs_s( hBWE_TD->state_syn_shbexc_fx[i] ); - max2 = s_max( max2, tempQ15 ); - } - - /* findMaxMem2() inside tbe com */ - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - tempQ15 = abs_s( hBWE_TD->mem_stp_swb_fx[i] ); - max2 = s_max( max2, tempQ15 ); - } - - /* for total_brate > 16.4kbps, use n_mem2; else account for the max2 for n_mem calculation */ - *n_mem2 = norm_s( max2 ); - move16(); - if ( max2 == 0 ) - { - *n_mem2 = 15; - move16(); - } - - if ( LT_32( st_fx->total_brate, ACELP_24k40 ) ) - { - max = s_max( max, max2 ); - } - - /* de-emph and pre-emph memory */ - tempQ15 = abs_s( hBWE_TD->tbe_demph_fx ); - max = s_max( max, tempQ15 ); - - tempQ15 = abs_s( hBWE_TD->tbe_premph_fx ); - max = s_max( max, tempQ15 ); - - IF( EQ_16( st_fx->extl, FB_TBE ) ) - { - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - tempQ15 = abs_s( hBWE_TD->fb_state_lpc_syn_fx[i] ); - max = s_max( max, tempQ15 ); - } - /* FB de-emph memory */ - tempQ15 = abs_s( hBWE_TD->fb_tbe_demph_fx ); - max = s_max( max, tempQ15 ); - } - /* estimate the norm for 16-bit memories */ - *n_mem = norm_s( max ); - move16(); - if ( max == 0 ) - { - *n_mem = 15; - move16(); - } - - /* estimate the norm for 32-bit memories */ - Lmax = L_abs( hBWE_TD->mem_csfilt_fx[0] ); /* only element [0] is used in env. shaping */ - - n_mem_32 = norm_l( Lmax ); - if ( Lmax == 0 ) - { - n_mem_32 = 31; - move16(); - } - - tempQ15 = sub( s_min( *n_mem, n_mem_32 ), 1 ); - *n_mem = s_max( tempQ15, 0 ); - move16(); - - /* --------------------------------------------------------------*/ - /* Find headroom for synthesis stage associated with these memories: - 1. st_fx->syn_overlap_fx - 2. st_fx->genSHBsynth_state_lsyn_filt_shb_local - 3. st_fx->genSHBsynth_Hilbert_Mem_fx (32-bit) */ - max3 = 0; - move16(); - /* find max in prev overlapSyn */ - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - tempQ15 = abs_s( hBWE_TD->syn_overlap_fx[i] ); - max3 = s_max( max3, tempQ15 ); - } - /* find max in prev genSHBsynth_state_lsyn_filt_shb_local_fx */ - FOR( i = 0; i < 2 * ALLPASSSECTIONS_STEEP; i++ ) - { - tempQ15 = abs_s( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx[i] ); - max3 = s_max( max3, tempQ15 ); - } - /* find max in prev int_3_over_2_tbemem_dec_fx */ - IF( EQ_32( st_fx->output_Fs, 48000 ) ) - { - FOR( i = 0; i < INTERP_3_2_MEM_LEN; i++ ) - { - tempQ15 = abs_s( hBWE_TD->int_3_over_2_tbemem_dec_fx[i] ); - max3 = s_max( max3, tempQ15 ); - } - } - IF( EQ_32( st_fx->output_Fs, 16000 ) ) - { - FOR( i = 0; i < ( 2 * ALLPASSSECTIONS_STEEP + 1 ); i++ ) - { - tempQ15 = abs_s( hBWE_TD->mem_resamp_HB_32k_fx[i] ); - max3 = s_max( max3, tempQ15 ); - } - } - /* estimate the norm for 16-bit memories */ - *n_mem3 = norm_s( max3 ); - move16(); - if ( max3 == 0 ) - { - *n_mem3 = 15; - move16(); - } - - Lmax3 = 0; - move32(); - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - /* find max in prev genSHBsynth_Hilbert_Mem_fx */ - FOR( i = 0; i < HILBERT_MEM_SIZE; i++ ) - { - tempQ32 = L_abs( hBWE_TD->genSHBsynth_Hilbert_Mem_fx[i] ); - Lmax3 = L_max( Lmax3, tempQ32 ); - } - } - - /* estimate the norm for 32-bit memories */ - n_mem_32 = norm_l( Lmax3 ); - if ( Lmax3 == 0 ) - { - n_mem_32 = 31; - move16(); - } - - tempQ15 = sub( s_min( *n_mem3, n_mem_32 ), 2 ); /* very important leave at least 2 bit head room - because of the Hilber transform and Q14 coeffs */ - *n_mem3 = s_max( tempQ15, 0 ); - move16(); - /* --------------------------------------------------------------*/ -} - -void find_max_mem_dec_m3( - Decoder_State *st, - Word16 *n_mem3 ) -{ - Word16 i; - // Word16 n_mem_32; - Word16 tempQ15; - Word16 max3; - // Word32 tempQ32, Lmax3; - TD_BWE_DEC_HANDLE hBWE_TD; - hBWE_TD = st->hBWE_TD; - - /* --------------------------------------------------------------*/ - /* Find headroom for synthesis stage associated with these memories: - 1. st->syn_overlap_fx*/ - max3 = 0; - move16(); - /* find max in prev overlapSyn */ - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - tempQ15 = abs_s( hBWE_TD->syn_overlap_fx[i] ); - max3 = s_max( max3, tempQ15 ); - } - /* find max in prev genSHBsynth_state_lsyn_filt_shb_local_fx */ - - /* estimate the norm for 16-bit memories */ - *n_mem3 = norm_s( max3 ); - move16(); - if ( max3 == 0 ) - { - *n_mem3 = 15; - move16(); - } -} - -/*-------------------------------------------------------------------* - * ivas_swb_tbe_dec_fx() - * - * SWB TBE decoder, 6 - 14 kHz (or 7.5 - 15.5 kHz) band decoding module - *-------------------------------------------------------------------*/ -void ivas_swb_tbe_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ - const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ - Word16 Q_exc, - const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ - const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ - Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ - Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ - Word16 *pitch_buf_fx, /* i : Q6 */ - Word16 *Q_white_exc ) -{ - Word16 i, j, cnt, n; - Word16 stemp; - TD_BWE_DEC_HANDLE hBWE_TD; - Word32 shaped_shb_excitation_fx_32[L_FRAME16k + L_SHB_LAHEAD]; - Word16 bwe_exc_extended_16[L_FRAME32k + NL_BUFF_OFFSET]; - Word16 shaped_shb_excitation_fx[L_FRAME16k + L_SHB_LAHEAD]; - Word16 lsf_shb_fx[LPC_SHB_ORDER], lpc_shb_fx[LPC_SHB_ORDER + 1], GainShape_fx[NUM_SHB_SUBFR]; // Q12,Q12,Q15 - Word32 GainFrame_fx; // Q18 - Word32 error_fx[L_FRAME32k]; - Word16 ener_fx; - Word32 L_ener; - Word16 is_fractive; - Word32 prev_pow_fx, curr_pow_fx, Lscale; - Word16 scale_fx; - Word16 max_val, temp_fx, shaped_shb_excitation_frac[L_FRAME16k + L_SHB_LAHEAD]; - Word32 curr_frame_pow_fx; - Word16 curr_frame_pow_exp; - Word32 L_prev_ener_shb; - Word16 vf_modified_fx[NB_SUBFR16k]; - Word16 f_fx, inc_fx; - Word32 GainFrame_prevfrm_fx; - Word32 tilt_swb_fec_32_fx; - Word16 tilt_swb_fec_fx_q; - Word16 tilt_swb_fec_fx; - Word32 prev_ener_ratio_fx = 0; /* initialize just to avoid compiler warning */ - Word16 lsp_shb_1_fx[LPC_SHB_ORDER], lsp_shb_2_fx[LPC_SHB_ORDER], lsp_temp_fx[LPC_SHB_ORDER]; - Word16 lpc_shb_sf_fx[4 * ( LPC_SHB_ORDER + 1 )]; - const Word16 *ptr_lsp_interp_coef_fx; - Word32 shb_ener_sf_32; - Word16 shb_res_gshape_fx[NB_SUBFR16k]; - Word16 mixFactors_fx; - Word16 vind; - Word16 shb_res_dummy_fx[L_FRAME16k]; - Word16 shaped_shb_excitationTemp_fx[L_FRAME16k]; - Word32 ener_tmp_fx[NUM_SHB_SUBGAINS]; - Word16 GainShape_tmp_fx[NUM_SHB_SUBGAINS]; - Word16 pitch_fx; - Word16 l_subframe; - Word16 formant_fac_fx; - Word16 synth_scale_fx; - Word16 lsf_diff_fx[LPC_SHB_ORDER], w_fx[LPC_SHB_ORDER]; - Word16 refl_fx[M]; - Word16 tilt_para_fx; - Word16 *nlExc16k_fx, *mixExc16k_fx; - Word16 MSFlag; - Word16 feedback_fx; - Word16 GainShape_tilt_fx; - - // scaling - Word16 exp, tmp; - Word16 tmp1, tmp2; - Word16 mean_vf; - Word32 Lmax, L_tmp; - Word16 frac; - Word32 L_tmp1, L_tmp2; - Word16 Q_bwe_exc; - Word16 Q_bwe_exc_fb; - Word16 Q_shb; - Word16 n_mem, n_mem2, n_mem3, Qx, sc; - Word16 expa, expb; - Word16 fraca, fracb; - Word16 exp_ener, inv_ener; - - hBWE_TD = st->hBWE_TD; - - /* initializations */ - GainFrame_fx = 0; - move32(); - mixFactors_fx = 0; - move16(); - shb_ener_sf_32 = 0; - move32(); - set16_fx( shaped_shb_excitationTemp_fx, 0, L_FRAME16k ); - if ( st->hTdCngDec != NULL ) - { - st->hTdCngDec->shb_dtx_count = 0; - move16(); - } - is_fractive = 0; - move16(); - - IF( hStereoICBWE != NULL ) - { - nlExc16k_fx = hStereoICBWE->nlExc16k_fx; - mixExc16k_fx = hStereoICBWE->mixExc16k_fx; - MSFlag = hStereoICBWE->MSFlag; - move16(); - } - ELSE - { - nlExc16k_fx = NULL; - mixExc16k_fx = NULL; - MSFlag = 0; - move16(); - } - - /* find tilt */ - calc_tilt_bwe_fx_loc( old_syn_12k8_16k_fx, &tilt_swb_fec_32_fx, &tilt_swb_fec_fx_q, L_FRAME ); - tilt_swb_fec_fx = round_fx_sat( L_shl_sat( tilt_swb_fec_32_fx, sub( 11 + 16, tilt_swb_fec_fx_q ) ) ); - test(); - if ( st->bfi && st->clas_dec != UNVOICED_CLAS ) - { - tilt_swb_fec_fx = hBWE_TD->tilt_swb_fec_fx; - move16(); - } - - /* WB/SWB bandwidth switching */ - test(); - test(); - IF( ( GT_16( st->tilt_wb_fx, 10240 /*5 in Q11*/ ) && ( EQ_16( st->clas_dec, UNVOICED_CLAS ) ) ) || GT_16( st->tilt_wb_fx, 20480 /*10 in Q11*/ ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( st->prev_fractive == 0 ) && - ( LT_32( st->prev_enerLH_fx, L_shl( st->enerLH_fx, 1 ) ) && GT_32( st->prev_enerLH_fx, L_shr( st->enerLH_fx, 1 ) ) && LT_32( st->prev_enerLL_fx, L_shl( st->enerLL_fx, 1 ) ) && GT_32( st->prev_enerLL_fx, L_shr( st->enerLL_fx, 1 ) ) ) ) || - ( EQ_16( st->prev_fractive, 1 ) && - GT_32( L_shr( st->prev_enerLH_fx, 2 ), Mult_32_16( st->enerLH_fx, 24576 ) ) ) /* 24576 in Q13*/ - || ( GT_32( L_shr( st->enerLL_fx, 1 ), Mult_32_16( st->enerLH_fx, 24576 ) ) && /*24576 = 1.5 in Q14*/ - LT_16( st->tilt_wb_fx, 20480 ) ) /* 20480 = 10 in Q11*/ - ) - { - is_fractive = 0; - } - ELSE - { - is_fractive = 1; - } - move16(); - } - - /* WB/SWB bandwidth switching */ - IF( st->bws_cnt > 0 ) - { - f_fx = 1489; /*1.0f / 22.0f in Q15*/ - move16(); - inc_fx = 1489; /*1.0f / 22.0f in Q15*/ - move16(); - - IF( EQ_16( is_fractive, 1 ) ) - { - Copy( lsf_tab_fx, hBWE_TD->lsp_prevfrm_fx, LPC_SHB_ORDER ); - } - ELSE - { - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - hBWE_TD->lsp_prevfrm_fx[i] = f_fx; /*Q15*/ - move16(); - f_fx = add( f_fx, inc_fx ); /*Q15*/ - } - } - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && !( ( L_sub( L_shr( st->prev_enerLH_fx, 1 ), st->enerLH_fx ) < 0 ) && L_sub( st->prev_enerLH_fx, ( L_shr( st->enerLH_fx, 1 ) > 0 ) ) ) ) || st->last_core != ACELP_CORE || ( ( st->last_core == ACELP_CORE ) && GT_32( abs( L_sub( st->last_core_brate, st->core_brate ) ), 3600 ) ) || EQ_16( s_xor( is_fractive, st->prev_fractive ), 1 ) ) - { - set16_fx( GainShape_fx, 11587, NUM_SHB_SUBFR ); /*0.3536f in Q15*/ - } - ELSE - { - if ( GT_16( hBWE_TD->prev_GainShape_fx, 11587 ) ) /*0.3536f in Q15*/ - { - hBWE_TD->prev_GainShape_fx = 11587; /*0.3536f in Q15*/ - move16(); - } - set16_fx( GainShape_fx, hBWE_TD->prev_GainShape_fx, NUM_SHB_SUBFR ); - } - - Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER ); - set16_fx( shb_res_gshape_fx, 3277 /*0.2f Q14*/, NB_SUBFR16k ); /* Q14 */ - } - ELSE - { - test(); - IF( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) - { - f_fx = 1489; /*Q15*/ - move16(); - inc_fx = 1489; /*Q15*/ - move16(); - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - hBWE_TD->lsp_prevfrm_fx[i] = f_fx; /*Q15*/ - move16(); - f_fx = add( f_fx, inc_fx ); - } - } - - IF( !st->bfi ) - { - IF( st->use_partial_copy ) - { - IF( NE_16( st->last_extl, SWB_TBE ) ) - { - hBWE_TD->GainFrame_prevfrm_fx = 0; - move32(); - f_fx = 1489 /*0.045454f Q15*/; - move16(); - inc_fx = 1489 /*0.045454f Q15*/; - move16(); - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - hBWE_TD->lsp_prevfrm_fx[i] = f_fx; /*Q15*/ - move16(); - f_fx = add( f_fx, inc_fx ); /*Q15*/ - } - } - Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER ); - set16_fx( GainShape_fx, RECIP_ROOT_EIGHT_FX, NUM_SHB_SUBFR ); - - IF( EQ_16( st->rf_frame_type, RF_NELP ) ) - { - /* Frame gain */ - - GainFrame_fx = L_mac( SHB_GAIN_QLOW_FX, st->rf_indx_tbeGainFr, SHB_GAIN_QDELTA_FX ); - L_tmp = Mult_32_16( GainFrame_fx, 27213 ); /*Q16*/ /* 3.321928 in Q13 */ - - frac = L_Extract_lc( L_tmp, &exp ); - L_tmp = Pow2( 30, frac ); - GainFrame_fx = L_shl( L_tmp, sub( exp, 12 ) ); /*Q18*/ - - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( st->core == ACELP_CORE ) && ( st->last_core == ACELP_CORE ) && !st->prev_use_partial_copy && EQ_16( st->prev_coder_type, UNVOICED ) && NE_32( GainFrame_fx, hBWE_TD->GainFrame_prevfrm_fx ) && NE_16( st->next_coder_type, GENERIC ) && EQ_16( st->last_extl, SWB_TBE ) ) - { - GainFrame_fx = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 26214 /*0.8f in Q15*/ ), Mult_32_16( GainFrame_fx, 6553 /*0.2f in Q15*/ ) ); - } - } - ELSE - { - temp_fx = 0; - move16(); - /* Frame gain */ - SWITCH( st->rf_indx_tbeGainFr ) - { - case 0: - GainFrame_fx = 131072; /* 0.5f in Q18 */ - move32(); - if ( LE_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) ) - { - temp_fx = 26214 /*0.8 Q15*/; - move16(); - } - BREAK; - case 1: - GainFrame_fx = 524288; /* 2.0f in Q18 */ - move32(); - test(); - if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) ) - { - temp_fx = 26214 /*0.8 Q15*/; - move16(); - } - BREAK; - case 2: - GainFrame_fx = 1048576; /* 4.0f in Q18 */ - move32(); - test(); - if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) ) - { - temp_fx = 26214 /*0.8 Q15*/; - move16(); - } - BREAK; - case 3: - GainFrame_fx = 2097152; /* 8.0f in Q18 */ - move32(); - test(); - if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 4194304l /*16Q18*/ ) ) - { - temp_fx = 26214 /*0.8 Q15*/; - move16(); - } - BREAK; - default: - fprintf( stderr, "RF SWB-TBE gain bits not supported." ); - } - - IF( EQ_16( st->last_extl, SWB_TBE ) ) - { - GainFrame_fx = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, temp_fx ), Mult_32_16( GainFrame_fx, sub( 32767, temp_fx ) ) ); - /*Q18*/ - } - - IF( ( st->core == ACELP_CORE ) && ( st->last_core == ACELP_CORE ) ) - { - if ( !st->prev_use_partial_copy && EQ_16( st->last_coder_type, VOICED ) && EQ_16( st->rf_frame_type, RF_GENPRED ) && GT_32( GainFrame_fx, 2097152 /*8.0f in Q18*/ ) && LT_32( GainFrame_fx, 3059606 /*11.67f in Q18*/ ) ) - { - GainFrame_fx = Mult_32_16( GainFrame_fx, 9830 /*0.3f in Q15*/ ); // Q18 - } - } - } - } - ELSE - { - /* de-quantization */ - ivas_dequantizeSHBparams_fx_9_1( st, st->extl, st->extl_brate, lsf_shb_fx, GainShape_fx, &GainFrame_fx, &stemp, - &shb_ener_sf_32, shb_res_gshape_fx, &mixFactors_fx, &MSFlag ); - if ( hStereoICBWE != NULL ) - { - hStereoICBWE->MSFlag = MSFlag; - move16(); - } - } - } - ELSE - { - Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER ); - test(); - IF( EQ_16( st->codec_mode, MODE1 ) && ( st->element_mode == EVS_MONO ) ) - { - gradientGainShape( st, GainShape_fx, &GainFrame_fx ); - } - ELSE - { - FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - GainShape_fx[i * 4 + j] = mult_r( st->cummulative_damping, st->GainShape_Delay[4 + i] ); - move16(); - } - } - IF( GT_16( tilt_swb_fec_fx, ( 8 << 11 ) ) ) /* tilt_swb_fec_fx in Q11 */ - { - IF( EQ_16( st->nbLostCmpt, 1 ) ) - { - GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 19661 /*0.6f Q15*/ ); - } - ELSE IF( EQ_16( st->nbLostCmpt, 2 ) ) - { - GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 11469 /*0.35f Q15*/ ); - } - ELSE - { - GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 6554 /*0.2f Q15*/ ); - } - GainFrame_fx = Mult_32_16( GainFrame_fx, st->cummulative_damping ); - } - ELSE - { - GainFrame_fx = hBWE_TD->GainFrame_prevfrm_fx; - move32(); /* gain locking */ - } - } - - IF( GE_32( st->extl_brate, SWB_TBE_2k8 ) ) - { - test(); - IF( EQ_16( st->codec_mode, MODE1 ) && ( st->element_mode == EVS_MONO ) ) - { - L_tmp = L_mult( extract_l( hBWE_TD->prev2_shb_ener_sf_fx ), extract_l( hBWE_TD->prev3_shb_ener_sf_fx ) ); /*Q1*/ - tmp = round_fx( root_a_fx( L_tmp, 1, &exp ) ); /* Q = 15-exp */ - tmp1 = extract_l( hBWE_TD->prev1_shb_ener_sf_fx ); /*Q0*/ - i = sub( norm_s( tmp1 ), 1 ); - tmp1 = shl( tmp1, i ); /* Qi */ - IF( tmp == 0 ) - { - tmp = 32767 /*1.0f Q15*/; - move16(); /*Q15*/ - } - ELSE - { - scale_fx = div_s( tmp1, tmp ); /* Q15 - Q(15-exp) + Qi = Qexp+i */ - scale_fx = s_max( scale_fx, 0 ); - tmp = shl_sat( scale_fx, sub( sub( 15, exp ), i ) ); /*Q15*/ - } - scale_fx = mult_r( hBWE_TD->prev_res_shb_gshape_fx, tmp ); /* Q14 */ - test(); - IF( GT_32( L_shr( hBWE_TD->prev2_shb_ener_sf_fx, 1 ), hBWE_TD->prev1_shb_ener_sf_fx ) || - GT_32( L_shr( hBWE_TD->prev3_shb_ener_sf_fx, 1 ), hBWE_TD->prev2_shb_ener_sf_fx ) ) - { - shb_ener_sf_32 = Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, scale_fx ); - - if ( GT_16( st->nbLostCmpt, 1 ) ) - { - shb_ener_sf_32 = L_shr( shb_ener_sf_32, 1 ); - } - } - ELSE - { - L_tmp = L_mult( scale_fx, scale_fx ); /* Q29 */ - shb_ener_sf_32 = L_shl( Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, round_fx( L_tmp ) ), 2 ); - } - } - ELSE - { - test(); - IF( GT_32( L_shr( hBWE_TD->prev2_shb_ener_sf_fx, 1 ), hBWE_TD->prev1_shb_ener_sf_fx ) || - GT_32( L_shr( hBWE_TD->prev3_shb_ener_sf_fx, 1 ), hBWE_TD->prev2_shb_ener_sf_fx ) ) - { - shb_ener_sf_32 = L_shr( Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, st->cummulative_damping ), 1 ); - } - ELSE - { - shb_ener_sf_32 = Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, st->cummulative_damping ); - } - } - } - - shb_ener_sf_32 = L_max( shb_ener_sf_32, 1l /*1.0f Q0*/ ); - mixFactors_fx = hBWE_TD->prev_mixFactors_fx; - move16(); - - IF( EQ_16( st->codec_mode, MODE1 ) ) - { - set16_fx( shb_res_gshape_fx, 3277 /*0.2f Q14*/, 5 ); /* Q14 */ - } - ELSE - { - set16_fx( shb_res_gshape_fx, 16384 /*1.0f Q14*/, 5 ); /* Q14 */ - } - } - } - - /* get the gainshape delay */ - Copy( &st->GainShape_Delay[4], &st->GainShape_Delay[0], NUM_SHB_SUBFR / 4 ); - FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) - { - st->GainShape_Delay[i + 4] = GainShape_fx[i * 4]; /*Q15*/ - move16(); - } - - L_tmp = L_mult( voice_factors_fx[0], 8192 ); - L_tmp = L_mac( L_tmp, voice_factors_fx[1], 8192 ); - L_tmp = L_mac( L_tmp, voice_factors_fx[2], 8192 ); - mean_vf = mac_r( L_tmp, voice_factors_fx[3], 8192 ); - - Copy( voice_factors_fx, vf_modified_fx, NB_SUBFR16k ); - - test(); - IF( EQ_16( st->coder_type, VOICED ) || GT_16( mean_vf, 13107 /*0.4f Q15*/ ) ) - { - FOR( i = 1; i < NB_SUBFR; i++ ) - { - L_tmp = L_mult( voice_factors_fx[i], 26214 /*0.8f Q15*/ ); - vf_modified_fx[i] = mac_r( L_tmp, voice_factors_fx[i - 1], 6554 /*0.2f Q15*/ ); - move16(); - } - - IF( st->L_frame != L_FRAME ) - { - L_tmp = L_mult( voice_factors_fx[4], 26214 /*0.8f Q15*/ ); - vf_modified_fx[4] = mac_r( L_tmp, voice_factors_fx[3], 6554 /*0.2f Q15*/ ); - move16(); - } - } - - test(); - IF( st->use_partial_copy && st->nelp_mode_dec ) - { - set16_fx( vf_modified_fx, 0, NB_SUBFR16k ); - } - - /* SHB LSF from current frame; and convert to LSP for interpolation */ - E_LPC_lsf_lsp_conversion( lsf_shb_fx, lsp_shb_2_fx, LPC_SHB_ORDER ); - - test(); - IF( EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) - { - /* SHB LSP values from prev. frame for interpolation */ - Copy( hBWE_TD->swb_lsp_prev_interp_fx, lsp_shb_1_fx, LPC_SHB_ORDER ); - } - ELSE - { - /* Use current frame's LSPs; in effect no interpolation */ - Copy( lsp_shb_2_fx, lsp_shb_1_fx, LPC_SHB_ORDER ); - } - - test(); - test(); - test(); - IF( ( st->bws_cnt == 0 ) && ( st->bws_cnt1 == 0 ) && ( st->prev_use_partial_copy == 0 ) && ( st->use_partial_copy == 0 ) ) - { - lsf_diff_fx[0] = 16384; - move16(); /*Q15*/ - lsf_diff_fx[LPC_SHB_ORDER - 1] = 16384; - move16(); /*Q15*/ - FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) - { - lsf_diff_fx[i] = sub( lsf_shb_fx[i], lsf_shb_fx[i - 1] ); - move16(); - } - - a2rc_fx( hBWE_TD->cur_sub_Aq_fx + 1, refl_fx, M ); - tmp = add( 16384, shr( refl_fx[0], 1 ) ); /*Q14*/ - tmp1 = mult( 27425, tmp ); - tmp1 = mult( tmp1, tmp ); /*Q10*/ - tmp2 = shr( mult( 31715, tmp ), 2 ); /*Q10*/ - tilt_para_fx = add( sub( tmp1, tmp2 ), 1335 ); /*Q10*/ - - test(); - IF( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) - { - FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) - { - hBWE_TD->prev_lsf_diff_fx[i - 1] = shr( lsf_diff_fx[i], 1 ); - move16(); - } - } - - IF( LE_32( st->extl_brate, FB_TBE_1k8 ) ) - { - test(); - test(); - test(); - test(); - test(); - IF( !( GT_16( hBWE_TD->prev_tilt_para_fx, 5120 ) && ( EQ_16( st->coder_type, TRANSITION ) || LT_16( tilt_para_fx, 1024 ) ) ) && - !( ( ( LT_16( hBWE_TD->prev_tilt_para_fx, 3072 ) && GE_16( st->prev_coder_type, VOICED ) ) ) && GT_16( tilt_para_fx, 5120 ) ) ) - { - FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) - { - IF( LT_16( lsf_diff_fx[i], hBWE_TD->prev_lsf_diff_fx[i - 1] ) ) - { - tmp = mult( 26214, lsf_diff_fx[i] ); - - test(); - IF( ( hBWE_TD->prev_lsf_diff_fx[i - 1] <= 0 ) || ( tmp < 0 ) ) /* safety check in case of bit errors */ - { - st->BER_detect = 1; - move16(); - tmp = 0; - move16(); - } - ELSE - { - tmp = div_s( tmp, hBWE_TD->prev_lsf_diff_fx[i - 1] ); - } - - tmp = s_max( tmp, 16384 ); - w_fx[i] = s_min( tmp, 32767 ); - move16(); - } - ELSE - { - tmp = mult( 26214, hBWE_TD->prev_lsf_diff_fx[i - 1] ); - - test(); - IF( ( lsf_diff_fx[i] <= 0 ) || ( tmp < 0 ) ) /* safety check in case of bit errors */ - { - st->BER_detect = 1; - move16(); - tmp = 0; - move16(); - } - ELSE - { - tmp = div_s( tmp, lsf_diff_fx[i] ); - } - - tmp = s_max( tmp, 16384 ); - w_fx[i] = s_min( tmp, 32767 ); - move16(); - } - } - w_fx[0] = w_fx[1]; - move16(); - w_fx[LPC_SHB_ORDER - 1] = w_fx[LPC_SHB_ORDER - 2]; - move16(); - - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - tmp1 = mult( lsp_shb_1_fx[i], sub( 32767, w_fx[i] ) ); - tmp2 = mult( lsp_shb_2_fx[i], w_fx[i] ); - lsp_temp_fx[i] = add( tmp1, tmp2 ); - move16(); - } - } - ELSE - { - Copy( lsp_shb_2_fx, lsp_temp_fx, LPC_SHB_ORDER ); - } - - /* convert from lsp to lsf */ - lsp2lsf_fx( lsp_temp_fx, lsf_shb_fx, LPC_SHB_ORDER, 1 ); - } - - Copy( lsf_diff_fx + 1, hBWE_TD->prev_lsf_diff_fx, LPC_SHB_ORDER - 2 ); - hBWE_TD->prev_tilt_para_fx = tilt_para_fx; - move16(); - } - ELSE - { - Copy( lsp_shb_2_fx, lsp_temp_fx, LPC_SHB_ORDER ); - } - - IF( GE_32( st->extl_brate, SWB_TBE_2k8 ) ) - { - /* SHB LSP interpolation */ - ptr_lsp_interp_coef_fx = interpol_frac_shb; /*Q15*/ - FOR( j = 0; j < 4; j++ ) - { - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - L_tmp = L_mult( lsp_shb_1_fx[i], ( *ptr_lsp_interp_coef_fx ) ); - lsp_temp_fx[i] = mac_r( L_tmp, lsp_shb_2_fx[i], ( *( ptr_lsp_interp_coef_fx + 1 ) ) ); - move16(); - } - ptr_lsp_interp_coef_fx += 2; - - tmp = i_mult( j, ( LPC_SHB_ORDER + 1 ) ); - /* convert LSPs to LP coefficients */ - E_LPC_f_lsp_a_conversion( lsp_temp_fx, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER ); -#ifndef FIX_1100_REMOVE_LPC_RESCALING - /* Bring the LPCs to Q12 */ - Copy_Scale_sig( lpc_shb_sf_fx + tmp, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_sf_fx[tmp] ), 2 ) ); - lpc_shb_sf_fx[i_mult( j, ( LPC_SHB_ORDER + 1 ) )] = ONE_IN_Q12; // recheck this - move16(); -#endif - } - } - - /* Save the SWB LSP values from current frame for interpolation */ - Copy( lsp_shb_2_fx, hBWE_TD->swb_lsp_prev_interp_fx, LPC_SHB_ORDER ); - - /* save the shb_ener and mixFactor values */ - hBWE_TD->prev3_shb_ener_sf_fx = hBWE_TD->prev2_shb_ener_sf_fx; - move32(); - hBWE_TD->prev2_shb_ener_sf_fx = hBWE_TD->prev1_shb_ener_sf_fx; - move32(); - hBWE_TD->prev1_shb_ener_sf_fx = shb_ener_sf_32; - move32(); - hBWE_TD->prev_res_shb_gshape_fx = shb_res_gshape_fx[4]; - move16(); - hBWE_TD->prev_mixFactors_fx = mixFactors_fx; - move16(); - - /* SWB CNG/DTX - update memories */ - IF( st->hTdCngDec != NULL ) - { - Copy( st->hTdCngDec->lsp_shb_prev_fx, st->hTdCngDec->lsp_shb_prev_prev_fx, LPC_SHB_ORDER ); - Copy( lsf_shb_fx, st->hTdCngDec->lsp_shb_prev_fx, LPC_SHB_ORDER ); - } - - /* convert LSPs back into LP coeffs */ - E_LPC_f_lsp_a_conversion( lsp_temp_fx, lpc_shb_fx, LPC_SHB_ORDER ); - Copy_Scale_sig( lpc_shb_fx, lpc_shb_fx, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_fx[0] ), 2 ) ); /* Q12 */ - lpc_shb_fx[0] = ONE_IN_Q12; - move16(); - - test(); - IF( EQ_32( st->extl_brate, SWB_TBE_1k10 ) || EQ_32( st->extl_brate, SWB_TBE_1k75 ) ) - { - Word32 vind_temp = Mpy_32_32( L_shl( L_add( L_deposit_l( mixFactors_fx ), 1 ), 15 ), ( ( ( 1 << NUM_BITS_SHB_VF ) - 1 ) << 16 ) ); // check addition of 1 - vind = extract_l( L_shr( vind_temp, 15 ) ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*7*/ - /* i: mixFactors_fx in Q15 */ - /* o: vind in Q0 */ - } - ELSE - { - vind = shl( mixFactors_fx, 3 - 15 ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*8*/ - /* i: mixFactors_fx in Q15 */ - /* o: vind in Q0 */ - } - - /* Determine formant PF strength */ - formant_fac_fx = swb_formant_fac_fx( lpc_shb_fx[1], &hBWE_TD->tilt_mem_fx ); - /* i:lpc_shb_fx Q12, o:formant_fac_fx Q15 */ - IF( GT_32( st->total_brate, ACELP_32k ) ) - { - FOR( j = 0; j < 4; j++ ) - { - Copy( lpc_shb_fx, &lpc_shb_sf_fx[i_mult( j, ( LPC_SHB_ORDER + 1 ) )], LPC_SHB_ORDER + 1 ); - } - } - - /* From low band excitation, generate highband excitation */ - - /* -------- start of memory rescaling -------- */ - /* ----- calculate optimum Q_bwe_exc and rescale memories accordingly ----- */ - Lmax = 0; - move32(); - FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) - { - Lmax = L_max( Lmax, L_abs( bwe_exc_extended_fx[cnt] ) ); - } - Q_bwe_exc = norm_l( Lmax ); - if ( Lmax == 0 ) - { - Q_bwe_exc = 31; - move16(); - } - Q_bwe_exc = add( Q_bwe_exc, add( Q_exc, Q_exc ) ); - find_max_mem_dec( st, &n_mem, &n_mem2, &n_mem3 ); /* for >=24.4, use n_mem2 lpc_syn, shb_20sample, and mem_stp_swb_fx memory */ - - tmp = add( st->prev_Q_bwe_exc, n_mem ); - if ( GT_16( Q_bwe_exc, tmp ) ) - { - Q_bwe_exc = tmp; - move16(); - } - - /* rescale the memories if Q_bwe_exc is different from previous frame */ - sc = sub( Q_bwe_exc, st->prev_Q_bwe_exc ); - IF( sc != 0 ) - { - rescale_genSHB_mem_dec( st, sc ); - } - - /* rescale the bwe_exc_extended and bring it to 16-bit single precision with dynamic norm */ - sc = sub( Q_bwe_exc, add( Q_exc, Q_exc ) ); - - FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) - { - bwe_exc_extended_16[cnt] = round_fx_sat( L_shl_sat( bwe_exc_extended_fx[cnt], sc ) ); - move16(); - } - - /* state_syn_shbexc_fx is kept at (st_fx->prev_Q_bwe_syn) for 24.4/32kbps or is kept at Q_bwe_exc for 13.2/16.4kbps */ - - /* save the previous Q factor (32-bit) of the buffer */ - st->prev_Q_bwe_exc = Q_bwe_exc; - move16(); - - Q_bwe_exc = sub( Q_bwe_exc, 16 ); /* Q_bwe_exc reflecting the single precision dynamic norm-ed buffers from here */ - - /* -------- end of rescaling memories -------- */ - - Q_bwe_exc_fb = st->prev_Q_bwe_exc_fb; - move16(); - - Q_shb = 0; - move16(); - - Copy( hBWE_TD->state_syn_shbexc_fx, shaped_shb_excitation_fx, L_SHB_LAHEAD ); - GenShapedSHBExcitation_ivas_dec_fx( shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, - hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, - st->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st->extl, - &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_32, - shb_res_gshape_fx, shb_res_dummy_fx, &vind, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, - &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, st->prev_Q_bwe_syn, st->total_brate, st->prev_bfi, - st->element_mode, st->flag_ACELP16k, nlExc16k_fx, mixExc16k_fx, st->extl_brate, MSFlag, - NULL, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), NULL, NULL ); - - *Q_white_exc = Q_bwe_exc_fb; - move16(); - IF( EQ_16( st->extl, FB_TBE ) ) - { - st->prev_Q_bwe_exc_fb = Q_bwe_exc_fb; - move16(); - } - ELSE - { - /*Indirectly a memory reset of FB memories for next frame such that rescaling of memories would lead to 0 due to such high prev. Q value. - 51 because of 31 + 20(shift of Q_bwe_exc_fb before de-emphasis)*/ - st->prev_Q_bwe_exc_fb = 51; - move16(); - } - - /* rescale the TBE post proc memory */ - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - hBWE_TD->mem_stp_swb_fx[i] = shl_sat( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, st->prev_Q_bwe_syn ) ); - move16(); - } - /* fill-in missing SHB excitation */ - test(); - test(); - IF( ( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) && LE_32( st->last_core_brate, SID_2k40 ) ) - { - Copy( shaped_shb_excitation_fx + L_SHB_LAHEAD, shaped_shb_excitation_fx, L_SHB_LAHEAD ); - } - - IF( hStereoICBWE != NULL ) - { - Copy( shaped_shb_excitation_fx + L_SHB_LAHEAD, hStereoICBWE->shbSynthRef_fx, L_FRAME16k ); - } - - test(); - IF( NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) ) - { - FOR( i = 0; i < L_FRAME16k; i += L_SUBFR16k ) - { - /* TD BWE post-processing */ - PostShortTerm_ivas_dec_fx( &shaped_shb_excitation_fx[L_SHB_LAHEAD + i], lpc_shb_fx, &shaped_shb_excitationTemp_fx[i], hBWE_TD->mem_stp_swb_fx, - hBWE_TD->ptr_mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ), hBWE_TD->mem_zero_swb_fx, formant_fac_fx ); - } - - Copy( shaped_shb_excitationTemp_fx, &shaped_shb_excitation_fx[L_SHB_LAHEAD], L_FRAME16k ); /* Q_bwe_exc */ - - tmp = sub( shl( Q_bwe_exc, 1 ), 31 + 16 ); - prev_pow_fx = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ - curr_pow_fx = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ - FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) - { - prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /*2*Q_bwe_exc*/ - curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ - } - - if ( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) ) - { - curr_pow_fx = L_shr( curr_pow_fx, 2 ); /* Q(2*Q_bwe_exc) */ - } - - Lscale = root_a_over_b_fx( curr_pow_fx, - shl( Q_bwe_exc, 1 ), - prev_pow_fx, - shl( Q_bwe_exc, 1 ), - &exp ); - - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ - move16(); - } - IF( exp < 0 ) - { - Lscale = L_shl( Lscale, exp ); - exp = 0; - move16(); - } - FOR( ; i < L_SHB_LAHEAD + 10; i++ ) - { - temp_fx = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp_fx ); /* Q31-exp */ - temp_fx = sub( 32767 /*1.0f Q15*/, temp_fx ); - Lscale = L_add( Mult_32_16( Lscale, temp_fx ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ - move16(); - } - } - ELSE - { - /* reset the PF memories if the PF is not running */ - set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); - hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; - move16(); - set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - } - - /* Update SHB excitation */ - Copy( shaped_shb_excitation_fx + L_FRAME16k, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD ); /* Q_bwe_exc */ - l_subframe = L_FRAME16k / NUM_SHB_SUBGAINS; - move16(); - L_ener = EPSILON_FX_SMALL; - move32(); - - FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) - { - L_tmp = 0; - move32(); - ener_tmp_fx[i] = EPSILON_FX_SMALL; - move32(); - - Word64 tmp64 = 0; - move64(); - FOR( j = 0; j < l_subframe; j++ ) - { - tmp64 = W_mac0_16_16( tmp64, shaped_shb_excitation_fx[add( i_mult( i, l_subframe ), j )], shaped_shb_excitation_fx[add( i_mult( i, l_subframe ), j )] ); /* 2*Q_bwe_exc */ - } - L_tmp = W_sat_l( tmp64 ); - - L_tmp = Mult_32_16( L_tmp, 410 /*0.0125 Q15*/ ); /* 2*Q_bwe_exc: ener_tmp_fx in (2*Q_bwe_exc) */ - IF( L_tmp != 0 ) - { - exp = norm_l( L_tmp ); - tmp = extract_h( L_shl( L_tmp, exp ) ); - exp = sub( exp, sub( 30, i_mult( 2, Q_bwe_exc ) ) ); - - tmp = div_s( 16384, tmp ); - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); - ener_tmp_fx[i] = L_shl_sat( L_tmp, sub( add( exp, shl( Q_bwe_exc, 1 ) ), 31 ) ); /*2 * Q_bwe_exc: Q31 -exp +exp +2 * Q_bwe_exc -31 */ - move32(); - L_ener = L_add_sat( L_ener, L_shr( ener_tmp_fx[i], 2 ) ); /* 2*Q_bwe_exc */ - } - } - ener_fx = s_max( 1, round_fx_sat( L_shl_sat( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */ - /* WB/SWB bandwidth switching */ - IF( st->bws_cnt > 0 ) - { - IF( is_fractive == 0 ) - { - IF( GT_16( st->tilt_wb_fx, 2048 ) ) /*assuming st->tilt_wb_fx in Q11*/ - { - st->tilt_wb_fx = 2048; - move16(); - } - ELSE IF( LT_16( st->tilt_wb_fx, 1024 ) ) - { - st->tilt_wb_fx = 1024; - move16(); - } - test(); - if ( EQ_16( st->prev_fractive, 1 ) && GT_16( st->tilt_wb_fx, 1024 ) ) - { - st->tilt_wb_fx = 1024; - move16(); - } - } - ELSE - { - IF( GT_16( st->tilt_wb_fx, 8192 ) ) - { - IF( st->prev_fractive == 0 ) - { - st->tilt_wb_fx = 8192; - move16(); - } - ELSE - { - st->tilt_wb_fx = 16384; - move16(); - } - } - ELSE - { - st->tilt_wb_fx = shl( st->tilt_wb_fx, 2 ); - move16(); - } - } - - IF( ener_fx != 0 ) - { - L_tmp = L_shl( L_mult0( ener_fx, st->tilt_wb_fx ), sub( st->Q_syn2, 13 ) ); /* 2+11 +st->Q_syn2 -13 = st->Q_syn2*/ - exp_ener = norm_s( ener_fx ); - tmp = shl( ener_fx, exp_ener ); /*Q(2+exp)*/ - inv_ener = shr( div_s( 16384, tmp ), 1 ); /*Q(15+14-2-exp-1) = 26 - exp*/ - - test(); - IF( GT_32( L_tmp, st->enerLH_fx ) ) /*st->Q_syn2*/ - { - st->tilt_wb_fx = extract_h( L_shr_sat( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 16 ) ) ); /*Q11*/ - move16(); - /*st->Q_syn2 -1 + 26- exp_ener -15 -(st->Q_syn2 -exp_ener -16 ) -16 +1 -1 = (11) *0.5*/ - } - ELSE IF( LT_32( L_tmp, Mult_32_16( st->enerLH_fx, 1638 ) ) && EQ_16( is_fractive, 1 ) ) - { - st->tilt_wb_fx = extract_h( L_shr_sat( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 15 ) ) ); /*Q11*/ - move16(); - /*st->Q_syn2 -1 + 26- exp_ener -15 -(st->Q_syn2 -exp_ener -15 ) -16 = (11) 0.25*/ - } - L_tmp = L_mult0( st->prev_ener_shb_fx, inv_ener ); /*Q(1+15+14-3-exp_ener) = 27 -exp_ener*/ - GainFrame_prevfrm_fx = L_shr( L_tmp, sub( 9, exp_ener ) ); /*27 -exp_ener -(9-exp_ener )= Q18*/ - } - ELSE - { - GainFrame_prevfrm_fx = 0; - move32(); - } - - IF( EQ_16( is_fractive, 1 ) ) - { - GainFrame_fx = L_shl( L_deposit_l( st->tilt_wb_fx ), 10 ); - } - ELSE - { - GainFrame_fx = L_shl( L_deposit_l( st->tilt_wb_fx ), 8 ); - } - - test(); - IF( EQ_16( ( is_fractive & st->prev_fractive ), 1 ) && GT_32( GainFrame_fx, GainFrame_prevfrm_fx ) ) - { - GainFrame_fx = L_add( Mult_32_16( GainFrame_prevfrm_fx, 26214 ), Mult_32_16( GainFrame_fx, 6554 ) ); /* 18 +15 -15 = 18*/ - } - ELSE - { - test(); - test(); - test(); - test(); - IF( ( LT_32( L_shr( st->prev_enerLH_fx, 1 ), st->enerLH_fx ) && GT_32( st->prev_enerLH_fx, L_shr( st->enerLH_fx, 1 ) ) ) && ( LT_32( L_shr( st->prev_enerLL_fx, 1 ), st->enerLL_fx ) && GT_32( st->prev_enerLL_fx, L_shr( st->enerLL_fx, 1 ) ) ) && ( s_xor( is_fractive, st->prev_fractive ) == 0 ) ) - { - GainFrame_fx = L_add( L_shr( GainFrame_fx, 1 ), L_shr( GainFrame_prevfrm_fx, 1 ) ); - } - ELSE - { - test(); - IF( ( is_fractive == 0 ) && EQ_16( st->prev_fractive, 1 ) ) - { - L_tmp1 = L_shl( Mult_32_16( GainFrame_fx, 3277 ), 13 ); /* 31 */ - L_tmp = L_sub( 2147483647, L_tmp1 ); /* 31 */ - GainFrame_fx = L_add( Mult_32_32( GainFrame_fx, L_tmp ), Mult_32_32( GainFrame_prevfrm_fx, L_tmp1 ) ); /* 18 */ - } - ELSE - { - GainFrame_fx = L_add( L_shr( GainFrame_fx, 1 ), L_shr( L_min( GainFrame_prevfrm_fx, GainFrame_fx ), 1 ) ); /* 18 */ - } - } - } - - GainFrame_fx = Mult_32_16( GainFrame_fx, i_mult( sub( N_WS2N_FRAMES, st->bws_cnt ), 819 ) ); /*Q18*/ - } - ELSE - { - IF( st->bws_cnt1 > 0 ) - { - GainFrame_fx = Mult_32_16( GainFrame_fx, i_mult( st->bws_cnt1, 819 ) ); /*Q18*/ - } - IF( GE_16( st->nbLostCmpt, 1 ) ) - { - ener_fx = s_max( 1, ener_fx ); - exp_ener = norm_s( ener_fx ); - tmp = shl( ener_fx, exp_ener ); /*Q(2+exp)*/ - inv_ener = div_s( 16384, tmp ); /*Q(15+14-2-exp)*/ - prev_ener_ratio_fx = L_shr( L_mult0( st->prev_ener_shb_fx, inv_ener ), add( sub( 9, exp_ener ), 1 ) ); /*Q: 1+27-exp-9+exp-1 = 18 */ - } - - IF( EQ_16( st->nbLostCmpt, 1 ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( st->clas_dec != UNVOICED_CLAS ) && NE_16( st->clas_dec, UNVOICED_TRANSITION ) && LT_16( hBWE_TD->tilt_swb_fec_fx, 16384 ) && - ( ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) && LT_32( L_shr( st->enerLL_fx, 1 ), st->prev_enerLL_fx ) ) || ( GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) && LT_32( L_shr( st->enerLH_fx, 1 ), st->prev_enerLH_fx ) ) ) ) - { - IF( GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) ) /*18*/ - { - GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 13107 ), Mult_32_16( GainFrame_fx, 19661 ) ); /*18*/ - } - ELSE IF( GT_32( L_shr( prev_ener_ratio_fx, 1 ), GainFrame_fx ) ) - { - GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 26214 ), Mult_32_16( GainFrame_fx, 6554 ) ); - } - ELSE - { - GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 ), Mult_32_16( GainFrame_fx, 26214 ) ); - } - - test(); - IF( GT_16( tilt_swb_fec_fx, hBWE_TD->tilt_swb_fec_fx ) && ( hBWE_TD->tilt_swb_fec_fx > 0 ) ) - { - exp = norm_s( hBWE_TD->tilt_swb_fec_fx ); - tmp = shl( hBWE_TD->tilt_swb_fec_fx, exp ); /*Q(11+exp)*/ - tmp = div_s( 16384, tmp ); /*Q(15+14-11-exp)*/ - tmp = extract_h( L_shl( L_mult0( tmp, st->tilt_wb_fx ), sub( exp, 1 ) ) ); /*18 -exp +11 + exp -1 -16 =12; */ - GainFrame_fx = L_shl( Mult_32_16( GainFrame_fx, s_min( tmp, 20480 ) ), 3 ); /*Q18 = 18 +12 -15 +3 */ - } - } - ELSE IF( ( ( st->clas_dec != UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 4096 ) ) && GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) && - ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) ) - { - GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 ), Mult_32_16( GainFrame_fx, 26214 ) ); - } - } - ELSE IF( GT_16( st->nbLostCmpt, 1 ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) && ( ( EQ_16( st->codec_mode, MODE1 ) && GT_32( st->enerLL_fx, st->prev_enerLL_fx ) && GT_32( st->enerLH_fx, st->prev_enerLH_fx ) ) || EQ_16( st->codec_mode, MODE2 ) ) ) - { - test(); - IF( GT_16( tilt_swb_fec_fx, 20480 /*10.0f in Q11*/ ) && GT_16( hBWE_TD->tilt_swb_fec_fx, 20480 /*10.0f in Q11*/ ) ) - { - GainFrame_fx = L_min( L_add( Mult_32_16( prev_ener_ratio_fx, 26214 /*0.8f in Q15*/ ), Mult_32_16( GainFrame_fx, 6554 /*0.2f in Q15*/ ) ), L_shl( Mult_32_16( GainFrame_fx, 16384 /*4.0f in Q12*/ ), 3 ) ); /*Q18*/ - } - ELSE - { - GainFrame_fx = L_min( L_add( Mult_32_16( prev_ener_ratio_fx, 16384 ), Mult_32_16( GainFrame_fx, 16384 ) ), L_shl( Mult_32_16( GainFrame_fx, 16384 ), 3 ) ); /*Q18*/ - } - } - ELSE IF( GT_32( prev_ener_ratio_fx, GainFrame_fx ) && ( ( EQ_16( st->codec_mode, MODE1 ) && GT_32( st->enerLL_fx, st->prev_enerLL_fx ) && GT_32( st->enerLH_fx, st->prev_enerLH_fx ) ) || EQ_16( st->codec_mode, MODE2 ) ) ) - { - test(); - IF( GT_16( tilt_swb_fec_fx, 20480 ) && GT_16( hBWE_TD->tilt_swb_fec_fx, 20480 ) ) - { - GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 16384 /*0.5f in Q15*/ ), Mult_32_16( GainFrame_fx, 16384 /*0.5f in Q15*/ ) ); /* Q18 */ - } - ELSE - { - GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 /*0.2f in Q15*/ ), Mult_32_16( GainFrame_fx, 26214 /*0.8f in Q15*/ ) ); /* Q18 */ - } - } - } - } - - st->prev_fractive = is_fractive; - move16(); - - /* Adjust the subframe and frame gain of the synthesized shb signal */ - /* Scale the shaped excitation */ - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - L_tmp = L_mult( pitch_buf_fx[0], 8192 ); - FOR( i = 1; i < NB_SUBFR; i++ ) - { - L_tmp = L_mac( L_tmp, pitch_buf_fx[i], 8192 ); /* pitch_buf in Q6 x 0.25 in Q15 */ - } - pitch_fx = round_fx( L_tmp ); /* Q6 */ - } - ELSE - { - L_tmp = L_mult( pitch_buf_fx[0], 6554 ); - FOR( i = 1; i < NB_SUBFR16k; i++ ) - { - L_tmp = L_mac( L_tmp, pitch_buf_fx[i], 6554 ); /* pitch_buf in Q6 x 0.2 in Q15 */ - } - pitch_fx = round_fx( L_tmp ); /* Q6 */ - } - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( GE_32( st->extl_brate, SWB_TBE_2k8 ) && EQ_16( st->prev_coder_type, st->coder_type ) && NE_16( st->coder_type, UNVOICED ) ) || ( LT_32( st->extl_brate, SWB_TBE_2k8 ) && ( EQ_16( st->prev_coder_type, st->coder_type ) || ( EQ_16( st->prev_coder_type, VOICED ) && EQ_16( st->coder_type, GENERIC ) ) || ( EQ_16( st->prev_coder_type, GENERIC ) && EQ_16( st->coder_type, VOICED ) ) ) ) ) && GT_16( pitch_fx, 4480 /*70 in Q6*/ ) && LT_16( st->extl, FB_TBE ) && NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) ) - { - FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) - { - GainShape_tmp_fx[i] = GainShape_fx[i * 4]; /* Q15 */ - move16(); - } - - FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) - { - L_tmp1 = Mult_32_16( ener_tmp_fx[i], GainShape_tmp_fx[i] ); /* (2*Q_bwe_exc) */ - L_tmp2 = Mult_32_16( hBWE_TD->prev_ener_fx, hBWE_TD->prev_GainShape_fx ); /* (2*st->prev_ener_fx_Q) */ - tmp = sub( shl( Q_bwe_exc, 1 ), shl( st->prev_ener_fx_Q, 1 ) ); - L_tmp2 = L_shl_sat( L_tmp2, tmp ); /* new Q = (2*Q_bwe_exc) */ - IF( GT_32( L_tmp1, L_tmp2 ) ) - { - L_tmp = L_tmp2; - move32(); - if ( L_tmp2 < 0 ) - { - L_tmp = L_negate( L_tmp2 ); - } - - expb = norm_l( L_tmp ); - fracb = round_fx_sat( L_shl_sat( L_tmp, expb ) ); - expb = sub( 30, expb ); /* - (2*Q_bwe_exc_ext); */ - - expa = norm_l( ener_tmp_fx[i] ); - fraca = extract_h( L_shl( ener_tmp_fx[i], expa ) ); - expa = sub( 30, expa ); - - scale_fx = shr( sub( fraca, fracb ), 15 ); - fracb = shl( fracb, scale_fx ); - expb = sub( expb, scale_fx ); - - tmp = div_s( fracb, fraca ); - exp = sub( sub( expb, expa ), 1 ); - tmp = shl( tmp, exp ); - GainShape_tmp_fx[i] = add( tmp, shr( GainShape_tmp_fx[i], 1 ) ); /* Q15 */ - move16(); - } - - hBWE_TD->prev_ener_fx = ener_tmp_fx[i]; - move32(); - hBWE_TD->prev_GainShape_fx = GainShape_tmp_fx[i]; - move16(); - st->prev_ener_fx_Q = Q_bwe_exc; - move16(); - } - - FOR( i = 0; i < NUM_SHB_SUBFR; i++ ) - { - Word16 idx = 0; - move16(); - IF( i != 0 ) - { - idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); - } - GainShape_fx[i] = GainShape_tmp_fx[idx]; - move16(); - } - } - ELSE - { - st->prev_ener_fx_Q = Q_bwe_exc; - move16(); - } - st->prev_Q_bwe_syn = Q_bwe_exc; - move16(); - - - /* Gain shape smoothing after quantization */ - test(); - IF( EQ_32( st->extl_brate, SWB_TBE_1k10 ) || EQ_32( st->extl_brate, SWB_TBE_1k75 ) ) - { - FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) - { - GainShape_tmp_fx[i] = GainShape_fx[i * NUM_SHB_SUBGAINS]; - move16(); - } - - lls_interp_n_fx( GainShape_tmp_fx, NUM_SHB_SUBGAINS, &GainShape_tilt_fx, &temp_fx, 1 ); - - test(); - IF( GE_16( vind, 6 ) && LT_16( abs_s( GainShape_tilt_fx ), 3932 ) ) - { - feedback_fx = 9830; - move16(); - FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) - { - GainShape_fx[i] = add_sat( mult( sub( 32767, feedback_fx ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), mult( feedback_fx, GainShape_tmp_fx[i] ) ); - move16(); - } - - FOR( i = NUM_SHB_SUBFR - 1; i > 0; i-- ) - { - Word16 idx = 0; - move16(); - IF( i != 0 ) - { - idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); - } - GainShape_fx[i] = GainShape_fx[idx]; - move16(); - } - } - } - - /* fil-in missing memory */ - test(); - test(); - IF( ( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) && LE_32( st->last_core_brate, SID_2k40 ) ) - { - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - Word16 intermediate = mult( shaped_shb_excitation_fx[i], subwin_shb_fx[L_SHB_LAHEAD - i] ); - Word32 intermediate_32 = Mpy_32_16_1( Mpy_32_16_1( GainFrame_fx, window_shb_fx[L_SHB_LAHEAD - 1 - i] ), intermediate ); - hBWE_TD->syn_overlap_fx[i] = round_fx( L_shl_sat( intermediate_32, sub( 16, ( add( Q_bwe_exc, 18 - 15 ) ) ) ) ); - move16(); - } - } - - Word16 n_mem3_new = 0; - move16(); - find_max_mem_dec_m3( st, &n_mem3_new ); - - ScaleShapedSHB_fx( SHB_OVERLAP_LEN, - shaped_shb_excitation_fx, /* i/o: Q_bwe_exc */ - hBWE_TD->syn_overlap_fx, - GainShape_fx, /* Q15 */ - GainFrame_fx, /* Q18 */ - window_shb_fx, - subwin_shb_fx, - &Q_bwe_exc, &Qx, n_mem3_new, st->prev_Q_bwe_syn2 ); - - IF( hStereoICBWE != NULL ) - { - Copy_Scale_sig_16_32_DEPREC( lpc_shb_fx, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER + 1, 0 ); - Copy( GainShape_fx, hStereoICBWE->gshapeRef_fx, NUM_SHB_SUBFR ); - hStereoICBWE->gFrameRef_fx = GainFrame_fx; - move32(); - - Copy( shaped_shb_excitation_fx, hStereoICBWE->shbSynthRef_fx, L_FRAME16k ); - } - - max_val = 0; - move16(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - max_val = s_max( max_val, abs_s( shaped_shb_excitation_fx[i] ) ); /* Q0 */ - } - IF( max_val == 0 ) - { - curr_frame_pow_fx = 0; - move32(); - n = 0; - move16(); - } - ELSE - { - n = norm_s( max_val ); - max_val = 0; - move16(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - shaped_shb_excitation_frac[i] = shl_sat( shaped_shb_excitation_fx[i], n ); /*Q_bwe_exc+n*/ - move16(); - } - - curr_frame_pow_fx = 0; - move32(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - L_tmp = L_mult0( shaped_shb_excitation_frac[i], shaped_shb_excitation_frac[i] ); /*2*(Q_bwe_exc+n)*/ - curr_frame_pow_fx = L_add( curr_frame_pow_fx, L_shr( L_tmp, 9 ) ); /*2*(Q_bwe_exc+n)-9*/ - } - } - curr_frame_pow_exp = sub( shl( add( Q_bwe_exc, n ), 1 ), 9 ); - tmp = sub( st->prev_frame_pow_exp, curr_frame_pow_exp ); - IF( tmp > 0 ) /* shifting prev */ - { - IF( GT_16( tmp, 32 ) ) - { - st->prev_frame_pow_exp = add( curr_frame_pow_exp, 32 ); - move16(); - tmp = 32; - move16(); - } - hBWE_TD->prev_swb_bwe_frame_pow_fx = L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, tmp ); - move32(); - st->prev_frame_pow_exp = curr_frame_pow_exp; - move16(); - } - ELSE /* shifting curr */ - { - IF( LT_16( tmp, -32 ) ) - { - curr_frame_pow_exp = sub( st->prev_frame_pow_exp, 32 ); - tmp = -32; - move16(); - } - curr_frame_pow_fx = L_shr( curr_frame_pow_fx, -tmp ); - curr_frame_pow_exp = st->prev_frame_pow_exp; - move16(); - } - test(); - test(); - IF( !st->bfi && ( st->prev_bfi || st->prev_use_partial_copy ) ) - { - test(); - test(); - IF( ( GT_32( L_shr( curr_frame_pow_fx, 1 ), hBWE_TD->prev_swb_bwe_frame_pow_fx ) ) && - ( GT_32( hBWE_TD->prev_swb_bwe_frame_pow_fx, L_tmp ) ) && EQ_16( st->prev_coder_type, UNVOICED ) ) - { - L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); - scale_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/ - - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - temp_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/ - } - ELSE - { - scale_fx = temp_fx = 32767; - move16(); /*Q15*/ - move16(); /*Q15*/ - } - - FOR( j = 0; j < 8; j++ ) - { - GainShape_fx[2 * j] = mult_r( GainShape_fx[2 * j], scale_fx ); - move16(); - GainShape_fx[2 * j + 1] = mult_r( GainShape_fx[2 * j + 1], scale_fx ); - move16(); - FOR( i = 0; i < L_FRAME16k / 8; i++ ) - { - shaped_shb_excitation_fx[add( i, j * ( L_FRAME16k / 8 ) )] = mult_r( shaped_shb_excitation_fx[add( i, j * ( L_FRAME16k / 8 ) )], scale_fx ); - move16(); - } - - IF( temp_fx > 0 ) - { - /* scale_fx <= temp_fx, due to scale_fx = sqrt( st->prev_swb_bwe_frame_pow_fx/curr_frame_pow_fx ), temp_fx = sqrt( scale_fx, 1.f/8.f ) - and curr_frame_pow_fx > st->prev_swb_bwe_frame_pow_fx -> scale_fx <= 1.0, sqrt(scale_fx, 1.f/8.f) >= scale_fx */ - IF( LT_16( scale_fx, temp_fx ) ) - { - scale_fx = div_s( scale_fx, temp_fx ); - } - ELSE - { - scale_fx = 32767; - move16(); - } - } - ELSE - { - scale_fx = 0; - move16(); - } - } - } - - /* adjust the FEC frame energy */ - IF( st->bfi ) - { - scale_fx = temp_fx = 4096; - move16(); /*Q12*/ - move16(); - IF( EQ_16( st->nbLostCmpt, 1 ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( GT_32( curr_frame_pow_fx, hBWE_TD->prev_swb_bwe_frame_pow_fx ) && - NE_16( st->prev_coder_type, UNVOICED ) && - ( st->last_good != UNVOICED_CLAS ) ) - { - L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); /*31 - exp*/ - scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - } - ELSE IF( LT_32( curr_frame_pow_fx, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) && EQ_16( st->nbLostCmpt, 1 ) && - ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) && - ( EQ_16( st->prev_coder_type, UNVOICED ) || ( st->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) ) - { - L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); - scale_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - } - } - ELSE IF( GT_16( st->nbLostCmpt, 1 ) ) - { - test(); - test(); - test(); - test(); - test(); - IF( GT_32( curr_frame_pow_fx, hBWE_TD->prev_swb_bwe_frame_pow_fx ) ) - { - L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); - scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - temp_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - } - ELSE IF( LT_32( curr_frame_pow_fx, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) && - ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) && - ( EQ_16( st->prev_coder_type, UNVOICED ) || ( st->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) ) - { - L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); - L_tmp = L_min( L_tmp, L_shl_sat( 2, sub( 31, exp ) ) ); /*31 - exp*/ - scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); - temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ - } - } - - FOR( j = 0; j < 8; j++ ) - { - GainShape_fx[2 * j] = shl_sat( mult_r( GainShape_fx[2 * j], scale_fx ), 3 ); - move16(); /* 15 +12 +3-15 =15*/ - GainShape_fx[add( 2 * j, 1 )] = shl_sat( mult_r( GainShape_fx[add( 2 * j, 1 )], scale_fx ), 3 ); - move16(); - FOR( i = 0; i < 40; i++ ) - { - shaped_shb_excitation_fx[i + j * L_FRAME16k / 8] = shl( mult_r( shaped_shb_excitation_fx[i + j * L_FRAME16k / 8], scale_fx ), 3 ); - move16(); /* Q_bwe_exc +12+3 -15 =Q_bwe_exc*/ - } - - IF( temp_fx > 0 ) - { - IF( LT_16( scale_fx, temp_fx ) ) - { - scale_fx = shr( div_s( scale_fx, temp_fx ), 3 ); - } - ELSE - { - tmp1 = sub( norm_s( scale_fx ), 1 ); - tmp2 = norm_s( temp_fx ); - scale_fx = div_s( shl( scale_fx, tmp1 ), shl( temp_fx, tmp2 ) ); - scale_fx = shr( scale_fx, add( sub( tmp1, tmp2 ), 3 ) ); - } - } - ELSE - { - scale_fx = 0; - move16(); - } - } - } - - hBWE_TD->prev_swb_bwe_frame_pow_fx = curr_frame_pow_fx; - move32(); - st->prev_frame_pow_exp = curr_frame_pow_exp; - move16(); - - Word64 prev_ener_shb64 = 0; - move64(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - prev_ener_shb64 = W_mac0_16_16( prev_ener_shb64, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* Q0 */ - } - L_prev_ener_shb = W_sat_l( prev_ener_shb64 ); - - L_prev_ener_shb = Mult_32_16( L_prev_ener_shb, 26214 ); /* 2*Q_bwe_exc_mod+8; 26214=(1/L_FRAME16k) in Q23 */ - st->prev_ener_shb_fx = 0; - move16(); - IF( L_prev_ener_shb != 0 ) - { - exp = norm_l( L_prev_ener_shb ); - tmp = extract_h( L_shl( L_prev_ener_shb, exp ) ); - exp = sub( exp, sub( 30, ( add( i_mult( 2, Q_bwe_exc ), 8 ) ) ) ); - - tmp = div_s( 16384, tmp ); - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); - st->prev_ener_shb_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ - move16(); - } - - IF( st->hBWE_FD != NULL ) - { - L_tmp = Mult_32_16( curr_frame_pow_fx, 26214 ); /* curr_frame_pow_exp+8; 26214=(1/L_FRAME16k) in Q23 */ - tmp = 0; - move16(); - IF( L_tmp != 0 ) - { - exp = norm_l( L_tmp ); - tmp = extract_h( L_shl( L_tmp, exp ) ); - exp = sub( exp, sub( 30, add( curr_frame_pow_exp, 8 ) ) ); - - tmp = div_s( 16384, tmp ); - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); - tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ - } - set16_fx( st->prev_SWB_fenv_fx, tmp, SWB_FENV ); /* Q1 */ - } - - FOR( i = 0; i < L_FRAME16k; i++ ) - { - shaped_shb_excitation_fx_32[i] = L_shl( shaped_shb_excitation_fx[i], sub( Q11, Q_bwe_exc ) ); - move32(); - } - - /* generate 32kHz SHB synthesis from 12.8(16)kHz signal */ - GenSHBSynth_fx_32( shaped_shb_excitation_fx_32, error_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->L_frame, &( hBWE_TD->syn_dm_phase ) ); - Copy_Scale_sig_32_16( st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, 2 * ALLPASSSECTIONS_STEEP, -( Q11 - Q_bwe_exc ) ); - Copy32( error_fx + L_FRAME32k - L_SHB_TRANSITION_LENGTH, hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH ); - - /* resample SHB synthesis (if needed) and scale down */ - synth_scale_fx = 32767; - move16(); /* 1.0 in Q15 */ - if ( EQ_16( st->codec_mode, MODE1 ) ) - { - synth_scale_fx = 29491; - move16(); /* 0.9 in Q15 */ - } - - IF( EQ_32( st->output_Fs, 48000 ) ) - { - IF( EQ_16( st->extl, FB_TBE ) ) - { - tmp = norm_l( GainFrame_fx ); - if ( GainFrame_fx == 0 ) - { - tmp = 31; - move16(); - } - L_tmp = L_shl( GainFrame_fx, tmp ); /* 18 + tmp */ - - tmp1 = 0; - move16(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - Word16 idx = 0; - move16(); - IF( i != 0 ) - { - idx = idiv1616( i_mult( NUM_SHB_SUBFR, i ), L_FRAME16k ); - } - L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[idx] ); /* Q : 18 + tmp +15 -15*/ - White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */ - move16(); - tmp1 = s_max( tmp1, abs_s( White_exc16k_fx[i] ) ); - } - - *Q_white_exc = sub( add( *Q_white_exc, tmp ), 13 ); /* *Q_white_exc + 18 + tmp -15 -16 */ - move16(); - tmp = norm_s( tmp1 ); - if ( tmp1 == 0 ) - { - tmp = 15; - move16(); - } - - FOR( i = 0; i < L_FRAME16k; i++ ) - { - White_exc16k_fx[i] = shl( White_exc16k_fx[i], sub( tmp, 1 ) ); - move16(); - } - *Q_white_exc = sub( add( *Q_white_exc, tmp ), 1 ); - move16(); - } - - IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */ - { - FOR( i = 0; i < L_FRAME32k; i++ ) - { - error_fx[i] = Mpy_32_16_1( error_fx[i], synth_scale_fx ); - move32(); - } - } - interpolate_3_over_2_allpass_32( error_fx, L_FRAME32k, synth_fx, hBWE_TD->int_3_over_2_tbemem_dec_fx_32 ); - } - ELSE IF( EQ_32( st->output_Fs, 32000 ) ) - { - IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */ - { - FOR( i = 0; i < L_FRAME32k; i++ ) - { - synth_fx[i] = Mpy_32_16_1( error_fx[i], synth_scale_fx ); - move32(); /*Qx*/ - } - } - ELSE - { - Copy32( error_fx, synth_fx, L_FRAME32k ); - } - } - ELSE IF( EQ_32( st->output_Fs, 16000 ) ) - { - IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */ - { - FOR( i = 0; i < L_FRAME32k; i++ ) - { - error_fx[i] = Mpy_32_16_1( error_fx[i], synth_scale_fx ); - move32(); - } - } - - Decimate_allpass_steep_fx32( error_fx, hBWE_TD->mem_resamp_HB_32k_fx_32, L_FRAME32k, synth_fx ); - } - - - /* Update previous frame parameters for FEC */ - Copy( lsf_shb_fx, hBWE_TD->lsp_prevfrm_fx, LPC_SHB_ORDER ); - IF( EQ_16( st->codec_mode, MODE1 ) ) - { - hBWE_TD->GainFrame_prevfrm_fx = GainFrame_fx; - move32(); /*Q18*/ - hBWE_TD->tilt_swb_fec_fx = tilt_swb_fec_fx; - move16(); - - if ( !st->bfi ) - { - hBWE_TD->GainAttn_fx = 32767; /*1.0f in Q15*/ - move16(); - } - } - ELSE - { - IF( !st->bfi ) - { - hBWE_TD->GainFrame_prevfrm_fx = GainFrame_fx; - move32(); /*Q18*/ - hBWE_TD->tilt_swb_fec_fx = tilt_swb_fec_fx; - move16(); - hBWE_TD->GainAttn_fx = 32767; /*1.0f in Q15*/ - move16(); - } - } - - hBWE_TD->prev_ener_fx = ener_tmp_fx[NUM_SHB_SUBGAINS - 1]; - move32(); - hBWE_TD->prev_GainShape_fx = GainShape_fx[NUM_SHB_SUBFR - 1]; - move16(); - st->prev_Q_bwe_syn2 = Q_bwe_exc; - move16(); - st->prev_Qx = Q_bwe_exc; - move16(); - - return; -} -/*-------------------------------------------------------------------* - * Dequant_lower_LSF() - * - * Dequantized the lower LSFs - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * Map_higher_LSF() - * - * Map the higher LSFs from the lower LSFs - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * Map_higher_LSF() - * - * Map the higher LSFs from the lower LSFs - *-------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------* - * dequantizeSHBparams() - * - * Dequantize super highband spectral envolope, temporal gains and frame gain - *-------------------------------------------------------------------*/ - - -void GenTransition_fixed( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs, /* i : output sampling rate : Q0 */ - const Word16 element_mode, /* i : element mode : Q0 */ - const Word16 L_frame, /* i : ACELP frame length : Q0 */ - const Word16 rf_flag, /* i : RF flag : Q0 */ - const Word32 total_brate, /* i : total bitrate : Q0 */ - const Word16 prev_Qx ) -{ - Word16 i, length; - - Word32 syn_overlap_32k_fx[2 * SHB_OVERLAP_LEN]; - - /* set targeted length of transition signal */ - length = i_mult( 2, NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ) ); - - /* upsample overlap snippet */ - Interpolate_allpass_steep_32( hBWE_TD->syn_overlap_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, SHB_OVERLAP_LEN, syn_overlap_32k_fx ); - - /* perFORm spectral flip and downmix with overlap snippet to match HB synth */ - test(); - test(); - test(); - test(); - IF( ( ( element_mode == EVS_MONO ) && ( rf_flag || EQ_32( total_brate, ACELP_9k60 ) ) ) || ( ( element_mode > EVS_MONO ) && EQ_16( L_frame, L_FRAME ) ) ) - { - flip_and_downmix_generic_fx_32( syn_overlap_32k_fx, syn_overlap_32k_fx, 2 * SHB_OVERLAP_LEN, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx + HILBERT_ORDER1, hBWE_TD->genSHBsynth_Hilbert_Mem_fx + ( HILBERT_ORDER1 + 2 * HILBERT_ORDER2 ), &( hBWE_TD->syn_dm_phase ) ); - } - ELSE - { - FOR( i = 0; i < 2 * SHB_OVERLAP_LEN; i++ ) - { - IF( i % 2 == 0 ) - { - syn_overlap_32k_fx[i] = L_negate( syn_overlap_32k_fx[i] ); - } - ELSE - { - syn_overlap_32k_fx[i] = syn_overlap_32k_fx[i]; - } - move32(); - } - } - - /* cross fade of overlap snippet and mirrored HB synth from previous frame */ - FOR( i = 0; i < 2 * L_SHB_LAHEAD; i++ ) - { - outputHB_fx[i] = L_add_sat( Mpy_32_16_1( hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i], window_shb_32k_fx[i] ), Mpy_32_16_1( syn_overlap_32k_fx[i], window_shb_32k_fx[2 * L_SHB_LAHEAD - 1 - i] ) ); - move32(); - } - - /* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */ - FOR( ; i < length; i++ ) - { - outputHB_fx[i] = L_shl( hBWE_TD->old_tbe_synth_fx[L_SHB_TRANSITION_LENGTH - 1 - i], sub( Q11, prev_Qx ) ); - move32(); - } - - IF( EQ_32( output_Fs, 48000 ) ) - { - interpolate_3_over_2_allpass_32( outputHB_fx, length, outputHB_fx, hBWE_TD->int_3_over_2_tbemem_dec_fx_32 ); - } - ELSE IF( EQ_32( output_Fs, 16000 ) ) - { - Decimate_allpass_steep_fx32( outputHB_fx, hBWE_TD->mem_resamp_HB_32k_fx_32, L_FRAME32k, outputHB_fx ); - } - - return; -} -void GenTransition_WB_fixed( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs /* i : output sampling rate */ -) -{ - Word16 i, length; - Word32 speech_buf_16k1_fx[SHB_OVERLAP_LEN], speech_buf_16k2_fx[2 * SHB_OVERLAP_LEN]; - Word32 upsampled_synth_fx[L_FRAME48k]; - - /* set targeted length of transition signal */ - length = i_mult( 2, NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ) ); - - /* upsample overlap snippet */ - Interpolate_allpass_steep_32( hBWE_TD->syn_overlap_fx_32, hBWE_TD->state_lsyn_filt_shb_fx_32, SHB_OVERLAP_LEN / 2, speech_buf_16k1_fx ); - Interpolate_allpass_steep_32( speech_buf_16k1_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, SHB_OVERLAP_LEN, speech_buf_16k2_fx ); - - /* perform spectral flip and downmix with overlap snippet to match HB synth */ - FOR( i = 0; i < SHB_OVERLAP_LEN; i++ ) - { - IF( i % 2 == 0 ) - { - speech_buf_16k2_fx[i] = L_negate( speech_buf_16k2_fx[i] ); - move32(); - } - ELSE - { - speech_buf_16k2_fx[i] = speech_buf_16k2_fx[i]; - move32(); - } - } - - /* cross fade of overlap snippet and mirrored HB synth from previous frame */ - FOR( i = 0; i < L_SHB_LAHEAD; i++ ) - { - outputHB_fx[i] = L_add( Mpy_32_16_1( hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i], window_shb_fx[i] ), Mpy_32_16_1( speech_buf_16k2_fx[i], window_shb_fx[L_SHB_LAHEAD - 1 - i] ) ); - move32(); - outputHB_fx[i] = Mpy_32_16_1( outputHB_fx[i], 21299 ); - move32(); - } - - /* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */ - FOR( ; i < length; i++ ) - { - outputHB_fx[i] = hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i]; - move32(); - outputHB_fx[i] = Mpy_32_16_1( outputHB_fx[i], 21299 ); - move32(); - } - - /* upsampling if necessary */ - IF( EQ_32( output_Fs, 32000 ) ) - { - Interpolate_allpass_steep_32( outputHB_fx, hBWE_TD->mem_resamp_HB_fx_32, L_FRAME16k, upsampled_synth_fx ); - Copy32( upsampled_synth_fx, outputHB_fx, L_FRAME32k ); - } - ELSE IF( EQ_32( output_Fs, 48000 ) ) - { - interpolate_3_over_1_allpass_32( outputHB_fx, L_FRAME16k, upsampled_synth_fx, hBWE_TD->mem_resamp_HB_fx_32 ); - Copy32( upsampled_synth_fx, outputHB_fx, L_FRAME48k ); - } - - return; -} - -/*-------------------------------------------------------------------* - * td_bwe_dec_init() - * - * Initialize TD BWE state structure at the decoder - *-------------------------------------------------------------------*/ diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 28ac01671..a37ebf9d9 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -7,6 +7,7 @@ #include "options.h" #include "rom_com.h" #include "prot_fx.h" +#include "prot.h" #include "rom_dec.h" #include "stl.h" @@ -31,6 +32,11 @@ Word16 dotp_loc( const Word16 n /* i : vector length */ ); +void find_max_mem_dec_m3( + Decoder_State *st, + Word16 *n_mem3 ); + + /* gain shape concealment code */ static void gradientGainShape( Decoder_State *st_fx, Word16 *GainShape, Word32 *GainFrame ); @@ -3695,12 +3701,12 @@ static void gradientGainShape( IF( GT_16( 8192, tmp ) ) { - GainShape[add( i * 4, j )] = shl( tmp, 2 ); + GainShape[i * 4 + j] = shl( tmp, 2 ); move16(); /* (GainShapeTemp[i]*0.6)>>1 */ } ELSE { - GainShape[add( i * 4, j )] = 32767; + GainShape[i * 4 + j] = 32767; move16(); /* Clipping here to avoid the a huge change of the code due to gain shape change */ } } @@ -3716,12 +3722,12 @@ static void gradientGainShape( { IF( LT_16( GainShapeTemp[i], 16384 ) ) { - GainShape[add( i * 4, j )] = shl( GainShapeTemp[i], 1 ); + GainShape[i * 4 + j] = shl( GainShapeTemp[i], 1 ); move16(); } ELSE { - GainShape[add( i * 4, j )] = 32767; + GainShape[i * 4 + j] = 32767; move16(); } } @@ -3750,12 +3756,12 @@ static void gradientGainShape( { IF( LT_16( GainShapeTemp[i], 16384 ) ) { - GainShape[add( i * 4, j )] = shl( GainShapeTemp[i], 1 ); + GainShape[i * 4 + j] = shl( GainShapeTemp[i], 1 ); move16(); } ELSE { - GainShape[add( i * 4, j )] = 32767; + GainShape[i * 4 + j] = 32767; move16(); } } @@ -5300,3 +5306,2019 @@ void td_bwe_dec_init_fx( return; } + +/*-------------------------------------------------------------------* + * ResetSHBbuffer_Dec() + * + * + *-------------------------------------------------------------------*/ + +static void calc_tilt_bwe_fx_loc( + const Word32 *sp_fx, /* i : input signal : Q11 */ + Word32 *tilt_fx, /* o : signal tilt : tilt_fx_q */ + Word16 *tilt_fx_q, /* o : signal tilt */ + const Word16 N /* i : signal length : Q0 */ +) +{ + Word16 i; + Word64 r0_fx, r1_fx; + + r0_fx = EPSILON_FX_SMALL; + move64(); + FOR( i = 0; i < N; i++ ) + { + r0_fx = W_add( r0_fx, W_shr( W_mult_32_32( sp_fx[i], sp_fx[i] ), 1 ) ); /*Q11*2 - 1*/ + } + r1_fx = W_deposit32_l( abs( L_sub( sp_fx[1], sp_fx[0] ) ) ); /*Q11*/ + FOR( i = 2; i < N; i++ ) + { + IF( W_mult_32_32( L_sub( sp_fx[i], sp_fx[i - 1] ) /*Q11*/, L_sub( sp_fx[i - 1], sp_fx[i - 2] ) /*Q11*/ ) /*Q11 * 2 - 1*/ < 0 ) + { + r1_fx = W_add( r1_fx, W_deposit32_l( abs( L_sub( sp_fx[i], sp_fx[i - 1] ) ) ) ); /*Q11*/ + } + } + Word16 headroom_left_r0 = W_norm( r0_fx ); + Word16 headroom_left_r1 = W_norm( r1_fx ); + Word16 r0_q = 0, r1_q = 0; + move16(); + move16(); + IF( LT_16( headroom_left_r0, 32 ) ) + { + r0_fx = W_shr( r0_fx, sub( 32, headroom_left_r0 ) ); + r0_q = sub( 31, sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_r0 ) ) ); + } + ELSE + { + r0_q = 31 - ( 2 * OUTPUT_Q ); + move16(); + } + + IF( LT_16( headroom_left_r1, 32 ) ) + { + r1_fx = W_shr( r1_fx, sub( 32, headroom_left_r1 ) ); + r1_q = sub( OUTPUT_Q, sub( 32, headroom_left_r1 ) ); + } + ELSE + { + r1_q = OUTPUT_Q; + move16(); + } + Word32 temp_r0_inv = ISqrt32( W_extract_l( r0_fx ), &r0_q ); + Word32 res = Mpy_32_32( W_extract_l( r1_fx ), temp_r0_inv ); + // Word16 res_q = r1_q + ( r0_q < 0 ? ( 31 + ( -1 * r0_q ) ) : r0_q ) - 31; + Word16 res_q; + IF( r0_q < 0 ) + { + res_q = add( r1_q, sub( add( 31, -r0_q ), 31 ) ); + } + ELSE + { + res_q = add( r1_q, sub( r0_q, 31 ) ); + } + Word16 norm_res = norm_l( res ); + IF( norm_res > 0 ) + { + *tilt_fx = L_shl_sat( res, norm_res ); + move32(); + *tilt_fx_q = add( res_q, norm_res ); + move16(); + } + ELSE + { + *tilt_fx = res; + move32(); + *tilt_fx_q = res_q; + move16(); + } + return; +} + +/*-------------------------------------------------------------------* + * swb_tbe_dec() + * + * SWB TBE decoder, 6 - 14 kHz (or 7.5 - 15.5 kHz) band decoding module + *-------------------------------------------------------------------*/ +static void rescale_genSHB_mem_dec_ivas( + Decoder_State *st_fx, + Word16 sf /*Q0*/ +) +{ + Word16 i; + TD_BWE_DEC_HANDLE hBWE_TD; + hBWE_TD = st_fx->hBWE_TD; + + FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) + { + hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf ); + move16(); + } + + FOR( i = 0; i < 7; i++ ) + { + hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i] = shl( hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i], sf ); + move16(); + } + + /* -- Apply memory scaling for 13.2 and 16.4k bps using sf ----*/ + IF( LT_32( st_fx->total_brate, ACELP_24k40 ) ) + { + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + hBWE_TD->state_lpc_syn_fx[i] = shl_sat( hBWE_TD->state_lpc_syn_fx[i], sf ); + move16(); + } + + FOR( i = 0; i < L_SHB_LAHEAD; i++ ) + { + hBWE_TD->state_syn_shbexc_fx[i] = shl_sat( hBWE_TD->state_syn_shbexc_fx[i], sf ); + move16(); + } + } + + hBWE_TD->mem_csfilt_fx[0] = L_shl( hBWE_TD->mem_csfilt_fx[0], sf ); + move32(); + + hBWE_TD->tbe_demph_fx = shl_r( hBWE_TD->tbe_demph_fx, sf ); + move16(); + hBWE_TD->tbe_premph_fx = shl_r( hBWE_TD->tbe_premph_fx, sf ); + move16(); +} + +void find_max_mem_dec_m3( + Decoder_State *st, + Word16 *n_mem3 ) +{ + Word16 i; + // Word16 n_mem_32; + Word16 tempQ15; + Word16 max3; + // Word32 tempQ32, Lmax3; + TD_BWE_DEC_HANDLE hBWE_TD; + hBWE_TD = st->hBWE_TD; + + /* --------------------------------------------------------------*/ + /* Find headroom for synthesis stage associated with these memories: + 1. st->syn_overlap_fx*/ + max3 = 0; + move16(); + /* find max in prev overlapSyn */ + FOR( i = 0; i < L_SHB_LAHEAD; i++ ) + { + tempQ15 = abs_s( hBWE_TD->syn_overlap_fx[i] ); + max3 = s_max( max3, tempQ15 ); + } + /* find max in prev genSHBsynth_state_lsyn_filt_shb_local_fx */ + + /* estimate the norm for 16-bit memories */ + *n_mem3 = norm_s( max3 ); + move16(); + if ( max3 == 0 ) + { + *n_mem3 = 15; + move16(); + } +} + +/*-------------------------------------------------------------------* + * ivas_swb_tbe_dec_fx() + * + * SWB TBE decoder, 6 - 14 kHz (or 7.5 - 15.5 kHz) band decoding module + *-------------------------------------------------------------------*/ +void ivas_swb_tbe_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ + const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ + Word16 Q_exc, + const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ + const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ + Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ + Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ + Word16 *pitch_buf_fx, /* i : Q6 */ + Word16 *Q_white_exc ) +{ + Word16 i, j, cnt, n; + Word16 stemp; + TD_BWE_DEC_HANDLE hBWE_TD; + Word32 shaped_shb_excitation_fx_32[L_FRAME16k + L_SHB_LAHEAD]; + Word16 bwe_exc_extended_16[L_FRAME32k + NL_BUFF_OFFSET]; + Word16 shaped_shb_excitation_fx[L_FRAME16k + L_SHB_LAHEAD]; + Word16 lsf_shb_fx[LPC_SHB_ORDER], lpc_shb_fx[LPC_SHB_ORDER + 1], GainShape_fx[NUM_SHB_SUBFR]; // Q12,Q12,Q15 + Word32 GainFrame_fx; // Q18 + Word32 error_fx[L_FRAME32k]; + Word16 ener_fx; + Word32 L_ener; + Word16 is_fractive; + Word32 prev_pow_fx, curr_pow_fx, Lscale; + Word16 scale_fx; + Word16 max_val, temp_fx, shaped_shb_excitation_frac[L_FRAME16k + L_SHB_LAHEAD]; + Word32 curr_frame_pow_fx; + Word16 curr_frame_pow_exp; + Word32 L_prev_ener_shb; + Word16 vf_modified_fx[NB_SUBFR16k]; + Word16 f_fx, inc_fx; + Word32 GainFrame_prevfrm_fx; + Word32 tilt_swb_fec_32_fx; + Word16 tilt_swb_fec_fx_q; + Word16 tilt_swb_fec_fx; + Word32 prev_ener_ratio_fx = 0; /* initialize just to avoid compiler warning */ + Word16 lsp_shb_1_fx[LPC_SHB_ORDER], lsp_shb_2_fx[LPC_SHB_ORDER], lsp_temp_fx[LPC_SHB_ORDER]; + Word16 lpc_shb_sf_fx[4 * ( LPC_SHB_ORDER + 1 )]; + const Word16 *ptr_lsp_interp_coef_fx; + Word32 shb_ener_sf_32; + Word16 shb_res_gshape_fx[NB_SUBFR16k]; + Word16 mixFactors_fx; + Word16 vind; + Word16 shb_res_dummy_fx[L_FRAME16k]; + Word16 shaped_shb_excitationTemp_fx[L_FRAME16k]; + Word32 ener_tmp_fx[NUM_SHB_SUBGAINS]; + Word16 GainShape_tmp_fx[NUM_SHB_SUBGAINS]; + Word16 pitch_fx; + Word16 l_subframe; + Word16 formant_fac_fx; + Word16 synth_scale_fx; + Word16 lsf_diff_fx[LPC_SHB_ORDER], w_fx[LPC_SHB_ORDER]; + Word16 refl_fx[M]; + Word16 tilt_para_fx; + Word16 *nlExc16k_fx, *mixExc16k_fx; + Word16 MSFlag; + Word16 feedback_fx; + Word16 GainShape_tilt_fx; + + // scaling + Word16 exp, tmp; + Word16 tmp1, tmp2; + Word16 mean_vf; + Word32 Lmax, L_tmp; + Word16 frac; + Word32 L_tmp1, L_tmp2; + Word16 Q_bwe_exc; + Word16 Q_bwe_exc_fb; + Word16 Q_shb; + Word16 n_mem, n_mem2, n_mem3, Qx, sc; + Word16 expa, expb; + Word16 fraca, fracb; + Word16 exp_ener, inv_ener; + + hBWE_TD = st->hBWE_TD; + + /* initializations */ + GainFrame_fx = 0; + move32(); + mixFactors_fx = 0; + move16(); + shb_ener_sf_32 = 0; + move32(); + set16_fx( shaped_shb_excitationTemp_fx, 0, L_FRAME16k ); + if ( st->hTdCngDec != NULL ) + { + st->hTdCngDec->shb_dtx_count = 0; + move16(); + } + is_fractive = 0; + move16(); + + IF( hStereoICBWE != NULL ) + { + nlExc16k_fx = hStereoICBWE->nlExc16k_fx; + mixExc16k_fx = hStereoICBWE->mixExc16k_fx; + MSFlag = hStereoICBWE->MSFlag; + move16(); + } + ELSE + { + nlExc16k_fx = NULL; + mixExc16k_fx = NULL; + MSFlag = 0; + move16(); + } + + /* find tilt */ + calc_tilt_bwe_fx_loc( old_syn_12k8_16k_fx, &tilt_swb_fec_32_fx, &tilt_swb_fec_fx_q, L_FRAME ); + tilt_swb_fec_fx = round_fx_sat( L_shl_sat( tilt_swb_fec_32_fx, sub( 11 + 16, tilt_swb_fec_fx_q ) ) ); + test(); + if ( st->bfi && st->clas_dec != UNVOICED_CLAS ) + { + tilt_swb_fec_fx = hBWE_TD->tilt_swb_fec_fx; + move16(); + } + + /* WB/SWB bandwidth switching */ + test(); + test(); + IF( ( GT_16( st->tilt_wb_fx, 10240 /*5 in Q11*/ ) && ( EQ_16( st->clas_dec, UNVOICED_CLAS ) ) ) || GT_16( st->tilt_wb_fx, 20480 /*10 in Q11*/ ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( st->prev_fractive == 0 ) && + ( LT_32( st->prev_enerLH_fx, L_shl( st->enerLH_fx, 1 ) ) && GT_32( st->prev_enerLH_fx, L_shr( st->enerLH_fx, 1 ) ) && LT_32( st->prev_enerLL_fx, L_shl( st->enerLL_fx, 1 ) ) && GT_32( st->prev_enerLL_fx, L_shr( st->enerLL_fx, 1 ) ) ) ) || + ( EQ_16( st->prev_fractive, 1 ) && + GT_32( L_shr( st->prev_enerLH_fx, 2 ), Mult_32_16( st->enerLH_fx, 24576 ) ) ) /* 24576 in Q13*/ + || ( GT_32( L_shr( st->enerLL_fx, 1 ), Mult_32_16( st->enerLH_fx, 24576 ) ) && /*24576 = 1.5 in Q14*/ + LT_16( st->tilt_wb_fx, 20480 ) ) /* 20480 = 10 in Q11*/ + ) + { + is_fractive = 0; + } + ELSE + { + is_fractive = 1; + } + move16(); + } + + /* WB/SWB bandwidth switching */ + IF( st->bws_cnt > 0 ) + { + f_fx = 1489; /*1.0f / 22.0f in Q15*/ + move16(); + inc_fx = 1489; /*1.0f / 22.0f in Q15*/ + move16(); + + IF( EQ_16( is_fractive, 1 ) ) + { + Copy( lsf_tab_fx, hBWE_TD->lsp_prevfrm_fx, LPC_SHB_ORDER ); + } + ELSE + { + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + hBWE_TD->lsp_prevfrm_fx[i] = f_fx; /*Q15*/ + move16(); + f_fx = add( f_fx, inc_fx ); /*Q15*/ + } + } + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) && !( ( L_sub( L_shr( st->prev_enerLH_fx, 1 ), st->enerLH_fx ) < 0 ) && L_sub( st->prev_enerLH_fx, ( L_shr( st->enerLH_fx, 1 ) > 0 ) ) ) ) || st->last_core != ACELP_CORE || ( ( st->last_core == ACELP_CORE ) && GT_32( abs( L_sub( st->last_core_brate, st->core_brate ) ), 3600 ) ) || EQ_16( s_xor( is_fractive, st->prev_fractive ), 1 ) ) + { + set16_fx( GainShape_fx, 11587, NUM_SHB_SUBFR ); /*0.3536f in Q15*/ + } + ELSE + { + if ( GT_16( hBWE_TD->prev_GainShape_fx, 11587 ) ) /*0.3536f in Q15*/ + { + hBWE_TD->prev_GainShape_fx = 11587; /*0.3536f in Q15*/ + move16(); + } + set16_fx( GainShape_fx, hBWE_TD->prev_GainShape_fx, NUM_SHB_SUBFR ); + } + + Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER ); + set16_fx( shb_res_gshape_fx, 3277 /*0.2f Q14*/, NB_SUBFR16k ); /* Q14 */ + } + ELSE + { + test(); + IF( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) + { + f_fx = 1489; /*Q15*/ + move16(); + inc_fx = 1489; /*Q15*/ + move16(); + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + hBWE_TD->lsp_prevfrm_fx[i] = f_fx; /*Q15*/ + move16(); + f_fx = add( f_fx, inc_fx ); + } + } + + IF( !st->bfi ) + { + IF( st->use_partial_copy ) + { + IF( NE_16( st->last_extl, SWB_TBE ) ) + { + hBWE_TD->GainFrame_prevfrm_fx = 0; + move32(); + f_fx = 1489 /*0.045454f Q15*/; + move16(); + inc_fx = 1489 /*0.045454f Q15*/; + move16(); + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + hBWE_TD->lsp_prevfrm_fx[i] = f_fx; /*Q15*/ + move16(); + f_fx = add( f_fx, inc_fx ); /*Q15*/ + } + } + Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER ); + set16_fx( GainShape_fx, RECIP_ROOT_EIGHT_FX, NUM_SHB_SUBFR ); + + IF( EQ_16( st->rf_frame_type, RF_NELP ) ) + { + /* Frame gain */ + + GainFrame_fx = L_mac( SHB_GAIN_QLOW_FX, st->rf_indx_tbeGainFr, SHB_GAIN_QDELTA_FX ); + L_tmp = Mult_32_16( GainFrame_fx, 27213 ); /*Q16*/ /* 3.321928 in Q13 */ + + frac = L_Extract_lc( L_tmp, &exp ); + L_tmp = Pow2( 30, frac ); + GainFrame_fx = L_shl( L_tmp, sub( exp, 12 ) ); /*Q18*/ + + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( st->core == ACELP_CORE ) && ( st->last_core == ACELP_CORE ) && !st->prev_use_partial_copy && EQ_16( st->prev_coder_type, UNVOICED ) && NE_32( GainFrame_fx, hBWE_TD->GainFrame_prevfrm_fx ) && NE_16( st->next_coder_type, GENERIC ) && EQ_16( st->last_extl, SWB_TBE ) ) + { + GainFrame_fx = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 26214 /*0.8f in Q15*/ ), Mult_32_16( GainFrame_fx, 6553 /*0.2f in Q15*/ ) ); + } + } + ELSE + { + temp_fx = 0; + move16(); + /* Frame gain */ + SWITCH( st->rf_indx_tbeGainFr ) + { + case 0: + GainFrame_fx = 131072; /* 0.5f in Q18 */ + move32(); + if ( LE_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) ) + { + temp_fx = 26214 /*0.8 Q15*/; + move16(); + } + BREAK; + case 1: + GainFrame_fx = 524288; /* 2.0f in Q18 */ + move32(); + test(); + if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 327680l /*1.25 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) ) + { + temp_fx = 26214 /*0.8 Q15*/; + move16(); + } + BREAK; + case 2: + GainFrame_fx = 1048576; /* 4.0f in Q18 */ + move32(); + test(); + if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 786432l /*3 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) ) + { + temp_fx = 26214 /*0.8 Q15*/; + move16(); + } + BREAK; + case 3: + GainFrame_fx = 2097152; /* 8.0f in Q18 */ + move32(); + test(); + if ( GT_32( hBWE_TD->GainFrame_prevfrm_fx, 1572864l /*6 Q18*/ ) && LE_32( hBWE_TD->GainFrame_prevfrm_fx, 4194304l /*16Q18*/ ) ) + { + temp_fx = 26214 /*0.8 Q15*/; + move16(); + } + BREAK; + default: + fprintf( stderr, "RF SWB-TBE gain bits not supported." ); + } + + IF( EQ_16( st->last_extl, SWB_TBE ) ) + { + GainFrame_fx = L_add( Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, temp_fx ), Mult_32_16( GainFrame_fx, sub( 32767, temp_fx ) ) ); + /*Q18*/ + } + + IF( ( st->core == ACELP_CORE ) && ( st->last_core == ACELP_CORE ) ) + { + if ( !st->prev_use_partial_copy && EQ_16( st->last_coder_type, VOICED ) && EQ_16( st->rf_frame_type, RF_GENPRED ) && GT_32( GainFrame_fx, 2097152 /*8.0f in Q18*/ ) && LT_32( GainFrame_fx, 3059606 /*11.67f in Q18*/ ) ) + { + GainFrame_fx = Mult_32_16( GainFrame_fx, 9830 /*0.3f in Q15*/ ); // Q18 + } + } + } + } + ELSE + { + /* de-quantization */ + ivas_dequantizeSHBparams_fx_9_1( st, st->extl, st->extl_brate, lsf_shb_fx, GainShape_fx, &GainFrame_fx, &stemp, + &shb_ener_sf_32, shb_res_gshape_fx, &mixFactors_fx, &MSFlag ); + if ( hStereoICBWE != NULL ) + { + hStereoICBWE->MSFlag = MSFlag; + move16(); + } + } + } + ELSE + { + Copy( hBWE_TD->lsp_prevfrm_fx, lsf_shb_fx, LPC_SHB_ORDER ); + test(); + IF( EQ_16( st->codec_mode, MODE1 ) && ( st->element_mode == EVS_MONO ) ) + { + gradientGainShape( st, GainShape_fx, &GainFrame_fx ); + } + ELSE + { + FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) + { + FOR( j = 0; j < 4; j++ ) + { + GainShape_fx[i * 4 + j] = mult_r( st->cummulative_damping, st->GainShape_Delay[4 + i] ); + move16(); + } + } + IF( GT_16( tilt_swb_fec_fx, ( 8 << 11 ) ) ) /* tilt_swb_fec_fx in Q11 */ + { + IF( EQ_16( st->nbLostCmpt, 1 ) ) + { + GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 19661 /*0.6f Q15*/ ); + } + ELSE IF( EQ_16( st->nbLostCmpt, 2 ) ) + { + GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 11469 /*0.35f Q15*/ ); + } + ELSE + { + GainFrame_fx = Mult_32_16( hBWE_TD->GainFrame_prevfrm_fx, 6554 /*0.2f Q15*/ ); + } + GainFrame_fx = Mult_32_16( GainFrame_fx, st->cummulative_damping ); + } + ELSE + { + GainFrame_fx = hBWE_TD->GainFrame_prevfrm_fx; + move32(); /* gain locking */ + } + } + + IF( GE_32( st->extl_brate, SWB_TBE_2k8 ) ) + { + test(); + IF( EQ_16( st->codec_mode, MODE1 ) && ( st->element_mode == EVS_MONO ) ) + { + L_tmp = L_mult( extract_l( hBWE_TD->prev2_shb_ener_sf_fx ), extract_l( hBWE_TD->prev3_shb_ener_sf_fx ) ); /*Q1*/ + tmp = round_fx( root_a_fx( L_tmp, 1, &exp ) ); /* Q = 15-exp */ + tmp1 = extract_l( hBWE_TD->prev1_shb_ener_sf_fx ); /*Q0*/ + i = sub( norm_s( tmp1 ), 1 ); + tmp1 = shl( tmp1, i ); /* Qi */ + IF( tmp == 0 ) + { + tmp = 32767 /*1.0f Q15*/; + move16(); /*Q15*/ + } + ELSE + { + scale_fx = div_s( tmp1, tmp ); /* Q15 - Q(15-exp) + Qi = Qexp+i */ + scale_fx = s_max( scale_fx, 0 ); + tmp = shl_sat( scale_fx, sub( sub( 15, exp ), i ) ); /*Q15*/ + } + scale_fx = mult_r( hBWE_TD->prev_res_shb_gshape_fx, tmp ); /* Q14 */ + test(); + IF( GT_32( L_shr( hBWE_TD->prev2_shb_ener_sf_fx, 1 ), hBWE_TD->prev1_shb_ener_sf_fx ) || + GT_32( L_shr( hBWE_TD->prev3_shb_ener_sf_fx, 1 ), hBWE_TD->prev2_shb_ener_sf_fx ) ) + { + shb_ener_sf_32 = Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, scale_fx ); + + if ( GT_16( st->nbLostCmpt, 1 ) ) + { + shb_ener_sf_32 = L_shr( shb_ener_sf_32, 1 ); + } + } + ELSE + { + L_tmp = L_mult( scale_fx, scale_fx ); /* Q29 */ + shb_ener_sf_32 = L_shl( Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, round_fx( L_tmp ) ), 2 ); + } + } + ELSE + { + test(); + IF( GT_32( L_shr( hBWE_TD->prev2_shb_ener_sf_fx, 1 ), hBWE_TD->prev1_shb_ener_sf_fx ) || + GT_32( L_shr( hBWE_TD->prev3_shb_ener_sf_fx, 1 ), hBWE_TD->prev2_shb_ener_sf_fx ) ) + { + shb_ener_sf_32 = L_shr( Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, st->cummulative_damping ), 1 ); + } + ELSE + { + shb_ener_sf_32 = Mult_32_16( hBWE_TD->prev1_shb_ener_sf_fx, st->cummulative_damping ); + } + } + } + + shb_ener_sf_32 = L_max( shb_ener_sf_32, 1l /*1.0f Q0*/ ); + mixFactors_fx = hBWE_TD->prev_mixFactors_fx; + move16(); + + IF( EQ_16( st->codec_mode, MODE1 ) ) + { + set16_fx( shb_res_gshape_fx, 3277 /*0.2f Q14*/, 5 ); /* Q14 */ + } + ELSE + { + set16_fx( shb_res_gshape_fx, 16384 /*1.0f Q14*/, 5 ); /* Q14 */ + } + } + } + + /* get the gainshape delay */ + Copy( &st->GainShape_Delay[4], &st->GainShape_Delay[0], NUM_SHB_SUBFR / 4 ); + FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ ) + { + st->GainShape_Delay[i + 4] = GainShape_fx[i * 4]; /*Q15*/ + move16(); + } + + L_tmp = L_mult( voice_factors_fx[0], 8192 ); + L_tmp = L_mac( L_tmp, voice_factors_fx[1], 8192 ); + L_tmp = L_mac( L_tmp, voice_factors_fx[2], 8192 ); + mean_vf = mac_r( L_tmp, voice_factors_fx[3], 8192 ); + + Copy( voice_factors_fx, vf_modified_fx, NB_SUBFR16k ); + + test(); + IF( EQ_16( st->coder_type, VOICED ) || GT_16( mean_vf, 13107 /*0.4f Q15*/ ) ) + { + FOR( i = 1; i < NB_SUBFR; i++ ) + { + L_tmp = L_mult( voice_factors_fx[i], 26214 /*0.8f Q15*/ ); + vf_modified_fx[i] = mac_r( L_tmp, voice_factors_fx[i - 1], 6554 /*0.2f Q15*/ ); + move16(); + } + + IF( st->L_frame != L_FRAME ) + { + L_tmp = L_mult( voice_factors_fx[4], 26214 /*0.8f Q15*/ ); + vf_modified_fx[4] = mac_r( L_tmp, voice_factors_fx[3], 6554 /*0.2f Q15*/ ); + move16(); + } + } + + test(); + IF( st->use_partial_copy && st->nelp_mode_dec ) + { + set16_fx( vf_modified_fx, 0, NB_SUBFR16k ); + } + + /* SHB LSF from current frame; and convert to LSP for interpolation */ + E_LPC_lsf_lsp_conversion( lsf_shb_fx, lsp_shb_2_fx, LPC_SHB_ORDER ); + + test(); + IF( EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) + { + /* SHB LSP values from prev. frame for interpolation */ + Copy( hBWE_TD->swb_lsp_prev_interp_fx, lsp_shb_1_fx, LPC_SHB_ORDER ); + } + ELSE + { + /* Use current frame's LSPs; in effect no interpolation */ + Copy( lsp_shb_2_fx, lsp_shb_1_fx, LPC_SHB_ORDER ); + } + + test(); + test(); + test(); + IF( ( st->bws_cnt == 0 ) && ( st->bws_cnt1 == 0 ) && ( st->prev_use_partial_copy == 0 ) && ( st->use_partial_copy == 0 ) ) + { + lsf_diff_fx[0] = 16384; + move16(); /*Q15*/ + lsf_diff_fx[LPC_SHB_ORDER - 1] = 16384; + move16(); /*Q15*/ + FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) + { + lsf_diff_fx[i] = sub( lsf_shb_fx[i], lsf_shb_fx[i - 1] ); + move16(); + } + + a2rc_fx( hBWE_TD->cur_sub_Aq_fx + 1, refl_fx, M ); + tmp = add( 16384, shr( refl_fx[0], 1 ) ); /*Q14*/ + tmp1 = mult( 27425, tmp ); + tmp1 = mult( tmp1, tmp ); /*Q10*/ + tmp2 = shr( mult( 31715, tmp ), 2 ); /*Q10*/ + tilt_para_fx = add( sub( tmp1, tmp2 ), 1335 ); /*Q10*/ + + test(); + IF( NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) + { + FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) + { + hBWE_TD->prev_lsf_diff_fx[i - 1] = shr( lsf_diff_fx[i], 1 ); + move16(); + } + } + + IF( LE_32( st->extl_brate, FB_TBE_1k8 ) ) + { + test(); + test(); + test(); + test(); + test(); + IF( !( GT_16( hBWE_TD->prev_tilt_para_fx, 5120 ) && ( EQ_16( st->coder_type, TRANSITION ) || LT_16( tilt_para_fx, 1024 ) ) ) && + !( ( ( LT_16( hBWE_TD->prev_tilt_para_fx, 3072 ) && GE_16( st->prev_coder_type, VOICED ) ) ) && GT_16( tilt_para_fx, 5120 ) ) ) + { + FOR( i = 1; i < LPC_SHB_ORDER - 1; i++ ) + { + IF( LT_16( lsf_diff_fx[i], hBWE_TD->prev_lsf_diff_fx[i - 1] ) ) + { + tmp = mult( 26214, lsf_diff_fx[i] ); + + test(); + IF( ( hBWE_TD->prev_lsf_diff_fx[i - 1] <= 0 ) || ( tmp < 0 ) ) /* safety check in case of bit errors */ + { + st->BER_detect = 1; + move16(); + tmp = 0; + move16(); + } + ELSE + { + tmp = div_s( tmp, hBWE_TD->prev_lsf_diff_fx[i - 1] ); + } + + tmp = s_max( tmp, 16384 ); + w_fx[i] = s_min( tmp, 32767 ); + move16(); + } + ELSE + { + tmp = mult( 26214, hBWE_TD->prev_lsf_diff_fx[i - 1] ); + + test(); + IF( ( lsf_diff_fx[i] <= 0 ) || ( tmp < 0 ) ) /* safety check in case of bit errors */ + { + st->BER_detect = 1; + move16(); + tmp = 0; + move16(); + } + ELSE + { + tmp = div_s( tmp, lsf_diff_fx[i] ); + } + + tmp = s_max( tmp, 16384 ); + w_fx[i] = s_min( tmp, 32767 ); + move16(); + } + } + w_fx[0] = w_fx[1]; + move16(); + w_fx[LPC_SHB_ORDER - 1] = w_fx[LPC_SHB_ORDER - 2]; + move16(); + + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + tmp1 = mult( lsp_shb_1_fx[i], sub( 32767, w_fx[i] ) ); + tmp2 = mult( lsp_shb_2_fx[i], w_fx[i] ); + lsp_temp_fx[i] = add( tmp1, tmp2 ); + move16(); + } + } + ELSE + { + Copy( lsp_shb_2_fx, lsp_temp_fx, LPC_SHB_ORDER ); + } + + /* convert from lsp to lsf */ + lsp2lsf_fx( lsp_temp_fx, lsf_shb_fx, LPC_SHB_ORDER, 1 ); + } + + Copy( lsf_diff_fx + 1, hBWE_TD->prev_lsf_diff_fx, LPC_SHB_ORDER - 2 ); + hBWE_TD->prev_tilt_para_fx = tilt_para_fx; + move16(); + } + ELSE + { + Copy( lsp_shb_2_fx, lsp_temp_fx, LPC_SHB_ORDER ); + } + + IF( GE_32( st->extl_brate, SWB_TBE_2k8 ) ) + { + /* SHB LSP interpolation */ + ptr_lsp_interp_coef_fx = interpol_frac_shb; /*Q15*/ + FOR( j = 0; j < 4; j++ ) + { + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + L_tmp = L_mult( lsp_shb_1_fx[i], ( *ptr_lsp_interp_coef_fx ) ); + lsp_temp_fx[i] = mac_r( L_tmp, lsp_shb_2_fx[i], ( *( ptr_lsp_interp_coef_fx + 1 ) ) ); + move16(); + } + ptr_lsp_interp_coef_fx += 2; + + tmp = i_mult( j, ( LPC_SHB_ORDER + 1 ) ); + /* convert LSPs to LP coefficients */ + E_LPC_f_lsp_a_conversion( lsp_temp_fx, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER ); +#ifndef FIX_1100_REMOVE_LPC_RESCALING + /* Bring the LPCs to Q12 */ + Copy_Scale_sig( lpc_shb_sf_fx + tmp, lpc_shb_sf_fx + tmp, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_sf_fx[tmp] ), 2 ) ); + lpc_shb_sf_fx[i_mult( j, ( LPC_SHB_ORDER + 1 ) )] = ONE_IN_Q12; // recheck this + move16(); +#endif + } + } + + /* Save the SWB LSP values from current frame for interpolation */ + Copy( lsp_shb_2_fx, hBWE_TD->swb_lsp_prev_interp_fx, LPC_SHB_ORDER ); + + /* save the shb_ener and mixFactor values */ + hBWE_TD->prev3_shb_ener_sf_fx = hBWE_TD->prev2_shb_ener_sf_fx; + move32(); + hBWE_TD->prev2_shb_ener_sf_fx = hBWE_TD->prev1_shb_ener_sf_fx; + move32(); + hBWE_TD->prev1_shb_ener_sf_fx = shb_ener_sf_32; + move32(); + hBWE_TD->prev_res_shb_gshape_fx = shb_res_gshape_fx[4]; + move16(); + hBWE_TD->prev_mixFactors_fx = mixFactors_fx; + move16(); + + /* SWB CNG/DTX - update memories */ + IF( st->hTdCngDec != NULL ) + { + Copy( st->hTdCngDec->lsp_shb_prev_fx, st->hTdCngDec->lsp_shb_prev_prev_fx, LPC_SHB_ORDER ); + Copy( lsf_shb_fx, st->hTdCngDec->lsp_shb_prev_fx, LPC_SHB_ORDER ); + } + + /* convert LSPs back into LP coeffs */ + E_LPC_f_lsp_a_conversion( lsp_temp_fx, lpc_shb_fx, LPC_SHB_ORDER ); + Copy_Scale_sig( lpc_shb_fx, lpc_shb_fx, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_fx[0] ), 2 ) ); /* Q12 */ + lpc_shb_fx[0] = ONE_IN_Q12; + move16(); + + test(); + IF( EQ_32( st->extl_brate, SWB_TBE_1k10 ) || EQ_32( st->extl_brate, SWB_TBE_1k75 ) ) + { + Word32 vind_temp = Mpy_32_32( L_shl( L_add( L_deposit_l( mixFactors_fx ), 1 ), 15 ), ( ( ( 1 << NUM_BITS_SHB_VF ) - 1 ) << 16 ) ); // check addition of 1 + vind = extract_l( L_shr( vind_temp, 15 ) ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*7*/ + /* i: mixFactors_fx in Q15 */ + /* o: vind in Q0 */ + } + ELSE + { + vind = shl( mixFactors_fx, 3 - 15 ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*8*/ + /* i: mixFactors_fx in Q15 */ + /* o: vind in Q0 */ + } + + /* Determine formant PF strength */ + formant_fac_fx = swb_formant_fac_fx( lpc_shb_fx[1], &hBWE_TD->tilt_mem_fx ); + /* i:lpc_shb_fx Q12, o:formant_fac_fx Q15 */ + IF( GT_32( st->total_brate, ACELP_32k ) ) + { + FOR( j = 0; j < 4; j++ ) + { + Copy( lpc_shb_fx, &lpc_shb_sf_fx[i_mult( j, ( LPC_SHB_ORDER + 1 ) )], LPC_SHB_ORDER + 1 ); + } + } + + /* From low band excitation, generate highband excitation */ + + /* -------- start of memory rescaling -------- */ + /* ----- calculate optimum Q_bwe_exc and rescale memories accordingly ----- */ + Lmax = 0; + move32(); + FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) + { + Lmax = L_max( Lmax, L_abs( bwe_exc_extended_fx[cnt] ) ); + } + Q_bwe_exc = norm_l( Lmax ); + if ( Lmax == 0 ) + { + Q_bwe_exc = 31; + move16(); + } + Q_bwe_exc = add( Q_bwe_exc, add( Q_exc, Q_exc ) ); + find_max_mem_dec( st, &n_mem, &n_mem2, &n_mem3 ); /* for >=24.4, use n_mem2 lpc_syn, shb_20sample, and mem_stp_swb_fx memory */ + + tmp = add( st->prev_Q_bwe_exc, n_mem ); + if ( GT_16( Q_bwe_exc, tmp ) ) + { + Q_bwe_exc = tmp; + move16(); + } + + /* rescale the memories if Q_bwe_exc is different from previous frame */ + sc = sub( Q_bwe_exc, st->prev_Q_bwe_exc ); + IF( sc != 0 ) + { + rescale_genSHB_mem_dec_ivas( st, sc ); + } + + /* rescale the bwe_exc_extended and bring it to 16-bit single precision with dynamic norm */ + sc = sub( Q_bwe_exc, add( Q_exc, Q_exc ) ); + + FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) + { + bwe_exc_extended_16[cnt] = round_fx_sat( L_shl_sat( bwe_exc_extended_fx[cnt], sc ) ); + move16(); + } + + /* state_syn_shbexc_fx is kept at (st_fx->prev_Q_bwe_syn) for 24.4/32kbps or is kept at Q_bwe_exc for 13.2/16.4kbps */ + + /* save the previous Q factor (32-bit) of the buffer */ + st->prev_Q_bwe_exc = Q_bwe_exc; + move16(); + + Q_bwe_exc = sub( Q_bwe_exc, 16 ); /* Q_bwe_exc reflecting the single precision dynamic norm-ed buffers from here */ + + /* -------- end of rescaling memories -------- */ + + Q_bwe_exc_fb = st->prev_Q_bwe_exc_fb; + move16(); + + Q_shb = 0; + move16(); + + Copy( hBWE_TD->state_syn_shbexc_fx, shaped_shb_excitation_fx, L_SHB_LAHEAD ); + GenShapedSHBExcitation_ivas_dec_fx( shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, + hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, + st->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st->extl, + &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_32, + shb_res_gshape_fx, shb_res_dummy_fx, &vind, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, + &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, st->prev_Q_bwe_syn, st->total_brate, st->prev_bfi, + st->element_mode, st->flag_ACELP16k, nlExc16k_fx, mixExc16k_fx, st->extl_brate, MSFlag, + NULL, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), NULL, NULL ); + + *Q_white_exc = Q_bwe_exc_fb; + move16(); + IF( EQ_16( st->extl, FB_TBE ) ) + { + st->prev_Q_bwe_exc_fb = Q_bwe_exc_fb; + move16(); + } + ELSE + { + /*Indirectly a memory reset of FB memories for next frame such that rescaling of memories would lead to 0 due to such high prev. Q value. + 51 because of 31 + 20(shift of Q_bwe_exc_fb before de-emphasis)*/ + st->prev_Q_bwe_exc_fb = 51; + move16(); + } + + /* rescale the TBE post proc memory */ + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) + { + hBWE_TD->mem_stp_swb_fx[i] = shl_sat( hBWE_TD->mem_stp_swb_fx[i], sub( Q_bwe_exc, st->prev_Q_bwe_syn ) ); + move16(); + } + /* fill-in missing SHB excitation */ + test(); + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) && LE_32( st->last_core_brate, SID_2k40 ) ) + { + Copy( shaped_shb_excitation_fx + L_SHB_LAHEAD, shaped_shb_excitation_fx, L_SHB_LAHEAD ); + } + + IF( hStereoICBWE != NULL ) + { + Copy( shaped_shb_excitation_fx + L_SHB_LAHEAD, hStereoICBWE->shbSynthRef_fx, L_FRAME16k ); + } + + test(); + IF( NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) ) + { + FOR( i = 0; i < L_FRAME16k; i += L_SUBFR16k ) + { + /* TD BWE post-processing */ + PostShortTerm_ivas_dec_fx( &shaped_shb_excitation_fx[L_SHB_LAHEAD + i], lpc_shb_fx, &shaped_shb_excitationTemp_fx[i], hBWE_TD->mem_stp_swb_fx, + hBWE_TD->ptr_mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ), hBWE_TD->mem_zero_swb_fx, formant_fac_fx ); + } + + Copy( shaped_shb_excitationTemp_fx, &shaped_shb_excitation_fx[L_SHB_LAHEAD], L_FRAME16k ); /* Q_bwe_exc */ + + tmp = sub( shl( Q_bwe_exc, 1 ), 31 + 16 ); + prev_pow_fx = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ + curr_pow_fx = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc) */ + FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) + { + prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /*2*Q_bwe_exc*/ + curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ + } + + if ( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) ) + { + curr_pow_fx = L_shr( curr_pow_fx, 2 ); /* Q(2*Q_bwe_exc) */ + } + + Lscale = root_a_over_b_fx( curr_pow_fx, + shl( Q_bwe_exc, 1 ), + prev_pow_fx, + shl( Q_bwe_exc, 1 ), + &exp ); + + FOR( i = 0; i < L_SHB_LAHEAD; i++ ) + { + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + move16(); + } + IF( exp < 0 ) + { + Lscale = L_shl( Lscale, exp ); + exp = 0; + move16(); + } + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + temp_fx = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp_fx ); /* Q31-exp */ + temp_fx = sub( 32767 /*1.0f Q15*/, temp_fx ); + Lscale = L_add( Mult_32_16( Lscale, temp_fx ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + move16(); + } + } + ELSE + { + /* reset the PF memories if the PF is not running */ + set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); + hBWE_TD->gain_prec_swb_fx = ONE_IN_Q14; + move16(); + set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); + } + + /* Update SHB excitation */ + Copy( shaped_shb_excitation_fx + L_FRAME16k, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD ); /* Q_bwe_exc */ + l_subframe = L_FRAME16k / NUM_SHB_SUBGAINS; + move16(); + L_ener = EPSILON_FX_SMALL; + move32(); + + FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) + { + L_tmp = 0; + move32(); + ener_tmp_fx[i] = EPSILON_FX_SMALL; + move32(); + + Word64 tmp64 = 0; + move64(); + FOR( j = 0; j < l_subframe; j++ ) + { + tmp64 = W_mac0_16_16( tmp64, shaped_shb_excitation_fx[add( i_mult( i, l_subframe ), j )], shaped_shb_excitation_fx[add( i_mult( i, l_subframe ), j )] ); /* 2*Q_bwe_exc */ + } + L_tmp = W_sat_l( tmp64 ); + + L_tmp = Mult_32_16( L_tmp, 410 /*0.0125 Q15*/ ); /* 2*Q_bwe_exc: ener_tmp_fx in (2*Q_bwe_exc) */ + IF( L_tmp != 0 ) + { + exp = norm_l( L_tmp ); + tmp = extract_h( L_shl( L_tmp, exp ) ); + exp = sub( exp, sub( 30, i_mult( 2, Q_bwe_exc ) ) ); + + tmp = div_s( 16384, tmp ); + L_tmp = L_deposit_h( tmp ); + L_tmp = Isqrt_lc( L_tmp, &exp ); + ener_tmp_fx[i] = L_shl_sat( L_tmp, sub( add( exp, shl( Q_bwe_exc, 1 ) ), 31 ) ); /*2 * Q_bwe_exc: Q31 -exp +exp +2 * Q_bwe_exc -31 */ + move32(); + L_ener = L_add_sat( L_ener, L_shr( ener_tmp_fx[i], 2 ) ); /* 2*Q_bwe_exc */ + } + } + ener_fx = s_max( 1, round_fx_sat( L_shl_sat( L_ener, sub( 18, shl( Q_bwe_exc, 1 ) ) ) ) ); /* Q2: 2*Q_bwe_exc+18-2*Q_bwe_exc-16 */ + /* WB/SWB bandwidth switching */ + IF( st->bws_cnt > 0 ) + { + IF( is_fractive == 0 ) + { + IF( GT_16( st->tilt_wb_fx, 2048 ) ) /*assuming st->tilt_wb_fx in Q11*/ + { + st->tilt_wb_fx = 2048; + move16(); + } + ELSE IF( LT_16( st->tilt_wb_fx, 1024 ) ) + { + st->tilt_wb_fx = 1024; + move16(); + } + test(); + if ( EQ_16( st->prev_fractive, 1 ) && GT_16( st->tilt_wb_fx, 1024 ) ) + { + st->tilt_wb_fx = 1024; + move16(); + } + } + ELSE + { + IF( GT_16( st->tilt_wb_fx, 8192 ) ) + { + IF( st->prev_fractive == 0 ) + { + st->tilt_wb_fx = 8192; + move16(); + } + ELSE + { + st->tilt_wb_fx = 16384; + move16(); + } + } + ELSE + { + st->tilt_wb_fx = shl( st->tilt_wb_fx, 2 ); + move16(); + } + } + + IF( ener_fx != 0 ) + { + L_tmp = L_shl( L_mult0( ener_fx, st->tilt_wb_fx ), sub( st->Q_syn2, 13 ) ); /* 2+11 +st->Q_syn2 -13 = st->Q_syn2*/ + exp_ener = norm_s( ener_fx ); + tmp = shl( ener_fx, exp_ener ); /*Q(2+exp)*/ + inv_ener = shr( div_s( 16384, tmp ), 1 ); /*Q(15+14-2-exp-1) = 26 - exp*/ + + test(); + IF( GT_32( L_tmp, st->enerLH_fx ) ) /*st->Q_syn2*/ + { + st->tilt_wb_fx = extract_h( L_shr_sat( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 16 ) ) ); /*Q11*/ + move16(); + /*st->Q_syn2 -1 + 26- exp_ener -15 -(st->Q_syn2 -exp_ener -16 ) -16 +1 -1 = (11) *0.5*/ + } + ELSE IF( LT_32( L_tmp, Mult_32_16( st->enerLH_fx, 1638 ) ) && EQ_16( is_fractive, 1 ) ) + { + st->tilt_wb_fx = extract_h( L_shr_sat( Mult_32_16( st->enerLH_fx, inv_ener ), sub( sub( st->Q_syn2, exp_ener ), 15 ) ) ); /*Q11*/ + move16(); + /*st->Q_syn2 -1 + 26- exp_ener -15 -(st->Q_syn2 -exp_ener -15 ) -16 = (11) 0.25*/ + } + L_tmp = L_mult0( st->prev_ener_shb_fx, inv_ener ); /*Q(1+15+14-3-exp_ener) = 27 -exp_ener*/ + GainFrame_prevfrm_fx = L_shr( L_tmp, sub( 9, exp_ener ) ); /*27 -exp_ener -(9-exp_ener )= Q18*/ + } + ELSE + { + GainFrame_prevfrm_fx = 0; + move32(); + } + + IF( EQ_16( is_fractive, 1 ) ) + { + GainFrame_fx = L_shl( L_deposit_l( st->tilt_wb_fx ), 10 ); + } + ELSE + { + GainFrame_fx = L_shl( L_deposit_l( st->tilt_wb_fx ), 8 ); + } + + test(); + IF( EQ_16( ( is_fractive & st->prev_fractive ), 1 ) && GT_32( GainFrame_fx, GainFrame_prevfrm_fx ) ) + { + GainFrame_fx = L_add( Mult_32_16( GainFrame_prevfrm_fx, 26214 ), Mult_32_16( GainFrame_fx, 6554 ) ); /* 18 +15 -15 = 18*/ + } + ELSE + { + test(); + test(); + test(); + test(); + IF( ( LT_32( L_shr( st->prev_enerLH_fx, 1 ), st->enerLH_fx ) && GT_32( st->prev_enerLH_fx, L_shr( st->enerLH_fx, 1 ) ) ) && ( LT_32( L_shr( st->prev_enerLL_fx, 1 ), st->enerLL_fx ) && GT_32( st->prev_enerLL_fx, L_shr( st->enerLL_fx, 1 ) ) ) && ( s_xor( is_fractive, st->prev_fractive ) == 0 ) ) + { + GainFrame_fx = L_add( L_shr( GainFrame_fx, 1 ), L_shr( GainFrame_prevfrm_fx, 1 ) ); + } + ELSE + { + test(); + IF( ( is_fractive == 0 ) && EQ_16( st->prev_fractive, 1 ) ) + { + L_tmp1 = L_shl( Mult_32_16( GainFrame_fx, 3277 ), 13 ); /* 31 */ + L_tmp = L_sub( 2147483647, L_tmp1 ); /* 31 */ + GainFrame_fx = L_add( Mult_32_32( GainFrame_fx, L_tmp ), Mult_32_32( GainFrame_prevfrm_fx, L_tmp1 ) ); /* 18 */ + } + ELSE + { + GainFrame_fx = L_add( L_shr( GainFrame_fx, 1 ), L_shr( L_min( GainFrame_prevfrm_fx, GainFrame_fx ), 1 ) ); /* 18 */ + } + } + } + + GainFrame_fx = Mult_32_16( GainFrame_fx, i_mult( sub( N_WS2N_FRAMES, st->bws_cnt ), 819 ) ); /*Q18*/ + } + ELSE + { + IF( st->bws_cnt1 > 0 ) + { + GainFrame_fx = Mult_32_16( GainFrame_fx, i_mult( st->bws_cnt1, 819 ) ); /*Q18*/ + } + IF( GE_16( st->nbLostCmpt, 1 ) ) + { + ener_fx = s_max( 1, ener_fx ); + exp_ener = norm_s( ener_fx ); + tmp = shl( ener_fx, exp_ener ); /*Q(2+exp)*/ + inv_ener = div_s( 16384, tmp ); /*Q(15+14-2-exp)*/ + prev_ener_ratio_fx = L_shr( L_mult0( st->prev_ener_shb_fx, inv_ener ), add( sub( 9, exp_ener ), 1 ) ); /*Q: 1+27-exp-9+exp-1 = 18 */ + } + + IF( EQ_16( st->nbLostCmpt, 1 ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( st->clas_dec != UNVOICED_CLAS ) && NE_16( st->clas_dec, UNVOICED_TRANSITION ) && LT_16( hBWE_TD->tilt_swb_fec_fx, 16384 ) && + ( ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) && LT_32( L_shr( st->enerLL_fx, 1 ), st->prev_enerLL_fx ) ) || ( GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) && LT_32( L_shr( st->enerLH_fx, 1 ), st->prev_enerLH_fx ) ) ) ) + { + IF( GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) ) /*18*/ + { + GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 13107 ), Mult_32_16( GainFrame_fx, 19661 ) ); /*18*/ + } + ELSE IF( GT_32( L_shr( prev_ener_ratio_fx, 1 ), GainFrame_fx ) ) + { + GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 26214 ), Mult_32_16( GainFrame_fx, 6554 ) ); + } + ELSE + { + GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 ), Mult_32_16( GainFrame_fx, 26214 ) ); + } + + test(); + IF( GT_16( tilt_swb_fec_fx, hBWE_TD->tilt_swb_fec_fx ) && ( hBWE_TD->tilt_swb_fec_fx > 0 ) ) + { + exp = norm_s( hBWE_TD->tilt_swb_fec_fx ); + tmp = shl( hBWE_TD->tilt_swb_fec_fx, exp ); /*Q(11+exp)*/ + tmp = div_s( 16384, tmp ); /*Q(15+14-11-exp)*/ + tmp = extract_h( L_shl( L_mult0( tmp, st->tilt_wb_fx ), sub( exp, 1 ) ) ); /*18 -exp +11 + exp -1 -16 =12; */ + GainFrame_fx = L_shl( Mult_32_16( GainFrame_fx, s_min( tmp, 20480 ) ), 3 ); /*Q18 = 18 +12 -15 +3 */ + } + } + ELSE IF( ( ( st->clas_dec != UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 4096 ) ) && GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) && + ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) ) + { + GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 ), Mult_32_16( GainFrame_fx, 26214 ) ); + } + } + ELSE IF( GT_16( st->nbLostCmpt, 1 ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( GT_32( L_shr( prev_ener_ratio_fx, 2 ), GainFrame_fx ) && ( ( EQ_16( st->codec_mode, MODE1 ) && GT_32( st->enerLL_fx, st->prev_enerLL_fx ) && GT_32( st->enerLH_fx, st->prev_enerLH_fx ) ) || EQ_16( st->codec_mode, MODE2 ) ) ) + { + test(); + IF( GT_16( tilt_swb_fec_fx, 20480 /*10.0f in Q11*/ ) && GT_16( hBWE_TD->tilt_swb_fec_fx, 20480 /*10.0f in Q11*/ ) ) + { + GainFrame_fx = L_min( L_add( Mult_32_16( prev_ener_ratio_fx, 26214 /*0.8f in Q15*/ ), Mult_32_16( GainFrame_fx, 6554 /*0.2f in Q15*/ ) ), L_shl( Mult_32_16( GainFrame_fx, 16384 /*4.0f in Q12*/ ), 3 ) ); /*Q18*/ + } + ELSE + { + GainFrame_fx = L_min( L_add( Mult_32_16( prev_ener_ratio_fx, 16384 ), Mult_32_16( GainFrame_fx, 16384 ) ), L_shl( Mult_32_16( GainFrame_fx, 16384 ), 3 ) ); /*Q18*/ + } + } + ELSE IF( GT_32( prev_ener_ratio_fx, GainFrame_fx ) && ( ( EQ_16( st->codec_mode, MODE1 ) && GT_32( st->enerLL_fx, st->prev_enerLL_fx ) && GT_32( st->enerLH_fx, st->prev_enerLH_fx ) ) || EQ_16( st->codec_mode, MODE2 ) ) ) + { + test(); + IF( GT_16( tilt_swb_fec_fx, 20480 ) && GT_16( hBWE_TD->tilt_swb_fec_fx, 20480 ) ) + { + GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 16384 /*0.5f in Q15*/ ), Mult_32_16( GainFrame_fx, 16384 /*0.5f in Q15*/ ) ); /* Q18 */ + } + ELSE + { + GainFrame_fx = L_add( Mult_32_16( prev_ener_ratio_fx, 6554 /*0.2f in Q15*/ ), Mult_32_16( GainFrame_fx, 26214 /*0.8f in Q15*/ ) ); /* Q18 */ + } + } + } + } + + st->prev_fractive = is_fractive; + move16(); + + /* Adjust the subframe and frame gain of the synthesized shb signal */ + /* Scale the shaped excitation */ + IF( EQ_16( st->L_frame, L_FRAME ) ) + { + L_tmp = L_mult( pitch_buf_fx[0], 8192 ); + FOR( i = 1; i < NB_SUBFR; i++ ) + { + L_tmp = L_mac( L_tmp, pitch_buf_fx[i], 8192 ); /* pitch_buf in Q6 x 0.25 in Q15 */ + } + pitch_fx = round_fx( L_tmp ); /* Q6 */ + } + ELSE + { + L_tmp = L_mult( pitch_buf_fx[0], 6554 ); + FOR( i = 1; i < NB_SUBFR16k; i++ ) + { + L_tmp = L_mac( L_tmp, pitch_buf_fx[i], 6554 ); /* pitch_buf in Q6 x 0.2 in Q15 */ + } + pitch_fx = round_fx( L_tmp ); /* Q6 */ + } + + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( GE_32( st->extl_brate, SWB_TBE_2k8 ) && EQ_16( st->prev_coder_type, st->coder_type ) && NE_16( st->coder_type, UNVOICED ) ) || ( LT_32( st->extl_brate, SWB_TBE_2k8 ) && ( EQ_16( st->prev_coder_type, st->coder_type ) || ( EQ_16( st->prev_coder_type, VOICED ) && EQ_16( st->coder_type, GENERIC ) ) || ( EQ_16( st->prev_coder_type, GENERIC ) && EQ_16( st->coder_type, VOICED ) ) ) ) ) && GT_16( pitch_fx, 4480 /*70 in Q6*/ ) && LT_16( st->extl, FB_TBE ) && NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) ) + { + FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) + { + GainShape_tmp_fx[i] = GainShape_fx[i * 4]; /* Q15 */ + move16(); + } + + FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) + { + L_tmp1 = Mult_32_16( ener_tmp_fx[i], GainShape_tmp_fx[i] ); /* (2*Q_bwe_exc) */ + L_tmp2 = Mult_32_16( hBWE_TD->prev_ener_fx, hBWE_TD->prev_GainShape_fx ); /* (2*st->prev_ener_fx_Q) */ + tmp = sub( shl( Q_bwe_exc, 1 ), shl( st->prev_ener_fx_Q, 1 ) ); + L_tmp2 = L_shl_sat( L_tmp2, tmp ); /* new Q = (2*Q_bwe_exc) */ + IF( GT_32( L_tmp1, L_tmp2 ) ) + { + L_tmp = L_tmp2; + move32(); + if ( L_tmp2 < 0 ) + { + L_tmp = L_negate( L_tmp2 ); + } + + expb = norm_l( L_tmp ); + fracb = round_fx_sat( L_shl_sat( L_tmp, expb ) ); + expb = sub( 30, expb ); /* - (2*Q_bwe_exc_ext); */ + + expa = norm_l( ener_tmp_fx[i] ); + fraca = extract_h( L_shl( ener_tmp_fx[i], expa ) ); + expa = sub( 30, expa ); + + scale_fx = shr( sub( fraca, fracb ), 15 ); + fracb = shl( fracb, scale_fx ); + expb = sub( expb, scale_fx ); + + tmp = div_s( fracb, fraca ); + exp = sub( sub( expb, expa ), 1 ); + tmp = shl( tmp, exp ); + GainShape_tmp_fx[i] = add( tmp, shr( GainShape_tmp_fx[i], 1 ) ); /* Q15 */ + move16(); + } + + hBWE_TD->prev_ener_fx = ener_tmp_fx[i]; + move32(); + hBWE_TD->prev_GainShape_fx = GainShape_tmp_fx[i]; + move16(); + st->prev_ener_fx_Q = Q_bwe_exc; + move16(); + } + + FOR( i = 0; i < NUM_SHB_SUBFR; i++ ) + { + Word16 idx = 0; + move16(); + IF( i != 0 ) + { + idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); + } + GainShape_fx[i] = GainShape_tmp_fx[idx]; + move16(); + } + } + ELSE + { + st->prev_ener_fx_Q = Q_bwe_exc; + move16(); + } + st->prev_Q_bwe_syn = Q_bwe_exc; + move16(); + + + /* Gain shape smoothing after quantization */ + test(); + IF( EQ_32( st->extl_brate, SWB_TBE_1k10 ) || EQ_32( st->extl_brate, SWB_TBE_1k75 ) ) + { + FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) + { + GainShape_tmp_fx[i] = GainShape_fx[i * NUM_SHB_SUBGAINS]; + move16(); + } + + lls_interp_n_fx( GainShape_tmp_fx, NUM_SHB_SUBGAINS, &GainShape_tilt_fx, &temp_fx, 1 ); + + test(); + IF( GE_16( vind, 6 ) && LT_16( abs_s( GainShape_tilt_fx ), 3932 ) ) + { + feedback_fx = 9830; + move16(); + FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) + { + GainShape_fx[i] = add_sat( mult( sub( 32767, feedback_fx ), GainShape_fx[i * NUM_SHB_SUBGAINS] ), mult( feedback_fx, GainShape_tmp_fx[i] ) ); + move16(); + } + + FOR( i = NUM_SHB_SUBFR - 1; i > 0; i-- ) + { + Word16 idx = 0; + move16(); + IF( i != 0 ) + { + idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); + } + GainShape_fx[i] = GainShape_fx[idx]; + move16(); + } + } + } + + /* fil-in missing memory */ + test(); + test(); + IF( ( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) && LE_32( st->last_core_brate, SID_2k40 ) ) + { + FOR( i = 0; i < L_SHB_LAHEAD; i++ ) + { + Word16 intermediate = mult( shaped_shb_excitation_fx[i], subwin_shb_fx[L_SHB_LAHEAD - i] ); + Word32 intermediate_32 = Mpy_32_16_1( Mpy_32_16_1( GainFrame_fx, window_shb_fx[L_SHB_LAHEAD - 1 - i] ), intermediate ); + hBWE_TD->syn_overlap_fx[i] = round_fx( L_shl_sat( intermediate_32, sub( 16, ( add( Q_bwe_exc, 18 - 15 ) ) ) ) ); + move16(); + } + } + + Word16 n_mem3_new = 0; + move16(); + find_max_mem_dec_m3( st, &n_mem3_new ); + + ScaleShapedSHB_fx( SHB_OVERLAP_LEN, + shaped_shb_excitation_fx, /* i/o: Q_bwe_exc */ + hBWE_TD->syn_overlap_fx, + GainShape_fx, /* Q15 */ + GainFrame_fx, /* Q18 */ + window_shb_fx, + subwin_shb_fx, + &Q_bwe_exc, &Qx, n_mem3_new, st->prev_Q_bwe_syn2 ); + + IF( hStereoICBWE != NULL ) + { + Copy_Scale_sig_16_32_DEPREC( lpc_shb_fx, hStereoICBWE->lpSHBRef_fx, LPC_SHB_ORDER + 1, 0 ); + Copy( GainShape_fx, hStereoICBWE->gshapeRef_fx, NUM_SHB_SUBFR ); + hStereoICBWE->gFrameRef_fx = GainFrame_fx; + move32(); + + Copy( shaped_shb_excitation_fx, hStereoICBWE->shbSynthRef_fx, L_FRAME16k ); + } + + max_val = 0; + move16(); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + max_val = s_max( max_val, abs_s( shaped_shb_excitation_fx[i] ) ); /* Q0 */ + } + IF( max_val == 0 ) + { + curr_frame_pow_fx = 0; + move32(); + n = 0; + move16(); + } + ELSE + { + n = norm_s( max_val ); + max_val = 0; + move16(); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + shaped_shb_excitation_frac[i] = shl_sat( shaped_shb_excitation_fx[i], n ); /*Q_bwe_exc+n*/ + move16(); + } + + curr_frame_pow_fx = 0; + move32(); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + L_tmp = L_mult0( shaped_shb_excitation_frac[i], shaped_shb_excitation_frac[i] ); /*2*(Q_bwe_exc+n)*/ + curr_frame_pow_fx = L_add( curr_frame_pow_fx, L_shr( L_tmp, 9 ) ); /*2*(Q_bwe_exc+n)-9*/ + } + } + curr_frame_pow_exp = sub( shl( add( Q_bwe_exc, n ), 1 ), 9 ); + tmp = sub( st->prev_frame_pow_exp, curr_frame_pow_exp ); + IF( tmp > 0 ) /* shifting prev */ + { + IF( GT_16( tmp, 32 ) ) + { + st->prev_frame_pow_exp = add( curr_frame_pow_exp, 32 ); + move16(); + tmp = 32; + move16(); + } + hBWE_TD->prev_swb_bwe_frame_pow_fx = L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, tmp ); + move32(); + st->prev_frame_pow_exp = curr_frame_pow_exp; + move16(); + } + ELSE /* shifting curr */ + { + IF( LT_16( tmp, -32 ) ) + { + curr_frame_pow_exp = sub( st->prev_frame_pow_exp, 32 ); + tmp = -32; + move16(); + } + curr_frame_pow_fx = L_shr( curr_frame_pow_fx, -tmp ); + curr_frame_pow_exp = st->prev_frame_pow_exp; + move16(); + } + test(); + test(); + IF( !st->bfi && ( st->prev_bfi || st->prev_use_partial_copy ) ) + { + test(); + test(); + IF( ( GT_32( L_shr( curr_frame_pow_fx, 1 ), hBWE_TD->prev_swb_bwe_frame_pow_fx ) ) && + ( GT_32( hBWE_TD->prev_swb_bwe_frame_pow_fx, L_tmp ) ) && EQ_16( st->prev_coder_type, UNVOICED ) ) + { + L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); + scale_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/ + + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + temp_fx = round_fx( L_shl( L_tmp, exp ) ); /*Q15*/ + } + ELSE + { + scale_fx = temp_fx = 32767; + move16(); /*Q15*/ + move16(); /*Q15*/ + } + + FOR( j = 0; j < 8; j++ ) + { + GainShape_fx[2 * j] = mult_r( GainShape_fx[2 * j], scale_fx ); + move16(); + GainShape_fx[2 * j + 1] = mult_r( GainShape_fx[2 * j + 1], scale_fx ); + move16(); + FOR( i = 0; i < L_FRAME16k / 8; i++ ) + { + shaped_shb_excitation_fx[add( i, j * ( L_FRAME16k / 8 ) )] = mult_r( shaped_shb_excitation_fx[add( i, j * ( L_FRAME16k / 8 ) )], scale_fx ); + move16(); + } + + IF( temp_fx > 0 ) + { + /* scale_fx <= temp_fx, due to scale_fx = sqrt( st->prev_swb_bwe_frame_pow_fx/curr_frame_pow_fx ), temp_fx = sqrt( scale_fx, 1.f/8.f ) + and curr_frame_pow_fx > st->prev_swb_bwe_frame_pow_fx -> scale_fx <= 1.0, sqrt(scale_fx, 1.f/8.f) >= scale_fx */ + IF( LT_16( scale_fx, temp_fx ) ) + { + scale_fx = div_s( scale_fx, temp_fx ); + } + ELSE + { + scale_fx = 32767; + move16(); + } + } + ELSE + { + scale_fx = 0; + move16(); + } + } + } + + /* adjust the FEC frame energy */ + IF( st->bfi ) + { + scale_fx = temp_fx = 4096; + move16(); /*Q12*/ + move16(); + IF( EQ_16( st->nbLostCmpt, 1 ) ) + { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( GT_32( curr_frame_pow_fx, hBWE_TD->prev_swb_bwe_frame_pow_fx ) && + NE_16( st->prev_coder_type, UNVOICED ) && + ( st->last_good != UNVOICED_CLAS ) ) + { + L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); /*31 - exp*/ + scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + } + ELSE IF( LT_32( curr_frame_pow_fx, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) && EQ_16( st->nbLostCmpt, 1 ) && + ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) && + ( EQ_16( st->prev_coder_type, UNVOICED ) || ( st->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) ) + { + L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); + scale_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + } + } + ELSE IF( GT_16( st->nbLostCmpt, 1 ) ) + { + test(); + test(); + test(); + test(); + test(); + IF( GT_32( curr_frame_pow_fx, hBWE_TD->prev_swb_bwe_frame_pow_fx ) ) + { + L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); + scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + temp_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + } + ELSE IF( LT_32( curr_frame_pow_fx, L_shr( hBWE_TD->prev_swb_bwe_frame_pow_fx, 1 ) ) && + ( GT_32( st->enerLL_fx, L_shr( st->prev_enerLL_fx, 1 ) ) || GT_32( st->enerLH_fx, L_shr( st->prev_enerLH_fx, 1 ) ) ) && + ( EQ_16( st->prev_coder_type, UNVOICED ) || ( st->last_good == UNVOICED_CLAS ) || GT_16( hBWE_TD->tilt_swb_fec_fx, 10240 ) ) ) + { + L_tmp = root_a_over_b_fx( hBWE_TD->prev_swb_bwe_frame_pow_fx, curr_frame_pow_exp, curr_frame_pow_fx, curr_frame_pow_exp, &exp ); + L_tmp = L_min( L_tmp, L_shl_sat( 2, sub( 31, exp ) ) ); /*31 - exp*/ + scale_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + L_tmp = root_a_fx( L_tmp, sub( 31, exp ), &exp ); + temp_fx = round_fx( L_shl( L_tmp, sub( exp, 3 ) ) ); /*Q12*/ + } + } + + FOR( j = 0; j < 8; j++ ) + { + GainShape_fx[2 * j] = shl_sat( mult_r( GainShape_fx[2 * j], scale_fx ), 3 ); + move16(); /* 15 +12 +3-15 =15*/ + GainShape_fx[add( 2 * j, 1 )] = shl_sat( mult_r( GainShape_fx[add( 2 * j, 1 )], scale_fx ), 3 ); + move16(); + FOR( i = 0; i < 40; i++ ) + { + shaped_shb_excitation_fx[i + j * L_FRAME16k / 8] = shl( mult_r( shaped_shb_excitation_fx[i + j * L_FRAME16k / 8], scale_fx ), 3 ); + move16(); /* Q_bwe_exc +12+3 -15 =Q_bwe_exc*/ + } + + IF( temp_fx > 0 ) + { + IF( LT_16( scale_fx, temp_fx ) ) + { + scale_fx = shr( div_s( scale_fx, temp_fx ), 3 ); + } + ELSE + { + tmp1 = sub( norm_s( scale_fx ), 1 ); + tmp2 = norm_s( temp_fx ); + scale_fx = div_s( shl( scale_fx, tmp1 ), shl( temp_fx, tmp2 ) ); + scale_fx = shr( scale_fx, add( sub( tmp1, tmp2 ), 3 ) ); + } + } + ELSE + { + scale_fx = 0; + move16(); + } + } + } + + hBWE_TD->prev_swb_bwe_frame_pow_fx = curr_frame_pow_fx; + move32(); + st->prev_frame_pow_exp = curr_frame_pow_exp; + move16(); + + Word64 prev_ener_shb64 = 0; + move64(); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + prev_ener_shb64 = W_mac0_16_16( prev_ener_shb64, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* Q0 */ + } + L_prev_ener_shb = W_sat_l( prev_ener_shb64 ); + + L_prev_ener_shb = Mult_32_16( L_prev_ener_shb, 26214 ); /* 2*Q_bwe_exc_mod+8; 26214=(1/L_FRAME16k) in Q23 */ + st->prev_ener_shb_fx = 0; + move16(); + IF( L_prev_ener_shb != 0 ) + { + exp = norm_l( L_prev_ener_shb ); + tmp = extract_h( L_shl( L_prev_ener_shb, exp ) ); + exp = sub( exp, sub( 30, ( add( i_mult( 2, Q_bwe_exc ), 8 ) ) ) ); + + tmp = div_s( 16384, tmp ); + L_tmp = L_deposit_h( tmp ); + L_tmp = Isqrt_lc( L_tmp, &exp ); + st->prev_ener_shb_fx = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ + move16(); + } + + IF( st->hBWE_FD != NULL ) + { + L_tmp = Mult_32_16( curr_frame_pow_fx, 26214 ); /* curr_frame_pow_exp+8; 26214=(1/L_FRAME16k) in Q23 */ + tmp = 0; + move16(); + IF( L_tmp != 0 ) + { + exp = norm_l( L_tmp ); + tmp = extract_h( L_shl( L_tmp, exp ) ); + exp = sub( exp, sub( 30, add( curr_frame_pow_exp, 8 ) ) ); + + tmp = div_s( 16384, tmp ); + L_tmp = L_deposit_h( tmp ); + L_tmp = Isqrt_lc( L_tmp, &exp ); + tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 14 ) ) ); /* Q1 */ + } + set16_fx( st->prev_SWB_fenv_fx, tmp, SWB_FENV ); /* Q1 */ + } + + FOR( i = 0; i < L_FRAME16k; i++ ) + { + shaped_shb_excitation_fx_32[i] = L_shl( shaped_shb_excitation_fx[i], sub( Q11, Q_bwe_exc ) ); + move32(); + } + + /* generate 32kHz SHB synthesis from 12.8(16)kHz signal */ + GenSHBSynth_fx_32( shaped_shb_excitation_fx_32, error_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->L_frame, &( hBWE_TD->syn_dm_phase ) ); + Copy_Scale_sig_32_16( st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, 2 * ALLPASSSECTIONS_STEEP, -( Q11 - Q_bwe_exc ) ); + Copy32( error_fx + L_FRAME32k - L_SHB_TRANSITION_LENGTH, hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH ); + + /* resample SHB synthesis (if needed) and scale down */ + synth_scale_fx = 32767; + move16(); /* 1.0 in Q15 */ + if ( EQ_16( st->codec_mode, MODE1 ) ) + { + synth_scale_fx = 29491; + move16(); /* 0.9 in Q15 */ + } + + IF( EQ_32( st->output_Fs, 48000 ) ) + { + IF( EQ_16( st->extl, FB_TBE ) ) + { + tmp = norm_l( GainFrame_fx ); + if ( GainFrame_fx == 0 ) + { + tmp = 31; + move16(); + } + L_tmp = L_shl( GainFrame_fx, tmp ); /* 18 + tmp */ + + tmp1 = 0; + move16(); + FOR( i = 0; i < L_FRAME16k; i++ ) + { + Word16 idx = 0; + move16(); + IF( i != 0 ) + { + idx = idiv1616( i_mult( NUM_SHB_SUBFR, i ), L_FRAME16k ); + } + L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[idx] ); /* Q : 18 + tmp +15 -15*/ + White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */ + move16(); + tmp1 = s_max( tmp1, abs_s( White_exc16k_fx[i] ) ); + } + + *Q_white_exc = sub( add( *Q_white_exc, tmp ), 13 ); /* *Q_white_exc + 18 + tmp -15 -16 */ + move16(); + tmp = norm_s( tmp1 ); + if ( tmp1 == 0 ) + { + tmp = 15; + move16(); + } + + FOR( i = 0; i < L_FRAME16k; i++ ) + { + White_exc16k_fx[i] = shl( White_exc16k_fx[i], sub( tmp, 1 ) ); + move16(); + } + *Q_white_exc = sub( add( *Q_white_exc, tmp ), 1 ); + move16(); + } + + IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */ + { + FOR( i = 0; i < L_FRAME32k; i++ ) + { + error_fx[i] = Mpy_32_16_1( error_fx[i], synth_scale_fx ); + move32(); + } + } + interpolate_3_over_2_allpass_32( error_fx, L_FRAME32k, synth_fx, hBWE_TD->int_3_over_2_tbemem_dec_fx_32 ); + } + ELSE IF( EQ_32( st->output_Fs, 32000 ) ) + { + IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */ + { + FOR( i = 0; i < L_FRAME32k; i++ ) + { + synth_fx[i] = Mpy_32_16_1( error_fx[i], synth_scale_fx ); + move32(); /*Qx*/ + } + } + ELSE + { + Copy32( error_fx, synth_fx, L_FRAME32k ); + } + } + ELSE IF( EQ_32( st->output_Fs, 16000 ) ) + { + IF( NE_16( synth_scale_fx, 32767 ) ) /* 1.0 in Q15 */ + { + FOR( i = 0; i < L_FRAME32k; i++ ) + { + error_fx[i] = Mpy_32_16_1( error_fx[i], synth_scale_fx ); + move32(); + } + } + + Decimate_allpass_steep_fx32( error_fx, hBWE_TD->mem_resamp_HB_32k_fx_32, L_FRAME32k, synth_fx ); + } + + + /* Update previous frame parameters for FEC */ + Copy( lsf_shb_fx, hBWE_TD->lsp_prevfrm_fx, LPC_SHB_ORDER ); + IF( EQ_16( st->codec_mode, MODE1 ) ) + { + hBWE_TD->GainFrame_prevfrm_fx = GainFrame_fx; + move32(); /*Q18*/ + hBWE_TD->tilt_swb_fec_fx = tilt_swb_fec_fx; + move16(); + + if ( !st->bfi ) + { + hBWE_TD->GainAttn_fx = 32767; /*1.0f in Q15*/ + move16(); + } + } + ELSE + { + IF( !st->bfi ) + { + hBWE_TD->GainFrame_prevfrm_fx = GainFrame_fx; + move32(); /*Q18*/ + hBWE_TD->tilt_swb_fec_fx = tilt_swb_fec_fx; + move16(); + hBWE_TD->GainAttn_fx = 32767; /*1.0f in Q15*/ + move16(); + } + } + + hBWE_TD->prev_ener_fx = ener_tmp_fx[NUM_SHB_SUBGAINS - 1]; + move32(); + hBWE_TD->prev_GainShape_fx = GainShape_fx[NUM_SHB_SUBFR - 1]; + move16(); + st->prev_Q_bwe_syn2 = Q_bwe_exc; + move16(); + st->prev_Qx = Q_bwe_exc; + move16(); + + return; +} + +void GenTransition_fixed( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs, /* i : output sampling rate : Q0 */ + const Word16 element_mode, /* i : element mode : Q0 */ + const Word16 L_frame, /* i : ACELP frame length : Q0 */ + const Word16 rf_flag, /* i : RF flag : Q0 */ + const Word32 total_brate, /* i : total bitrate : Q0 */ + const Word16 prev_Qx ) +{ + Word16 i, length; + + Word32 syn_overlap_32k_fx[2 * SHB_OVERLAP_LEN]; + + /* set targeted length of transition signal */ + length = i_mult( 2, NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ) ); + + /* upsample overlap snippet */ + Interpolate_allpass_steep_32( hBWE_TD->syn_overlap_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, SHB_OVERLAP_LEN, syn_overlap_32k_fx ); + + /* perFORm spectral flip and downmix with overlap snippet to match HB synth */ + test(); + test(); + test(); + test(); + IF( ( ( element_mode == EVS_MONO ) && ( rf_flag || EQ_32( total_brate, ACELP_9k60 ) ) ) || ( ( element_mode > EVS_MONO ) && EQ_16( L_frame, L_FRAME ) ) ) + { + flip_and_downmix_generic_fx_32( syn_overlap_32k_fx, syn_overlap_32k_fx, 2 * SHB_OVERLAP_LEN, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx + HILBERT_ORDER1, hBWE_TD->genSHBsynth_Hilbert_Mem_fx + ( HILBERT_ORDER1 + 2 * HILBERT_ORDER2 ), &( hBWE_TD->syn_dm_phase ) ); + } + ELSE + { + FOR( i = 0; i < 2 * SHB_OVERLAP_LEN; i++ ) + { + IF( i % 2 == 0 ) + { + syn_overlap_32k_fx[i] = L_negate( syn_overlap_32k_fx[i] ); + } + ELSE + { + syn_overlap_32k_fx[i] = syn_overlap_32k_fx[i]; + } + move32(); + } + } + + /* cross fade of overlap snippet and mirrored HB synth from previous frame */ + FOR( i = 0; i < 2 * L_SHB_LAHEAD; i++ ) + { + outputHB_fx[i] = L_add_sat( Mpy_32_16_1( hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i], window_shb_32k_fx[i] ), Mpy_32_16_1( syn_overlap_32k_fx[i], window_shb_32k_fx[2 * L_SHB_LAHEAD - 1 - i] ) ); + move32(); + } + + /* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */ + FOR( ; i < length; i++ ) + { + outputHB_fx[i] = L_shl( hBWE_TD->old_tbe_synth_fx[L_SHB_TRANSITION_LENGTH - 1 - i], sub( Q11, prev_Qx ) ); + move32(); + } + + IF( EQ_32( output_Fs, 48000 ) ) + { + interpolate_3_over_2_allpass_32( outputHB_fx, length, outputHB_fx, hBWE_TD->int_3_over_2_tbemem_dec_fx_32 ); + } + ELSE IF( EQ_32( output_Fs, 16000 ) ) + { + Decimate_allpass_steep_fx32( outputHB_fx, hBWE_TD->mem_resamp_HB_32k_fx_32, L_FRAME32k, outputHB_fx ); + } + + return; +} +void GenTransition_WB_fixed( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs /* i : output sampling rate */ +) +{ + Word16 i, length; + Word32 speech_buf_16k1_fx[SHB_OVERLAP_LEN], speech_buf_16k2_fx[2 * SHB_OVERLAP_LEN]; + Word32 upsampled_synth_fx[L_FRAME48k]; + + /* set targeted length of transition signal */ + length = i_mult( 2, NS2SA_FX2( output_Fs, DELAY_BWE_TOTAL_NS ) ); + + /* upsample overlap snippet */ + Interpolate_allpass_steep_32( hBWE_TD->syn_overlap_fx_32, hBWE_TD->state_lsyn_filt_shb_fx_32, SHB_OVERLAP_LEN / 2, speech_buf_16k1_fx ); + Interpolate_allpass_steep_32( speech_buf_16k1_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx_32, SHB_OVERLAP_LEN, speech_buf_16k2_fx ); + + /* perform spectral flip and downmix with overlap snippet to match HB synth */ + FOR( i = 0; i < SHB_OVERLAP_LEN; i++ ) + { + IF( i % 2 == 0 ) + { + speech_buf_16k2_fx[i] = L_negate( speech_buf_16k2_fx[i] ); + move32(); + } + ELSE + { + speech_buf_16k2_fx[i] = speech_buf_16k2_fx[i]; + move32(); + } + } + + /* cross fade of overlap snippet and mirrored HB synth from previous frame */ + FOR( i = 0; i < L_SHB_LAHEAD; i++ ) + { + outputHB_fx[i] = L_add( Mpy_32_16_1( hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i], window_shb_fx[i] ), Mpy_32_16_1( speech_buf_16k2_fx[i], window_shb_fx[L_SHB_LAHEAD - 1 - i] ) ); + move32(); + outputHB_fx[i] = Mpy_32_16_1( outputHB_fx[i], 21299 ); + move32(); + } + + /* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */ + FOR( ; i < length; i++ ) + { + outputHB_fx[i] = hBWE_TD->old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH - 1 - i]; + move32(); + outputHB_fx[i] = Mpy_32_16_1( outputHB_fx[i], 21299 ); + move32(); + } + + /* upsampling if necessary */ + IF( EQ_32( output_Fs, 32000 ) ) + { + Interpolate_allpass_steep_32( outputHB_fx, hBWE_TD->mem_resamp_HB_fx_32, L_FRAME16k, upsampled_synth_fx ); + Copy32( upsampled_synth_fx, outputHB_fx, L_FRAME32k ); + } + ELSE IF( EQ_32( output_Fs, 48000 ) ) + { + interpolate_3_over_1_allpass_32( outputHB_fx, L_FRAME16k, upsampled_synth_fx, hBWE_TD->mem_resamp_HB_fx_32 ); + Copy32( upsampled_synth_fx, outputHB_fx, L_FRAME48k ); + } + + return; +} diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c deleted file mode 100644 index 6a74d3b87..000000000 --- a/lib_dec/tonalMDCTconcealment.c +++ /dev/null @@ -1,436 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#define _USE_MATH_DEFINES - -#include -#include -#include "options.h" -#include -#include "prot.h" -#include "ivas_prot.h" -#include "wmc_auto.h" -#include "ivas_prot_fx.h" -#include "prot_fx.h" - - -/*******************************************************/ -/*-------------- public functions -------------------- */ -/*******************************************************/ - -void TonalMdctConceal_create_concealment_noise_ivas_fx( - Word32 concealment_noise[L_FRAME48k], // Q31-concealment_noise_exp - Word16 *concealment_noise_exp, - CPE_DEC_HANDLE hCPE, - const Word16 L_frameTCX, // Q0 - const Word16 L_frame, // Q0 - const Word16 idchan, // Q0 - const Word16 subframe_idx, // Q0 - const Word16 core, // Q0 - const Word16 crossfade_gain, // Q15 - const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode ) -{ - STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct; - TonalMDCTConcealPtr hTonalMDCTConc; - Decoder_State *st; - HANDLE_FD_CNG_COM hFdCngCom; - Word16 *rnd_c, *rnd; - Word16 crossOverFreq, i, save_rnd_c, max_noise_line; - Word16 c, c_inv, inc; - Word32 noise_shape_buffer[L_FRAME48k]; - Word16 noise_shape_buffer_e[L_FRAME48k]; - Word16 start_idx, stop_idx, noise_shape_buffer_common_exp = MIN16B_FLT_FX, last_scf_e, temp_e; - move16(); - Word32 *cngNoiseLevelPtr; - Word32 last_scf; - - Word16 c_e, c_inv_e; - - push_wmops( "create_conc_noise" ); - - hStereoMdct = hCPE->hStereoMdct; - st = hCPE->hCoreCoder[idchan]; - hTonalMDCTConc = st->hTonalMDCTConc; - hFdCngCom = st->hFdCngDec->hFdCngCom; - rnd = &hStereoMdct->noise_seeds_channels[idchan]; - rnd_c = &hStereoMdct->noise_seed_common; - - /* determine start bin for IGF */ - IF( st->igf == 0 ) - { - IF( st->narrowBand == 0 ) - { - /* minimum needed for output with sampling rates lower then the - nominal sampling rate */ - crossOverFreq = s_min( L_frameTCX, L_frame ); - } - ELSE - { - crossOverFreq = L_frameTCX; - move16(); - } - } - ELSE - { - crossOverFreq = s_min( st->hIGFDec->infoIGFStartLine, L_frameTCX ); - } - - /* for tonal mdct concealment with tonal components above the crossover frequency, conditionally raise the frequency index until which noise is generated */ - max_noise_line = crossOverFreq; - move16(); - IF( st->tonal_mdct_plc_active ) - { - max_noise_line = s_max( max_noise_line, extract_l( L_add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ) ) ); - } - - /* first lost frame is handled separately */ - IF( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) - { - *rnd = add( 1977, idchan ); // Q0 - move16(); - /* will be set twice when looping over two channels, but does not matter */ - *rnd_c = 1979; // Q0 - move16(); - } - - IF( GT_16( crossfade_gain, 32734 ) ) - /* Due to precision loss */ /* 0.999 in Q15*/ - { - /* In first frame, noise is weighted with zero anyway, we only need the random numbers for the sign scrambling */ - FOR( i = 0; i < max_noise_line; i++ ) - { - *rnd = own_random( rnd ); - move16(); - concealment_noise[i] = *rnd; // Q31-concealment_noise_exp - move32(); - } - *concealment_noise_exp = 31; - move16(); - pop_wmops(); - - return; - } - - save_rnd_c = *rnd_c; // Q0 - move16(); - - c_e = 1; - move16(); - c_inv_e = 1; - move16(); - - c = Sqrt16( hStereoMdct->lastCoh_fx, &c_e ); // Q1 = 15 - c_e - c_inv = Sqrt16( sub( ONE_IN_Q14, hStereoMdct->lastCoh_fx ), &c_inv_e ); // Q2 = 15 - c_inv_e - - IF( NE_16( c_e, c_inv_e ) ) - { - IF( LT_16( c_e, c_inv_e ) ) - { - c = shr( c, sub( c_inv_e, c_e ) ); // Q0 - c_e = c_inv_e; - move16(); - } - ELSE - { - c_inv = shr( c_inv, sub( c_e, c_inv_e ) ); // Q0 - } - } - - /* pre-compute the noise shape for later weighting of the noise spectra */ - cngNoiseLevelPtr = &hFdCngCom->cngNoiseLevel[0]; - last_scf_e = hFdCngCom->cngNoiseLevelExp; - move16(); - - IF( GT_16( st->core, TCX_20_CORE ) ) - { - inc = 2; - } - ELSE - { - inc = 1; - } - move16(); - start_idx = idiv1616( hFdCngCom->startBand, inc ); - stop_idx = idiv1616( hFdCngCom->stopFFTbin, inc ); - - FOR( i = 0; i < start_idx; i++ ) - { - noise_shape_buffer[i] = 0; - move32(); - noise_shape_buffer_e[i] = 0; - move16(); - } - FOR( ; i < stop_idx; ( i++, cngNoiseLevelPtr += inc ) ) - { - noise_shape_buffer_e[i] = hFdCngCom->cngNoiseLevelExp; - move16(); - noise_shape_buffer[i] = Sqrt32( *( cngNoiseLevelPtr ), &noise_shape_buffer_e[i] ); // Q31-noise_shape_buffer_e[i] - move32(); - noise_shape_buffer_common_exp = s_max( noise_shape_buffer_e[i], noise_shape_buffer_common_exp ); - } - - FOR( i = 0; i < stop_idx; i++ ) - { - IF( NE_16( noise_shape_buffer_common_exp, noise_shape_buffer_e[i] ) ) - { - - noise_shape_buffer[i] = L_shr( noise_shape_buffer[i], sub( noise_shape_buffer_common_exp, noise_shape_buffer_e[i] ) ); // Q31- (noise_shape_buffer_common_exp-noise_shape_buffer_e[i]) - move32(); - } - } - - last_scf = Sqrt32( *( cngNoiseLevelPtr - inc ), &last_scf_e ); // Q31-last_scf_e - - IF( LT_16( noise_shape_buffer_common_exp, last_scf_e ) ) - { - Scale_sig32( noise_shape_buffer, stop_idx, sub( noise_shape_buffer_common_exp, last_scf_e ) ); // Q31- (noise_shape_buffer_common_exp-last_scf_e) - - noise_shape_buffer_common_exp = last_scf_e; - move16(); - } - ELSE - { - last_scf = L_shl( last_scf, sub( last_scf_e, noise_shape_buffer_common_exp ) ); // Q31-(last_scf_e-noise_shape_buffer_common_exp) - } - - FOR( ; i < max_noise_line; i++ ) - { - noise_shape_buffer[i] = last_scf; // Q31 - noise_shape_buffer_common_exp - move32(); - } - - /* fill the noise vector */ - hTonalMDCTConc->curr_noise_nrg = MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG_Q31; // Q31 - move32(); - hTonalMDCTConc->curr_noise_nrg_exp = 0; - move16(); - *concealment_noise_exp = add( 16, add( noise_shape_buffer_common_exp, c_e ) ); - move16(); - temp_e = hTonalMDCTConc->curr_noise_nrg_exp; - move16(); - - test(); - test(); - test(); - test(); - IF( EQ_16( noise_gen_mode, EQUAL_CORES ) || ( ( EQ_16( noise_gen_mode, TCX20_IN_0_TCX10_IN_1 ) && EQ_16( idchan, 0 ) ) || ( EQ_16( noise_gen_mode, TCX10_IN_0_TCX20_IN_1 ) && EQ_16( idchan, 1 ) ) ) ) - { - /* current channel is TCX20 -> generate noise for "full-length" spectrum */ - - FOR( i = 0; i < max_noise_line; i++ ) - { - *rnd = own_random( rnd ); // Q0 - *rnd_c = own_random( rnd_c ); - - move16(); - move16(); - - concealment_noise[i] = Mpy_32_32( L_add( L_shr( L_mult( c_inv, *rnd ), 1 ), L_shr( L_mult( c, *rnd_c ), 1 ) ), noise_shape_buffer[i] ); // Q31 - *concealment_noise_exp - move32(); - IF( concealment_noise[i] != 0 ) - { - hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); // Q31-temp_e - } - hTonalMDCTConc->curr_noise_nrg_exp = temp_e; - move16(); - } - } - ELSE /* ( ( noise_gen_mode == TCX10_IN_0_TCX20_IN_1 && idchan == 0 ) || ( noise_gen_mode == TCX20_IN_0_TCX10_IN_1 && idchan == 1 ) ) */ - { - /* current channel is TCX10 and the other is TCX20 -> generate noise for "half-length" spectrum, but "increment" mid seed twice, to have the same seed in mid as the other (TCX20) channel for next frame */ - FOR( i = 0; i < max_noise_line; i++ ) - { - *rnd = own_random( rnd ); // Q0 - *rnd_c = own_random( rnd_c ); // Q0 - move16(); - move16(); - - concealment_noise[i] = Mpy_32_32( L_add( L_shr( L_mult( c_inv, *rnd ), 1 ), L_shr( L_mult( c, *rnd_c ), 1 ) ), noise_shape_buffer[i] ); - move32(); - IF( concealment_noise[i] != 0 ) - { - hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); // Q31-temp_e - } - hTonalMDCTConc->curr_noise_nrg_exp = temp_e; - move16(); - - *rnd_c = own_random( rnd_c ); - move16(); - } - } - - IF( st->tonal_mdct_plc_active ) - { - FOR( i = crossOverFreq; i < s_max( crossOverFreq, hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ); ++i ) - { - concealment_noise[i] = 0; - move32(); - } - } - - /* restore common seed - - after finishing the first channel - - after a first subframe if the current channel is TCX10 */ - - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( idchan, 0 ) && ( EQ_16( core, TCX_20 ) || ( EQ_16( core, TCX_10 ) && EQ_16( subframe_idx, 1 ) ) ) ) || ( EQ_16( core, TCX_10 ) && EQ_16( subframe_idx, 0 ) ) ) - { - *rnd_c = save_rnd_c; - move16(); - } - - st->seed_tcx_plc = *rnd; - move16(); - - pop_wmops(); - - return; -} - - -void TonalMdctConceal_whiten_noise_shape_ivas_fx( - Decoder_State *st, - const Word16 L_frame, - const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE whitening_mode ) -{ - Word16 inc, start_idx, stop_idx, i; - Word32 *noiseLevelPtr, *scfs_bg, *scfs_for_shaping; - Word16 noiseLevelPtr_exp; - HANDLE_FD_CNG_COM hFdCngCom; - Word32 whitenend_noise_shape[L_FRAME16k]; - Word16 q_wns; - Word32 scfs_int[FDNS_NPTS]; - const PsychoacousticParameters *psychParams; - - push_wmops( "apply_sns_on_noise_shape" ); - - scfs_bg = &st->hTonalMDCTConc->scaleFactorsBackground_fx[0]; - psychParams = st->hTonalMDCTConc->psychParams; - hFdCngCom = st->hFdCngDec->hFdCngCom; - -#ifdef MSAN_FIX - set32_fx( whitenend_noise_shape, 0, L_FRAME16k ); -#endif - - IF( EQ_32( whitening_mode, ON_FIRST_LOST_FRAME ) ) - { - IF( GT_16( st->core, TCX_20_CORE ) ) - { - inc = 2; - move16(); - } - ELSE - { - inc = 1; - move16(); - } - } - ELSE - { - IF( GT_16( st->last_core, TCX_20_CORE ) ) - { - inc = 2; - move16(); - } - ELSE - { - inc = 1; - move16(); - } - } - start_idx = shr( hFdCngCom->startBand, sub( inc, 1 ) ); - stop_idx = shr( L_frame, sub( inc, 1 ) ); - noiseLevelPtr = hFdCngCom->cngNoiseLevel; - noiseLevelPtr_exp = hFdCngCom->cngNoiseLevelExp; - move16(); - - FOR( Word16 j = start_idx; j < stop_idx; j++ ) - { - whitenend_noise_shape[j] = L_shr( *noiseLevelPtr, 3 ); - move32(); - noiseLevelPtr += inc; - } - - IF( EQ_32( whitening_mode, ON_FIRST_LOST_FRAME ) ) - { - Word32 scf[SNS_NPTS]; - - sns_compute_scf_fx( whitenend_noise_shape, psychParams, L_frame, scf, sub( sub( 31, noiseLevelPtr_exp ), 3 ) ); - - sns_interpolate_scalefactors_fx( scfs_int, scf, ENC ); - sns_interpolate_scalefactors_fx( scfs_bg, scf, DEC ); - - scfs_for_shaping = &scfs_int[0]; // Q16 - } - ELSE /* whitening_mode == ON_FIRST_GOOD_FRAME */ - { - scfs_for_shaping = &scfs_bg[0]; // Q16 - } - - IF( sum32_sat( scfs_for_shaping, FDNS_NPTS ) > 0 ) - { - q_wns = sub( sub( 31, noiseLevelPtr_exp ), 3 ); - sns_shape_spectrum_fx( whitenend_noise_shape, &q_wns, psychParams, scfs_for_shaping, Q16, L_frame, NULL ); - - IF( GT_16( add( q_wns, 1 ), sub( 31, hFdCngCom->cngNoiseLevelExp ) ) ) - { - FOR( i = 0; i < sub( stop_idx, start_idx ); i++ ) - { - hFdCngCom->cngNoiseLevel[i] = L_shr( whitenend_noise_shape[start_idx + i], sub( add( q_wns, hFdCngCom->cngNoiseLevelExp ), 30 ) ); //(q_wns + 1) - move32(); - } - } - ELSE - { - Copy32( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel, sub( stop_idx, start_idx ) ); - - scale_sig32( hFdCngCom->cngNoiseLevel + sub( stop_idx, start_idx ), sub( FFTCLDFBLEN, sub( stop_idx, start_idx ) ), sub( add( q_wns, hFdCngCom->cngNoiseLevelExp ), 30 ) ); - - hFdCngCom->cngNoiseLevelExp = sub( Q30, q_wns ); // Exponent = 31 - (q_wns + 1) - move16(); - } - } - ELSE - { - set32_fx( hFdCngCom->cngNoiseLevel, 0, sub( stop_idx, start_idx ) ); - } - - pop_wmops(); -} diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index a4aa23e7f..3cf5f51f3 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -3200,6 +3200,397 @@ static void CalcPowerSpec( powerSpec[nSamples - 1] = L_shr( powerSpec[nSamples - 2], 1 ); move32(); } + + +/*******************************************************/ +/*-------------- public functions -------------------- */ +/*******************************************************/ + +void TonalMdctConceal_create_concealment_noise_ivas_fx( + Word32 concealment_noise[L_FRAME48k], // Q31-concealment_noise_exp + Word16 *concealment_noise_exp, + CPE_DEC_HANDLE hCPE, + const Word16 L_frameTCX, // Q0 + const Word16 L_frame, // Q0 + const Word16 idchan, // Q0 + const Word16 subframe_idx, // Q0 + const Word16 core, // Q0 + const Word16 crossfade_gain, // Q15 + const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode ) +{ + STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct; + TonalMDCTConcealPtr hTonalMDCTConc; + Decoder_State *st; + HANDLE_FD_CNG_COM hFdCngCom; + Word16 *rnd_c, *rnd; + Word16 crossOverFreq, i, save_rnd_c, max_noise_line; + Word16 c, c_inv, inc; + Word32 noise_shape_buffer[L_FRAME48k]; + Word16 noise_shape_buffer_e[L_FRAME48k]; + Word16 start_idx, stop_idx, noise_shape_buffer_common_exp = MIN16B_FLT_FX, last_scf_e, temp_e; + move16(); + Word32 *cngNoiseLevelPtr; + Word32 last_scf; + + Word16 c_e, c_inv_e; + + push_wmops( "create_conc_noise" ); + + hStereoMdct = hCPE->hStereoMdct; + st = hCPE->hCoreCoder[idchan]; + hTonalMDCTConc = st->hTonalMDCTConc; + hFdCngCom = st->hFdCngDec->hFdCngCom; + rnd = &hStereoMdct->noise_seeds_channels[idchan]; + rnd_c = &hStereoMdct->noise_seed_common; + + /* determine start bin for IGF */ + IF( st->igf == 0 ) + { + IF( st->narrowBand == 0 ) + { + /* minimum needed for output with sampling rates lower then the + nominal sampling rate */ + crossOverFreq = s_min( L_frameTCX, L_frame ); + } + ELSE + { + crossOverFreq = L_frameTCX; + move16(); + } + } + ELSE + { + crossOverFreq = s_min( st->hIGFDec->infoIGFStartLine, L_frameTCX ); + } + + /* for tonal mdct concealment with tonal components above the crossover frequency, conditionally raise the frequency index until which noise is generated */ + max_noise_line = crossOverFreq; + move16(); + IF( st->tonal_mdct_plc_active ) + { + max_noise_line = s_max( max_noise_line, extract_l( L_add( hTonalMDCTConc->pTCI->upperIndex[hTonalMDCTConc->pTCI->numIndexes - 1], 1 ) ) ); + } + + /* first lost frame is handled separately */ + IF( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) + { + *rnd = add( 1977, idchan ); // Q0 + move16(); + /* will be set twice when looping over two channels, but does not matter */ + *rnd_c = 1979; // Q0 + move16(); + } + + IF( GT_16( crossfade_gain, 32734 ) ) + /* Due to precision loss */ /* 0.999 in Q15*/ + { + /* In first frame, noise is weighted with zero anyway, we only need the random numbers for the sign scrambling */ + FOR( i = 0; i < max_noise_line; i++ ) + { + *rnd = own_random( rnd ); + move16(); + concealment_noise[i] = *rnd; // Q31-concealment_noise_exp + move32(); + } + *concealment_noise_exp = 31; + move16(); + pop_wmops(); + + return; + } + + save_rnd_c = *rnd_c; // Q0 + move16(); + + c_e = 1; + move16(); + c_inv_e = 1; + move16(); + + c = Sqrt16( hStereoMdct->lastCoh_fx, &c_e ); // Q1 = 15 - c_e + c_inv = Sqrt16( sub( ONE_IN_Q14, hStereoMdct->lastCoh_fx ), &c_inv_e ); // Q2 = 15 - c_inv_e + + IF( NE_16( c_e, c_inv_e ) ) + { + IF( LT_16( c_e, c_inv_e ) ) + { + c = shr( c, sub( c_inv_e, c_e ) ); // Q0 + c_e = c_inv_e; + move16(); + } + ELSE + { + c_inv = shr( c_inv, sub( c_e, c_inv_e ) ); // Q0 + } + } + + /* pre-compute the noise shape for later weighting of the noise spectra */ + cngNoiseLevelPtr = &hFdCngCom->cngNoiseLevel[0]; + last_scf_e = hFdCngCom->cngNoiseLevelExp; + move16(); + + IF( GT_16( st->core, TCX_20_CORE ) ) + { + inc = 2; + } + ELSE + { + inc = 1; + } + move16(); + start_idx = idiv1616( hFdCngCom->startBand, inc ); + stop_idx = idiv1616( hFdCngCom->stopFFTbin, inc ); + + FOR( i = 0; i < start_idx; i++ ) + { + noise_shape_buffer[i] = 0; + move32(); + noise_shape_buffer_e[i] = 0; + move16(); + } + FOR( ; i < stop_idx; ( i++, cngNoiseLevelPtr += inc ) ) + { + noise_shape_buffer_e[i] = hFdCngCom->cngNoiseLevelExp; + move16(); + noise_shape_buffer[i] = Sqrt32( *( cngNoiseLevelPtr ), &noise_shape_buffer_e[i] ); // Q31-noise_shape_buffer_e[i] + move32(); + noise_shape_buffer_common_exp = s_max( noise_shape_buffer_e[i], noise_shape_buffer_common_exp ); + } + + FOR( i = 0; i < stop_idx; i++ ) + { + IF( NE_16( noise_shape_buffer_common_exp, noise_shape_buffer_e[i] ) ) + { + + noise_shape_buffer[i] = L_shr( noise_shape_buffer[i], sub( noise_shape_buffer_common_exp, noise_shape_buffer_e[i] ) ); // Q31- (noise_shape_buffer_common_exp-noise_shape_buffer_e[i]) + move32(); + } + } + + last_scf = Sqrt32( *( cngNoiseLevelPtr - inc ), &last_scf_e ); // Q31-last_scf_e + + IF( LT_16( noise_shape_buffer_common_exp, last_scf_e ) ) + { + Scale_sig32( noise_shape_buffer, stop_idx, sub( noise_shape_buffer_common_exp, last_scf_e ) ); // Q31- (noise_shape_buffer_common_exp-last_scf_e) + + noise_shape_buffer_common_exp = last_scf_e; + move16(); + } + ELSE + { + last_scf = L_shl( last_scf, sub( last_scf_e, noise_shape_buffer_common_exp ) ); // Q31-(last_scf_e-noise_shape_buffer_common_exp) + } + + FOR( ; i < max_noise_line; i++ ) + { + noise_shape_buffer[i] = last_scf; // Q31 - noise_shape_buffer_common_exp + move32(); + } + + /* fill the noise vector */ + hTonalMDCTConc->curr_noise_nrg = MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG_Q31; // Q31 + move32(); + hTonalMDCTConc->curr_noise_nrg_exp = 0; + move16(); + *concealment_noise_exp = add( 16, add( noise_shape_buffer_common_exp, c_e ) ); + move16(); + temp_e = hTonalMDCTConc->curr_noise_nrg_exp; + move16(); + + test(); + test(); + test(); + test(); + IF( EQ_16( noise_gen_mode, EQUAL_CORES ) || ( ( EQ_16( noise_gen_mode, TCX20_IN_0_TCX10_IN_1 ) && EQ_16( idchan, 0 ) ) || ( EQ_16( noise_gen_mode, TCX10_IN_0_TCX20_IN_1 ) && EQ_16( idchan, 1 ) ) ) ) + { + /* current channel is TCX20 -> generate noise for "full-length" spectrum */ + + FOR( i = 0; i < max_noise_line; i++ ) + { + *rnd = own_random( rnd ); // Q0 + *rnd_c = own_random( rnd_c ); + + move16(); + move16(); + + concealment_noise[i] = Mpy_32_32( L_add( L_shr( L_mult( c_inv, *rnd ), 1 ), L_shr( L_mult( c, *rnd_c ), 1 ) ), noise_shape_buffer[i] ); // Q31 - *concealment_noise_exp + move32(); + IF( concealment_noise[i] != 0 ) + { + hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); // Q31-temp_e + } + hTonalMDCTConc->curr_noise_nrg_exp = temp_e; + move16(); + } + } + ELSE /* ( ( noise_gen_mode == TCX10_IN_0_TCX20_IN_1 && idchan == 0 ) || ( noise_gen_mode == TCX20_IN_0_TCX10_IN_1 && idchan == 1 ) ) */ + { + /* current channel is TCX10 and the other is TCX20 -> generate noise for "half-length" spectrum, but "increment" mid seed twice, to have the same seed in mid as the other (TCX20) channel for next frame */ + FOR( i = 0; i < max_noise_line; i++ ) + { + *rnd = own_random( rnd ); // Q0 + *rnd_c = own_random( rnd_c ); // Q0 + move16(); + move16(); + + concealment_noise[i] = Mpy_32_32( L_add( L_shr( L_mult( c_inv, *rnd ), 1 ), L_shr( L_mult( c, *rnd_c ), 1 ) ), noise_shape_buffer[i] ); + move32(); + IF( concealment_noise[i] != 0 ) + { + hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); // Q31-temp_e + } + hTonalMDCTConc->curr_noise_nrg_exp = temp_e; + move16(); + + *rnd_c = own_random( rnd_c ); + move16(); + } + } + + IF( st->tonal_mdct_plc_active ) + { + FOR( i = crossOverFreq; i < s_max( crossOverFreq, hTonalMDCTConc->pTCI->lowerIndex[hTonalMDCTConc->pTCI->numIndexes - 1] ); ++i ) + { + concealment_noise[i] = 0; + move32(); + } + } + + /* restore common seed + - after finishing the first channel + - after a first subframe if the current channel is TCX10 */ + + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( idchan, 0 ) && ( EQ_16( core, TCX_20 ) || ( EQ_16( core, TCX_10 ) && EQ_16( subframe_idx, 1 ) ) ) ) || ( EQ_16( core, TCX_10 ) && EQ_16( subframe_idx, 0 ) ) ) + { + *rnd_c = save_rnd_c; + move16(); + } + + st->seed_tcx_plc = *rnd; + move16(); + + pop_wmops(); + + return; +} + + +void TonalMdctConceal_whiten_noise_shape_ivas_fx( + Decoder_State *st, + const Word16 L_frame, + const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE whitening_mode ) +{ + Word16 inc, start_idx, stop_idx, i; + Word32 *noiseLevelPtr, *scfs_bg, *scfs_for_shaping; + Word16 noiseLevelPtr_exp; + HANDLE_FD_CNG_COM hFdCngCom; + Word32 whitenend_noise_shape[L_FRAME16k]; + Word16 q_wns; + Word32 scfs_int[FDNS_NPTS]; + const PsychoacousticParameters *psychParams; + + push_wmops( "apply_sns_on_noise_shape" ); + + scfs_bg = &st->hTonalMDCTConc->scaleFactorsBackground_fx[0]; + psychParams = st->hTonalMDCTConc->psychParams; + hFdCngCom = st->hFdCngDec->hFdCngCom; + +#ifdef MSAN_FIX + set32_fx( whitenend_noise_shape, 0, L_FRAME16k ); +#endif + + IF( EQ_32( whitening_mode, ON_FIRST_LOST_FRAME ) ) + { + IF( GT_16( st->core, TCX_20_CORE ) ) + { + inc = 2; + move16(); + } + ELSE + { + inc = 1; + move16(); + } + } + ELSE + { + IF( GT_16( st->last_core, TCX_20_CORE ) ) + { + inc = 2; + move16(); + } + ELSE + { + inc = 1; + move16(); + } + } + start_idx = shr( hFdCngCom->startBand, sub( inc, 1 ) ); + stop_idx = shr( L_frame, sub( inc, 1 ) ); + noiseLevelPtr = hFdCngCom->cngNoiseLevel; + noiseLevelPtr_exp = hFdCngCom->cngNoiseLevelExp; + move16(); + + FOR( Word16 j = start_idx; j < stop_idx; j++ ) + { + whitenend_noise_shape[j] = L_shr( *noiseLevelPtr, 3 ); + move32(); + noiseLevelPtr += inc; + } + + IF( EQ_32( whitening_mode, ON_FIRST_LOST_FRAME ) ) + { + Word32 scf[SNS_NPTS]; + + sns_compute_scf_fx( whitenend_noise_shape, psychParams, L_frame, scf, sub( sub( 31, noiseLevelPtr_exp ), 3 ) ); + + sns_interpolate_scalefactors_fx( scfs_int, scf, ENC ); + sns_interpolate_scalefactors_fx( scfs_bg, scf, DEC ); + + scfs_for_shaping = &scfs_int[0]; // Q16 + } + ELSE /* whitening_mode == ON_FIRST_GOOD_FRAME */ + { + scfs_for_shaping = &scfs_bg[0]; // Q16 + } + + IF( sum32_sat( scfs_for_shaping, FDNS_NPTS ) > 0 ) + { + q_wns = sub( sub( 31, noiseLevelPtr_exp ), 3 ); + sns_shape_spectrum_fx( whitenend_noise_shape, &q_wns, psychParams, scfs_for_shaping, Q16, L_frame, NULL ); + + IF( GT_16( add( q_wns, 1 ), sub( 31, hFdCngCom->cngNoiseLevelExp ) ) ) + { + FOR( i = 0; i < sub( stop_idx, start_idx ); i++ ) + { + hFdCngCom->cngNoiseLevel[i] = L_shr( whitenend_noise_shape[start_idx + i], sub( add( q_wns, hFdCngCom->cngNoiseLevelExp ), 30 ) ); //(q_wns + 1) + move32(); + } + } + ELSE + { + Copy32( whitenend_noise_shape + start_idx, hFdCngCom->cngNoiseLevel, sub( stop_idx, start_idx ) ); + + scale_sig32( hFdCngCom->cngNoiseLevel + sub( stop_idx, start_idx ), sub( FFTCLDFBLEN, sub( stop_idx, start_idx ) ), sub( add( q_wns, hFdCngCom->cngNoiseLevelExp ), 30 ) ); + + hFdCngCom->cngNoiseLevelExp = sub( Q30, q_wns ); // Exponent = 31 - (q_wns + 1) + move16(); + } + } + ELSE + { + set32_fx( hFdCngCom->cngNoiseLevel, 0, sub( stop_idx, start_idx ) ); + } + + pop_wmops(); +} + + #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT void TonalMdctConceal_create_concealment_noise( float concealment_noise[L_FRAME48k], -- GitLab From 5424115f277ce702a36ade2f97f07029b2c543a6 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 4 Mar 2025 20:44:33 +0530 Subject: [PATCH 15/97] Clang formatting --- lib_dec/ari_dec_fx.c | 1 - lib_dec/arith_coder_dec_fx.c | 1 - lib_dec/bass_psfilter_fx.c | 10 +++++----- lib_dec/core_dec_init_fx.c | 1 - lib_dec/core_switching_dec_fx.c | 2 +- lib_dec/dec_prm_fx.c | 1 - lib_dec/dec_tcx_fx.c | 1 - lib_dec/fd_cng_dec_fx.c | 8 ++++---- lib_dec/swb_bwe_dec_fx.c | 1 - 9 files changed, 10 insertions(+), 16 deletions(-) diff --git a/lib_dec/ari_dec_fx.c b/lib_dec/ari_dec_fx.c index 524f9d121..3aabbdaa5 100644 --- a/lib_dec/ari_dec_fx.c +++ b/lib_dec/ari_dec_fx.c @@ -839,4 +839,3 @@ Word16 ari_decode_14bits_sign_ivas( return bp; } - diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index 6df1eb268..e5a1220e0 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -420,4 +420,3 @@ void tcx_arith_decode_envelope_ivas_fx( return; } - diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c index 7d2be2c52..75cabf160 100644 --- a/lib_dec/bass_psfilter_fx.c +++ b/lib_dec/bass_psfilter_fx.c @@ -4,12 +4,12 @@ #include #include -#include "options.h" /* Compilation switches */ -#include "prot_fx.h" /* Function prototypes */ +#include "options.h" /* Compilation switches */ +#include "prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ -#include "cnst.h" /* Common constants */ -#include "rom_com.h" /* Static table prototypes */ -#include "rom_dec.h" /* Static table prototypes */ +#include "cnst.h" /* Common constants */ +#include "rom_com.h" /* Static table prototypes */ +#include "rom_dec.h" /* Static table prototypes */ #include "basop_util.h" /*---------------------------------------------------------------------* diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index f649772b2..8fefa3bb2 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -2216,4 +2216,3 @@ void reset_tcx_overl_buf_fx( move16(); return; } - diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index caef9485b..52c3e3073 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -3443,4 +3443,4 @@ void ivas_bw_switching_pre_proc_fx( } return; -} \ No newline at end of file +} diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 77fd7d421..3d277807d 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -2011,4 +2011,3 @@ void getTCXWindowing_ivas_fx( return; } - diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 4d97367ef..e71157a1e 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -5302,4 +5302,3 @@ void decoder_tcx_imdct_fx( return; } - diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index f788144fa..70c4760ae 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -20,10 +20,10 @@ #endif -#define CNA_ACT_DN_LARGE_PARTITION 50 /* index of the first larger partition */ -#define ST_PERIODOG_FACT_Q15 29491 /* 0.9 in Q15, short-term filter factor for periodogram */ -#define CNA_ACT_DN_FACT_Q15 22938 /* 0.7 in Q15, downward updating factor for CNA during active frames */ -#define FIRST_CNA_NOISE_UPD_FRAMES 5 /* minimum number of CN initialization frames */ +#define CNA_ACT_DN_LARGE_PARTITION 50 /* index of the first larger partition */ +#define ST_PERIODOG_FACT_Q15 29491 /* 0.9 in Q15, short-term filter factor for periodogram */ +#define CNA_ACT_DN_FACT_Q15 22938 /* 0.7 in Q15, downward updating factor for CNA during active frames */ +#define FIRST_CNA_NOISE_UPD_FRAMES 5 /* minimum number of CN initialization frames */ #define DELTA_MASKING_NOISE_Q15 0 #define LOG_10_BASE_2 1783446566 /* Q29 */ #define GAIN_Q_OFFSET_IVAS_FX 45 diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 23c4c3e8a..d15a97821 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -1634,4 +1634,3 @@ void fd_bwe_dec_init_fx( return; } - -- GitLab From a8e2883c2491bc9327bf11f806321d6f14e29b59 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 3 Mar 2025 22:29:22 +0530 Subject: [PATCH 16/97] Fix for 3GPP issue 1325: saturation occuring in tcx_encoder_memory_update_ivas_fx() Link #1325 --- lib_enc/ivas_tcx_core_enc.c | 18 ++---------------- lib_enc/tcx_utils_enc_fx.c | 26 ++++++++++++++++++++------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index cecc1bf80..84bffa87c 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -570,23 +570,9 @@ void stereo_tcx_core_enc( move16(); move16(); - /* Scaling old_exc buffer to Q_new */ - IF( NE_16( Q_new, Q_exc ) ) - { - Scale_sig( st->hLPDmem->old_exc, L_EXC_MEM, sub( Q_new, Q_exc ) ); - } - coder_tcx_post_ivas_fx( st, st->hLPDmem, st->hTcxCfg, st->synth, A_q_fx, Aw_fx, st->wspeech_enc, Q_new ); - /* Upscaling old_exc buffer */ - s = norm_arr( st->hLPDmem->old_exc, L_EXC_MEM ) - 1; - Scale_sig( st->hLPDmem->old_exc, L_EXC_MEM, s ); - IF( st->hTdCngEnc != NULL ) - { - Scale_sig( st->hTdCngEnc->cng_exc2_buf, HO_HIST_SIZE * L_FFT, sub( add( shl( Q_new, 1 ), s ), Q_exc ) ); - } - Q_exc = add( shl( Q_new, 1 ), s ); // 2 * Q_new + s - st->hLPDmem->q_lpd_old_exc = Q_exc; + Q_exc = Q_new; // Q_new move16(); IF( st->enableTcxLpc ) @@ -659,7 +645,7 @@ void stereo_tcx_core_enc( 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, 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->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 ); } diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 5e7ca7be8..2a6f040ac 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -2814,12 +2814,12 @@ void tcx_encoder_memory_update_ivas_fx( /* Emphasis of synth -> synth_pe */ tmp = synth[-( M + 1 )]; move16(); - E_UTIL_f_preemph2( Q_new - 1, synth - M, preemph, add( M, L_frame_glob ), &tmp ); + E_UTIL_f_preemph2( 0, synth - M, preemph, add( M, L_frame_glob ), &tmp ); // Q_new Copy( synth + sub( L_frame_glob, M ), LPDmem->mem_syn, M ); Copy( synth + sub( L_frame_glob, M ), LPDmem->mem_syn2, M ); Copy( synth + sub( L_frame_glob, L_SYN_MEM ), LPDmem->mem_syn_r, L_SYN_MEM ); - LPDmem->q_mem_syn = sub( shl( Q_new, 1 ), 1 ); // resultant q of synth after E_UTIL_f_preemph2 + LPDmem->q_mem_syn = Q_new; // resultant q of synth after E_UTIL_f_preemph2 move16(); test(); @@ -2828,13 +2828,27 @@ void tcx_encoder_memory_update_ivas_fx( /* Update excitation */ IF( LT_16( L_frame_glob, L_EXC_MEM ) ) { - Copy( LPDmem->old_exc + L_frame_glob, LPDmem->old_exc, sub( L_EXC_MEM, L_frame_glob ) ); - Scale_sig( LPDmem->old_exc, sub( L_EXC_MEM, L_frame_glob ), Q_new ); // Q_new->2*Q_new - Residu3_fx( A, synth, LPDmem->old_exc + sub( L_EXC_MEM, L_frame_glob ), L_frame_glob, 1 ); // 2*Q_new + Word16 shift = norm_arr( LPDmem->old_exc + L_frame_glob, sub( L_EXC_MEM, L_frame_glob ) ); + IF( LT_16( shift, sub( Q_new, LPDmem->q_lpd_old_exc ) ) ) + { + Copy_Scale_sig( LPDmem->old_exc + L_frame_glob, LPDmem->old_exc, sub( L_EXC_MEM, L_frame_glob ), shift ); + LPDmem->q_lpd_old_exc = add( LPDmem->q_lpd_old_exc, shift ); + move16(); + Residu3_fx( A, synth, LPDmem->old_exc + sub( L_EXC_MEM, L_frame_glob ), L_frame_glob, sub( LPDmem->q_lpd_old_exc, Q_new ) ); // LPDmem->q_lpd_old_exc + } + ELSE + { + Copy_Scale_sig( LPDmem->old_exc + L_frame_glob, LPDmem->old_exc, sub( L_EXC_MEM, L_frame_glob ), sub( Q_new, LPDmem->q_lpd_old_exc ) ); + Residu3_fx( A, synth, LPDmem->old_exc + sub( L_EXC_MEM, L_frame_glob ), L_frame_glob, 0 ); // Q_new + LPDmem->q_lpd_old_exc = Q_new; + move16(); + } } ELSE { - Residu3_fx( A, synth + sub( L_frame_glob, L_EXC_MEM ), LPDmem->old_exc, L_EXC_MEM, 1 ); // 2*Q_new + Residu3_fx( A, synth + sub( L_frame_glob, L_EXC_MEM ), LPDmem->old_exc, L_EXC_MEM, 0 ); // Q_new + LPDmem->q_lpd_old_exc = Q_new; + move16(); } } } -- GitLab From 1e58f1597c8d14b4bcecd1658fd3a6e0f4a99ac7 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 4 Mar 2025 20:50:46 +0100 Subject: [PATCH 17/97] encapsulate changes --- lib_com/ivas_prot_fx.h | 7 ++++-- lib_com/ivas_tools.c | 14 ++++-------- lib_com/options.h | 1 + lib_enc/speech_music_classif_fx.c | 36 ++++++++++++++++++++++++++++--- 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 6b09b1b47..1bdc33439 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4706,6 +4706,8 @@ Word32 dot_product_cholesky_fx( const Word32 *A, /* i : Cholesky matrix A */ const Word16 N /* i : vector & matrix size */ ); + +#ifndef DOT_PROD_CHOLESKY_64BIT Word32 dot_product_cholesky_fixed( const Word32 *x, /* i : vector x */ const Word32 *A, /* i : Cholesky matrix A */ @@ -4713,12 +4715,13 @@ Word32 dot_product_cholesky_fixed( const Word16 exp_x, const Word16 exp_A, Word16 *exp_sum ); - -Word64 dot_product_cholesky_fixed64( +#else +Word64 dot_product_cholesky_fixed( const Word32 *x, /* i : vector x */ const Word32 *A, /* i : Cholesky matrix A */ const Word16 N /* i : vector & matrix size */ ); +#endif void v_mult_mat_fx( Word32 *y_fx, /* o : the product x*A */ diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index dc45e3f0e..d55766928 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -606,6 +606,7 @@ void v_sub32_fx( * Therefore, S=A*A' where A is upper triangular matrix of size (m*m+m)/2 (zeros ommitted, column-wise) *---------------------------------------------------------------------*/ +#ifndef DOT_PROD_CHOLESKY_64BIT /*! r: the dot product x'*A*A'*x */ Word32 dot_product_cholesky_fixed( const Word32 *x, /* i : vector x Q31 - exp_x*/ @@ -642,17 +643,9 @@ Word32 dot_product_cholesky_fixed( return suma; } - -/*---------------------------------------------------------------------* - * dot_product_cholesky() - * - * Calculates dot product of type x'*A*A'*x, where x is column vector of size m, - * and A is a Cholesky decomposition of some Hermitian matrix S whose size is m*m. - * Therefore, S=A*A' where A is upper triangular matrix of size (m*m+m)/2 (zeros ommitted, column-wise) - *---------------------------------------------------------------------*/ - +#else /*! r: the dot product x'*A*A'*x */ -Word64 dot_product_cholesky_fixed64( +Word64 dot_product_cholesky_fixed( const Word32 *x, /* i : vector x Q31 - exp_x*/ const Word32 *A, /* i : Cholesky matrix A Q31 - exp_A*/ const Word16 N /* i : vector & matrix size Q0*/ @@ -686,6 +679,7 @@ Word64 dot_product_cholesky_fixed64( return suma; } +#endif void v_mult_mat_fixed( Word32 *y, /* o : the product x*A Qx - guardbits*/ diff --git a/lib_com/options.h b/lib_com/options.h index a37ccf387..5fc9a375f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,4 +169,5 @@ #define FIX_1298 /* VA: fix possible assert in gaus_enc */ #define FIX_1300_ICA_SHIFT_QUANT_IMPROV /* VA: Fix to 1300 to improve precision of the lag quantizer */ #define FIX_1301_CORRECT_TD_CNST /* VA: Fix 1301, correct wrong constant in TD stereo */ +#define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ #endif diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index fe6647a6c..f0fc3f304 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1683,8 +1683,16 @@ Word16 ivas_smc_gmm_fx( Word16 flag_odv; Word32 lps_fx, lpm_fx, lpn_fx; Word32 ps_fx[N_SMC_MIXTURES], pm_fx[N_SMC_MIXTURES], pn_fx[N_SMC_MIXTURES]; +#ifndef DOT_PROD_CHOLESKY_64BIT + Word32 lprob_fx; + Word16 lprob_exp = 0; +#else Word64 wprob_fx; +#endif Word32 fvm_fx[N_PCA_COEF]; +#ifndef DOT_PROD_CHOLESKY_64BIT + Word16 fvm_exp = 0; +#endif Word32 sum_PS_fx, ps_diff_fx, ps_sta_fx; Word32 dlp_fx, wrelE_fx, wdrop_fx, wght_fx; Word32 wrise_fx; @@ -2271,16 +2279,38 @@ Word16 ivas_smc_gmm_fx( FOR( m = 0; m < N_SMC_MIXTURES; m++ ) { v_sub32_fx( FV_fx, &means_speech_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 +#ifndef DOT_PROD_CHOLESKY_64BIT + fvm_exp = sub( 31, Qfact_FV ); + lprob_exp = 0; + move16(); + lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); + ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 +#else + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 +#endif move32(); v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 +#ifndef DOT_PROD_CHOLESKY_64BIT + lprob_exp = 0; + move16(); + lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); + pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 +#else + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 +#endif move32(); v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); - wprob_fx = dot_product_cholesky_fixed64( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 +#ifndef DOT_PROD_CHOLESKY_64BIT + lprob_exp = 0; + move16(); + lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); + pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 +#else + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 +#endif move32(); } -- GitLab From 0a6e192810ff8bd1bfa653f383dc55039487756c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 10:56:41 +0530 Subject: [PATCH 18/97] Renaming all files with "_fx" suffix --- Workspace_msvc/lib_com.vcxproj | 60 ++-- Workspace_msvc/lib_com.vcxproj.filters | 180 +++++----- Workspace_msvc/lib_dec.vcxproj | 96 ++--- Workspace_msvc/lib_dec.vcxproj.filters | 288 +++++++-------- Workspace_msvc/lib_enc.vcxproj | 110 +++--- Workspace_msvc/lib_enc.vcxproj.filters | 330 +++++++++--------- Workspace_msvc/lib_rend.vcxproj | 76 ++-- Workspace_msvc/lib_rend.vcxproj.filters | 83 +++-- lib_com/{ivas_arith.c => ivas_arith_fx.c} | 0 ...er_com.c => ivas_avq_pos_reorder_com_fx.c} | 0 ...ivas_cov_smooth.c => ivas_cov_smooth_fx.c} | 0 .../{ivas_dirac_com.c => ivas_dirac_com_fx.c} | 0 ...ommon.c => ivas_entropy_coder_common_fx.c} | 0 .../{ivas_fb_mixer.c => ivas_fb_mixer_fx.c} | 0 lib_com/{ivas_filters.c => ivas_filters_fx.c} | 0 lib_com/{ivas_ism_com.c => ivas_ism_com_fx.c} | 0 lib_com/{ivas_lfe_com.c => ivas_lfe_com_fx.c} | 0 .../{ivas_masa_com.c => ivas_masa_com_fx.c} | 0 lib_com/{ivas_mc_com.c => ivas_mc_com_fx.c} | 0 ..._mc_param_com.c => ivas_mc_param_com_fx.c} | 0 ...ivas_mcmasa_com.c => ivas_mcmasa_com-fx.c} | 0 lib_com/{ivas_mct_com.c => ivas_mct_com_fx.c} | 0 ...dct_core_com.c => ivas_mdct_core_com_fx.c} | 0 ...ivas_mdft_imdft.c => ivas_mdft_imdft_fx.c} | 0 .../{ivas_omasa_com.c => ivas_omasa_com_fx.c} | 0 .../{ivas_pca_tools.c => ivas_pca_tools_fx.c} | 0 ...metadata_com.c => ivas_qmetadata_com_fx.c} | 0 ...herical_com.c => ivas_qspherical_com_fx.c} | 0 ...ivas_sba_config.c => ivas_sba_config_fx.c} | 0 .../{ivas_spar_com.c => ivas_spar_com_fx.c} | 0 ...t_util.c => ivas_spar_com_quant_util_fx.c} | 0 ...reo_dft_com.c => ivas_stereo_dft_com_fx.c} | 0 ..._com.c => ivas_stereo_mdct_bands_com_fx.c} | 0 ...com.c => ivas_stereo_mdct_stereo_com_fx.c} | 0 ...pc_com.c => ivas_stereo_psychlpc_com_fx.c} | 0 ..._alloc.c => ivas_stereo_td_bit_alloc_fx.c} | 0 lib_com/{ivas_tools.c => ivas_tools_fx.c} | 0 ...ransient_det.c => ivas_transient_det_fx.c} | 0 ...ernal.c => ivas_binRenderer_internal_fx.c} | 0 .../{ivas_core_dec.c => ivas_core_dec_fx.c} | 0 ...fig.c => ivas_corecoder_dec_reconfig_fx.c} | 0 ...ix_dec.c => ivas_decision_matrix_dec_fx.c} | 0 .../{ivas_dirac_dec.c => ivas_dirac_dec_fx.c} | 0 ...c => ivas_dirac_output_synthesis_cov_fx.c} | 0 ...py_decoder.c => ivas_entropy_decoder_fx.c} | 0 lib_dec/{ivas_ism_dec.c => ivas_ism_dec_fx.c} | 0 ...as_ism_dtx_dec.c => ivas_ism_dtx_dec_fx.c} | 0 ...adata_dec.c => ivas_ism_metadata_dec_fx.c} | 0 ...sm_param_dec.c => ivas_ism_param_dec_fx.c} | 0 ..._ism_renderer.c => ivas_ism_renderer_fx.c} | 0 lib_dec/{ivas_jbm_dec.c => ivas_jbm_dec_fx.c} | 0 ...s_custom_dec.c => ivas_ls_custom_dec_fx.c} | 0 .../{ivas_masa_dec.c => ivas_masa_dec_fx.c} | 0 ..._mc_param_dec.c => ivas_mc_param_dec_fx.c} | 0 ...pmix_dec.c => ivas_mc_paramupmix_dec_fx.c} | 0 ...ivas_mcmasa_dec.c => ivas_mcmasa_dec_fx.c} | 0 ..._mct_core_dec.c => ivas_mct_core_dec_fx.c} | 0 lib_dec/{ivas_mct_dec.c => ivas_mct_dec_fx.c} | 0 ..._dec_mct_fx.c => ivas_mct_dec_mct_fx_fx.c} | 0 ...dct_core_dec.c => ivas_mdct_core_dec_fx.c} | 0 ...renderer.c => ivas_mono_dmx_renderer_fx.c} | 0 ...al.c => ivas_objectRenderer_internal_fx.c} | 0 .../{ivas_omasa_dec.c => ivas_omasa_dec_fx.c} | 0 .../{ivas_osba_dec.c => ivas_osba_dec_fx.c} | 0 ...rsion.c => ivas_out_setup_conversion_fx.c} | 0 ...utput_config.c => ivas_output_config_fx.c} | 0 .../{ivas_post_proc.c => ivas_post_proc_fx.c} | 0 ...metadata_dec.c => ivas_qmetadata_dec_fx.c} | 0 ...herical_dec.c => ivas_qspherical_dec_fx.c} | 0 ...ange_uni_dec.c => ivas_range_uni_dec_fx.c} | 0 lib_dec/{ivas_sba_dec.c => ivas_sba_dec_fx.c} | 0 ...nal.c => ivas_sba_rendering_internal_fx.c} | 0 ..._spar_decoder.c => ivas_spar_decoder_fx.c} | 0 ...as_spar_md_dec.c => ivas_spar_md_dec_fx.c} | 0 ...GR_dec.c => ivas_stereo_adapt_GR_dec_fx.c} | 0 ...dec_dmx.c => ivas_stereo_dft_dec_dmx_fx.c} | 0 ...eclvq_dec.c => ivas_stereo_eclvq_dec_fx.c} | 0 ...reo_esf_dec.c => ivas_stereo_esf_dec_fx.c} | 0 ...reo_ica_dec.c => ivas_stereo_ica_dec_fx.c} | 0 ...icbwe_dec.c => ivas_stereo_icbwe_dec_fx.c} | 0 ...dec.c => ivas_stereo_mdct_stereo_dec_fx.c} | 0 ...g_dec.c => ivas_stereo_switching_dec_fx.c} | 0 ...tereo_td_dec.c => ivas_stereo_td_dec_fx.c} | 0 lib_dec/{ivas_svd_dec.c => ivas_svd_dec_fx.c} | 0 ..._tcx_core_dec.c => ivas_tcx_core_dec_fx.c} | 0 ...w_rate_dec.c => ivas_td_low_rate_dec_fx.c} | 0 lib_enc/{ivas_agc_enc.c => ivas_agc_enc_fx.c} | 0 .../{ivas_core_enc.c => ivas_core_enc_fx.c} | 0 ..._front.c => ivas_core_pre_proc_front_fx.c} | 0 ...ore_pre_proc.c => ivas_core_pre_proc_fx.c} | 0 ...fig.c => ivas_corecoder_enc_reconfig_fx.c} | 0 lib_enc/{ivas_cpe_enc.c => ivas_cpe_enc_fx.c} | 0 ...ix_enc.c => ivas_decision_matrix_enc_fx.c} | 0 .../{ivas_dirac_enc.c => ivas_dirac_enc_fx.c} | 0 ...ov_handler.c => ivas_enc_cov_handler_fx.c} | 0 lib_enc/{ivas_enc.c => ivas_enc_fx.c} | 0 ...ntropy_coder.c => ivas_entropy_coder_fx.c} | 0 .../{ivas_front_vad.c => ivas_front_vad_fx.c} | 0 .../{ivas_init_enc.c => ivas_init_enc_fx.c} | 0 ...as_ism_dtx_enc.c => ivas_ism_dtx_enc_fx.c} | 0 lib_enc/{ivas_ism_enc.c => ivas_ism_enc_fx.c} | 0 ...adata_enc.c => ivas_ism_metadata_enc_fx.c} | 0 ...sm_param_enc.c => ivas_ism_param_enc_fx.c} | 0 lib_enc/{ivas_lfe_enc.c => ivas_lfe_enc_fx.c} | 0 .../{ivas_masa_enc.c => ivas_masa_enc_fx.c} | 0 ..._mc_param_enc.c => ivas_mc_param_enc_fx.c} | 0 ...pmix_enc.c => ivas_mc_paramupmix_enc_fx.c} | 0 ...ivas_mcmasa_enc.c => ivas_mcmasa_enc_fx.c} | 0 ..._mct_core_enc.c => ivas_mct_core_enc_fx.c} | 0 lib_enc/{ivas_mct_enc.c => ivas_mct_enc_fx.c} | 0 ...as_mct_enc_mct.c => ivas_mct_enc_mct_fx.c} | 0 ...dct_core_enc.c => ivas_mdct_core_enc_fx.c} | 0 .../{ivas_omasa_enc.c => ivas_omasa_enc_fx.c} | 0 .../{ivas_osba_enc.c => ivas_osba_enc_fx.c} | 0 lib_enc/{ivas_pca_enc.c => ivas_pca_enc_fx.c} | 0 ...metadata_enc.c => ivas_qmetadata_enc_fx.c} | 0 ...herical_enc.c => ivas_qspherical_enc_fx.c} | 0 ...ange_uni_enc.c => ivas_range_uni_enc_fx.c} | 0 lib_enc/{ivas_sba_enc.c => ivas_sba_enc_fx.c} | 0 lib_enc/{ivas_sce_enc.c => ivas_sce_enc_fx.c} | 0 lib_enc/{ivas_sns_enc.c => ivas_sns_enc_fx.c} | 0 ..._spar_encoder.c => ivas_spar_encoder_fx.c} | 0 ...as_spar_md_enc.c => ivas_spar_md_enc_fx.c} | 0 ...GR_enc.c => ivas_stereo_adapt_GR_enc_fx.c} | 0 ...assifier.c => ivas_stereo_classifier_fx.c} | 0 ...reo_cng_enc.c => ivas_stereo_cng_enc_fx.c} | 0 ...reo_dft_enc.c => ivas_stereo_dft_enc_fx.c} | 0 ...enc_itd.c => ivas_stereo_dft_enc_itd_fx.c} | 0 ...t_td_itd.c => ivas_stereo_dft_td_itd_fx.c} | 0 ...reo_dmx_evs.c => ivas_stereo_dmx_evs_fx.c} | 0 ...eclvq_enc.c => ivas_stereo_eclvq_enc_fx.c} | 0 ...reo_ica_enc.c => ivas_stereo_ica_enc_fx.c} | 0 ...icbwe_enc.c => ivas_stereo_icbwe_enc_fx.c} | 0 ...e_enc.c => ivas_stereo_mdct_core_enc_fx.c} | 0 ...gf_enc.c => ivas_stereo_mdct_igf_enc_fx.c} | 0 ...enc.c => ivas_stereo_mdct_stereo_enc_fx.c} | 0 ...g_enc.c => ivas_stereo_switching_enc_fx.c} | 0 ...nalysis.c => ivas_stereo_td_analysis_fx.c} | 0 ...tereo_td_enc.c => ivas_stereo_td_enc_fx.c} | 0 ..._tcx_core_enc.c => ivas_tcx_core_enc_fx.c} | 0 ...w_rate_enc.c => ivas_td_low_rate_enc_fx.c} | 0 ...ivas_allrad_dec.c => ivas_allrad_dec_fx.c} | 0 lib_rend/{ivas_crend.c => ivas_crend_fx.c} | 0 .../{ivas_dirac_ana.c => ivas_dirac_ana_fx.c} | 0 ...=> ivas_dirac_dec_binaural_functions_fx.c} | 0 ...ecorr_dec.c => ivas_dirac_decorr_dec_fx.c} | 0 ...nsets_dec.c => ivas_dirac_onsets_dec_fx.c} | 0 ...c => ivas_dirac_output_synthesis_dec_fx.c} | 0 ...ivas_dirac_rend.c => ivas_dirac_rend_fx.c} | 0 lib_rend/{ivas_efap.c => ivas_efap_fx.c} | 0 lib_rend/{ivas_hrtf.c => ivas_hrtf_fx.c} | 0 .../{ivas_limiter.c => ivas_limiter_fx.c} | 0 ...ivas_masa_merge.c => ivas_masa_merge_fx.c} | 0 ...ivas_mcmasa_ana.c => ivas_mcmasa_ana_fx.c} | 0 ...ectRenderer.c => ivas_objectRenderer_fx.c} | 0 ...Filt.c => ivas_objectRenderer_hrFilt_fx.c} | 0 ...rer_mix.c => ivas_objectRenderer_mix_fx.c} | 0 ...rer_sfx.c => ivas_objectRenderer_sfx_fx.c} | 0 ...ces.c => ivas_objectRenderer_sources_fx.c} | 0 ...rer_vec.c => ivas_objectRenderer_vec_fx.c} | 0 .../{ivas_omasa_ana.c => ivas_omasa_ana_fx.c} | 0 ...ivas_orient_trk.c => ivas_orient_trk_fx.c} | 0 ...as_reflections.c => ivas_reflections_fx.c} | 0 ...ender_config.c => ivas_render_config_fx.c} | 0 ...lay_line.c => ivas_reverb_delay_line_fx.c} | 0 ...t_filter.c => ivas_reverb_fft_filter_fx.c} | 0 ...esign.c => ivas_reverb_filter_design_fx.c} | 0 lib_rend/{ivas_reverb.c => ivas_reverb_fx.c} | 0 ...r_filter.c => ivas_reverb_iir_filter_fx.c} | 0 ..._reverb_utils.c => ivas_reverb_utils_fx.c} | 0 ...rer.c => ivas_rom_TdBinauralRenderer_fx.c} | 0 ...derer.c => ivas_rom_binauralRenderer_fx.c} | 0 ...ad.c => ivas_rom_binaural_crend_head_fx.c} | 0 .../{ivas_rom_rend.c => ivas_rom_rend_fx.c} | 0 .../{ivas_rotation.c => ivas_rotation_fx.c} | 0 ...ba_rendering.c => ivas_sba_rendering_fx.c} | 0 .../{ivas_shoebox.c => ivas_shoebox_fx.c} | 0 .../{ivas_td_decorr.c => ivas_td_decorr_fx.c} | 0 lib_rend/{ivas_vbap.c => ivas_vbap_fx.c} | 0 179 files changed, 610 insertions(+), 613 deletions(-) rename lib_com/{ivas_arith.c => ivas_arith_fx.c} (100%) rename lib_com/{ivas_avq_pos_reorder_com.c => ivas_avq_pos_reorder_com_fx.c} (100%) rename lib_com/{ivas_cov_smooth.c => ivas_cov_smooth_fx.c} (100%) rename lib_com/{ivas_dirac_com.c => ivas_dirac_com_fx.c} (100%) rename lib_com/{ivas_entropy_coder_common.c => ivas_entropy_coder_common_fx.c} (100%) rename lib_com/{ivas_fb_mixer.c => ivas_fb_mixer_fx.c} (100%) rename lib_com/{ivas_filters.c => ivas_filters_fx.c} (100%) rename lib_com/{ivas_ism_com.c => ivas_ism_com_fx.c} (100%) rename lib_com/{ivas_lfe_com.c => ivas_lfe_com_fx.c} (100%) rename lib_com/{ivas_masa_com.c => ivas_masa_com_fx.c} (100%) rename lib_com/{ivas_mc_com.c => ivas_mc_com_fx.c} (100%) rename lib_com/{ivas_mc_param_com.c => ivas_mc_param_com_fx.c} (100%) rename lib_com/{ivas_mcmasa_com.c => ivas_mcmasa_com-fx.c} (100%) rename lib_com/{ivas_mct_com.c => ivas_mct_com_fx.c} (100%) rename lib_com/{ivas_mdct_core_com.c => ivas_mdct_core_com_fx.c} (100%) rename lib_com/{ivas_mdft_imdft.c => ivas_mdft_imdft_fx.c} (100%) rename lib_com/{ivas_omasa_com.c => ivas_omasa_com_fx.c} (100%) rename lib_com/{ivas_pca_tools.c => ivas_pca_tools_fx.c} (100%) rename lib_com/{ivas_qmetadata_com.c => ivas_qmetadata_com_fx.c} (100%) rename lib_com/{ivas_qspherical_com.c => ivas_qspherical_com_fx.c} (100%) rename lib_com/{ivas_sba_config.c => ivas_sba_config_fx.c} (100%) rename lib_com/{ivas_spar_com.c => ivas_spar_com_fx.c} (100%) rename lib_com/{ivas_spar_com_quant_util.c => ivas_spar_com_quant_util_fx.c} (100%) rename lib_com/{ivas_stereo_dft_com.c => ivas_stereo_dft_com_fx.c} (100%) rename lib_com/{ivas_stereo_mdct_bands_com.c => ivas_stereo_mdct_bands_com_fx.c} (100%) rename lib_com/{ivas_stereo_mdct_stereo_com.c => ivas_stereo_mdct_stereo_com_fx.c} (100%) rename lib_com/{ivas_stereo_psychlpc_com.c => ivas_stereo_psychlpc_com_fx.c} (100%) rename lib_com/{ivas_stereo_td_bit_alloc.c => ivas_stereo_td_bit_alloc_fx.c} (100%) rename lib_com/{ivas_tools.c => ivas_tools_fx.c} (100%) rename lib_com/{ivas_transient_det.c => ivas_transient_det_fx.c} (100%) rename lib_dec/{ivas_binRenderer_internal.c => ivas_binRenderer_internal_fx.c} (100%) rename lib_dec/{ivas_core_dec.c => ivas_core_dec_fx.c} (100%) rename lib_dec/{ivas_corecoder_dec_reconfig.c => ivas_corecoder_dec_reconfig_fx.c} (100%) rename lib_dec/{ivas_decision_matrix_dec.c => ivas_decision_matrix_dec_fx.c} (100%) rename lib_dec/{ivas_dirac_dec.c => ivas_dirac_dec_fx.c} (100%) rename lib_dec/{ivas_dirac_output_synthesis_cov.c => ivas_dirac_output_synthesis_cov_fx.c} (100%) rename lib_dec/{ivas_entropy_decoder.c => ivas_entropy_decoder_fx.c} (100%) rename lib_dec/{ivas_ism_dec.c => ivas_ism_dec_fx.c} (100%) rename lib_dec/{ivas_ism_dtx_dec.c => ivas_ism_dtx_dec_fx.c} (100%) rename lib_dec/{ivas_ism_metadata_dec.c => ivas_ism_metadata_dec_fx.c} (100%) rename lib_dec/{ivas_ism_param_dec.c => ivas_ism_param_dec_fx.c} (100%) rename lib_dec/{ivas_ism_renderer.c => ivas_ism_renderer_fx.c} (100%) rename lib_dec/{ivas_jbm_dec.c => ivas_jbm_dec_fx.c} (100%) rename lib_dec/{ivas_ls_custom_dec.c => ivas_ls_custom_dec_fx.c} (100%) rename lib_dec/{ivas_masa_dec.c => ivas_masa_dec_fx.c} (100%) rename lib_dec/{ivas_mc_param_dec.c => ivas_mc_param_dec_fx.c} (100%) rename lib_dec/{ivas_mc_paramupmix_dec.c => ivas_mc_paramupmix_dec_fx.c} (100%) rename lib_dec/{ivas_mcmasa_dec.c => ivas_mcmasa_dec_fx.c} (100%) rename lib_dec/{ivas_mct_core_dec.c => ivas_mct_core_dec_fx.c} (100%) rename lib_dec/{ivas_mct_dec.c => ivas_mct_dec_fx.c} (100%) rename lib_dec/{ivas_mct_dec_mct_fx.c => ivas_mct_dec_mct_fx_fx.c} (100%) rename lib_dec/{ivas_mdct_core_dec.c => ivas_mdct_core_dec_fx.c} (100%) rename lib_dec/{ivas_mono_dmx_renderer.c => ivas_mono_dmx_renderer_fx.c} (100%) rename lib_dec/{ivas_objectRenderer_internal.c => ivas_objectRenderer_internal_fx.c} (100%) rename lib_dec/{ivas_omasa_dec.c => ivas_omasa_dec_fx.c} (100%) rename lib_dec/{ivas_osba_dec.c => ivas_osba_dec_fx.c} (100%) rename lib_dec/{ivas_out_setup_conversion.c => ivas_out_setup_conversion_fx.c} (100%) rename lib_dec/{ivas_output_config.c => ivas_output_config_fx.c} (100%) rename lib_dec/{ivas_post_proc.c => ivas_post_proc_fx.c} (100%) rename lib_dec/{ivas_qmetadata_dec.c => ivas_qmetadata_dec_fx.c} (100%) rename lib_dec/{ivas_qspherical_dec.c => ivas_qspherical_dec_fx.c} (100%) rename lib_dec/{ivas_range_uni_dec.c => ivas_range_uni_dec_fx.c} (100%) rename lib_dec/{ivas_sba_dec.c => ivas_sba_dec_fx.c} (100%) rename lib_dec/{ivas_sba_rendering_internal.c => ivas_sba_rendering_internal_fx.c} (100%) rename lib_dec/{ivas_spar_decoder.c => ivas_spar_decoder_fx.c} (100%) rename lib_dec/{ivas_spar_md_dec.c => ivas_spar_md_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_adapt_GR_dec.c => ivas_stereo_adapt_GR_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_dft_dec_dmx.c => ivas_stereo_dft_dec_dmx_fx.c} (100%) rename lib_dec/{ivas_stereo_eclvq_dec.c => ivas_stereo_eclvq_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_esf_dec.c => ivas_stereo_esf_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_ica_dec.c => ivas_stereo_ica_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_icbwe_dec.c => ivas_stereo_icbwe_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_mdct_stereo_dec.c => ivas_stereo_mdct_stereo_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_switching_dec.c => ivas_stereo_switching_dec_fx.c} (100%) rename lib_dec/{ivas_stereo_td_dec.c => ivas_stereo_td_dec_fx.c} (100%) rename lib_dec/{ivas_svd_dec.c => ivas_svd_dec_fx.c} (100%) rename lib_dec/{ivas_tcx_core_dec.c => ivas_tcx_core_dec_fx.c} (100%) rename lib_dec/{ivas_td_low_rate_dec.c => ivas_td_low_rate_dec_fx.c} (100%) rename lib_enc/{ivas_agc_enc.c => ivas_agc_enc_fx.c} (100%) rename lib_enc/{ivas_core_enc.c => ivas_core_enc_fx.c} (100%) rename lib_enc/{ivas_core_pre_proc_front.c => ivas_core_pre_proc_front_fx.c} (100%) rename lib_enc/{ivas_core_pre_proc.c => ivas_core_pre_proc_fx.c} (100%) rename lib_enc/{ivas_corecoder_enc_reconfig.c => ivas_corecoder_enc_reconfig_fx.c} (100%) rename lib_enc/{ivas_cpe_enc.c => ivas_cpe_enc_fx.c} (100%) rename lib_enc/{ivas_decision_matrix_enc.c => ivas_decision_matrix_enc_fx.c} (100%) rename lib_enc/{ivas_dirac_enc.c => ivas_dirac_enc_fx.c} (100%) rename lib_enc/{ivas_enc_cov_handler.c => ivas_enc_cov_handler_fx.c} (100%) rename lib_enc/{ivas_enc.c => ivas_enc_fx.c} (100%) rename lib_enc/{ivas_entropy_coder.c => ivas_entropy_coder_fx.c} (100%) rename lib_enc/{ivas_front_vad.c => ivas_front_vad_fx.c} (100%) rename lib_enc/{ivas_init_enc.c => ivas_init_enc_fx.c} (100%) rename lib_enc/{ivas_ism_dtx_enc.c => ivas_ism_dtx_enc_fx.c} (100%) rename lib_enc/{ivas_ism_enc.c => ivas_ism_enc_fx.c} (100%) rename lib_enc/{ivas_ism_metadata_enc.c => ivas_ism_metadata_enc_fx.c} (100%) rename lib_enc/{ivas_ism_param_enc.c => ivas_ism_param_enc_fx.c} (100%) rename lib_enc/{ivas_lfe_enc.c => ivas_lfe_enc_fx.c} (100%) rename lib_enc/{ivas_masa_enc.c => ivas_masa_enc_fx.c} (100%) rename lib_enc/{ivas_mc_param_enc.c => ivas_mc_param_enc_fx.c} (100%) rename lib_enc/{ivas_mc_paramupmix_enc.c => ivas_mc_paramupmix_enc_fx.c} (100%) rename lib_enc/{ivas_mcmasa_enc.c => ivas_mcmasa_enc_fx.c} (100%) rename lib_enc/{ivas_mct_core_enc.c => ivas_mct_core_enc_fx.c} (100%) rename lib_enc/{ivas_mct_enc.c => ivas_mct_enc_fx.c} (100%) rename lib_enc/{ivas_mct_enc_mct.c => ivas_mct_enc_mct_fx.c} (100%) rename lib_enc/{ivas_mdct_core_enc.c => ivas_mdct_core_enc_fx.c} (100%) rename lib_enc/{ivas_omasa_enc.c => ivas_omasa_enc_fx.c} (100%) rename lib_enc/{ivas_osba_enc.c => ivas_osba_enc_fx.c} (100%) rename lib_enc/{ivas_pca_enc.c => ivas_pca_enc_fx.c} (100%) rename lib_enc/{ivas_qmetadata_enc.c => ivas_qmetadata_enc_fx.c} (100%) rename lib_enc/{ivas_qspherical_enc.c => ivas_qspherical_enc_fx.c} (100%) rename lib_enc/{ivas_range_uni_enc.c => ivas_range_uni_enc_fx.c} (100%) rename lib_enc/{ivas_sba_enc.c => ivas_sba_enc_fx.c} (100%) rename lib_enc/{ivas_sce_enc.c => ivas_sce_enc_fx.c} (100%) rename lib_enc/{ivas_sns_enc.c => ivas_sns_enc_fx.c} (100%) rename lib_enc/{ivas_spar_encoder.c => ivas_spar_encoder_fx.c} (100%) rename lib_enc/{ivas_spar_md_enc.c => ivas_spar_md_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_adapt_GR_enc.c => ivas_stereo_adapt_GR_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_classifier.c => ivas_stereo_classifier_fx.c} (100%) rename lib_enc/{ivas_stereo_cng_enc.c => ivas_stereo_cng_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_dft_enc.c => ivas_stereo_dft_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_dft_enc_itd.c => ivas_stereo_dft_enc_itd_fx.c} (100%) rename lib_enc/{ivas_stereo_dft_td_itd.c => ivas_stereo_dft_td_itd_fx.c} (100%) rename lib_enc/{ivas_stereo_dmx_evs.c => ivas_stereo_dmx_evs_fx.c} (100%) rename lib_enc/{ivas_stereo_eclvq_enc.c => ivas_stereo_eclvq_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_ica_enc.c => ivas_stereo_ica_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_icbwe_enc.c => ivas_stereo_icbwe_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_mdct_core_enc.c => ivas_stereo_mdct_core_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_mdct_igf_enc.c => ivas_stereo_mdct_igf_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_mdct_stereo_enc.c => ivas_stereo_mdct_stereo_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_switching_enc.c => ivas_stereo_switching_enc_fx.c} (100%) rename lib_enc/{ivas_stereo_td_analysis.c => ivas_stereo_td_analysis_fx.c} (100%) rename lib_enc/{ivas_stereo_td_enc.c => ivas_stereo_td_enc_fx.c} (100%) rename lib_enc/{ivas_tcx_core_enc.c => ivas_tcx_core_enc_fx.c} (100%) rename lib_enc/{ivas_td_low_rate_enc.c => ivas_td_low_rate_enc_fx.c} (100%) rename lib_rend/{ivas_allrad_dec.c => ivas_allrad_dec_fx.c} (100%) rename lib_rend/{ivas_crend.c => ivas_crend_fx.c} (100%) rename lib_rend/{ivas_dirac_ana.c => ivas_dirac_ana_fx.c} (100%) rename lib_rend/{ivas_dirac_dec_binaural_functions.c => ivas_dirac_dec_binaural_functions_fx.c} (100%) rename lib_rend/{ivas_dirac_decorr_dec.c => ivas_dirac_decorr_dec_fx.c} (100%) rename lib_rend/{ivas_dirac_onsets_dec.c => ivas_dirac_onsets_dec_fx.c} (100%) rename lib_rend/{ivas_dirac_output_synthesis_dec.c => ivas_dirac_output_synthesis_dec_fx.c} (100%) rename lib_rend/{ivas_dirac_rend.c => ivas_dirac_rend_fx.c} (100%) rename lib_rend/{ivas_efap.c => ivas_efap_fx.c} (100%) rename lib_rend/{ivas_hrtf.c => ivas_hrtf_fx.c} (100%) rename lib_rend/{ivas_limiter.c => ivas_limiter_fx.c} (100%) rename lib_rend/{ivas_masa_merge.c => ivas_masa_merge_fx.c} (100%) rename lib_rend/{ivas_mcmasa_ana.c => ivas_mcmasa_ana_fx.c} (100%) rename lib_rend/{ivas_objectRenderer.c => ivas_objectRenderer_fx.c} (100%) rename lib_rend/{ivas_objectRenderer_hrFilt.c => ivas_objectRenderer_hrFilt_fx.c} (100%) rename lib_rend/{ivas_objectRenderer_mix.c => ivas_objectRenderer_mix_fx.c} (100%) rename lib_rend/{ivas_objectRenderer_sfx.c => ivas_objectRenderer_sfx_fx.c} (100%) rename lib_rend/{ivas_objectRenderer_sources.c => ivas_objectRenderer_sources_fx.c} (100%) rename lib_rend/{ivas_objectRenderer_vec.c => ivas_objectRenderer_vec_fx.c} (100%) rename lib_rend/{ivas_omasa_ana.c => ivas_omasa_ana_fx.c} (100%) rename lib_rend/{ivas_orient_trk.c => ivas_orient_trk_fx.c} (100%) rename lib_rend/{ivas_reflections.c => ivas_reflections_fx.c} (100%) rename lib_rend/{ivas_render_config.c => ivas_render_config_fx.c} (100%) rename lib_rend/{ivas_reverb_delay_line.c => ivas_reverb_delay_line_fx.c} (100%) rename lib_rend/{ivas_reverb_fft_filter.c => ivas_reverb_fft_filter_fx.c} (100%) rename lib_rend/{ivas_reverb_filter_design.c => ivas_reverb_filter_design_fx.c} (100%) rename lib_rend/{ivas_reverb.c => ivas_reverb_fx.c} (100%) rename lib_rend/{ivas_reverb_iir_filter.c => ivas_reverb_iir_filter_fx.c} (100%) rename lib_rend/{ivas_reverb_utils.c => ivas_reverb_utils_fx.c} (100%) rename lib_rend/{ivas_rom_TdBinauralRenderer.c => ivas_rom_TdBinauralRenderer_fx.c} (100%) rename lib_rend/{ivas_rom_binauralRenderer.c => ivas_rom_binauralRenderer_fx.c} (100%) rename lib_rend/{ivas_rom_binaural_crend_head.c => ivas_rom_binaural_crend_head_fx.c} (100%) rename lib_rend/{ivas_rom_rend.c => ivas_rom_rend_fx.c} (100%) rename lib_rend/{ivas_rotation.c => ivas_rotation_fx.c} (100%) rename lib_rend/{ivas_sba_rendering.c => ivas_sba_rendering_fx.c} (100%) rename lib_rend/{ivas_shoebox.c => ivas_shoebox_fx.c} (100%) rename lib_rend/{ivas_td_decorr.c => ivas_td_decorr_fx.c} (100%) rename lib_rend/{ivas_vbap.c => ivas_vbap_fx.c} (100%) diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index c88725ef0..8c42f19ca 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -200,42 +200,42 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - + + + + + - + - - - + + + - - - - - - + + + + + + diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index c58edbff6..8f2be8853 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -1,81 +1,6 @@ - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - common_all_c @@ -469,18 +394,6 @@ common_ivas_c - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - common_ivas_c @@ -493,9 +406,6 @@ common_ivas_c - - common_ivas_c - common_all_c @@ -544,6 +454,96 @@ common_all_c + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index b3a847791..2d06d29aa 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -210,69 +210,69 @@ - - - + + + - - - - + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - + + + + - + - + - - - + + + - + - - - - + + + + - - - - - - + + + + + + diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index c4e148b89..8a4fc4605 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -71,195 +71,51 @@ decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c decoder_ivas_c - - decoder_ivas_c - decoder_ivas_c decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_ivas_c - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - decoder_all_c @@ -518,6 +374,150 @@ decoder_all_c + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 86e56d42a..86dcef905 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -215,64 +215,64 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -319,7 +319,7 @@ - + diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters index 406c01b86..899097163 100644 --- a/Workspace_msvc/lib_enc.vcxproj.filters +++ b/Workspace_msvc/lib_enc.vcxproj.filters @@ -107,174 +107,9 @@ encoder_evs_c - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - encoder_ivas_c - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - encoder_all_c @@ -602,6 +437,171 @@ encoder_all_c + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index fa11b23be..1ffab139a 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -136,46 +136,46 @@ - - - - - - + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 01f3dfb74..47b4fee01 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -2,124 +2,124 @@ - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c - + rend_c @@ -143,9 +143,6 @@ rend_h - - rend_h - diff --git a/lib_com/ivas_arith.c b/lib_com/ivas_arith_fx.c similarity index 100% rename from lib_com/ivas_arith.c rename to lib_com/ivas_arith_fx.c diff --git a/lib_com/ivas_avq_pos_reorder_com.c b/lib_com/ivas_avq_pos_reorder_com_fx.c similarity index 100% rename from lib_com/ivas_avq_pos_reorder_com.c rename to lib_com/ivas_avq_pos_reorder_com_fx.c diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth_fx.c similarity index 100% rename from lib_com/ivas_cov_smooth.c rename to lib_com/ivas_cov_smooth_fx.c diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com_fx.c similarity index 100% rename from lib_com/ivas_dirac_com.c rename to lib_com/ivas_dirac_com_fx.c diff --git a/lib_com/ivas_entropy_coder_common.c b/lib_com/ivas_entropy_coder_common_fx.c similarity index 100% rename from lib_com/ivas_entropy_coder_common.c rename to lib_com/ivas_entropy_coder_common_fx.c diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer_fx.c similarity index 100% rename from lib_com/ivas_fb_mixer.c rename to lib_com/ivas_fb_mixer_fx.c diff --git a/lib_com/ivas_filters.c b/lib_com/ivas_filters_fx.c similarity index 100% rename from lib_com/ivas_filters.c rename to lib_com/ivas_filters_fx.c diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com_fx.c similarity index 100% rename from lib_com/ivas_ism_com.c rename to lib_com/ivas_ism_com_fx.c diff --git a/lib_com/ivas_lfe_com.c b/lib_com/ivas_lfe_com_fx.c similarity index 100% rename from lib_com/ivas_lfe_com.c rename to lib_com/ivas_lfe_com_fx.c diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com_fx.c similarity index 100% rename from lib_com/ivas_masa_com.c rename to lib_com/ivas_masa_com_fx.c diff --git a/lib_com/ivas_mc_com.c b/lib_com/ivas_mc_com_fx.c similarity index 100% rename from lib_com/ivas_mc_com.c rename to lib_com/ivas_mc_com_fx.c diff --git a/lib_com/ivas_mc_param_com.c b/lib_com/ivas_mc_param_com_fx.c similarity index 100% rename from lib_com/ivas_mc_param_com.c rename to lib_com/ivas_mc_param_com_fx.c diff --git a/lib_com/ivas_mcmasa_com.c b/lib_com/ivas_mcmasa_com-fx.c similarity index 100% rename from lib_com/ivas_mcmasa_com.c rename to lib_com/ivas_mcmasa_com-fx.c diff --git a/lib_com/ivas_mct_com.c b/lib_com/ivas_mct_com_fx.c similarity index 100% rename from lib_com/ivas_mct_com.c rename to lib_com/ivas_mct_com_fx.c diff --git a/lib_com/ivas_mdct_core_com.c b/lib_com/ivas_mdct_core_com_fx.c similarity index 100% rename from lib_com/ivas_mdct_core_com.c rename to lib_com/ivas_mdct_core_com_fx.c diff --git a/lib_com/ivas_mdft_imdft.c b/lib_com/ivas_mdft_imdft_fx.c similarity index 100% rename from lib_com/ivas_mdft_imdft.c rename to lib_com/ivas_mdft_imdft_fx.c diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com_fx.c similarity index 100% rename from lib_com/ivas_omasa_com.c rename to lib_com/ivas_omasa_com_fx.c diff --git a/lib_com/ivas_pca_tools.c b/lib_com/ivas_pca_tools_fx.c similarity index 100% rename from lib_com/ivas_pca_tools.c rename to lib_com/ivas_pca_tools_fx.c diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com_fx.c similarity index 100% rename from lib_com/ivas_qmetadata_com.c rename to lib_com/ivas_qmetadata_com_fx.c diff --git a/lib_com/ivas_qspherical_com.c b/lib_com/ivas_qspherical_com_fx.c similarity index 100% rename from lib_com/ivas_qspherical_com.c rename to lib_com/ivas_qspherical_com_fx.c diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config_fx.c similarity index 100% rename from lib_com/ivas_sba_config.c rename to lib_com/ivas_sba_config_fx.c diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com_fx.c similarity index 100% rename from lib_com/ivas_spar_com.c rename to lib_com/ivas_spar_com_fx.c diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util_fx.c similarity index 100% rename from lib_com/ivas_spar_com_quant_util.c rename to lib_com/ivas_spar_com_quant_util_fx.c diff --git a/lib_com/ivas_stereo_dft_com.c b/lib_com/ivas_stereo_dft_com_fx.c similarity index 100% rename from lib_com/ivas_stereo_dft_com.c rename to lib_com/ivas_stereo_dft_com_fx.c diff --git a/lib_com/ivas_stereo_mdct_bands_com.c b/lib_com/ivas_stereo_mdct_bands_com_fx.c similarity index 100% rename from lib_com/ivas_stereo_mdct_bands_com.c rename to lib_com/ivas_stereo_mdct_bands_com_fx.c diff --git a/lib_com/ivas_stereo_mdct_stereo_com.c b/lib_com/ivas_stereo_mdct_stereo_com_fx.c similarity index 100% rename from lib_com/ivas_stereo_mdct_stereo_com.c rename to lib_com/ivas_stereo_mdct_stereo_com_fx.c diff --git a/lib_com/ivas_stereo_psychlpc_com.c b/lib_com/ivas_stereo_psychlpc_com_fx.c similarity index 100% rename from lib_com/ivas_stereo_psychlpc_com.c rename to lib_com/ivas_stereo_psychlpc_com_fx.c diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc_fx.c similarity index 100% rename from lib_com/ivas_stereo_td_bit_alloc.c rename to lib_com/ivas_stereo_td_bit_alloc_fx.c diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools_fx.c similarity index 100% rename from lib_com/ivas_tools.c rename to lib_com/ivas_tools_fx.c diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det_fx.c similarity index 100% rename from lib_com/ivas_transient_det.c rename to lib_com/ivas_transient_det_fx.c diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal_fx.c similarity index 100% rename from lib_dec/ivas_binRenderer_internal.c rename to lib_dec/ivas_binRenderer_internal_fx.c diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec_fx.c similarity index 100% rename from lib_dec/ivas_core_dec.c rename to lib_dec/ivas_core_dec_fx.c diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c similarity index 100% rename from lib_dec/ivas_corecoder_dec_reconfig.c rename to lib_dec/ivas_corecoder_dec_reconfig_fx.c diff --git a/lib_dec/ivas_decision_matrix_dec.c b/lib_dec/ivas_decision_matrix_dec_fx.c similarity index 100% rename from lib_dec/ivas_decision_matrix_dec.c rename to lib_dec/ivas_decision_matrix_dec_fx.c diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec_fx.c similarity index 100% rename from lib_dec/ivas_dirac_dec.c rename to lib_dec/ivas_dirac_dec_fx.c diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c similarity index 100% rename from lib_dec/ivas_dirac_output_synthesis_cov.c rename to lib_dec/ivas_dirac_output_synthesis_cov_fx.c diff --git a/lib_dec/ivas_entropy_decoder.c b/lib_dec/ivas_entropy_decoder_fx.c similarity index 100% rename from lib_dec/ivas_entropy_decoder.c rename to lib_dec/ivas_entropy_decoder_fx.c diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec_fx.c similarity index 100% rename from lib_dec/ivas_ism_dec.c rename to lib_dec/ivas_ism_dec_fx.c diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec_fx.c similarity index 100% rename from lib_dec/ivas_ism_dtx_dec.c rename to lib_dec/ivas_ism_dtx_dec_fx.c diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec_fx.c similarity index 100% rename from lib_dec/ivas_ism_metadata_dec.c rename to lib_dec/ivas_ism_metadata_dec_fx.c diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec_fx.c similarity index 100% rename from lib_dec/ivas_ism_param_dec.c rename to lib_dec/ivas_ism_param_dec_fx.c diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer_fx.c similarity index 100% rename from lib_dec/ivas_ism_renderer.c rename to lib_dec/ivas_ism_renderer_fx.c diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec_fx.c similarity index 100% rename from lib_dec/ivas_jbm_dec.c rename to lib_dec/ivas_jbm_dec_fx.c diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec_fx.c similarity index 100% rename from lib_dec/ivas_ls_custom_dec.c rename to lib_dec/ivas_ls_custom_dec_fx.c diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec_fx.c similarity index 100% rename from lib_dec/ivas_masa_dec.c rename to lib_dec/ivas_masa_dec_fx.c diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec_fx.c similarity index 100% rename from lib_dec/ivas_mc_param_dec.c rename to lib_dec/ivas_mc_param_dec_fx.c diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c similarity index 100% rename from lib_dec/ivas_mc_paramupmix_dec.c rename to lib_dec/ivas_mc_paramupmix_dec_fx.c diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec_fx.c similarity index 100% rename from lib_dec/ivas_mcmasa_dec.c rename to lib_dec/ivas_mcmasa_dec_fx.c diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec_fx.c similarity index 100% rename from lib_dec/ivas_mct_core_dec.c rename to lib_dec/ivas_mct_core_dec_fx.c diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec_fx.c similarity index 100% rename from lib_dec/ivas_mct_dec.c rename to lib_dec/ivas_mct_dec_fx.c diff --git a/lib_dec/ivas_mct_dec_mct_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c similarity index 100% rename from lib_dec/ivas_mct_dec_mct_fx.c rename to lib_dec/ivas_mct_dec_mct_fx_fx.c diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec_fx.c similarity index 100% rename from lib_dec/ivas_mdct_core_dec.c rename to lib_dec/ivas_mdct_core_dec_fx.c diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer_fx.c similarity index 100% rename from lib_dec/ivas_mono_dmx_renderer.c rename to lib_dec/ivas_mono_dmx_renderer_fx.c diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal_fx.c similarity index 100% rename from lib_dec/ivas_objectRenderer_internal.c rename to lib_dec/ivas_objectRenderer_internal_fx.c diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec_fx.c similarity index 100% rename from lib_dec/ivas_omasa_dec.c rename to lib_dec/ivas_omasa_dec_fx.c diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec_fx.c similarity index 100% rename from lib_dec/ivas_osba_dec.c rename to lib_dec/ivas_osba_dec_fx.c diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion_fx.c similarity index 100% rename from lib_dec/ivas_out_setup_conversion.c rename to lib_dec/ivas_out_setup_conversion_fx.c diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config_fx.c similarity index 100% rename from lib_dec/ivas_output_config.c rename to lib_dec/ivas_output_config_fx.c diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc_fx.c similarity index 100% rename from lib_dec/ivas_post_proc.c rename to lib_dec/ivas_post_proc_fx.c diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec_fx.c similarity index 100% rename from lib_dec/ivas_qmetadata_dec.c rename to lib_dec/ivas_qmetadata_dec_fx.c diff --git a/lib_dec/ivas_qspherical_dec.c b/lib_dec/ivas_qspherical_dec_fx.c similarity index 100% rename from lib_dec/ivas_qspherical_dec.c rename to lib_dec/ivas_qspherical_dec_fx.c diff --git a/lib_dec/ivas_range_uni_dec.c b/lib_dec/ivas_range_uni_dec_fx.c similarity index 100% rename from lib_dec/ivas_range_uni_dec.c rename to lib_dec/ivas_range_uni_dec_fx.c diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec_fx.c similarity index 100% rename from lib_dec/ivas_sba_dec.c rename to lib_dec/ivas_sba_dec_fx.c diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal_fx.c similarity index 100% rename from lib_dec/ivas_sba_rendering_internal.c rename to lib_dec/ivas_sba_rendering_internal_fx.c diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder_fx.c similarity index 100% rename from lib_dec/ivas_spar_decoder.c rename to lib_dec/ivas_spar_decoder_fx.c diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec_fx.c similarity index 100% rename from lib_dec/ivas_spar_md_dec.c rename to lib_dec/ivas_spar_md_dec_fx.c diff --git a/lib_dec/ivas_stereo_adapt_GR_dec.c b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_adapt_GR_dec.c rename to lib_dec/ivas_stereo_adapt_GR_dec_fx.c diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c similarity index 100% rename from lib_dec/ivas_stereo_dft_dec_dmx.c rename to lib_dec/ivas_stereo_dft_dec_dmx_fx.c diff --git a/lib_dec/ivas_stereo_eclvq_dec.c b/lib_dec/ivas_stereo_eclvq_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_eclvq_dec.c rename to lib_dec/ivas_stereo_eclvq_dec_fx.c diff --git a/lib_dec/ivas_stereo_esf_dec.c b/lib_dec/ivas_stereo_esf_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_esf_dec.c rename to lib_dec/ivas_stereo_esf_dec_fx.c diff --git a/lib_dec/ivas_stereo_ica_dec.c b/lib_dec/ivas_stereo_ica_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_ica_dec.c rename to lib_dec/ivas_stereo_ica_dec_fx.c diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_icbwe_dec.c rename to lib_dec/ivas_stereo_icbwe_dec_fx.c diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_mdct_stereo_dec.c rename to lib_dec/ivas_stereo_mdct_stereo_dec_fx.c diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_switching_dec.c rename to lib_dec/ivas_stereo_switching_dec_fx.c diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec_fx.c similarity index 100% rename from lib_dec/ivas_stereo_td_dec.c rename to lib_dec/ivas_stereo_td_dec_fx.c diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec_fx.c similarity index 100% rename from lib_dec/ivas_svd_dec.c rename to lib_dec/ivas_svd_dec_fx.c diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec_fx.c similarity index 100% rename from lib_dec/ivas_tcx_core_dec.c rename to lib_dec/ivas_tcx_core_dec_fx.c diff --git a/lib_dec/ivas_td_low_rate_dec.c b/lib_dec/ivas_td_low_rate_dec_fx.c similarity index 100% rename from lib_dec/ivas_td_low_rate_dec.c rename to lib_dec/ivas_td_low_rate_dec_fx.c diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc_fx.c similarity index 100% rename from lib_enc/ivas_agc_enc.c rename to lib_enc/ivas_agc_enc_fx.c diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc_fx.c similarity index 100% rename from lib_enc/ivas_core_enc.c rename to lib_enc/ivas_core_enc_fx.c diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front_fx.c similarity index 100% rename from lib_enc/ivas_core_pre_proc_front.c rename to lib_enc/ivas_core_pre_proc_front_fx.c diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc_fx.c similarity index 100% rename from lib_enc/ivas_core_pre_proc.c rename to lib_enc/ivas_core_pre_proc_fx.c diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c similarity index 100% rename from lib_enc/ivas_corecoder_enc_reconfig.c rename to lib_enc/ivas_corecoder_enc_reconfig_fx.c diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc_fx.c similarity index 100% rename from lib_enc/ivas_cpe_enc.c rename to lib_enc/ivas_cpe_enc_fx.c diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc_fx.c similarity index 100% rename from lib_enc/ivas_decision_matrix_enc.c rename to lib_enc/ivas_decision_matrix_enc_fx.c diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc_fx.c similarity index 100% rename from lib_enc/ivas_dirac_enc.c rename to lib_enc/ivas_dirac_enc_fx.c diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler_fx.c similarity index 100% rename from lib_enc/ivas_enc_cov_handler.c rename to lib_enc/ivas_enc_cov_handler_fx.c diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc_fx.c similarity index 100% rename from lib_enc/ivas_enc.c rename to lib_enc/ivas_enc_fx.c diff --git a/lib_enc/ivas_entropy_coder.c b/lib_enc/ivas_entropy_coder_fx.c similarity index 100% rename from lib_enc/ivas_entropy_coder.c rename to lib_enc/ivas_entropy_coder_fx.c diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad_fx.c similarity index 100% rename from lib_enc/ivas_front_vad.c rename to lib_enc/ivas_front_vad_fx.c diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc_fx.c similarity index 100% rename from lib_enc/ivas_init_enc.c rename to lib_enc/ivas_init_enc_fx.c diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc_fx.c similarity index 100% rename from lib_enc/ivas_ism_dtx_enc.c rename to lib_enc/ivas_ism_dtx_enc_fx.c diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc_fx.c similarity index 100% rename from lib_enc/ivas_ism_enc.c rename to lib_enc/ivas_ism_enc_fx.c diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc_fx.c similarity index 100% rename from lib_enc/ivas_ism_metadata_enc.c rename to lib_enc/ivas_ism_metadata_enc_fx.c diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc_fx.c similarity index 100% rename from lib_enc/ivas_ism_param_enc.c rename to lib_enc/ivas_ism_param_enc_fx.c diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc_fx.c similarity index 100% rename from lib_enc/ivas_lfe_enc.c rename to lib_enc/ivas_lfe_enc_fx.c diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc_fx.c similarity index 100% rename from lib_enc/ivas_masa_enc.c rename to lib_enc/ivas_masa_enc_fx.c diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc_fx.c similarity index 100% rename from lib_enc/ivas_mc_param_enc.c rename to lib_enc/ivas_mc_param_enc_fx.c diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c similarity index 100% rename from lib_enc/ivas_mc_paramupmix_enc.c rename to lib_enc/ivas_mc_paramupmix_enc_fx.c diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc_fx.c similarity index 100% rename from lib_enc/ivas_mcmasa_enc.c rename to lib_enc/ivas_mcmasa_enc_fx.c diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc_fx.c similarity index 100% rename from lib_enc/ivas_mct_core_enc.c rename to lib_enc/ivas_mct_core_enc_fx.c diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc_fx.c similarity index 100% rename from lib_enc/ivas_mct_enc.c rename to lib_enc/ivas_mct_enc_fx.c diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct_fx.c similarity index 100% rename from lib_enc/ivas_mct_enc_mct.c rename to lib_enc/ivas_mct_enc_mct_fx.c diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc_fx.c similarity index 100% rename from lib_enc/ivas_mdct_core_enc.c rename to lib_enc/ivas_mdct_core_enc_fx.c diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc_fx.c similarity index 100% rename from lib_enc/ivas_omasa_enc.c rename to lib_enc/ivas_omasa_enc_fx.c diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc_fx.c similarity index 100% rename from lib_enc/ivas_osba_enc.c rename to lib_enc/ivas_osba_enc_fx.c diff --git a/lib_enc/ivas_pca_enc.c b/lib_enc/ivas_pca_enc_fx.c similarity index 100% rename from lib_enc/ivas_pca_enc.c rename to lib_enc/ivas_pca_enc_fx.c diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc_fx.c similarity index 100% rename from lib_enc/ivas_qmetadata_enc.c rename to lib_enc/ivas_qmetadata_enc_fx.c diff --git a/lib_enc/ivas_qspherical_enc.c b/lib_enc/ivas_qspherical_enc_fx.c similarity index 100% rename from lib_enc/ivas_qspherical_enc.c rename to lib_enc/ivas_qspherical_enc_fx.c diff --git a/lib_enc/ivas_range_uni_enc.c b/lib_enc/ivas_range_uni_enc_fx.c similarity index 100% rename from lib_enc/ivas_range_uni_enc.c rename to lib_enc/ivas_range_uni_enc_fx.c diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc_fx.c similarity index 100% rename from lib_enc/ivas_sba_enc.c rename to lib_enc/ivas_sba_enc_fx.c diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc_fx.c similarity index 100% rename from lib_enc/ivas_sce_enc.c rename to lib_enc/ivas_sce_enc_fx.c diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc_fx.c similarity index 100% rename from lib_enc/ivas_sns_enc.c rename to lib_enc/ivas_sns_enc_fx.c diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder_fx.c similarity index 100% rename from lib_enc/ivas_spar_encoder.c rename to lib_enc/ivas_spar_encoder_fx.c diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc_fx.c similarity index 100% rename from lib_enc/ivas_spar_md_enc.c rename to lib_enc/ivas_spar_md_enc_fx.c diff --git a/lib_enc/ivas_stereo_adapt_GR_enc.c b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_adapt_GR_enc.c rename to lib_enc/ivas_stereo_adapt_GR_enc_fx.c diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier_fx.c similarity index 100% rename from lib_enc/ivas_stereo_classifier.c rename to lib_enc/ivas_stereo_classifier_fx.c diff --git a/lib_enc/ivas_stereo_cng_enc.c b/lib_enc/ivas_stereo_cng_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_cng_enc.c rename to lib_enc/ivas_stereo_cng_enc_fx.c diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_dft_enc.c rename to lib_enc/ivas_stereo_dft_enc_fx.c diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c similarity index 100% rename from lib_enc/ivas_stereo_dft_enc_itd.c rename to lib_enc/ivas_stereo_dft_enc_itd_fx.c diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c similarity index 100% rename from lib_enc/ivas_stereo_dft_td_itd.c rename to lib_enc/ivas_stereo_dft_td_itd_fx.c diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs_fx.c similarity index 100% rename from lib_enc/ivas_stereo_dmx_evs.c rename to lib_enc/ivas_stereo_dmx_evs_fx.c diff --git a/lib_enc/ivas_stereo_eclvq_enc.c b/lib_enc/ivas_stereo_eclvq_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_eclvq_enc.c rename to lib_enc/ivas_stereo_eclvq_enc_fx.c diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_ica_enc.c rename to lib_enc/ivas_stereo_ica_enc_fx.c diff --git a/lib_enc/ivas_stereo_icbwe_enc.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_icbwe_enc.c rename to lib_enc/ivas_stereo_icbwe_enc_fx.c diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_mdct_core_enc.c rename to lib_enc/ivas_stereo_mdct_core_enc_fx.c diff --git a/lib_enc/ivas_stereo_mdct_igf_enc.c b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_mdct_igf_enc.c rename to lib_enc/ivas_stereo_mdct_igf_enc_fx.c diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_mdct_stereo_enc.c rename to lib_enc/ivas_stereo_mdct_stereo_enc_fx.c diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_switching_enc.c rename to lib_enc/ivas_stereo_switching_enc_fx.c diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis_fx.c similarity index 100% rename from lib_enc/ivas_stereo_td_analysis.c rename to lib_enc/ivas_stereo_td_analysis_fx.c diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc_fx.c similarity index 100% rename from lib_enc/ivas_stereo_td_enc.c rename to lib_enc/ivas_stereo_td_enc_fx.c diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc_fx.c similarity index 100% rename from lib_enc/ivas_tcx_core_enc.c rename to lib_enc/ivas_tcx_core_enc_fx.c diff --git a/lib_enc/ivas_td_low_rate_enc.c b/lib_enc/ivas_td_low_rate_enc_fx.c similarity index 100% rename from lib_enc/ivas_td_low_rate_enc.c rename to lib_enc/ivas_td_low_rate_enc_fx.c diff --git a/lib_rend/ivas_allrad_dec.c b/lib_rend/ivas_allrad_dec_fx.c similarity index 100% rename from lib_rend/ivas_allrad_dec.c rename to lib_rend/ivas_allrad_dec_fx.c diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend_fx.c similarity index 100% rename from lib_rend/ivas_crend.c rename to lib_rend/ivas_crend_fx.c diff --git a/lib_rend/ivas_dirac_ana.c b/lib_rend/ivas_dirac_ana_fx.c similarity index 100% rename from lib_rend/ivas_dirac_ana.c rename to lib_rend/ivas_dirac_ana_fx.c diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c similarity index 100% rename from lib_rend/ivas_dirac_dec_binaural_functions.c rename to lib_rend/ivas_dirac_dec_binaural_functions_fx.c diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec_fx.c similarity index 100% rename from lib_rend/ivas_dirac_decorr_dec.c rename to lib_rend/ivas_dirac_decorr_dec_fx.c diff --git a/lib_rend/ivas_dirac_onsets_dec.c b/lib_rend/ivas_dirac_onsets_dec_fx.c similarity index 100% rename from lib_rend/ivas_dirac_onsets_dec.c rename to lib_rend/ivas_dirac_onsets_dec_fx.c diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c similarity index 100% rename from lib_rend/ivas_dirac_output_synthesis_dec.c rename to lib_rend/ivas_dirac_output_synthesis_dec_fx.c diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend_fx.c similarity index 100% rename from lib_rend/ivas_dirac_rend.c rename to lib_rend/ivas_dirac_rend_fx.c diff --git a/lib_rend/ivas_efap.c b/lib_rend/ivas_efap_fx.c similarity index 100% rename from lib_rend/ivas_efap.c rename to lib_rend/ivas_efap_fx.c diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf_fx.c similarity index 100% rename from lib_rend/ivas_hrtf.c rename to lib_rend/ivas_hrtf_fx.c diff --git a/lib_rend/ivas_limiter.c b/lib_rend/ivas_limiter_fx.c similarity index 100% rename from lib_rend/ivas_limiter.c rename to lib_rend/ivas_limiter_fx.c diff --git a/lib_rend/ivas_masa_merge.c b/lib_rend/ivas_masa_merge_fx.c similarity index 100% rename from lib_rend/ivas_masa_merge.c rename to lib_rend/ivas_masa_merge_fx.c diff --git a/lib_rend/ivas_mcmasa_ana.c b/lib_rend/ivas_mcmasa_ana_fx.c similarity index 100% rename from lib_rend/ivas_mcmasa_ana.c rename to lib_rend/ivas_mcmasa_ana_fx.c diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer_fx.c similarity index 100% rename from lib_rend/ivas_objectRenderer.c rename to lib_rend/ivas_objectRenderer_fx.c diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c similarity index 100% rename from lib_rend/ivas_objectRenderer_hrFilt.c rename to lib_rend/ivas_objectRenderer_hrFilt_fx.c diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix_fx.c similarity index 100% rename from lib_rend/ivas_objectRenderer_mix.c rename to lib_rend/ivas_objectRenderer_mix_fx.c diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c similarity index 100% rename from lib_rend/ivas_objectRenderer_sfx.c rename to lib_rend/ivas_objectRenderer_sfx_fx.c diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources_fx.c similarity index 100% rename from lib_rend/ivas_objectRenderer_sources.c rename to lib_rend/ivas_objectRenderer_sources_fx.c diff --git a/lib_rend/ivas_objectRenderer_vec.c b/lib_rend/ivas_objectRenderer_vec_fx.c similarity index 100% rename from lib_rend/ivas_objectRenderer_vec.c rename to lib_rend/ivas_objectRenderer_vec_fx.c diff --git a/lib_rend/ivas_omasa_ana.c b/lib_rend/ivas_omasa_ana_fx.c similarity index 100% rename from lib_rend/ivas_omasa_ana.c rename to lib_rend/ivas_omasa_ana_fx.c diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk_fx.c similarity index 100% rename from lib_rend/ivas_orient_trk.c rename to lib_rend/ivas_orient_trk_fx.c diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections_fx.c similarity index 100% rename from lib_rend/ivas_reflections.c rename to lib_rend/ivas_reflections_fx.c diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config_fx.c similarity index 100% rename from lib_rend/ivas_render_config.c rename to lib_rend/ivas_render_config_fx.c diff --git a/lib_rend/ivas_reverb_delay_line.c b/lib_rend/ivas_reverb_delay_line_fx.c similarity index 100% rename from lib_rend/ivas_reverb_delay_line.c rename to lib_rend/ivas_reverb_delay_line_fx.c diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter_fx.c similarity index 100% rename from lib_rend/ivas_reverb_fft_filter.c rename to lib_rend/ivas_reverb_fft_filter_fx.c diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design_fx.c similarity index 100% rename from lib_rend/ivas_reverb_filter_design.c rename to lib_rend/ivas_reverb_filter_design_fx.c diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb_fx.c similarity index 100% rename from lib_rend/ivas_reverb.c rename to lib_rend/ivas_reverb_fx.c diff --git a/lib_rend/ivas_reverb_iir_filter.c b/lib_rend/ivas_reverb_iir_filter_fx.c similarity index 100% rename from lib_rend/ivas_reverb_iir_filter.c rename to lib_rend/ivas_reverb_iir_filter_fx.c diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils_fx.c similarity index 100% rename from lib_rend/ivas_reverb_utils.c rename to lib_rend/ivas_reverb_utils_fx.c diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.c b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c similarity index 100% rename from lib_rend/ivas_rom_TdBinauralRenderer.c rename to lib_rend/ivas_rom_TdBinauralRenderer_fx.c diff --git a/lib_rend/ivas_rom_binauralRenderer.c b/lib_rend/ivas_rom_binauralRenderer_fx.c similarity index 100% rename from lib_rend/ivas_rom_binauralRenderer.c rename to lib_rend/ivas_rom_binauralRenderer_fx.c diff --git a/lib_rend/ivas_rom_binaural_crend_head.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c similarity index 100% rename from lib_rend/ivas_rom_binaural_crend_head.c rename to lib_rend/ivas_rom_binaural_crend_head_fx.c diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend_fx.c similarity index 100% rename from lib_rend/ivas_rom_rend.c rename to lib_rend/ivas_rom_rend_fx.c diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation_fx.c similarity index 100% rename from lib_rend/ivas_rotation.c rename to lib_rend/ivas_rotation_fx.c diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering_fx.c similarity index 100% rename from lib_rend/ivas_sba_rendering.c rename to lib_rend/ivas_sba_rendering_fx.c diff --git a/lib_rend/ivas_shoebox.c b/lib_rend/ivas_shoebox_fx.c similarity index 100% rename from lib_rend/ivas_shoebox.c rename to lib_rend/ivas_shoebox_fx.c diff --git a/lib_rend/ivas_td_decorr.c b/lib_rend/ivas_td_decorr_fx.c similarity index 100% rename from lib_rend/ivas_td_decorr.c rename to lib_rend/ivas_td_decorr_fx.c diff --git a/lib_rend/ivas_vbap.c b/lib_rend/ivas_vbap_fx.c similarity index 100% rename from lib_rend/ivas_vbap.c rename to lib_rend/ivas_vbap_fx.c -- GitLab From f3a52497e1298d393cf5d34fb298caf9534183a2 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 11:51:18 +0530 Subject: [PATCH 19/97] Fix for 3GPP issue 1313: Multi-frame attenuation for MDCT-stereo 48kbps with input +10dB Link #1313 --- lib_enc/ivas_mc_param_enc_fx.c | 10 +++--- lib_enc/ivas_stereo_mdct_core_enc_fx.c | 8 ++--- lib_enc/stat_enc.h | 4 +-- lib_enc/transient_detection_fx.c | 48 ++++++++++---------------- 4 files changed, 30 insertions(+), 40 deletions(-) diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 859ce3a9b..36324ae0f 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -1639,8 +1639,8 @@ static void ivas_param_mc_transient_detection_fx( push_wmops( "param_mc_trn_det" ); attackRatioThreshold_fx = hTranDet->transientDetector.attackRatioThreshold; - pSubblockNrg_fx = &hTranDet->subblockEnergies.subblockNrg[hParamMC->transient_detector_delay]; // Q0 - pAccSubblockNrg_fx = &hTranDet->subblockEnergies.accSubblockNrg[hParamMC->transient_detector_delay]; // Q0 + pSubblockNrg_fx = &hTranDet->subblockEnergies.subblockNrg[hParamMC->transient_detector_delay]; // Q(-1) + pAccSubblockNrg_fx = &hTranDet->subblockEnergies.accSubblockNrg[hParamMC->transient_detector_delay]; // Q(-1) bIsAttackPresent = FALSE; move16(); @@ -1651,8 +1651,8 @@ static void ivas_param_mc_transient_detection_fx( * if we had an attack very late in the last frame, * make the current frame also a transient one... */ test(); - IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg_fx[-1], 31, Mpy_32_16_1( pAccSubblockNrg_fx[-1], attackRatioThreshold_fx ), ( 31 + ATTACKTHRESHOLD_E ) ), 1 ) || - EQ_16( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg_fx[-2], 31, Mpy_32_16_1( pAccSubblockNrg_fx[-2], attackRatioThreshold_fx ), ( 31 + ATTACKTHRESHOLD_E ) ), 1 ) ) + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg_fx[-1], 32, Mpy_32_16_1( pAccSubblockNrg_fx[-1], attackRatioThreshold_fx ), ( 32 + ATTACKTHRESHOLD_E ) ), 1 ) || + EQ_16( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg_fx[-2], 32, Mpy_32_16_1( pAccSubblockNrg_fx[-2], attackRatioThreshold_fx ), ( 32 + ATTACKTHRESHOLD_E ) ), 1 ) ) { bIsAttackPresent = TRUE; move16(); @@ -1661,7 +1661,7 @@ static void ivas_param_mc_transient_detection_fx( } FOR( i = 0; i < NSUBBLOCKS; i++ ){ - IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg_fx[i], 31, Mpy_32_16_1( pAccSubblockNrg_fx[i], attackRatioThreshold_fx ), ( 31 + ATTACKTHRESHOLD_E ) ), 1 ) ){ + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg_fx[i], 32, Mpy_32_16_1( pAccSubblockNrg_fx[i], attackRatioThreshold_fx ), ( 32 + ATTACKTHRESHOLD_E ) ), 1 ) ){ bIsAttackPresent = TRUE; move16(); attackIndex = i; diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index b43c8dfdb..2a87ea4f9 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -53,13 +53,13 @@ static void sync_tcx_mode_fx( Encoder_State **st /* i/o: Encoder state */ ) { - const Word32 prevAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[st[0]->hTranDet->subblockEnergies.nDelay]; /* Q0 */ + const Word32 prevAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[st[0]->hTranDet->subblockEnergies.nDelay]; /* Q(-1) */ move32(); - const Word32 prevAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[st[1]->hTranDet->subblockEnergies.nDelay]; /* Q0 */ + const Word32 prevAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[st[1]->hTranDet->subblockEnergies.nDelay]; /* Q(-1) */ move32(); - const Word32 lastAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[( st[0]->hTranDet->subblockEnergies.nDelay + st[0]->hTranDet->transientDetector.nSubblocksToCheck )]; /* Q0 */ + const Word32 lastAccNrg0 = st[0]->hTranDet->subblockEnergies.accSubblockNrg[( st[0]->hTranDet->subblockEnergies.nDelay + st[0]->hTranDet->transientDetector.nSubblocksToCheck )]; /* Q(-1) */ move32(); - const Word32 lastAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[( st[1]->hTranDet->subblockEnergies.nDelay + st[1]->hTranDet->transientDetector.nSubblocksToCheck )]; /* Q0 */ + const Word32 lastAccNrg1 = st[1]->hTranDet->subblockEnergies.accSubblockNrg[( st[1]->hTranDet->subblockEnergies.nDelay + st[1]->hTranDet->transientDetector.nSubblocksToCheck )]; /* Q(-1) */ move32(); test(); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 5067cb410..6292c4b33 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -138,8 +138,8 @@ typedef struct typedef struct { DelayBuffer *pDelayBuffer; /* Delay buffer. */ - Word32 subblockNrg[NSUBBLOCKS + MAX_TD_DELAY]; // IVAS Q0 - Word32 accSubblockNrg[NSUBBLOCKS + MAX_TD_DELAY + 1]; // IVAS Q0 + Word32 subblockNrg[NSUBBLOCKS + MAX_TD_DELAY]; // IVAS Q(-1) + Word32 accSubblockNrg[NSUBBLOCKS + MAX_TD_DELAY + 1]; // IVAS Q(-1) Word16 subblockNrgChange[NSUBBLOCKS + MAX_TD_DELAY]; /* EVS: Q7(15 - SUBBLOCK_NRG_CHANGE_E) */ /* IVAS: Q3 */ int16_t nDelay; /* Size of the delay buffer in use, as number of subblocks. Maximum delay from all users of this buffer. */ int16_t nPartialDelay; /* Delay of the input (modulo pDelayBuffer->nSubblockSize), nPartialDelay <= pDelayBuffer->nDelay. */ diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index d9859a1a1..82d24ceba 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -726,7 +726,7 @@ void RunTransientDetection_ivas_fx( e0_fx = dotp_fx( filteredInput_fx + /* length / 2 */ shr( length, 1 ), filteredInput_fx + /* length / 2 */ shr( length, 1 ), shr( pSubblockEnergies->pDelayBuffer->nSubblockSize, 1 ) /* pSubblockEnergies->pDelayBuffer->nSubblockSize / 2 */, &exp ); exp = sub( exp, 2 * 0 - 1 ); // Q = 2*0 + (30-exp), E = 31 - (2*0 + 30 - exp) = 1 + exp - 2*0 = exp - (2*0-1) e0_fx = BASOP_Util_Add_Mant32Exp( MIN_BLOCK_ENERGY_IVAS_FX_Q7 / 2, 31 - Q7, e0_fx, exp, &exp ); - e1_fx = BASOP_Util_Add_Mant32Exp( pSubblockEnergies->subblockNrg[pSubblockEnergies->nDelay + 4], 31 - 0, L_negate( e0_fx ), exp, &exp1 ); + e1_fx = BASOP_Util_Add_Mant32Exp( pSubblockEnergies->subblockNrg[pSubblockEnergies->nDelay + 4], 32, L_negate( e0_fx ), exp, &exp1 ); IF( BASOP_Util_Cmp_Mant32Exp( e1_fx, exp1, e0_fx, exp ) > 0 ) { pSubblockEnergies->ramp_up_flag = (UWord16) L_or( pSubblockEnergies->ramp_up_flag, 0x0001 ); @@ -1122,8 +1122,8 @@ static void InitSubblockEnergies_ivas_fx( Word16 nFrameLength, Word16 nDelay, De assert( ( pDelayBuffer != NULL ) && ( pSubblockEnergies != NULL ) && ( pDelayBuffer->nSubblockSize * NSUBBLOCKS == nFrameLength ) && ( pDelayBuffer->nSubblockSize > 0 ) ); - set32_fx( pSubblockEnergies->subblockNrg, 107 /* 107.37 in Q0 */, nMaxBuffSize ); - set32_fx( pSubblockEnergies->accSubblockNrg, 107 /* 107.37 in Q0 */, nMaxBuffSize + 1 ); + set32_fx( pSubblockEnergies->subblockNrg, 54 /* 107.37 in Q(-1) */, nMaxBuffSize ); + set32_fx( pSubblockEnergies->accSubblockNrg, 54 /* 107.37 in Q(-1) */, nMaxBuffSize + 1 ); set16_fx( pSubblockEnergies->subblockNrgChange, ONE_IN_Q3, nMaxBuffSize ); IF( nDelay != 0 ) { @@ -1495,9 +1495,9 @@ static void CalculateSubblockEnergies_ivas_fx( Word16 const *input, Word16 nSamp Word16 *pSubblockNrgChange; Word32 *pAccSubblockTmp; Word16 nWindows; - Word16 w, k, k2, tmp; + Word16 w, k, k2; Word32 w0, w1; - Word32 accu; + Word64 accu; move16(); pDelayBuffer = pSubblockEnergies->pDelayBuffer; @@ -1522,45 +1522,35 @@ static void CalculateSubblockEnergies_ivas_fx( Word16 const *input, Word16 nSamp IF( nWindows > 0 ) { /* Process left over samples from the previous frame. */ - accu = 107; // 107.37f in Q0 - move32(); - assert( ( SUBBLOCK_NRG_E & 1 ) == 0 ); + accu = 215; // 107.37f in Q1 + move64(); FOR( k = 0; k < nPartialDelay; k++ ) { - tmp = delayBuffer[k]; // Q0 - move16(); - accu = L_mac0( accu, tmp, tmp ); // Q0 + accu = W_mac_16_16( accu, delayBuffer[k], delayBuffer[k] ); // Q1 } /* Process new samples in the 0. subblock. */ - w = sub( nSubblockSize, nPartialDelay ); - assert( ( SUBBLOCK_NRG_E & 1 ) == 0 ); - FOR( k = 0; k < w; k++ ) + FOR( k = 0; k < ( nSubblockSize - nPartialDelay ); k++ ) { - tmp = input[k]; // Q0 - move16(); - accu = L_mac0_sat( accu, tmp, tmp ); // Q0 + accu = W_mac_16_16( accu, input[k], input[k] ); // Q1 } - pSubblockNrg[0] = accu; // Q0 + pSubblockNrg[0] = W_shl_sat_l( accu, -2 ); // Q(-1) move32(); /* Set accumulated subblock energy at this point. */ UpdatedAndStoreAccWindowNrg( pSubblockNrg[0], pAccSubblockTmp, facAccSubblockNrg, &pAccSubblockNrg[0] ); FOR( w = 1; w < nWindows; w++ ) { - accu = 107; // 107.37f in Q0 - move32(); + accu = 215; // 107.37f in Q1 + move64(); /* Process new samples in the w. subblock. */ k2 = add( k, nSubblockSize ); - assert( ( SUBBLOCK_NRG_E & 1 ) == 0 ); FOR( ; k < k2; k++ ) { - tmp = input[k]; // Q0 - move16(); - accu = L_mac0_sat( accu, tmp, tmp ); // Q0 + accu = W_mac_16_16( accu, input[k], input[k] ); // Q1 } - pSubblockNrg[w] = accu; // Q0 + pSubblockNrg[w] = W_shl_sat_l( accu, -2 ); // Q(-1) move32(); /* Set accumulated subblock energy at this point. */ UpdatedAndStoreAccWindowNrg( pSubblockNrg[w], pAccSubblockTmp, facAccSubblockNrg, &pAccSubblockNrg[w] ); @@ -1743,7 +1733,7 @@ Word16 transient_analysis_ivas_fx( /* Forward attack analysis */ FOR( i = -2; i < 7; i++ ) { - IF( BASOP_Util_Cmp_Mant32Exp( hTranDet->subblockEnergies.subblockNrg[nRelativeDelay + i], 31, Mpy_32_16_1( hTranDet->subblockEnergies.accSubblockNrg[nRelativeDelay + i], thr_fwd_fx ), ( 31 + 4 ) ) > 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( hTranDet->subblockEnergies.subblockNrg[nRelativeDelay + i], 32, Mpy_32_16_1( hTranDet->subblockEnergies.accSubblockNrg[nRelativeDelay + i], thr_fwd_fx ), ( 32 + 4 ) ) > 0 ) { prel_force_td = s_or( prel_force_td, 0x0001 ); } @@ -1780,7 +1770,7 @@ Word16 transient_analysis_ivas_fx( /* -3 check */ test(); - IF( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg[1 + offset], 31, Mpy_32_16_1( accSubblockNrgRev_fx[1], thr_rev_fx ), ( 31 + 4 ) ) > 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg[1 + offset], 32, Mpy_32_16_1( accSubblockNrgRev_fx[1], thr_rev_fx ), ( 32 + 4 ) ) > 0 ) { prel_force_td = s_or( prel_force_td, 0x0002 ); move16(); @@ -1788,10 +1778,10 @@ Word16 transient_analysis_ivas_fx( /* -4 check */ test(); - IF( prel_force_td == 0 && BASOP_Util_Cmp_Mant32Exp( pSubblockNrg[offset], 31, Mpy_32_16_1( accSubblockNrgRev_fx[0], thr_rev_fx ), ( 31 + 4 ) ) > 0 ) + IF( prel_force_td == 0 && BASOP_Util_Cmp_Mant32Exp( pSubblockNrg[offset], 32, Mpy_32_16_1( accSubblockNrgRev_fx[0], thr_rev_fx ), ( 32 + 4 ) ) > 0 ) { - IF( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg[offset], 31, Mpy_32_16_1( accSubblockNrgRev_fx[0], add( thr_rev_fx, THR_LOW_STEP_FX ) ), ( 31 + 4 ) ) > 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( pSubblockNrg[offset], 32, Mpy_32_16_1( accSubblockNrgRev_fx[0], add( thr_rev_fx, THR_LOW_STEP_FX ) ), ( 32 + 4 ) ) > 0 ) { prel_force_td = s_or( prel_force_td, 0x0004 ); } -- GitLab From 47fe3fc529be651d476e21441652186b54d0299e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 12:31:16 +0530 Subject: [PATCH 20/97] Speech buffer scaling fix and scaling fix in ivas_core_enc --- lib_com/ivas_prot_fx.h | 3 +- lib_com/prot.h | 1 + lib_enc/core_enc_init_fx.c | 47 +++++++++++++++++---------- lib_enc/ext_sig_ana_fx.c | 11 ++++--- lib_enc/ivas_core_enc_fx.c | 14 ++++---- lib_enc/ivas_core_pre_proc_front_fx.c | 4 +-- lib_enc/ivas_core_pre_proc_fx.c | 40 ++++++++++++----------- lib_enc/stat_enc.h | 20 ++++++------ 8 files changed, 78 insertions(+), 62 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 80bdda3c2..b581dfa7e 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5857,8 +5857,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new, - Word16 downscale_buf_speech_enc_pe ); + Word16 *Q_new); ivas_error ivas_enc_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 16f4659a0..f5d69075e 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -761,6 +761,7 @@ void preemph_ivas_fx( const Word16 L, /* i : vector size Q0*/ Word32 *mem /* i/o: memory (x[-1]) Qx*/ ); + void cb_shape( const int16_t preemphFlag, /* i : flag for pre-emphasis */ const int16_t pitchFlag, /* i : flag for pitch sharpening */ diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 4151725af..c2b1c22e1 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -3,8 +3,8 @@ ====================================================================================*/ #include -//#include "prot_fx.h" -//#include "basop_mpy.h" +// #include "prot_fx.h" +// #include "basop_mpy.h" #include "options.h" #include "cnst.h" #include "stl.h" @@ -1375,6 +1375,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol } // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); + Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( 0, sub( st->exp_old_wsp, st->exp_buf_wspeech_enc ) ) ); Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); st->exp_buf_wspeech_enc = st->exp_old_wsp; move16(); @@ -1384,25 +1385,36 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol test(); IF( EQ_16( st->L_frame, L_FRAME ) && !st->tcxonly ) { - // Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); - Copy( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); - /* SCaling to common exponent*/ - Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_12k8, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ) ); // Q(15-max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe )) - st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ); - move16(); + if ( st->exp_buf_speech_enc_pe >= st->exp_old_inp_12k8 ) + { + Copy_Scale_sig( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->exp_old_inp_12k8, st->exp_buf_speech_enc_pe ) ); // Scaling to common Q + // st->buf_speech_enc_pe is in st->exp_buf_speech_enc_pe + } + else + { + Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( st->exp_buf_speech_enc_pe, st->exp_old_inp_12k8 ) ); // Scaling to common Q + Copy( st->old_inp_12k8_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); + st->exp_buf_speech_enc_pe = st->exp_old_inp_12k8; + // st->buf_speech_enc_pe is in st->exp_buf_speech_enc_pe + move16(); + } } ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) && !st->tcxonly ) { lerp( st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, st->buf_wspeech_enc + st->L_frame + L_SUBFR - 310, 310, L_WSP_MEM ); - Copy( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); - /* SCaling to common exponent*/ - Scale_sig( st->buf_speech_enc_pe + sub( st->L_frame, L_INP_MEM ), L_INP_MEM, sub( st->exp_old_inp_16k, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - Scale_sig( st->buf_speech_enc_pe, sub( st->L_frame, L_INP_MEM ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - Scale_sig( st->buf_speech_enc_pe + st->L_frame, sub( L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, st->L_frame ), sub( st->exp_buf_speech_enc_pe, s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ) ); - st->exp_buf_speech_enc_pe = s_max( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ); - move16(); + if ( st->exp_buf_speech_enc_pe >= st->exp_old_inp_16k ) + { + Copy_Scale_sig( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM, sub( st->exp_old_inp_16k, st->exp_buf_speech_enc_pe ) ); // Scaling to common Q + // st->buf_speech_enc_pe is in st->exp_buf_speech_enc_pe + } + else + { + Scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( st->exp_buf_speech_enc_pe, st->exp_old_inp_16k ) ); // Scaling to common Q + Copy( st->old_inp_16k_fx, st->buf_speech_enc_pe + st->L_frame - L_INP_MEM, L_INP_MEM ); + st->exp_buf_speech_enc_pe = st->exp_old_inp_16k; + // st->buf_speech_enc_pe is in st->exp_buf_speech_enc_pe + move16(); + } } st->mem_preemph_enc = st->buf_speech_enc[st->encoderPastSamples_enc + st->encoderLookahead_enc - 1]; @@ -1416,6 +1428,7 @@ static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_ol ELSE IF( !st->tcxonly && GE_32( last_total_brate, ACELP_32k ) ) { + Scale_sig( st->buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320, sub( 0, sub( st->exp_old_wsp, st->exp_buf_wspeech_enc ) ) ); Copy( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM ); // Copy_Scale_sig( st->old_wsp_fx, st->buf_wspeech_enc + st->L_frame + L_SUBFR - L_WSP_MEM, L_WSP_MEM, sub( st->prev_Q_new, st->prev_Q_old ) ); st->exp_buf_wspeech_enc = st->exp_old_wsp; diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index c437be5be..732c1ba11 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -710,8 +710,9 @@ void core_signal_analysis_high_bitrate_ivas_fx( test(); IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy( new_samples, st->new_speech_enc, L_frame ); /* Q0 */ - Scale_sig( st->new_speech_enc, L_frame, 1 ); // Q1 + Copy_Scale_sig(new_samples, st->new_speech_enc, L_frame, sub( 15, st->exp_buf_speech_enc)); + /* st->new_speech_enc copied from new_samples in Q st->exp_buf_speech_enc + This is considering new_samples is in q 0 in current code*/ } /*--------------------------------------------------------------* @@ -747,10 +748,10 @@ void core_signal_analysis_high_bitrate_ivas_fx( test(); IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); + Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); //Assuming both exp_buf_speech_enc_pe and exp_buf_speech_enc are same + + PREEMPH_FX(st->new_speech_enc_pe, st->preemph_fac, L_frame, &(st->mem_preemph_enc)); //using this to keep values alligned in Q-1 - Preemph_scaled( st->new_speech_enc_pe, Q_new, &( st->mem_preemph_enc ), - st->Q_max_enc, st->preemph_fac, 1, 0, 2, L_frame, st->coder_type_raw, 1 ); } /* Rescale Memory */ diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 6dc3d10ec..303adecfd 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -734,8 +734,8 @@ ivas_error ivas_core_enc_fx( Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda } - Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, input_frame ); - Scale_sig( new_swb_speech_buffer_fx_16, input_frame, q_new_swb_speech_buffer ); // Q0->q_new_swb_speech_buffer + Word16 q_new_swb_speech_buffer = getScaleFactor16( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX ); + Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // Q0->q_new_swb_speech_buffer /* SWB TBE encoder */ test(); @@ -759,11 +759,11 @@ ivas_error ivas_core_enc_fx( } ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) ) { - Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16 - Scale_sig( new_swb_speech_fx_16, input_frame, negate( q_new_swb_speech_buffer ) ); // Q0 + Copy_Scale_sig_32_16( shb_speech_fx32, shb_speech_fx, L_FRAME16k, -Q16 ); // Q_shb_spch - 16 + Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, negate( q_new_swb_speech_buffer ) ); // q_new_swb_speech_buffer -> Q0 /* SWB(FB) BWE encoder */ swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, shb_speech_fx, sub( Q_shb_spch, Q16 ), sub( Q_new[n], 1 ) ); - Scale_sig( new_swb_speech_fx_16, input_frame, q_new_swb_speech_buffer ); // q_new_swb_speech_buffer + Scale_sig( new_swb_speech_buffer_fx_16, L_FRAME48k + STEREO_DFT_OVL_MAX, q_new_swb_speech_buffer ); // Q0 -> q_new_swb_speech_buffer } Scale_sig( old_syn_12k8_16k_fx[n], L_FRAME16k, sub( Q1, Q_new[n] ) ); // Q0 @@ -793,8 +793,8 @@ ivas_error ivas_core_enc_fx( stereo_icBWE_preproc_fx( hCPE, input_frame, new_swb_speech_buffer_fx_16 /*tmp buffer*/, q_new_swb_speech_buffer ); q_new_swb_speech_buffer = add( q_new_swb_speech_buffer, 16 ); - Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, input_frame, Q16 ); // q_new_swb_speech_buffer - Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 + Copy_Scale_sig_16_32_no_sat( new_swb_speech_buffer_fx_16, new_swb_speech_buffer_fx, L_FRAME48k + STEREO_DFT_OVL_MAX, Q16 ); // q_new_swb_speech_buffer - 16 - > q_new_swb_speech_buffer + Copy_Scale_sig_16_32_no_sat( voice_factors_fx[0], voice_factors_fx32[0], NB_SUBFR16k, Q16 ); // Q31 stereo_icBWE_enc_ivas_fx( hCPE, shb_speech_fx32, sub( Q31, Q_shb_spch ), new_swb_speech_buffer_fx, sub( Q31, q_new_swb_speech_buffer ), voice_factors_fx32[0] ); diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 7bb67cbbd..04e518e99 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -725,7 +725,7 @@ ivas_error pre_proc_front_ivas_fx( shift = sub( norm_s( inp_max ), headroom ); Word16 Q_min; - shift = s_max( shift, -1 ); + shift = s_max( shift, 0 ); shift = s_min( shift, Q_MAX ); minimum_fx( st->Q_max, L_Q_MEM, &Q_min ); *Q_new = s_min( shift, Q_min ); @@ -1702,7 +1702,7 @@ ivas_error pre_proc_front_ivas_fx( 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, 1 ); + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 718a09026..f4712a771 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -579,14 +579,28 @@ ivas_error pre_proc_ivas_fx( move16(); st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k ); move16(); - Word16 Q_old_inp_128k = *Q_new; + Word16 Q_inp_12k8 = *Q_new; + move16(); + Word16 Q_inp_16k = *Q_new; move16(); IF( !flag_16k_smc ) { 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_new, 0 ); + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k); + IF (GT_16(Q_inp_16k, Q_inp_12k8)) + { + Scale_sig(old_inp_16k_fx, L_INP, sub(Q_inp_12k8, Q_inp_16k)); + *Q_new = Q_inp_12k8; + } + ELSE + { + Scale_sig(old_inp_12k8_fx, L_INP_12k8, sub(Q_inp_16k, Q_inp_12k8)); + *Q_new = Q_inp_16k; + } + move16(); + IF( error != IVAS_ERR_OK ) { return error; @@ -628,7 +642,7 @@ ivas_error pre_proc_ivas_fx( IF( flag_16k_smc ) { - Copy( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_new - 1 */ + Copy( st->buf_speech_enc + L_FRAME16k, new_inp_resamp16k_fx, L_FRAME16k ); /* Q_old_inp_16k */ } /*-----------------------------------------------------------------* @@ -643,14 +657,11 @@ ivas_error pre_proc_ivas_fx( /* set the pointer of the current frame for the ACELP core */ IF( EQ_16( st->L_frame, L_FRAME ) ) { - *inp_fx = inp_12k8_fx; /* Q_old_inp_128k */ - *Q_new = Q_old_inp_128k; - move16(); + *inp_fx = inp_12k8_fx; /* Q_old_inp_12k8 */ } ELSE { *inp_fx = inp_16k_fx; - Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( *Q_new, Q_old_inp_128k ) ); } /* Update VAD hangover frame counter in active frames */ @@ -703,9 +714,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new, - Word16 downscale_buf_speech_enc_pe /* Q0 */ -) + Word16 *Q_new) { Word16 *inp_16k_fx, *new_inp_16k_fx; Word16 delay, element_mode; @@ -1103,14 +1112,7 @@ ivas_error ivas_compute_core_buffers_fx( { /* update signal buffers */ Word16 shift; - IF( downscale_buf_speech_enc_pe ) - { - shift = negate( *Q_new ); - } - ELSE - { - shift = 0; - } + shift = negate(*Q_new); move16(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { @@ -1148,7 +1150,7 @@ ivas_error ivas_compute_core_buffers_fx( /*--------------------------------------------------------------* * Compute Weighted Input *---------------------------------------------------------------*/ - + ivas_find_wsp_fx( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k ); } diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 6292c4b33..12cf078cf 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -113,9 +113,9 @@ typedef struct signal_buffers_enc_data_structure Word16 old_inp_12k8_fx[L_INP_MEM]; /* memory of input signal at 12.8kHz */ Word16 old_inp_16k_fx[L_INP_MEM]; /* ACELP@16kHz - memory of input signal @16 kHz */ - Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; + Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; // exp_buf_speech_enc_pe Word16 buf_synth[OLD_SYNTH_SIZE_ENC + L_FRAME32k]; - Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; + Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; //exp_buf_speech_enc Word16 buf_wspeech_enc[L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320]; /*normally there is a lookahead for 12k8 and 16k but L_FRAME_MAX=L_FRAME_16K+L_NEXT_16k*/ /* increased by 320 to avoid memory overlap in ivas_find_wsp() and also to accomodate for the wspeech_enc */ } SIGNAL_BUFFERS_ENC_DATA, *SIGNAL_BUFFERS_ENC_HANDLE; @@ -1463,10 +1463,10 @@ typedef struct enc_core_structure Word16 *old_inp_12k8_fx; /* memory of input signal at 12.8kHz */ Word16 *old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */ - Word16 *buf_speech_enc_pe; + Word16 *buf_speech_enc_pe; // exp_buf_speech_enc_pe Word16 *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ - Word16 *buf_speech_enc; - Word16 *buf_wspeech_enc; + Word16 *buf_speech_enc; //exp_buf_speech_enc + Word16 *buf_wspeech_enc; //exp_buf_wspeech_enc Word16 exp_buf_speech_enc_pe; Word16 exp_buf_speech_enc; @@ -1640,11 +1640,11 @@ typedef struct enc_core_structure Word16 exp_mem_preemph_enc; /* speech preemph filter memory (at encoder-sampling-rate) */ /* Signal Buffers and Pointers at encoder-sampling-rate */ - Word16 *speech_enc; - Word16 *speech_enc_pe; - Word16 *new_speech_enc; - Word16 *new_speech_enc_pe; - Word16 *wspeech_enc; + Word16 *speech_enc; //exp_buf_speech_enc + Word16 *speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *new_speech_enc; //exp_buf_speech_enc + Word16 *new_speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *wspeech_enc; //exp_buf_wspeech_enc Word16 *synth; int16_t enableTcxLpc; /* global toggle for the TCX LPC quantizer */ -- GitLab From 42806254d09551b20f527354a61fff694d80d9a9 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 12:33:58 +0530 Subject: [PATCH 21/97] Clang formatting changes --- lib_com/ivas_prot_fx.h | 2 +- lib_enc/ext_sig_ana_fx.c | 11 +++++------ lib_enc/ivas_core_pre_proc_front_fx.c | 2 +- lib_enc/ivas_core_pre_proc_fx.c | 20 ++++++++++---------- lib_enc/stat_enc.h | 22 +++++++++++----------- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index b581dfa7e..a61d6228d 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5857,7 +5857,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new); + Word16 *Q_new ); ivas_error ivas_enc_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 732c1ba11..9e6318591 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -710,9 +710,9 @@ void core_signal_analysis_high_bitrate_ivas_fx( test(); IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy_Scale_sig(new_samples, st->new_speech_enc, L_frame, sub( 15, st->exp_buf_speech_enc)); - /* st->new_speech_enc copied from new_samples in Q st->exp_buf_speech_enc - This is considering new_samples is in q 0 in current code*/ + Copy_Scale_sig( new_samples, st->new_speech_enc, L_frame, sub( 15, st->exp_buf_speech_enc ) ); + /* st->new_speech_enc copied from new_samples in Q st->exp_buf_speech_enc + This is considering new_samples is in q 0 in current code*/ } /*--------------------------------------------------------------* @@ -748,10 +748,9 @@ void core_signal_analysis_high_bitrate_ivas_fx( test(); IF( st->tcxonly && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); //Assuming both exp_buf_speech_enc_pe and exp_buf_speech_enc are same - - PREEMPH_FX(st->new_speech_enc_pe, st->preemph_fac, L_frame, &(st->mem_preemph_enc)); //using this to keep values alligned in Q-1 + Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); // Assuming both exp_buf_speech_enc_pe and exp_buf_speech_enc are same + PREEMPH_FX( st->new_speech_enc_pe, st->preemph_fac, L_frame, &( st->mem_preemph_enc ) ); // using this to keep values alligned in Q-1 } /* Rescale Memory */ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 04e518e99..f963b55a4 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1702,7 +1702,7 @@ ivas_error pre_proc_front_ivas_fx( 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); + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new ); IF( NE_32( error, IVAS_ERR_OK ) ) { return error; diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index f4712a771..1234a6876 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -588,19 +588,19 @@ ivas_error pre_proc_ivas_fx( 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); - IF (GT_16(Q_inp_16k, Q_inp_12k8)) + lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k ); + IF( GT_16( Q_inp_16k, Q_inp_12k8 ) ) { - Scale_sig(old_inp_16k_fx, L_INP, sub(Q_inp_12k8, Q_inp_16k)); - *Q_new = Q_inp_12k8; + Scale_sig( old_inp_16k_fx, L_INP, sub( Q_inp_12k8, Q_inp_16k ) ); + *Q_new = Q_inp_12k8; } ELSE { - Scale_sig(old_inp_12k8_fx, L_INP_12k8, sub(Q_inp_16k, Q_inp_12k8)); - *Q_new = Q_inp_16k; + Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( Q_inp_16k, Q_inp_12k8 ) ); + *Q_new = Q_inp_16k; } move16(); - + IF( error != IVAS_ERR_OK ) { return error; @@ -714,7 +714,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new) + Word16 *Q_new ) { Word16 *inp_16k_fx, *new_inp_16k_fx; Word16 delay, element_mode; @@ -1112,7 +1112,7 @@ ivas_error ivas_compute_core_buffers_fx( { /* update signal buffers */ Word16 shift; - shift = negate(*Q_new); + shift = negate( *Q_new ); move16(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { @@ -1150,7 +1150,7 @@ ivas_error ivas_compute_core_buffers_fx( /*--------------------------------------------------------------* * Compute Weighted Input *---------------------------------------------------------------*/ - + ivas_find_wsp_fx( L_FRAME16k, L_SUBFR, NB_SUBFR16k, A_fx, Aw_fx, st->speech_enc_pe, PREEMPH_FAC_16k, st->wspeech_enc, &st->mem_wsp_enc, st->gamma, L_LOOK_16k ); } diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 12cf078cf..d9f71128d 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -113,9 +113,9 @@ typedef struct signal_buffers_enc_data_structure Word16 old_inp_12k8_fx[L_INP_MEM]; /* memory of input signal at 12.8kHz */ Word16 old_inp_16k_fx[L_INP_MEM]; /* ACELP@16kHz - memory of input signal @16 kHz */ - Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; // exp_buf_speech_enc_pe + Word16 buf_speech_enc_pe[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; // exp_buf_speech_enc_pe Word16 buf_synth[OLD_SYNTH_SIZE_ENC + L_FRAME32k]; - Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; //exp_buf_speech_enc + Word16 buf_speech_enc[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; // exp_buf_speech_enc Word16 buf_wspeech_enc[L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320]; /*normally there is a lookahead for 12k8 and 16k but L_FRAME_MAX=L_FRAME_16K+L_NEXT_16k*/ /* increased by 320 to avoid memory overlap in ivas_find_wsp() and also to accomodate for the wspeech_enc */ } SIGNAL_BUFFERS_ENC_DATA, *SIGNAL_BUFFERS_ENC_HANDLE; @@ -1463,10 +1463,10 @@ typedef struct enc_core_structure Word16 *old_inp_12k8_fx; /* memory of input signal at 12.8kHz */ Word16 *old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */ - Word16 *buf_speech_enc_pe; // exp_buf_speech_enc_pe - Word16 *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ - Word16 *buf_speech_enc; //exp_buf_speech_enc - Word16 *buf_wspeech_enc; //exp_buf_wspeech_enc + Word16 *buf_speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ + Word16 *buf_speech_enc; // exp_buf_speech_enc + Word16 *buf_wspeech_enc; // exp_buf_wspeech_enc Word16 exp_buf_speech_enc_pe; Word16 exp_buf_speech_enc; @@ -1640,11 +1640,11 @@ typedef struct enc_core_structure Word16 exp_mem_preemph_enc; /* speech preemph filter memory (at encoder-sampling-rate) */ /* Signal Buffers and Pointers at encoder-sampling-rate */ - Word16 *speech_enc; //exp_buf_speech_enc - Word16 *speech_enc_pe; // exp_buf_speech_enc_pe - Word16 *new_speech_enc; //exp_buf_speech_enc - Word16 *new_speech_enc_pe; // exp_buf_speech_enc_pe - Word16 *wspeech_enc; //exp_buf_wspeech_enc + Word16 *speech_enc; // exp_buf_speech_enc + Word16 *speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *new_speech_enc; // exp_buf_speech_enc + Word16 *new_speech_enc_pe; // exp_buf_speech_enc_pe + Word16 *wspeech_enc; // exp_buf_wspeech_enc Word16 *synth; int16_t enableTcxLpc; /* global toggle for the TCX LPC quantizer */ -- GitLab From 9002a018c57848060404d8e92908c9dacfce05a8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 09:17:58 +0100 Subject: [PATCH 22/97] remove unused switches --- lib_com/ivas_ism_com_fx.c | 1 - lib_com/ivas_prot.h | 1 - lib_com/options.h | 1 - lib_enc/ivas_ism_dtx_enc_fx.c | 1 - lib_enc/ivas_ism_metadata_enc_fx.c | 3 +-- lib_rend/lib_rend.c | 10 +++------- 6 files changed, 4 insertions(+), 13 deletions(-) diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index 74e9641aa..d3f18a795 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -43,7 +43,6 @@ #include "ivas_prot_fx.h" #include "prot_fx.h" -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED /*-----------------------------------------------------------------------* * Local constants diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2493add28..34f11c01f 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -45,7 +45,6 @@ #include "ivas_stat_com.h" #include "ivas_error_utils.h" -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED /* clang-format off */ diff --git a/lib_com/options.h b/lib_com/options.h index d3570004d..7d65c5eac 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -70,7 +70,6 @@ #define IVAS_FLOAT_FIXED #define IVAS_FLOAT_FIXED_CONVERSIONS /* Temporary macro to keep track of intermediate flt to fixed and fixed to flt conversions */ #define MSAN_FIX -#define ISM_DISABLE #define FIX_TMP_714 #define BASOP_NOGLOB_TMP_715 #define EVS_FUNC_MODIFIED diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 3439baff1..615660761 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -40,7 +40,6 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED /*-----------------------------------------------------------------------* diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index d78281ff4..a5a1286a2 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -44,8 +44,7 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED -#include "ivas_rom_com_fx.h" + /*-----------------------------------------------------------------------* * Local constants diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index a1c551405..698c652e5 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -33,24 +33,20 @@ #include "options.h" #include "lib_rend.h" #include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" +#include "ivas_rom_com_fx.h" #include "ivas_rom_rend.h" #include #include #include #include "wmc_auto.h" -#include "ivas_rom_com_fx.h" -#include "ivas_prot_fx.h" -#include "prot_fx.h" -#include "debug.h" -#define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) -#define fix_to_float( n, factor ) ( (float) n / ( 1 << factor ) ) -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED + /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ -- GitLab From 65bee438bed413351f4b84df7a3fcdb6f76bbce0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 10:12:57 +0100 Subject: [PATCH 23/97] review and remove ADD_LRTD --- lib_com/est_tilt_fx.c | 35 +- lib_com/gs_bitallocation_fx.c | 925 ++++++++--------------------- lib_com/gs_bitallocation_ivas_fx.c | 144 ++--- lib_com/gs_noisefill_fx.c | 108 +--- lib_com/gs_preech_fx.c | 7 +- lib_com/options.h | 3 - lib_com/prot_fx.h | 91 ++- lib_com/syn_filt_fx.c | 18 - lib_dec/acelp_core_dec_fx.c | 123 +--- lib_dec/acelp_core_dec_ivas_fx.c | 8 +- lib_dec/core_switching_dec_fx.c | 4 - lib_dec/dec_amr_wb_fx.c | 8 +- lib_dec/dec_pit_exc_fx.c | 76 +-- lib_dec/evs_dec_fx.c | 9 +- lib_dec/gs_dec_fx.c | 335 ++--------- lib_dec/inov_dec_fx.c | 4 +- lib_dec/lsf_dec_fx.c | 5 - lib_dec/pit_dec_fx.c | 56 -- lib_dec/stat_dec.h | 37 +- lib_enc/acelp_core_enc_fx.c | 113 +--- lib_enc/cng_enc_fx.c | 4 - lib_enc/enc_pit_exc_fx.c | 5 +- lib_enc/enc_uv_fx.c | 3 +- lib_enc/evs_enc_fx.c | 7 +- lib_enc/gain_enc_fx.c | 14 - lib_enc/gs_enc_fx.c | 37 +- lib_enc/init_enc_fx.c | 5 +- lib_enc/lib_enc.c | 3 - lib_enc/lsf_enc_fx.c | 289 +++------ lib_enc/pit_enc_fx.c | 42 -- lib_enc/prot_fx_enc.h | 21 +- 31 files changed, 567 insertions(+), 1972 deletions(-) diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c index 138b8c1bc..4ff9c6c11 100644 --- a/lib_com/est_tilt_fx.c +++ b/lib_com/est_tilt_fx.c @@ -40,18 +40,12 @@ Word16 est_tilt_fx( /* o : tilt of the code const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ -#ifdef ADD_LRTD - , - const Word16 L_subfr /* i : Sub frame length */ -#endif ) { Word16 i, tmp, exp, ener1, exp1, ener2, exp2; Word32 L_tmp; Word16 tilt_code; -#ifdef ADD_LRTD - PMT( "FIX POINT NEED to be adapted for 16 kHz frame length " ) -#endif + ener1 = extract_h( Dot_product12( exc, exc, L_SUBFR, &exp1 ) ); exp1 = sub( exp1, add( Q_exc, Q_exc ) ); L_tmp = L_mult( gain_pit, gain_pit ); /* energy of pitch excitation */ @@ -117,26 +111,23 @@ Word16 est_tilt_fx( /* o : tilt of the code /* RETURN ARGUMENTS : */ /* _ (Word16) tolt_code : tilt of the code Q15 */ /*=======================================================================*/ -Word16 est_tilt_ivas_fx( /* o : tilt of the code Q15 */ - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic excitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ -#if 1 // def ADD_LRTD - , - const Word16 L_subfr, /* i : Sub frame length */ - const Word16 flag_tilt /* i : flag for special tilt */ -#endif + +/* o : tilt of the code Q15 */ +Word16 est_tilt_ivas_fx( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic excitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr, /* i : Sub frame length */ + const Word16 flag_tilt /* i : flag for special tilt */ ) { Word16 i, tmp, exp, ener1, exp1, ener2, exp2; Word32 L_tmp; Word16 tilt_code; -#ifdef ADD_LRTD - PMT( "FIX POINT NEED to be adapted for 16 kHz frame length " ) -#endif + ener1 = extract_h( Dot_product12( exc, exc, L_subfr, &exp1 ) ); exp1 = sub( exp1, add( Q_exc, Q_exc ) ); L_tmp = L_mult( gain_pit, gain_pit ); /* energy of pitch excitation */ diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c index 47d3679a8..e8f32c804 100644 --- a/lib_com/gs_bitallocation_fx.c +++ b/lib_com/gs_bitallocation_fx.c @@ -120,40 +120,7 @@ void bands_and_bit_alloc_fx( move16(); bit_new_bands = 5; move16(); -#ifdef ADD_LRTD - if ( GT_32( core_brate, ACELP_16k40 ) && EQ_16( L_frame, L_FRAME16k ) ) - { - bit_new_bands = 7; - move16(); - } - - i = 0; - move16(); - WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) ) - { - IF( LE_32( core_brate, brate_intermed_tbl[i] ) ) - { - BREAK; - } - - IF( EQ_32( brate_intermed_tbl[i], ACELP_24k40 ) ) - { - BREAK; - } - - i = add( i, 1 ); - } - - if ( GT_16( element_mode, EVS_MONO ) && EQ_16( coder_type, AUDIO ) && - LE_32( core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */ - { - i = sub( i, 1 ); - } - - bit_index = i_mult2( BRATE2IDX_fx( brate_intermed_tbl[i] ), 17 ); -#else bit_index = i_mult2( BRATE2IDX_fx( core_brate ), 17 ); -#endif bit_index_mem = bit_index; move16(); @@ -189,668 +156,330 @@ void bands_and_bit_alloc_fx( move16(); } -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k ) - { - *bit -= 8; - } - - if ( coder_type == INACTIVE && core_brate <= GSC_LRES_GAINQ_LIMIT ) /* can happen only for 2nd channel inactive */ - { - *bit += GSC_LRES_NB_NITS; - } - - if ( *bit > 0 ) + IF( EQ_16( GSC_noisy_speech, 1 ) ) { - if ( GSC_IVAS_mode > 0 ) - { - SWB_bit_budget = *bit; - st_band = 5; - - set_f( bits_per_bands, 0, MBANDS_GN_BITALLOC16k ); - - /* 2- Decide the pourcentage of bits allocated to LF (between 50-75%) depending of the temporal contribution in GSC */ - bit_fracf = ( -0.125f * Diff_len + 76.0f ) / 100; - bit_fracf = check_bounds( bit_fracf, 0.50f, 0.75f ); - - /* Adjusment of the bitrate between LF and HF base on the content type */ - /* 1 = new GSC bit alloc - 2 = GSC bit alloc for tc frame - 3 = more music like (should not happen often given music is coded with dft) */ - - if ( GSC_IVAS_mode <= 3 ) - { - nb_bands_max -= 6; - } - - if ( GSC_IVAS_mode == 2 ) - { - bit_fracf += 0.1f; - nb_bands_max--; - } - - if ( GSC_IVAS_mode == 3 ) - { - bit_fracf -= 0.1f; - nb_bands_max += 3; - } - - /* First find how much we want to share between LF and HF, at low bitrate, a miminum of bits is needed in LF by limitating the number of bands*/ - /* Adjust the number of band based on the content type and bitrate */ - nb_bands_adj = 1.0f; - if ( GSC_IVAS_mode == 1 && core_brate < GSC_L_RATE_STG ) - { - nb_bands_adj = 0.0125f * SWB_bit_budget - 0.75f; - } - else if ( GSC_IVAS_mode != 2 && core_brate > GSC_H_RATE_STG ) - { - nb_bands_adj = 0.02f * SWB_bit_budget - 1.2f; - } - nb_bands_max = (int16_t) ( nb_bands_max * nb_bands_adj + 0.5f ); - nb_bands_max = check_bounds_s( nb_bands_max, 5, nb_tot_bands ); - - bit_fracf *= SWB_bit_budget; - - /* Estimation of the number of bit used in HF */ - /* with only the first weigthing The number of bits in max_ener_band[st_band-1] = 17% of bit_fracf */ - mb = .17f * bit_fracf; - mp = ( 2.0f * DSR_NB_PULSE ); - if ( core_brate < GSC_L_RATE_STG && GSC_IVAS_mode == 3 ) - { - mp = 1.5f * DSR_NB_PULSE; - } - else if ( core_brate < GSC_L_RATE_STG ) - { - mp = DSR_NB_PULSE; - } - - /* We want max_ener_band[st_band] <= max_ener_band[st_band-1] and max_ener_band[nb_bands_max-1] <= max_ener_band[st_band]*/ - /* We will estimate the number of bits to allocate of HF and put the remaining bits, if any, back on LF */ - /* compute the total possible number of band to be coded */ - nb_tot_bands = (int16_t) ( ( SWB_bit_budget - bit_fracf ) / ( mp + ( mb - mp ) / 2.0f ) ); - mp = min( mp, mb ); - if ( nb_tot_bands + st_band > nb_bands_max ) - { - bit_adj = ( ( mb + mp ) / 2 ) * ( nb_tot_bands + st_band - nb_bands_max ); - bit_adj = max( 0, bit_adj ); - nb_tot_bands = nb_bands_max - st_band; - bit_fracf += bit_adj; - } - nb_tot_bands += st_band; - - /* Allocate bits to LF */ - etmp = 0.23f; - for ( j = 0; j < st_band; j++ ) - { - i = j; - max_ener_band[j] = i; - ener_vec[i] = MIN16B; - bits_per_bands[j] = etmp * bit_fracf; - etmp -= 0.015f; - } - - SWB_bit_budget -= bit_fracf; - - /* Find low energy band in HF */ - set_s( nb_pulse_per_band, 2, MBANDS_GN_BITALLOC16k ); - for ( i = st_band + 2; i < nb_tot_bands - 1; i++ ) - { - if ( ener_vec[i] < ener_vec[i - 1] && ener_vec[i] < ener_vec[i + 1] ) - { - nb_pulse_per_band[i] = 1; - } - } - for ( j = st_band; j < nb_tot_bands; j++ ) - { - if ( j > 6 ) - { - i = maximum( ener_vec, nb_tot_bands, &etmp ); - } - else - { - i = j; - } - - max_ener_band[j] = i; - ener_vec[i] = MIN16B; - } - - /* Recompute the final bit distribution for HF */ - if ( nb_tot_bands > st_band ) - { - bit_fracf = DSR_NB_PULSE; - mb = ( SWB_bit_budget * 2 / ( nb_tot_bands - st_band ) ) - mp; - bit_fracf = ( mb - mp ) / ( nb_tot_bands - st_band ); - mb -= bit_fracf; - /* Do the distribution */ - for ( j = st_band; j < nb_tot_bands; j++ ) - { - if ( nb_pulse_per_band[max_ener_band[j]] > 1 ) - { - bits_per_bands[max_ener_band[j]] = mb; - } - else - { - bits_per_bands[max_ener_band[j]] = 4.5f; - } - mb -= bit_fracf; - SWB_bit_budget -= bits_per_bands[max_ener_band[j]]; - } - } - - /* Series of verification in case bit allocated != the budget */ - if ( SWB_bit_budget > 0 ) - { - i = st_band - 1; - while ( SWB_bit_budget > 0 ) - { - bits_per_bands[i]++; - SWB_bit_budget--; - i--; - if ( i == -1 ) - { - i = st_band - 1; - } - } - } + SWB_bit_budget = *bit; + move16(); + nb_bands = 5; + move16(); - nb_bands = nb_tot_bands; + st_band = nb_bands; + move16(); - sum_bit = 0; - j = 0; - for ( i = 0; i < nb_bands; i++ ) - { - if ( bits_per_bands[i] > 112 ) - { - sum_bit += bits_per_bands[i] - 112; - bits_per_bands[i] = 112; - j = i + 1; - } + set32_fx( bits_per_bands, 0, MBANDS_GN ); + /*bit_fracf = (1.0f/nb_bands)*(SWB_bit_budget); */ + bit_fracf = L_mult( div_s( 1, nb_bands ), shl( SWB_bit_budget, 2 ) ); /* Q18 */ - /* safety check for overage bit reallocation */ - else if ( bits_per_bands[i] + sum_bit / 3 > 112 ) - { - j = i + 1; - } - } + nb_tot_bands = sub( nb_bands_max, 6 ); + nb_tot_bands = s_min( nb_tot_bands, 16 ); - if ( sum_bit != 0 ) - { - sum_bit /= ( nb_bands - j ); - for ( i = j; i < nb_bands; i++ ) - { - bits_per_bands[i] += sum_bit; - } - } + FOR( j = 0; j < 2; j++ ) + { + i = j; + move16(); + max_ener_band[j] = i; + move16(); + ener_vec[i] = 0; + move16(); } - else -#endif - IF( EQ_16( GSC_noisy_speech, 1 ) ) - { - SWB_bit_budget = *bit; - move16(); - nb_bands = 5; - move16(); -#ifdef ADD_LRTD - - fzero_val = 0.0f; - if ( element_mode > EVS_MONO ) - { - fzero_val = MIN16B_FLT; - } - - if ( coder_type == UNVOICED && element_mode > EVS_MONO ) - { - nb_bands = 3; - if ( SWB_bit_budget > 20 ) - { - nb_bands = 5; - } - } - else if ( bwidth < SWB ) - { - nb_bands = 7; - } - -#endif - - st_band = nb_bands; - move16(); + FOR( ; j < nb_bands; j++ ) + { + i = maximum_fx( ener_vec, nb_tot_bands, &etmp ); + max_ener_band[j] = i; + move16(); + ener_vec[i] = 0; + move16(); + } - set32_fx( bits_per_bands, 0, MBANDS_GN ); - /*bit_fracf = (1.0f/nb_bands)*(SWB_bit_budget); */ - bit_fracf = L_mult( div_s( 1, nb_bands ), shl( SWB_bit_budget, 2 ) ); /* Q18 */ + set32_fx( bits_per_bands, bit_fracf, nb_bands ); + } + ELSE + { + bit_index++; + bit_tmp = sub( *bit, GSC_freq_bits[bit_index] ); + bit_index++; + nb_bands_max = add( nb_bands_max, GSC_freq_bits[bit_index] ); + bit_index++; - nb_tot_bands = sub( nb_bands_max, 6 ); - nb_tot_bands = s_min( nb_tot_bands, 16 ); + *pvq_len = 112; + move16(); + st_band = 7; + move16(); - FOR( j = 0; j < 2; j++ ) - { - i = j; - move16(); - max_ener_band[j] = i; - move16(); - ener_vec[i] = 0; - move16(); - } -#ifdef ADD_LRTD - if ( bwidth < SWB ) - { - if ( coder_type == UNVOICED && element_mode > EVS_MONO ) - { - nb_tot_bands = 5; - } -#endif - FOR( ; j < nb_bands; j++ ) - { - i = maximum_fx( ener_vec, nb_tot_bands, &etmp ); - max_ener_band[j] = i; - move16(); - ener_vec[i] = 0; - move16(); - } -#ifdef ADD_LRTD - } - else - { - for ( ; j < nb_bands; j++ ) - { - i = maximum( ener_vec, nb_tot_bands, &etmp ); - max_ener_band[j] = i; - ener_vec[i] = fzero_val; - } - } -#endif - set32_fx( bits_per_bands, bit_fracf, nb_bands ); - } - ELSE + IF( LE_32( core_brate, ACELP_9k60 ) ) { - bit_index++; - bit_tmp = sub( *bit, GSC_freq_bits[bit_index] ); - bit_index++; - nb_bands_max = add( nb_bands_max, GSC_freq_bits[bit_index] ); - bit_index++; - - *pvq_len = 112; + *pvq_len = 80; move16(); - st_band = 7; + st_band = 5; move16(); -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k && core_brate > ACELP_16k40 ) - { - *pvq_len = 160; - st_band = 10; - nb_bands = *pvq_len / 16; - bit_tmp -= 35; - bit_new_bands = 5; - } -#endif - IF( LE_32( core_brate, ACELP_9k60 ) ) - { - *pvq_len = 80; - move16(); - st_band = 5; - move16(); - - IF( Diff_len == 0 ) - { - nb_bands_max = add( nb_bands_max, 2 ); - bit_tmp = sub( bit_tmp, 13 ); - } - } - ELSE IF( Diff_len == 0 ) + IF( Diff_len == 0 ) { nb_bands_max = add( nb_bands_max, 2 ); - bit_tmp = sub( bit_tmp, 17 ); + bit_tmp = sub( bit_tmp, 13 ); } + } - nb_bands = shr( *pvq_len, 4 ); -#ifdef ADD_LRTD - nb_bands_max = min( nb_bands_max, MBANDS_GN_BITALLOC16k ); -#endif - /*------------------------------------------------------------------------ + ELSE IF( Diff_len == 0 ) + { + nb_bands_max = add( nb_bands_max, 2 ); + bit_tmp = sub( bit_tmp, 17 ); + } + + nb_bands = shr( *pvq_len, 4 ); + + /*------------------------------------------------------------------------ * Ajustement of the maximum number of bands in function of the * dynamics of the spectrum (more or less speech like) *-----------------------------------------------------------------------*/ - test(); - test(); - test(); - test(); - IF( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) - { - /* Probably classification error -> concentrate bits on LF */ -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k && core_brate >= ACELP_24k40 ) - { - nb_bands_max = nb_tot_bands - 2; - } - else if ( core_brate >= ACELP_16k40 ) - { - nb_bands_max = nb_bands + 2; - } - else -#endif - if ( GE_32( core_brate, ACELP_8k00 ) ) - { - nb_bands_max = add( nb_bands, 1 ); - } - else - { - nb_bands_max = nb_bands; - move16(); - } - } - ELSE IF( GE_16( noise_lev, NOISE_LEVEL_SP2 ) || - ( LE_32( core_brate, ACELP_13k20 ) && GE_32( core_brate, ACELP_9k60 ) && cor_strong_limit == 0 ) ) /* Very low dynamic, tend to speech, do not try to code HF at all */ - { - nb_bands_max = sub( nb_bands_max, 2 ); - } - ELSE IF( GE_16( noise_lev, NOISE_LEVEL_SP1 ) ) /* Very low dynamic, tend to speech, code less HF */ + test(); + test(); + test(); + test(); + IF( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) + { + /* Probably classification error -> concentrate bits on LF */ + if ( GE_32( core_brate, ACELP_8k00 ) ) { - nb_bands_max = sub( nb_bands_max, 1 ); + nb_bands_max = add( nb_bands, 1 ); } -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k ) - { - if ( core_brate < ACELP_24k40 ) - { - nb_bands_max -= 4; - } - else if ( core_brate < ACELP_32k ) - { - if ( Diff_len > 0 || noise_lev >= NOISE_LEVEL_SP2 ) - { - nb_bands_max -= 2; - bit_new_bands *= 2; - } - } - else if ( core_brate >= ACELP_32k ) - { - bit_new_bands *= 2; - } - } - -#endif - test(); - if ( ( EQ_16( bwidth, NB ) ) && GT_16( nb_bands_max, 10 ) ) + else { - nb_bands_max = 10; + nb_bands_max = nb_bands; move16(); } + } + ELSE IF( GE_16( noise_lev, NOISE_LEVEL_SP2 ) || + ( LE_32( core_brate, ACELP_13k20 ) && GE_32( core_brate, ACELP_9k60 ) && cor_strong_limit == 0 ) ) /* Very low dynamic, tend to speech, do not try to code HF at all */ + { + nb_bands_max = sub( nb_bands_max, 2 ); + } + ELSE IF( GE_16( noise_lev, NOISE_LEVEL_SP1 ) ) /* Very low dynamic, tend to speech, code less HF */ + { + nb_bands_max = sub( nb_bands_max, 1 ); + } + + test(); + if ( ( EQ_16( bwidth, NB ) ) && GT_16( nb_bands_max, 10 ) ) + { + nb_bands_max = 10; + move16(); + } - /*------------------------------------------------------------------------ + /*------------------------------------------------------------------------ * Find extra number of band to code according to bit rate availables *-----------------------------------------------------------------------*/ + test(); + WHILE( GE_16( bit_tmp, bit_new_bands ) && LE_16( nb_bands, sub( nb_bands_max, 1 ) ) ) + { test(); - WHILE( GE_16( bit_tmp, bit_new_bands ) && LE_16( nb_bands, sub( nb_bands_max, 1 ) ) ) - { - test(); - bit_tmp = sub( bit_tmp, bit_new_bands ); - nb_bands = add( nb_bands, 1 ); - } + bit_tmp = sub( bit_tmp, bit_new_bands ); + nb_bands = add( nb_bands, 1 ); + } - /*------------------------------------------------------------------------ + /*------------------------------------------------------------------------ * Fractional bits to distribute on the first x bands *-----------------------------------------------------------------------*/ -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k && core_brate > ACELP_32k ) - { - bit_fracf = 0; - } - else -#endif - { - bit_fracf = L_mult( div_s( 1, st_band ), shl( bit_tmp, 2 ) ); /* Q18 */ - } - /*------------------------------------------------------------------------ + + { + bit_fracf = L_mult( div_s( 1, st_band ), shl( bit_tmp, 2 ) ); /* Q18 */ + } + /*------------------------------------------------------------------------ * Complete the bit allocation per frequency band *-----------------------------------------------------------------------*/ - imax = 5; + imax = 5; + move16(); + + if ( GT_32( core_brate, ACELP_9k60 ) ) + { + imax = 7; move16(); + } + FOR( i = 0; i < imax; i++ ) + { + bits_per_bands[i] = L_add( GSC_freq_bits_fx[bit_index], bit_fracf ); + move32(); /* Q18 */ + bit_index = add( bit_index, 1 ); + } - if ( GT_32( core_brate, ACELP_9k60 ) ) - { - imax = 7; - move16(); - } - FOR( i = 0; i < imax; i++ ) + IF( Diff_len == 0 ) + { + bit_index = add( bit_index_mem, 10 ); + FOR( i = 0; i < 7; i++ ) { - bits_per_bands[i] = L_add( GSC_freq_bits_fx[bit_index], bit_fracf ); - move32(); /* Q18 */ + bits_per_bands[i] = L_add( bits_per_bands[i], GSC_freq_bits_fx[bit_index] ); + move32(); /*chk Q18 */ bit_index = add( bit_index, 1 ); } -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k && core_brate > ACELP_16k40 ) - { - bit_index = 0; - i = imax - 1; - bits_per_bands[i] += Compl_GSC_freq_bits[bit_index]; - i++; - bit_index++; - - for ( ; i < 10; i++ ) - { - bits_per_bands[i] += Compl_GSC_freq_bits[bit_index] + bit_fracf; - bit_index++; - } - } -#endif - IF( Diff_len == 0 ) - { - bit_index = add( bit_index_mem, 10 ); - FOR( i = 0; i < 7; i++ ) - { - bits_per_bands[i] = L_add( bits_per_bands[i], GSC_freq_bits_fx[bit_index] ); - move32(); /*chk Q18 */ - bit_index = add( bit_index, 1 ); - } - } -#ifdef ADD_LRTD - if ( bit_fracf < 0 ) - { - for ( j = 0; j < nb_tot_bands; j++ ) - { - bits_per_bands[j] = max( bits_per_bands[j], 0 ); - } - } + } -#endif - /*-------------------------------------------------------------------------- + /*-------------------------------------------------------------------------- * Complete the bit allocation per frequency band for 16kHz high brate mode *--------------------------------------------------------------------------*/ -#ifdef ADD_LRTD - if ( L_frame == L_FRAME16k && core_brate > ACELP_32k ) - { - for ( j = st_band; j < nb_bands; j++ ) - { - bits_per_bands[j] = bit_new_bands; - } - - bit_fracf = ( 1.0f / nb_bands ) * ( bit_tmp ); - etmp = 2.0f * bit_fracf / ( nb_bands + 1 ); - bit_fracf = etmp; - for ( j = nb_bands - 1; j >= 0; j-- ) - { - bits_per_bands[j] += etmp; - etmp += bit_fracf; - } - } - else -#endif + { + FOR( j = st_band; j < nb_bands; j++ ) { - FOR( j = st_band; j < nb_bands; j++ ) - { - bits_per_bands[j] = L_shl( bit_new_bands, 18 ); - move32(); /*chk Q18 */ - } + bits_per_bands[j] = L_shl( bit_new_bands, 18 ); + move32(); /*chk Q18 */ } + } - /*-------------------------------------------------------------------------- + /*-------------------------------------------------------------------------- * Compute a maximum band (band offset) for the search on maximal energy * This is function of the spectral dynamic and the bitrate *--------------------------------------------------------------------------*/ - bandoffset = sub( nb_tot_bands, add( nb_bands, 2 ) ); + bandoffset = sub( nb_tot_bands, add( nb_bands, 2 ) ); - test(); - test(); - test(); - test(); - test(); - IF( LE_16( noise_lev, NOISE_LEVEL_SP1a ) ) - { - bandoffset = sub( bandoffset, 1 ); - } - ELSE IF( ( LE_32( core_brate, ACELP_13k20 ) && ( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) ) || - ( LE_32( core_brate, ACELP_13k20 ) && GE_32( core_brate, ACELP_9k60 ) && cor_strong_limit == 0 ) ) - { - bandoffset = add( bandoffset, 1 ); - } + test(); + test(); + test(); + test(); + test(); + IF( LE_16( noise_lev, NOISE_LEVEL_SP1a ) ) + { + bandoffset = sub( bandoffset, 1 ); + } + ELSE IF( ( LE_32( core_brate, ACELP_13k20 ) && ( EQ_16( coder_type, INACTIVE ) || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) ) || + ( LE_32( core_brate, ACELP_13k20 ) && GE_32( core_brate, ACELP_9k60 ) && cor_strong_limit == 0 ) ) + { + bandoffset = add( bandoffset, 1 ); + } - bandoffset = s_max( bandoffset, 0 ); + bandoffset = s_max( bandoffset, 0 ); - /*-------------------------------------------------------------------------- + /*-------------------------------------------------------------------------- * Initiazed sorted vector * For the first x bands to be included in th final sorted vector * Sort the remaining bands in decrease energy order *--------------------------------------------------------------------------*/ - FOR( j = 0; j < nb_tot_bands; j++ ) - { - max_ener_band[j] = -10; - move16(); - } - FOR( j = 0; j < st_band; j++ ) - { - max_ener_band[j] = j; - move16(); - ener_vec[j] = -10; - move16(); - } - pos = st_band; + FOR( j = 0; j < nb_tot_bands; j++ ) + { + max_ener_band[j] = -10; move16(); - FOR( ; j < nb_bands; j++ ) + } + FOR( j = 0; j < st_band; j++ ) + { + max_ener_band[j] = j; + move16(); + ener_vec[j] = -10; + move16(); + } + pos = st_band; + move16(); + FOR( ; j < nb_bands; j++ ) + { + i = maximum_fx( ener_vec, sub( nb_tot_bands, bandoffset ), &etmp ); + pos = s_max( pos, i ); + max_ener_band[j] = i; + move16(); + ener_vec[i] = -10; + move16(); + } + + /* re-allocate bits to the frames such that the highest band with allocated bits is higher than the threshold */ + test(); + test(); + test(); + IF( GT_16( sub( nb_tot_bands, bandoffset ), nb_bands ) && ( GT_16( pos, 7 ) && EQ_32( core_brate, ACELP_8k00 ) ) && EQ_16( bwidth, WB ) ) + { + band = sub( nb_tot_bands, add( bandoffset, nb_bands ) ); + FOR( j = 0; j < band; j++ ) { i = maximum_fx( ener_vec, sub( nb_tot_bands, bandoffset ), &etmp ); - pos = s_max( pos, i ); - max_ener_band[j] = i; + max_ener_band[add( nb_bands, j )] = i; move16(); ener_vec[i] = -10; move16(); + bits_per_bands[add( nb_bands, j )] = 1310720; + move32(); /*Q18 */ } + nb_bands = add( nb_bands, band ); - /* re-allocate bits to the frames such that the highest band with allocated bits is higher than the threshold */ - test(); - test(); - test(); - IF( GT_16( sub( nb_tot_bands, bandoffset ), nb_bands ) && ( GT_16( pos, 7 ) && EQ_32( core_brate, ACELP_8k00 ) ) && EQ_16( bwidth, WB ) ) + bit_tmp = i_mult2( band, 5 ); + + IF( LE_16( band, 2 ) ) { - band = sub( nb_tot_bands, add( bandoffset, nb_bands ) ); - FOR( j = 0; j < band; j++ ) + FOR( j = sub( st_band, 1 ); j < nb_bands; j++ ) { - i = maximum_fx( ener_vec, sub( nb_tot_bands, bandoffset ), &etmp ); - max_ener_band[add( nb_bands, j )] = i; - move16(); - ener_vec[i] = -10; - move16(); - bits_per_bands[add( nb_bands, j )] = 1310720; - move32(); /*Q18 */ + bits_per_bands[j] = L_add( bits_per_bands[j], 262144 ); /*Q18 */ + move32(); } - nb_bands = add( nb_bands, band ); - - bit_tmp = i_mult2( band, 5 ); + bit_tmp = add( bit_tmp, add( sub( nb_bands, st_band ), 1 ) ); + } - IF( LE_16( band, 2 ) ) + i = 0; + move16(); + j = 0; + move16(); + FOR( ; bit_tmp > 0; bit_tmp-- ) + { + bits_per_bands[j] = L_sub( bits_per_bands[j], 262144 ); /*Q18 */ + j = add( j, 1 ); + if ( EQ_16( j, sub( st_band, i ) ) ) { - FOR( j = sub( st_band, 1 ); j < nb_bands; j++ ) - { - bits_per_bands[j] = L_add( bits_per_bands[j], 262144 ); /*Q18 */ - move32(); - } - bit_tmp = add( bit_tmp, add( sub( nb_bands, st_band ), 1 ) ); + j = 0; + move16(); } - - i = 0; - move16(); - j = 0; - move16(); - FOR( ; bit_tmp > 0; bit_tmp-- ) + test(); + if ( j == 0 && LT_16( i, sub( st_band, 1 ) ) ) { - bits_per_bands[j] = L_sub( bits_per_bands[j], 262144 ); /*Q18 */ - j = add( j, 1 ); - if ( EQ_16( j, sub( st_band, i ) ) ) - { - j = 0; - move16(); - } - test(); - if ( j == 0 && LT_16( i, sub( st_band, 1 ) ) ) - { - i = add( i, 1 ); - } + i = add( i, 1 ); } } } - /*-------------------------------------------------------------------------- + } + /*-------------------------------------------------------------------------- * Bit sum verification for GSC inactive at very high rate * The maximum number of bits per band of length 16 is 112 * Redistribute the overage bits if needed *--------------------------------------------------------------------------*/ - sum_bit = 0; - move16(); - j = 0; - move16(); - FOR( i = 0; i < nb_bands; i++ ) - { - L_tmp = Mult_32_16( sum_bit, 10923 ); + sum_bit = 0; + move16(); + j = 0; + move16(); + FOR( i = 0; i < nb_bands; i++ ) + { + L_tmp = Mult_32_16( sum_bit, 10923 ); - IF( GT_32( bits_per_bands[i], 29360128 ) ) /* 112 in Q18 */ - { - sum_bit = L_add( sum_bit, L_sub( bits_per_bands[i], 29360128 ) ); /* Q18 */ - bits_per_bands[i] = 29360128; - move32(); - j = add( i, 1 ); - } - ELSE IF( GT_32( L_add( bits_per_bands[i], L_tmp ), 29360128 ) ) /* Q18 */ - { - j = add( i, 1 ); - } + IF( GT_32( bits_per_bands[i], 29360128 ) ) /* 112 in Q18 */ + { + sum_bit = L_add( sum_bit, L_sub( bits_per_bands[i], 29360128 ) ); /* Q18 */ + bits_per_bands[i] = 29360128; + move32(); + j = add( i, 1 ); } + ELSE IF( GT_32( L_add( bits_per_bands[i], L_tmp ), 29360128 ) ) /* Q18 */ + { + j = add( i, 1 ); + } + } - IF( sum_bit != 0 ) + IF( sum_bit != 0 ) + { + tmp = sub( nb_bands, j ); + sum_bit = Mult_32_16( sum_bit, div_s( 1, tmp ) ); /* Q18 */ + FOR( i = j; i < nb_bands; i++ ) { - tmp = sub( nb_bands, j ); - sum_bit = Mult_32_16( sum_bit, div_s( 1, tmp ) ); /* Q18 */ - FOR( i = j; i < nb_bands; i++ ) - { - bits_per_bands[i] = L_add( bits_per_bands[i], sum_bit ); - move32(); /* Q18 */ - } + bits_per_bands[i] = L_add( bits_per_bands[i], sum_bit ); + move32(); /* Q18 */ } - /*-------------------------------------------------------------------------- + } + /*-------------------------------------------------------------------------- * second step of bit sum verification, normally sum_bit == *bit *--------------------------------------------------------------------------*/ - w_sum_bit = 0; + w_sum_bit = 0; + move16(); + FOR( i = 0; i < nb_bands; i++ ) + { + out_bits_per_bands[i] = shl( extract_l( L_shr( bits_per_bands[i], 18 ) ), 3 ); move16(); - FOR( i = 0; i < nb_bands; i++ ) - { - out_bits_per_bands[i] = shl( extract_l( L_shr( bits_per_bands[i], 18 ) ), 3 ); - move16(); - w_sum_bit = add( w_sum_bit, out_bits_per_bands[i] ); /* Q3 */ - } - tmp = shl( *bit, 3 ); -#ifdef ADD_LRTD - if ( GSC_IVAS_mode != 0 && sum_bit < *bit ) /* If we need to add bits, we are doing it on the LF */ - { - reajust_bits( bits_per_bands, 0, nb_bands, (int16_t) sum_bit, *bit ); - } - else - { - reajust_bits( bits_per_bands, nb_bands - 1, 0, (int16_t) sum_bit, *bit ); - } -#else + w_sum_bit = add( w_sum_bit, out_bits_per_bands[i] ); /* Q3 */ + } + tmp = shl( *bit, 3 ); + IF( GT_16( tmp, w_sum_bit ) ) { i = sub( nb_bands, 1 ); @@ -866,88 +495,24 @@ void bands_and_bit_alloc_fx( } } } -#endif - /*-------------------------------------------------------------------------- + + /*-------------------------------------------------------------------------- * Recompute the real number/length of frequency bands to encode *--------------------------------------------------------------------------*/ - *nb_subbands = nb_bands; - move16(); - *pvq_len = shl( *nb_subbands, 4 ); + *nb_subbands = nb_bands; + move16(); + *pvq_len = shl( *nb_subbands, 4 ); - /*-------------------------------------------------------------------------- + /*-------------------------------------------------------------------------- * Concatenate bands (encoder only) *--------------------------------------------------------------------------*/ - IF( exc_diff != NULL ) - { - FOR( j = 0; j < nb_bands; j++ ) - { - Copy( exc_diff + shl( max_ener_band[j], 4 ), concat_in + shl( j, 4 ), 16 ); - } - } -#ifdef ADD_LRTD - } - else /* *bit == 0 */ - { - set_s( bits_per_bands_s, 0, nb_tot_bands ); - *nb_subbands = 0; - *pvq_len = 0; - } -#endif - return; -} -#ifdef ADD_LRTD -/*-------------------------------------------------------------------* - * reajust_bits() - * - * - *-------------------------------------------------------------------*/ - -static void reajust_bits( - float *bits_per_bands, - const int16_t st_band, - const int16_t end_band, - const int16_t sum_bit_in, - const int16_t bit_bdgt_in ) -{ - int16_t i, amount_to_add, incr; - int16_t bit_bdgt, sum_bit; - - incr = 1; - if ( end_band < st_band ) - { - incr = -1; - } - - if ( bit_bdgt_in < sum_bit_in ) - { - amount_to_add = -1; - bit_bdgt = sum_bit_in; - sum_bit = bit_bdgt_in; - } - else - { - bit_bdgt = bit_bdgt_in; - sum_bit = sum_bit_in; - amount_to_add = 1; - } - - i = st_band; - while ( bit_bdgt > sum_bit ) + IF( exc_diff != NULL ) { - if ( amount_to_add > 0 || ( amount_to_add < 0 && bits_per_bands[i] > 1 ) ) + FOR( j = 0; j < nb_bands; j++ ) { - bits_per_bands[i] += amount_to_add; - sum_bit += (int16_t) abs( amount_to_add ); - } - - i += incr; - if ( i == end_band ) - { - i = st_band; + Copy( exc_diff + shl( max_ener_band[j], 4 ), concat_in + shl( j, 4 ), 16 ); } } return; } - -#endif diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c index 0ab167015..eef3d50c6 100644 --- a/lib_com/gs_bitallocation_ivas_fx.c +++ b/lib_com/gs_bitallocation_ivas_fx.c @@ -103,8 +103,8 @@ void bands_and_bit_alloc_ivas_fx( Word16 etmp; Word16 tmp; Word16 pos, band; - Word32 SWB_bit_budget; // Q0 -> Q18 - Word32 bits_per_bands[MBANDS_GN_BITALLOC16k]; // Q18 + Word32 SWB_bit_budget; /* Q0 -> Q18 */ + Word32 bits_per_bands[MBANDS_GN_BITALLOC16k]; /* Q18 */ Word16 w_sum_bit; Word16 fzero_val; #ifdef BASOP_NOGLOB_DECLARE_LOCAL @@ -148,7 +148,7 @@ void bands_and_bit_alloc_ivas_fx( move16(); bit_new_bands = 5; move16(); -#if 1 // def ADD_LRTD + test(); if ( GT_32( core_brate, ACELP_16k40 ) && EQ_16( L_frame, L_FRAME16k ) ) { @@ -183,9 +183,6 @@ void bands_and_bit_alloc_ivas_fx( } bit_index = i_mult2( BRATE2IDX_fx( brate_intermed_tbl[i] ), 17 ); -#else - bit_index = i_mult2( BRATE2IDX_fx( core_brate ), 17 ); -#endif bit_index_mem = bit_index; move16(); @@ -221,7 +218,6 @@ void bands_and_bit_alloc_ivas_fx( move16(); } -#if 1 // def ADD_LRTD IF( EQ_16( L_frame, L_FRAME16k ) ) { *bit = sub( *bit, 8 ); @@ -242,18 +238,12 @@ void bands_and_bit_alloc_ivas_fx( nb_tot_bands = Find_bit_alloc_IVAS_fx( core_brate, GSC_IVAS_mode, Diff_len, nb_tot_bands, bit, max_ener_band, ener_vec, bits_per_bands ); nb_bands = nb_tot_bands; } - ELSE -#endif - IF( EQ_16( GSC_noisy_speech, 1 ) ) + ELSE IF( EQ_16( GSC_noisy_speech, 1 ) ) { SWB_bit_budget = *bit; /*Q0*/ move32(); nb_bands = 5; move16(); - -#if 1 // def ADD_LRTD - - // fzero_val = 0.0f; fzero_val = 0; move16(); @@ -281,8 +271,6 @@ void bands_and_bit_alloc_ivas_fx( move16(); } -#endif - st_band = nb_bands; move16(); @@ -298,11 +286,10 @@ void bands_and_bit_alloc_ivas_fx( move16(); max_ener_band[j] = i; move16(); - // ener_vec[i] = 0; ener_vec[i] = fzero_val; move16(); } -#if 1 // def ADD_LRTD + IF( LT_16( bwidth, SWB ) ) { test(); @@ -311,17 +298,15 @@ void bands_and_bit_alloc_ivas_fx( nb_tot_bands = 5; move16(); } -#endif + FOR( ; j < nb_bands; j++ ) { i = maximum_fx( ener_vec, nb_tot_bands, &etmp ); max_ener_band[j] = i; move16(); - // ener_vec[i] = 0; ener_vec[i] = fzero_val; move16(); } -#if 1 // def ADD_LRTD } ELSE { @@ -334,7 +319,7 @@ void bands_and_bit_alloc_ivas_fx( move16(); } } -#endif + set32_fx( bits_per_bands, bit_fracf, nb_bands ); } ELSE @@ -349,7 +334,7 @@ void bands_and_bit_alloc_ivas_fx( move16(); st_band = 7; move16(); -#if 1 // def ADD_LRTD + test(); IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_16k40 ) ) { @@ -362,7 +347,7 @@ void bands_and_bit_alloc_ivas_fx( bit_new_bands = 5; move16(); } -#endif + IF( LE_32( core_brate, ACELP_9k60 ) ) { *pvq_len = 80; @@ -384,9 +369,8 @@ void bands_and_bit_alloc_ivas_fx( } nb_bands = shr( *pvq_len, 4 ); -#if 1 // def ADD_LRTD nb_bands_max = s_min( nb_bands_max, MBANDS_GN_BITALLOC16k ); -#endif + /*------------------------------------------------------------------------ * Ajustement of the maximum number of bands in function of the * dynamics of the spectrum (more or less speech like) @@ -398,7 +382,6 @@ void bands_and_bit_alloc_ivas_fx( IF( coder_type == INACTIVE || GE_16( noise_lev, NOISE_LEVEL_SP3 ) ) { /* Probably classification error -> concentrate bits on LF */ -#if 1 // def ADD_LRTD IF( EQ_16( L_frame, L_FRAME16k ) && GE_32( core_brate, ACELP_24k40 ) ) { nb_bands_max = sub( nb_tot_bands, 2 ); @@ -407,9 +390,7 @@ void bands_and_bit_alloc_ivas_fx( { nb_bands_max = add( nb_bands, 2 ); } - ELSE -#endif - IF( GE_32( core_brate, ACELP_8k00 ) ) + ELSE IF( GE_32( core_brate, ACELP_8k00 ) ) { nb_bands_max = add( nb_bands, 1 ); } @@ -428,7 +409,7 @@ void bands_and_bit_alloc_ivas_fx( { nb_bands_max = sub( nb_bands_max, 1 ); } -#if 1 // def ADD_LRTD + IF( EQ_16( L_frame, L_FRAME16k ) ) { IF( LT_32( core_brate, ACELP_24k40 ) ) @@ -450,7 +431,6 @@ void bands_and_bit_alloc_ivas_fx( } } -#endif test(); if ( ( bwidth == NB ) && GT_16( nb_bands_max, 10 ) ) { @@ -472,7 +452,7 @@ void bands_and_bit_alloc_ivas_fx( /*------------------------------------------------------------------------ * Fractional bits to distribute on the first x bands *-----------------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + test(); IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_32k ) ) { @@ -480,10 +460,10 @@ void bands_and_bit_alloc_ivas_fx( move32(); } ELSE -#endif { bit_fracf = Find_bit_frac_fx( st_band, bit_tmp ); /*Q18*/ } + /*------------------------------------------------------------------------ * Complete the bit allocation per frequency band *-----------------------------------------------------------------------*/ @@ -501,13 +481,12 @@ void bands_and_bit_alloc_ivas_fx( move32(); /* Q18 */ bit_index = add( bit_index, 1 ); } -#if 1 // def ADD_LRTD + IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_16k40 ) ) { bit_index = 0; move16(); i = sub( imax, 1 ); - // bits_per_bands[i] += Compl_GSC_freq_bits[bit_index]; bits_per_bands[i] = L_add( bits_per_bands[i], L_shl( Compl_GSC_freq_bits[bit_index], Q18 ) ); /*Q18*/ move32(); i = add( i, 1 ); @@ -515,13 +494,12 @@ void bands_and_bit_alloc_ivas_fx( FOR( ; i < 10; i++ ) { - // bits_per_bands[i] += Compl_GSC_freq_bits[bit_index] + bit_fracf; bits_per_bands[i] = L_add( bits_per_bands[i], L_add( L_shl( Compl_GSC_freq_bits[bit_index], Q18 ), bit_fracf ) ); /*Q18*/ move32(); bit_index = add( bit_index, 1 ); } } -#endif + IF( Diff_len == 0 ) { bit_index = add( bit_index_mem, 10 ); @@ -532,7 +510,7 @@ void bands_and_bit_alloc_ivas_fx( bit_index = add( bit_index, 1 ); } } -#if 1 // def ADD_LRTD + IF( bit_fracf < 0 ) { FOR( j = 0; j < nb_tot_bands; j++ ) @@ -542,39 +520,33 @@ void bands_and_bit_alloc_ivas_fx( } } -#endif /*-------------------------------------------------------------------------- * Complete the bit allocation per frequency band for 16kHz high brate mode *--------------------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + test(); IF( EQ_16( L_frame, L_FRAME16k ) && GT_32( core_brate, ACELP_32k ) ) { FOR( j = st_band; j < nb_bands; j++ ) { - // bits_per_bands[j] = bit_new_bands; bits_per_bands[j] = L_shl( bit_new_bands, Q18 ); move32(); } - // bit_fracf = (1.0f / nb_bands) * (bit_tmp); bit_fracf = L_shl( L_mult0( idiv1616( 16384, nb_bands ), bit_tmp ), 4 ); /*Q18*/ - // etmp = 2.0f * bit_fracf / (nb_bands + 1); - etmp = divide3216( L_shr( bit_fracf, Q2 ), add( nb_bands, 1 ) ); // Q15 - // bit_fracf = etmp; - bit_fracf = L_shl( etmp, Q3 ); // Q18 + etmp = divide3216( L_shr( bit_fracf, Q2 ), add( nb_bands, 1 ) ); /* Q15 */ + + bit_fracf = L_shl( etmp, Q3 ); /* Q18 */ + FOR( j = nb_bands - 1; j >= 0; j-- ) { - // bits_per_bands[j] = etmp; - // etmp += bit_fracf; - bits_per_bands[j] = L_add( bits_per_bands[j], L_shl( etmp, Q3 ) ); // Q18 + bits_per_bands[j] = L_add( bits_per_bands[j], L_shl( etmp, Q3 ) ); /* Q18 */ move32(); etmp = extract_l( L_add( etmp, L_shr( bit_fracf, Q3 ) ) ); } } ELSE -#endif { FOR( j = st_band; j < nb_bands; j++ ) { @@ -688,6 +660,7 @@ void bands_and_bit_alloc_ivas_fx( } } } + /*-------------------------------------------------------------------------- * Bit sum verification for GSC inactive at very high rate * The maximum number of bits per band of length 16 is 112 @@ -724,19 +697,20 @@ void bands_and_bit_alloc_ivas_fx( move32(); /* Q18 */ } } + /*-------------------------------------------------------------------------- * second step of bit sum verification, normally sum_bit == *bit *--------------------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + sum_bit = 0; move32(); FOR( i = 0; i < nb_bands; i++ ) { - // bits_per_bands[i] = (float)floor(bits_per_bands[i]); bits_per_bands[i] = L_shl( L_shr( bits_per_bands[i], Q18 ), Q18 ); move32(); sum_bit = L_add( sum_bit, L_shr( bits_per_bands[i], Q18 ) ); /*Q0*/ } + test(); IF( GSC_IVAS_mode != 0 && LT_32( sum_bit, *bit ) ) /* If we need to add bits, we are doing it on the LF */ { @@ -755,23 +729,7 @@ void bands_and_bit_alloc_ivas_fx( w_sum_bit = add( w_sum_bit, out_bits_per_bands[i] ); /* Q3 */ } tmp = shl( *bit, 3 ); -#else - IF( GT_16( tmp, w_sum_bit ) ) - { - i = sub( nb_bands, 1 ); - move16(); - FOR( ; tmp > w_sum_bit; w_sum_bit += ( 1 << 3 ) ) - { - out_bits_per_bands[i] = add( out_bits_per_bands[i], 1 << 3 ); - move16(); - i = sub( i, 1 ); - IF( i == 0 ) - { - i = sub( nb_bands, 1 ); - } - } - } -#endif + /*-------------------------------------------------------------------------- * Recompute the real number/length of frequency bands to encode *--------------------------------------------------------------------------*/ @@ -790,7 +748,6 @@ void bands_and_bit_alloc_ivas_fx( Copy( exc_diff + shl( max_ener_band[j], 4 ), concat_in + shl( j, 4 ), 16 ); } } -#if 1 // def ADD_LRTD } ELSE /* *bit == 0 */ { @@ -800,10 +757,11 @@ void bands_and_bit_alloc_ivas_fx( *pvq_len = 0; move16(); } -#endif + return; } -#if 1 // def ADD_LRTD + + /*-------------------------------------------------------------------* * reajust_bits() * @@ -924,26 +882,28 @@ static Word32 Find_bit_frac_fx( return ( L_out ); } -static Word16 Find_bit_alloc_IVAS_fx( /*o: Number of band to encode */ - const Word32 core_brate, /* i : core bit rate */ - const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ - const Word16 Diff_len, /* i : Length of the difference signal (before pure spectral)*/ - const Word16 nb_tot_bands_in, /* i : total number of band */ - Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ - Word16 *max_ener_band, /* i/o: Energy based sorted order */ - Word16 *ener_vec, /* i/o: Energy per band order */ - Word32 *bits_per_bands /* o : Number of bit allowed per allowed subband Q18 */ + +/* o : Number of band to encode */ +static Word16 Find_bit_alloc_IVAS_fx( + const Word32 core_brate, /* i : core bit rate */ + const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ + const Word16 Diff_len, /* i : Length of the difference signal (before pure spectral)*/ + const Word16 nb_tot_bands_in, /* i : total number of band */ + Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ + Word16 *max_ener_band, /* i/o: Energy based sorted order */ + Word16 *ener_vec, /* i/o: Energy per band order */ + Word32 *bits_per_bands /* o : Number of bit allowed per allowed subband Q18 */ ) { Word32 mp, mb, nb_bands_adj, bit_adj; Word16 nb_pulse_per_band[MBANDS_GN_BITALLOC16k]; - Word32 SWB_bit_budget; // Q0 -> Q18 + Word32 SWB_bit_budget; /* Q0 -> Q18 */ Word16 i, j, nb_bands_max, st_band, nb_tot_bands_loc, etmp; Word32 sum_bit /*Q18*/, bit_fracf /*Q18*/; Word16 d_tmp, e_div, tmp16; Word32 Ltmp, etmp_32fx; - SWB_bit_budget = *bit; // Q0 + SWB_bit_budget = *bit; /* Q0 */ st_band = 5; nb_bands_max = nb_tot_bands_in; @@ -993,12 +953,12 @@ static Word16 Find_bit_alloc_IVAS_fx( /*o: Number IF( EQ_16( GSC_IVAS_mode, 1 ) && LT_32( core_brate, GSC_L_RATE_STG ) ) { /* nb_bands_adj = 0.0125f * SWB_bit_budget - 0.75f;*/ - nb_bands_adj = L_sub( Mpy_32_32( Q31_0_0125, L_shl( SWB_bit_budget, Q18 ) ), Q18_0_75 ); // Q18 + nb_bands_adj = L_sub( Mpy_32_32( Q31_0_0125, L_shl( SWB_bit_budget, Q18 ) ), Q18_0_75 ); /* Q18 */ } ELSE IF( NE_16( GSC_IVAS_mode, 2 ) && GT_32( core_brate, GSC_H_RATE_STG ) ) { /*nb_bands_adj = 0.02f * SWB_bit_budget - 1.2f;*/ - nb_bands_adj = L_sub( Mpy_32_32( Q31_0_02, L_shl( SWB_bit_budget, Q18 ) ), Q18_1_2 ); // Q18 + nb_bands_adj = L_sub( Mpy_32_32( Q31_0_02, L_shl( SWB_bit_budget, Q18 ) ), Q18_1_2 ); /* Q18 */ } /*nb_bands_max = (int16_t)(nb_bands_max * nb_bands_adj + 0.5f);*/ @@ -1131,7 +1091,7 @@ static Word16 Find_bit_alloc_IVAS_fx( /*o: Number move32(); } mb = L_sub( mb, bit_fracf ); - SWB_bit_budget = L_sub( SWB_bit_budget, bits_per_bands[max_ener_band[j]] ); // Q18 + SWB_bit_budget = L_sub( SWB_bit_budget, bits_per_bands[max_ener_band[j]] ); /* Q18 */ } } @@ -1192,17 +1152,23 @@ static Word16 Find_bit_alloc_IVAS_fx( /*o: Number move32(); } } + return nb_tot_bands_loc; } -static Word16 Find_norm_inv_fx( const Word32 ToDivide, Word16 *e_div ) /* Find normalized 1 / ToDivide */ + +/* Find normalized 1 / ToDivide */ +static Word16 Find_norm_inv_fx( + const Word32 ToDivide, + Word16 *e_div ) { Word16 d_tmp, e_tmp; + e_tmp = norm_l( ToDivide ); d_tmp = round_fx( L_shl( ToDivide, e_tmp ) ); d_tmp = div_s( 16384, d_tmp ); /* 1.0 in Q14, dividend is normalize so >= 16384 as required for the division */ *e_div = sub( 14, e_tmp ); move16(); + return d_tmp; } -#endif diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index d2a576dbe..2e00e4641 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -793,7 +793,6 @@ void highband_exc_dct_in_fx( { IF( exc_diffQ[i] == 0 ) { - // PMT("code below to be validated for IVAS use") /* exc_diffQ[i] += 2.0f * noisepb[0] * ((float)own_random(seed_tcx) / PCM16_TO_FLT_FAC);*/ tmp = mult( shl( noisepb[0], 1 ), Random( seed_tcx ) ); /*Q15 */ tmp = shr( tmp, sub( 15, Qexc_diffQ ) ); /*qNoise_fac */ @@ -876,66 +875,7 @@ void highband_exc_dct_in_fx( /*--------------------------------------------------------------------------------------* * Apply decoded gain onto the difference signal *--------------------------------------------------------------------------------------*/ -#ifdef ADD_LRTD - if ( GSC_IVAS_mode >= 1 ) - { - float scale_factLF = 0.9f; - float scale_factHF = 0.9f; - - if ( GSC_IVAS_mode == 1 && GSC_noisy_speech == 0 ) - { - scale_factHF = 0.8f; - } - else if ( GSC_IVAS_mode == 2 || GSC_noisy_speech == 1 ) - { - scale_factHF = 0.71f; - } - else if ( GSC_IVAS_mode == 3 ) - { - scale_factHF = 0.9f; - } - for ( i = 0; i < pit_band_idx * 16; i++ ) - { - exc_diffQ[i] *= scale_factLF; - } - for ( ; i < L_frame; i++ ) - { - exc_diffQ[i] *= scale_factHF; - } - } - else if ( GSC_noisy_speech ) - { - float scale_fact = 0.9f; - - if ( element_mode == IVAS_CPE_TD ) - { - if ( coder_type == INACTIVE ) - { - scale_fact = 1.0f; - } - else - { - scale_fact = 0.95f; - } - } - else if ( element_mode > IVAS_SCE ) - { - scale_fact = 0.71f; - } - for ( i = 0; i < L_frame; i++ ) - { - exc_diffQ[i] *= scale_fact; - } - } - if ( GSC_noisy_speech && element_mode > IVAS_SCE && core_brate < ACELP_7k20 ) - { - for ( i = 80; i < L_frame; i++ ) - { - exc_diffQ[i] *= ( +0.0024f * (float) i + 1.192f ); - } - } -#else IF( GSC_noisy_speech ) { FOR( i = 0; i < L_frame; i++ ) @@ -944,7 +884,7 @@ void highband_exc_dct_in_fx( move16(); } } -#endif + Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); IF( exc_wo_nf != NULL ) @@ -1232,7 +1172,6 @@ void highband_exc_dct_in_ivas_fx( { IF( exc_diffQ[i] == 0 ) { - // PMT("code below to be validated for IVAS use") /* exc_diffQ[i] += 2.0f * noisepb[0] * ((float)own_random(seed_tcx) / PCM16_TO_FLT_FAC);*/ tmp = mult( shl( noisepb[0], 1 ), Random( seed_tcx ) ); /*Q15 */ tmp = shr( tmp, sub( 15, Qexc_diffQ ) ); /*qNoise_fac */ @@ -1313,105 +1252,86 @@ void highband_exc_dct_in_ivas_fx( } } } + /*--------------------------------------------------------------------------------------* * Apply decoded gain onto the difference signal *--------------------------------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + IF( GSC_IVAS_mode >= 1 ) { - // float scale_factLF = 0.9f; - Word16 scale_factLF = 29491; + Word16 scale_factLF = 29491; /* 0.9f */ move16(); - // float scale_factHF = 0.9f; - Word16 scale_factHF = 29491; + Word16 scale_factHF = 29491; /* 0.9f */ move16(); test(); test(); IF( EQ_16( GSC_IVAS_mode, 1 ) && GSC_noisy_speech == 0 ) { - // scale_factHF = 0.8f; scale_factHF = 26214; move16(); } ELSE IF( EQ_16( GSC_IVAS_mode, 2 ) || EQ_16( GSC_noisy_speech, 1 ) ) { - // scale_factHF = 0.71f; - scale_factHF = 23265; + scale_factHF = 23265; /* 0.71f */ move16(); } ELSE IF( EQ_16( GSC_IVAS_mode, 3 ) ) { - // scale_factHF = 0.9f; - scale_factHF = 29491; + scale_factHF = 29491; /* 0.9f */ move16(); } FOR( i = 0; i < pit_band_idx * 16; i++ ) { - // exc_diffQ[i] *= scale_factLF; exc_diffQ[i] = mult_r( exc_diffQ[i], scale_factLF ); } FOR( ; i < L_frame; i++ ) { - // exc_diffQ[i] *= scale_factHF; exc_diffQ[i] = mult_r( exc_diffQ[i], scale_factHF ); move16(); } } ELSE IF( GSC_noisy_speech ) { - // float scale_fact = 0.9f; - Word16 scale_fact = 29491; + Word16 scale_fact = 29491; /* 0.9f */ move16(); IF( EQ_16( element_mode, IVAS_CPE_TD ) ) { IF( coder_type == INACTIVE ) { - // scale_fact = 1.0f; - scale_fact = 32767; + scale_fact = 32767; /* 1.0f */ move16(); } ELSE { - // scale_fact = 0.95f; - scale_fact = 31129; + scale_fact = 31129; /* 0.95f */ move16(); } } ELSE IF( GT_16( element_mode, IVAS_SCE ) ) { - // scale_fact = 0.71f; - scale_fact = 23265; + scale_fact = 23265; /* 0.71f */ move16(); } FOR( i = 0; i < L_frame; i++ ) { - // exc_diffQ[i] *= scale_fact; exc_diffQ[i] = mult_r( exc_diffQ[i], scale_fact ); move16(); } } + IF( GSC_noisy_speech && GT_16( element_mode, IVAS_SCE ) && LT_32( core_brate, ACELP_7k20 ) ) { FOR( i = 80; i < L_frame; i++ ) { - // exc_diffQ[i] *= (+0.0024f * (float)i + 1.192f); + /* exc_diffQ[i] *= (+0.0024f * (float)i + 1.192f); */ exc_diffQ[i] = mult_r( shl( exc_diffQ[i], 1 ) /*Q16*/, (Word16) L_shr( L_add( 629 * i, 312475 ) /*Q18*/, Q4 ) /*Q14*/ ); move16(); } } -#else - IF( GSC_noisy_speech ) - { - FOR( i = 0; i < L_frame; i++ ) - { - exc_diffQ[i] = mult_r( exc_diffQ[i], 29491 ); - move16(); - } - } -#endif + Word16 Q_tmp = *Q_exc; move16(); Word16 Q_old = *Q_exc; diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index 9d905bcf2..2e9e5eb96 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -154,13 +154,8 @@ void pre_echo_att_fx( * In normal cases, just compute the energy of the frame *-------------------------------------------------------*/ - etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */ -#ifdef ADD_LRTD - PMTE() + etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */ etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ -#else - etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ -#endif *Last_frame_ener_fx = etmp_fx; move32(); /*2*Q_new+1*/ } diff --git a/lib_com/options.h b/lib_com/options.h index 7d65c5eac..f2014f019 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -67,14 +67,11 @@ #define BASOP_NOGLOB_DECLARE_LOCAL #endif -#define IVAS_FLOAT_FIXED #define IVAS_FLOAT_FIXED_CONVERSIONS /* Temporary macro to keep track of intermediate flt to fixed and fixed to flt conversions */ #define MSAN_FIX #define FIX_TMP_714 #define BASOP_NOGLOB_TMP_715 #define EVS_FUNC_MODIFIED -//#define EVS_FLOAT_ENC -#define IVAS_CNST #define REMOVE_IVAS_UNUSED_PARAMETERS_WARNING /*temporary operation on unused EVS parameters to remove warnings, these parameters will be used in IVAS */ #define MOD_BIT_ALLOC_ROM_TABLE /* Just to highlight modification in bit allocation table and to ensure these modifications doesn't affect EVS modes*/ #define SIMPLIFY_CODE_BE // Simplify synthesis loop diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 5a6e24046..6f5519f68 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4866,24 +4866,18 @@ Word16 est_tilt_fx( /* o : tilt of the code const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ -#ifdef ADD_LRTD - , - const Word16 L_subfr /* i : Sub frame lenght */ -#endif ); -Word16 est_tilt_ivas_fx( /* o : tilt of the code Q15 */ - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic excitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ -#if 1 // def ADD_LRTD - , - const Word16 L_subfr, /* i : Sub frame length */ - const Word16 flag_tilt /* i : flag for special tilt */ -#endif +/* o : tilt of the code Q15 */ +Word16 est_tilt_ivas_fx( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic excitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr, /* i : Sub frame length */ + const Word16 flag_tilt /* i : flag for special tilt */ ); Word16 Est_tilt2( /* o : tilt of the code */ @@ -7127,30 +7121,21 @@ void dec_pit_exc_fx( const Word16 nb_subfr_fx /* i : Number of subframe considered */ , Word16 *gain_buf /*Q14*/ -#ifdef ADD_LRTD - , - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ); void dec_pit_exc_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type, /* i : coding type */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *code_fx, /* o : innovation */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - const Word16 nb_subfr_fx /* i : Number of subframe considered */ - , - Word16 *gain_buf /*Q14*/ -#if 1 // def ADD_LRTD - , + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 coder_type, /* i : coding type */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *code_fx, /* o : innovation */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + const Word16 nb_subfr_fx, /* i : Number of subframe considered */ + Word16 *gain_buf, /*Q14*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ); // pit_dec_fx.c @@ -7205,28 +7190,24 @@ Word16 pit_decode_fx( /* o : floating pitch value Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ const Word16 L_subfr /* i : subframe length */ -#ifdef ADD_LRTD - , - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ); -Word16 pit_decode_ivas_fx( /* o : floating pitch value */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - Word16 i_subfr, /* i : subframe index */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ +/* o : floating pitch value */ +Word16 pit_decode_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + Word16 i_subfr, /* i : subframe index */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ ); void pit_Q_dec_fx( diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index 6e0f7e716..968cc8359 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -639,25 +639,7 @@ void synth_mem_updt2( { lerp( old_exc + L_EXC_MEM - last_L_frame, old_exc + L_EXC_MEM - L_frame, L_frame, last_L_frame ); } -#ifdef ADD_LRTD - IF( EQ_16( dec, DEC_IVAS ) ) - { - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - /* find scaling factor */ - PME() - en1 = 1.25f * sum2_f( mem_syn2, M ); - en2 = sum2_f( mem_syn_r + L_SYN_MEM - M, M ); - loc_rat = sqrtf( en2 ) / ( sqrtf( en1 ) + 0.01f ); - /* scale synthesis filter memory */ - FOR( i = 0; i < M; i++ ) - { - mem_syn_r[L_SYN_MEM - M + i] *= loc_rat; - } - } - } -#endif /*Resamp memory*/ /*Size of LPC syn memory*/ /* 1.25/20.0 = 1.0/16.0 -> shift 4 to the right. */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 1b2207491..903a37163 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -107,9 +107,6 @@ ivas_error acelp_core_dec_fx( Word16 uc_two_stage_flag, dec; Word16 nb_bits, indice; Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag; -#ifdef ADD_LRTD - Word16 *p_tdm_Pri_pitch_buf; -#endif MUSIC_POSTFILT_HANDLE hMusicPF; BPF_DEC_HANDLE hBPF; TD_BWE_DEC_HANDLE hBWE_TD; @@ -359,9 +356,6 @@ ivas_error acelp_core_dec_fx( tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; -#ifdef ADD_LRTD - p_tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf; -#endif move16(); move16(); move16(); @@ -380,9 +374,6 @@ ivas_error acelp_core_dec_fx( move16(); } tdm_Pitch_reuse_flag = 0; -#ifdef ADD_LRTD - p_tdm_Pri_pitch_buf = NULL; -#endif move16(); } /*----------------------------------------------------------------* @@ -830,86 +821,10 @@ ivas_error acelp_core_dec_fx( /*-----------------------------------------------------------------* * LSF de-quantization and interpolation *-----------------------------------------------------------------*/ -#ifdef ADD_LRTD - if ( !tdm_lp_reuse_flag ) -#endif - { - lsf_dec_fx( st_fx, tc_subfr_fx, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, - tdm_lsfQ_PCh ); - } -#ifdef ADD_LRTD - else - { - const float *pt_interp_2; -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - if ( st->active_cnt != 1 ) - { - int16_t beta_index; - beta_index = get_next_indice( st, TDM_IC_LSF_PRED_BITS ); - tdm_SCh_lsf_reuse( DEC, st->element_brate, lsf_new, lsp_new, tdm_lsfQ_PCh, NULL, &beta_index ); - } - else - { - mvr2r( tdm_lspQ_PCh, lsp_new, M ); - mvr2r( tdm_lsfQ_PCh, lsf_new, M ); - } -#else - mvr2r( tdm_lspQ_PCh, lsp_new, M ); - mvr2r( tdm_lsfQ_PCh, lsf_new, M ); -#endif - if ( st->rate_switching_reset ) - { - /* extrapolation in case of unstable LSF convert */ - mvr2r( lsp_new, st->lsp_old, M ); - mvr2r( lsf_new, st->lsf_old, M ); - } - - pt_interp_2 = interpol_frac_12k8; - if ( tdm_low_rate_mode == 1 && st->coder_type > UNVOICED ) - { - pt_interp_2 = interpol_frac2; - } + lsf_dec_fx( st_fx, tc_subfr_fx, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, + tdm_lsfQ_PCh ); - if ( st->active_cnt == 1 ) - { - mvr2r( lsp_new, st->lsp_old, M ); - lsp2lsf( lsp_new, st->lsf_old, M, st->sr_core ); - } - - /* LSP interpolation and conversion of LSPs to A(z) */ - int_lsp( st->L_frame, st->lsp_old, lsp_new, Aq, M, pt_interp_2, 0 ); - /* Check LSF stability (distance between old LSFs and current LSFs) */ - st->stab_fac = lsf_stab( lsf_new, st->lsf_old, 0, st->L_frame ); - } - - if ( st->last_core == HQ_CORE && st->element_mode > EVS_MONO ) - { - /* Prepare ACB memory from last HQ frame */ - old_exc_s = st->old_exc + L_EXC_MEM_DEC - st->L_frame; - tmpF = *old_exc_s; - st->mem_deemph = old_exc_s[st->L_frame - 1]; - preemph( old_exc_s, st->preemph_fac, L_FRAME16k, &tmpF ); - mvr2r( old_exc_s + st->L_frame - M, st->mem_syn2, M ); - residu( Aq, M, old_exc_s, old_exc + L_EXC_MEM_DEC - st->L_frame, st->L_frame ); - } - if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO ) - { - /* Prepare ACB memory of old_bwe_exc */ -#ifdef CR_FIX_639_HQ_ACELP_TRANSITION - if ( st->L_frame == L_FRAME ) - { - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); - } - else - { - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC ); - } -#else - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); -#endif - } -#endif /*-----------------------------------------------------------------* * FEC - first good frame after lost frame(s) (possibility to correct the ACB) *-----------------------------------------------------------------*/ @@ -979,27 +894,7 @@ ivas_error acelp_core_dec_fx( test(); test(); -#ifdef ADD_LRTD - IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */ - { - IF( LE_16( st_fx->coder_type, UNVOICED ) ) - { - tdm_low_rate_dec( st_fx, dct_exc_tmp, &tmp_noise, pitch_buf, voice_factors, exc, exc2, bwe_exc, lsf_new ); - } - ELSE /* GENERIC */ - { - decod_gen_2sbfr( st_fx, sharpFlag, Aq, pitch_buf, voice_factors, exc, exc2, bwe_exc, gain_buf, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf ); - - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - tmp_noise = st_fx->lp_gainc_fx; - move16(); - } - } - } - else -#endif - IF( EQ_16( st_fx->nelp_mode_dec, 1 ) ) + IF( EQ_16( st_fx->nelp_mode_dec, 1 ) ) { /* SC-VBR - NELP frames */ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0 @@ -1033,12 +928,7 @@ ivas_error acelp_core_dec_fx( } ELSE IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) ) ) { - decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf -#ifdef ADD_LRTD - , - tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf -#endif - ); + decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf ); tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ } ELSE @@ -1676,10 +1566,7 @@ ivas_error acelp_core_dec_fx( move16(); } } -#ifdef ADD_LRTD - /* analyze pitch coherence for bass post-filter */ - bpf_pitch_coherence( st, pitch_buf ); -#endif + test(); IF( !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->bpf_off ) ) { diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 5c16bc3e9..9597a97ae 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1100,12 +1100,8 @@ ivas_error acelp_core_dec_ivas_fx( ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( ( st->coder_type == INACTIVE ) && st->inactive_coder_type_flag ) ) { /* AUDIO and INACTIVE frames (coded by GSC technology) */ - decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx -#if 1 // def ADD_LRTD - , - tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx -#endif - ); + decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx, + tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } ELSE diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 52c3e3073..f984f2ce9 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1164,8 +1164,6 @@ ivas_error core_switching_post_dec_fx( error = IVAS_ERR_OK; move32(); - // PMT("core_switching_post_dec_fx : Only handles has been converted, code needs to be entirely reviewed ") - /* Rescale synthesis in Q0 to avoid multiple rescaling after */ tmp = Find_Max_Norm16( synth, output_frame ); Scale_sig( synth, output_frame, tmp ); @@ -1560,8 +1558,6 @@ ivas_error core_switching_post_dec_ivas_fx( error = IVAS_ERR_OK; move32(); - // PMT("core_switching_post_dec_fx : Only handles has been converted, code needs to be entirely reviewed ") - /* Rescale synthesis in Q0 to avoid multiple rescaling after */ tmp = Find_Max_Norm16( synth, output_frame ); Scale_sig( synth, output_frame, tmp ); /* Qsynth + tmp */ diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index baea98a2c..415b4584e 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -71,12 +71,8 @@ void decod_amr_wb_fx( * Decode pitch lag *----------------------------------------------------------------------*/ - *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR -#ifdef ADD_LRTD - , - 0, NULL -#endif - ); + *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); + /*--------------------------------------------------------------* * Find the adaptive codebook vector *--------------------------------------------------------------*/ diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 4e18eebce..746b66819 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -41,11 +41,6 @@ void dec_pit_exc_fx( const Word16 nb_subfr_fx /* i : Number of subframe considered */ , Word16 *gain_buf /*Q14*/ -#ifdef ADD_LRTD - , - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ) { Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ @@ -179,12 +174,7 @@ void dec_pit_exc_fx( /*----------------------------------------------------------------------* * Decode pitch lag *----------------------------------------------------------------------*/ - *pt_pitch_fx = pit_decode_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx -#ifdef ADD_LRTD - , - tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf -#endif - ); + *pt_pitch_fx = pit_decode_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx ); move16(); /*--------------------------------------------------------------* @@ -207,12 +197,7 @@ void dec_pit_exc_fx( gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); - st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 -#ifdef ADD_LRTD - , - L_subfr_fx -#endif - ); + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 ); move16(); } ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */ @@ -225,12 +210,7 @@ void dec_pit_exc_fx( gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx ); - st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 -#ifdef ADD_LRTD - , - L_subfr_fx -#endif - ); + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 ); move16(); } ELSE @@ -457,22 +437,18 @@ void dec_pit_exc_fx( /* _ None */ /*==========================================================================*/ void dec_pit_exc_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type, /* i : coding type */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */ - Word16 *code_fx, /* o : innovation */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - const Word16 nb_subfr_fx /* i : Number of subframe considered */ - , - Word16 *gain_buf /*Q14*/ -#if 1 // def ADD_LRTD - , + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 coder_type, /* i : coding type */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */ + Word16 *code_fx, /* o : innovation */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + const Word16 nb_subfr_fx, /* i : Number of subframe considered */ + Word16 *gain_buf, /*Q14*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ) { Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ @@ -591,9 +567,11 @@ void dec_pit_exc_ivas_fx( set16_fx( st_fx->acelp_cfg.pitch_bits, 9, 4 ); set16_fx( st_fx->acelp_cfg.fixed_cdk_index, 14, 5 ); } + /*------------------------------------------------------------------* * ACELP subframe loop *------------------------------------------------------------------*/ + p_Aq_fx = Aq_fx; /* pointer to interpolated LPC parameters */ pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */ pt_gain = gain_buf; /* pointer to the gain buffer */ @@ -602,12 +580,8 @@ void dec_pit_exc_ivas_fx( /*----------------------------------------------------------------------* * Decode pitch lag *----------------------------------------------------------------------*/ - *pt_pitch_fx = pit_decode_ivas_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx -#if 1 // def ADD_LRTD - , - tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf -#endif - ); + + *pt_pitch_fx = pit_decode_ivas_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); move16(); /*--------------------------------------------------------------* @@ -623,6 +597,7 @@ void dec_pit_exc_ivas_fx( IF( EQ_16( use_fcb, 1 ) ) { inov_decode_fx( st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx ); + /*--------------------------------------------------------------* * Gain decoding * Estimate spectrum tilt and voicing @@ -630,18 +605,14 @@ void dec_pit_exc_ivas_fx( gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 -#if 1 // def ADD_LRTD - , - L_subfr_fx, 0 -#endif - ); + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); move16(); } ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */ { /*inov_decode_fx(st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx);*/ inov_decode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, 0, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx ); + /*--------------------------------------------------------------* * Gain decoding * Estimate spectrum tilt and voicing @@ -649,12 +620,7 @@ void dec_pit_exc_ivas_fx( gain_dec_lbr_ivas_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx ); - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 -#if 1 // def ADD_LRTD - , - L_subfr_fx, 0 -#endif - ); + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); move16(); } ELSE diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 945e149f2..5a12d1a2c 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -333,7 +333,7 @@ ivas_error evs_dec_fx( /*---------------------------------------------------------------------* * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ - // PMT("core_switching_pre_dec_fx missign args") + IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame ) ) != IVAS_ERR_OK ) { return error; @@ -346,7 +346,6 @@ ivas_error evs_dec_fx( IF( EQ_16( st_fx->core, ACELP_CORE ) ) { /* ACELP core decoder */ - IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) { return error; @@ -356,12 +355,11 @@ ivas_error evs_dec_fx( } ELSE { - // PMT("HQ core missing args") - hq_core_dec_fx( st_fx, synth_fx, &Q_synth, output_frame, hq_core_type, core_switching_flag ); Qpostd = Q_synth; move16(); } + /*---------------------------------------------------------------------* * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ @@ -382,7 +380,6 @@ ivas_error evs_dec_fx( * Pre-processing for bandwidth switching *---------------------------------------------------------------------*/ - /// PMT("bw_switching_pre_proc_fx missing args") bw_switching_pre_proc_fx( old_syn_12k8_16k_fx, st_fx ); /*---------------------------------------------------------------------* @@ -1372,7 +1369,7 @@ ivas_error evs_dec_fx( /*----------------------------------------------------------------* * Save synthesis for HQ FEC *----------------------------------------------------------------*/ - // PMT("The code below could be move to save_synthesis_hq_fec") + post_hq_delay = NS2SA_FX2( st_fx->output_Fs, POST_HQ_DELAY_NS ); IF( EQ_16( st_fx->codec_mode, MODE1 ) ) { diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 3a39f9e33..a80cfe796 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -75,12 +75,7 @@ void decod_audio_fx( /* decode GSC SWB speech flag */ test(); -#if !defined ADD_LRTD IF( st_fx->coder_type != INACTIVE && GE_32( st_fx->total_brate, ACELP_13k20 ) ) -#else - if ( st_fx->GSC_IVAS_mode >= 1 || ( st_fx->coder_type != INACTIVE && ( ( st_fx->element_mode == EVS_MONO && st_fx->total_brate >= ACELP_13k20 ) || - ( st_fx->element_mode > EVS_MONO && st_fx->total_brate > MIN_BRATE_GSC_NOISY_FLAG && st_fx->bwidth >= SWB && !st_fx->flag_ACELP16k ) ) ) ) -#endif { st_fx->GSC_noisy_speech = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */ move16(); @@ -98,30 +93,17 @@ void decod_audio_fx( } /* set bit-allocation */ -#ifdef ADD_LRTD -#ifdef NONBE_FIX_GSC_BSTR - config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#else - config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#endif -#else #ifdef NONBE_FIX_GSC_BSTR config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#endif #endif /*---------------------------------------------------------------* * Decode energy dynamics *---------------------------------------------------------------*/ -#if defined ADD_LRTD - test(); - test(); - IF( st_fx->GSC_IVAS_mode >= 1 || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && st_fx->GSC_IVAS_mode == 0 ) ) -#else + IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) ) -#endif { nb_subfr = NB_SUBFR; /* Q0 */ move16(); @@ -129,25 +111,6 @@ void decod_audio_fx( move16(); hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */ move16(); -#ifdef ADD_LRTD - if ( st_fx->GSC_IVAS_mode >= 1 ) - { - if ( st_fx->core_brate < GSC_L_RATE_STG && st_fx->GSC_IVAS_mode < 3 ) - { - nb_subfr = 2; - } - hGSCDec->noise_lev = NOISE_LEVEL_SP2; - - if ( st_fx->GSC_IVAS_mode == 3 ) /* Music like */ - { - hGSCDec->noise_lev = NOISE_LEVEL_SP0; - } - else if ( st_fx->GSC_noisy_speech == 0 ) /* speech like but not noisy */ - { - hGSCDec->noise_lev = NOISE_LEVEL_SP3; - } - } -#endif } ELSE { @@ -165,54 +128,30 @@ void decod_audio_fx( /*---------------------------------------------------------------* * Decode number of subframes *---------------------------------------------------------------*/ -#ifdef ADD_LRTD - if ( st_fx->L_frame == L_FRAME16k && ( st_fx->core_brate <= ACELP_13k20 || st_fx->coder_type == INACTIVE ) ) - { - hGSCDec->cor_strong_limit = 0; - nb_subfr = 1; - } - else -#endif + + + hGSCDec->cor_strong_limit = 1; /* Q0 */ + move16(); + nb_subfr = SWNB_SUBFR; + move16(); + + IF( GE_32( st_fx->core_brate, ACELP_9k60 ) ) { - hGSCDec->cor_strong_limit = 1; /* Q0 */ + nbits = 1; move16(); - nb_subfr = SWNB_SUBFR; + nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */ move16(); - IF( GE_32( st_fx->core_brate, ACELP_9k60 ) ) + IF( s_and( nb_frame_flg, 0x1 ) == 0 ) { - nbits = 1; + nb_subfr = 2 * SWNB_SUBFR; /* Q0 */ move16(); -#ifdef ADD_LRTD - if ( st_fx->L_frame == L_FRAME16k && st_fx->core_brate >= MIN_RATE_4SBFR ) - { - nbits = 2; - } -#endif - nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */ + hGSCDec->cor_strong_limit = 0; move16(); - - IF( s_and( nb_frame_flg, 0x1 ) == 0 ) - { - nb_subfr = 2 * SWNB_SUBFR; /* Q0 */ - move16(); - hGSCDec->cor_strong_limit = 0; - move16(); - } -#ifdef ADD_LRTD - else if ( st_fx->L_frame == L_FRAME16k && st_fx->core_brate >= MIN_RATE_4SBFR ) - { - nb_subfr = 2 * SWNB_SUBFR; /* cor_strong already set to 1 */ - } - - if ( ( nb_frame_flg >> 1 ) == 1 ) - { - nb_subfr *= 2; - } -#endif } } } + /*---------------------------------------------------------------* * Decode the last band where the adaptive (pitch) contribution is significant *---------------------------------------------------------------*/ @@ -282,13 +221,7 @@ void decod_audio_fx( * Decode adaptive (pitch) excitation contribution *---------------------------------------------------------------*/ test(); -#ifdef ADD_LRTD - if ( !( st_fx->GSC_IVAS_mode > 0 && st_fx->L_frame / nb_subfr == 2 * L_SUBFR && st_fx->GSC_IVAS_mode < 3 ) && - ( ( st_fx->core_brate >= MIN_RATE_FCB || st_fx->GSC_noisy_speech ) && - ( ( nb_subfr == NB_SUBFR && st_fx->L_frame == L_FRAME ) || ( nb_subfr == NB_SUBFR16k && st_fx->L_frame == L_FRAME16k ) ) ) ) -#else IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) && EQ_16( nb_subfr, NB_SUBFR ) ) -#endif { Word16 indice; nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; /* Q0 */ @@ -303,11 +236,9 @@ void decod_audio_fx( Es_pred_dec_fx( &Es_pred, indice, nbits, 0 ); } -#ifdef ADD_LRTD - dec_pit_exc_fx( st_fx, Aq, coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); -#else + dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf ); -#endif + IF( LT_32( st_fx->core_brate, ACELP_9k60 ) ) { minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit ); @@ -449,29 +380,12 @@ void decod_audio_fx( tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */ } - - test(); -#if defined ADD_LRTD - test(); - if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 ) -#else test(); if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) ) -#endif { tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); /* Q0 */ } -#ifdef ADD_LRTD - IF( EQ_16( st_fx->idchan, 1 ) ) - { - tmp_nb_bits_tot = add( tmp_nb_bits_tot, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ); - IF( EQ_16( st_fx->tdm_LRTD_flag, 1 ) ) - { - tmp_nb_bits_tot = sub( tmp_nb_bits_tot, STEREO_BITS_TCA ); - } - } -#endif gsc_dec_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc ); /*--------------------------------------------------------------------------------------* * iDCT transform @@ -612,26 +526,19 @@ void decod_audio_ivas_fx( } /* set bit-allocation */ -#if 1 // def ADD_LRTD #ifdef NONBE_FIX_GSC_BSTR config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #else config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); #endif -#else - config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#endif /*---------------------------------------------------------------* * Decode energy dynamics *---------------------------------------------------------------*/ -#if 1 // defined ADD_LRTD + test(); test(); IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && st_fx->GSC_IVAS_mode == 0 ) ) -#else - IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) ) -#endif { nb_subfr = NB_SUBFR; /* Q0 */ move16(); @@ -639,7 +546,7 @@ void decod_audio_ivas_fx( move16(); hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */ move16(); -#if 1 // def ADD_LRTD + IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) ) { test(); @@ -662,7 +569,6 @@ void decod_audio_ivas_fx( move16(); } } -#endif } ELSE { @@ -680,7 +586,7 @@ void decod_audio_ivas_fx( /*---------------------------------------------------------------* * Decode number of subframes *---------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + test(); test(); IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && ( LE_32( st_fx->core_brate, ACELP_13k20 ) || st_fx->coder_type == INACTIVE ) ) @@ -691,7 +597,6 @@ void decod_audio_ivas_fx( move16(); } ELSE -#endif { hGSCDec->cor_strong_limit = 1; /* Q0 */ move16(); @@ -702,14 +607,14 @@ void decod_audio_ivas_fx( { nbits = 1; /* Q0 */ move16(); -#if 1 // def ADD_LRTD + test(); if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) ) { nbits = 2; /* Q0 */ move16(); } -#endif + nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */ move16(); @@ -721,7 +626,6 @@ void decod_audio_ivas_fx( hGSCDec->cor_strong_limit = 0; move16(); } -#if 1 // def ADD_LRTD ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) ) { nb_subfr = 2 * SWNB_SUBFR; /* cor_strong already set to 1 */ @@ -732,18 +636,17 @@ void decod_audio_ivas_fx( { nb_subfr = shl( nb_subfr, 1 ); /* Q0 */ } -#endif } } } -#if 1 + test(); if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( nb_subfr, NB_SUBFR ) ) { nb_subfr = NB_SUBFR16k; /* Q0 */ move16(); } -#endif + /*---------------------------------------------------------------* * Decode the last band where the adaptive (pitch) contribution is significant *---------------------------------------------------------------*/ @@ -802,7 +705,6 @@ void decod_audio_ivas_fx( hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */ move16(); - /*--------------------------------------------------------------------------------------* * Decode adaptive (pitch) excitation contribution * Reset unvaluable part of the adaptive (pitch) excitation contribution @@ -813,7 +715,6 @@ void decod_audio_ivas_fx( * Decode adaptive (pitch) excitation contribution *---------------------------------------------------------------*/ test(); -#if 1 // def ADD_LRTD test(); test(); test(); @@ -824,9 +725,6 @@ void decod_audio_ivas_fx( IF( !( ( st_fx->GSC_IVAS_mode > 0 ) && EQ_16( idiv1616( st_fx->L_frame, nb_subfr ), 2 * L_SUBFR ) && LT_16( st_fx->GSC_IVAS_mode, 3 ) ) && ( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || st_fx->GSC_noisy_speech ) && ( ( EQ_16( nb_subfr, NB_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && EQ_16( st_fx->L_frame, L_FRAME16k ) ) ) ) ) -#else - IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) && EQ_16( nb_subfr, NB_SUBFR ) ) -#endif { Word16 indice; nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; /* Q0 */ @@ -841,11 +739,9 @@ void decod_audio_ivas_fx( Es_pred_dec_fx( &Es_pred, indice, nbits, 0 ); } -#if 1 // def ADD_LRTD + dec_pit_exc_ivas_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); -#else - dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf ); -#endif + IF( LT_32( st_fx->core_brate, ACELP_9k60 ) ) { minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit ); @@ -989,17 +885,12 @@ void decod_audio_ivas_fx( test(); -#if 1 // defined ADD_LRTD test(); if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 ) -#else - if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) ) -#endif { tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); /* Q0 */ } -#if 1 // ydef ADD_LRTD IF( EQ_16( st_fx->idchan, 1 ) ) { tmp_nb_bits_tot = add( tmp_nb_bits_tot, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ); /* Q0 */ @@ -1008,7 +899,7 @@ void decod_audio_ivas_fx( tmp_nb_bits_tot = sub( tmp_nb_bits_tot, STEREO_BITS_TCA ); /* Q0 */ } } -#endif + Word16 Q_exc_old = st_fx->Q_exc; move16(); gsc_dec_ivas_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc ); @@ -1105,7 +996,6 @@ void gsc_dec_fx( Word16 Q_exc ) { Word16 i, j, bit, nb_subbands, pvq_len; -#if 1 // def ADD_LRTD Word16 bitallocation_band[MBANDS_GN_BITALLOC16k]; Word16 bitallocation_exc[2]; Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k]; @@ -1113,15 +1003,6 @@ void gsc_dec_fx( Word16 exc_diffQ[L_FRAME16k]; Word16 bits_per_bands[MBANDS_GN_BITALLOC16k]; Word16 concat_out[L_FRAME16k]; -#else - Word16 bitallocation_band[MBANDS_GN]; - Word16 bitallocation_exc[2]; - Word16 Ener_per_bd_iQ[MBANDS_GN]; - Word16 max_ener_band[MBANDS_GN]; - Word16 exc_diffQ[L_FRAME]; - Word16 bits_per_bands[MBANDS_GN]; - Word16 concat_out[L_FRAME]; -#endif Word16 inpulses_fx[NB_SFM]; Word16 imaxpulse_fx[NB_SFM]; Word16 mean_gain; @@ -1145,22 +1026,7 @@ void gsc_dec_fx( *--------------------------------------------------------------------------------------*/ bit = bits_used; move16(); -#ifdef ADD_LRTD - test(); - test(); - test(); - test(); - IF( EQ_16( coder_type, INACTIVE ) && ( EQ_16( st_fx->tdm_LRTD_flag, 1 ) || EQ_16( st_fx->element_mode, IVAS_SCE ) ) && LE_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) ) - { - bit = add( bit, GSC_LRES_NB_NITS ); - } - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - Mbands_gn = MBANDS_GN16k; - move16(); - } -#endif set16_fx( exc_diffQ, 0, st_fx->L_frame ); /*--------------------------------------------------------------------------------------* @@ -1184,33 +1050,8 @@ void gsc_dec_fx( } ELSE { - -#ifdef ADD_LRTD - i = 0; - move16(); - While( LT_16( i, SIZE_BRATE_INTERMED_TBL ) ) - { - IF( LQ_32( st_fx->core_brate, brate_intermed_tbl[i] ) ) - { - break; - } - i = add( i, 1 ); - } - - test(); - test(); - test(); - test(); - IF( GT_16( st_fx->element_mode, EVS_MONO ) > &&EQ_16( coder_type, AUDIO ) && - LE_32( st_fx->core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation is mapped to 8 kb/s instead of 9.6 kb/s in this case */ - { - i--; - } - mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); - -#else mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q12 */ -#endif + st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ move16(); } @@ -1236,10 +1077,7 @@ void gsc_dec_fx( * reduce spectral dynamic * save spectrum *--------------------------------------------------------------------------------------*/ -#ifdef ADD_LRTD - max_eq = 32767; - move16(); -#endif + test(); IF( EQ_16( st_fx->last_good, INACTIVE_CLAS ) || EQ_16( st_fx->Last_GSC_noisy_speech_flag, 1 ) ) { @@ -1270,12 +1108,6 @@ void gsc_dec_fx( max_ener_band, bits_per_bands, &nb_subbands, NULL, NULL, &pvq_len, coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); -#ifdef ADD_LRTD - if ( bit == 0 ) - { - set16_fx( concact_out, 0, L_FRAME16k ); - } -#endif { pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ @@ -1283,17 +1115,6 @@ void gsc_dec_fx( seed_init = 0; move16(); -#ifdef ADD_LRTD - max_eq = 0.0f; - max_eq_val = 1.0f; - - if ( ( ( st_fx->core_brate < ACELP_7k20 && st_fx->GSC_noisy_speech == 1 ) || st_fx->core_brate < 6000 ) && coder_type <= UNVOICED ) - { - j = emaximum( concat_out, nb_subbands * 16, &max_eq ); - max_eq = (float) ( max_eq_val / ( fabs( concat_out[j] ) + 0.01f ) ); - max_eq = min( max_eq_val, max_eq ); - } -#endif /* Reorder Q bands */ FOR( j = 0; j < nb_subbands; j++ ) { @@ -1350,34 +1171,8 @@ void gsc_dec_fx( * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal * Gain is based on the inter-correlation gain between the pulses found and residual signal *--------------------------------------------------------------------------------------*/ -#ifdef ADD_LRTD - test(); - test(); - test(); - test(); - test(); - test(); - IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) - { - FOR( i = 64; i < st_fx->L_frame; i++ ) - { - PMT( "GSC FIX point to be done here" ) - exc_diffQ[i] *= max_eq; - } - } - ELSE IF( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( st_fx->coder_type, UNVOICED ) ) - { - FOR( i = 0; i < L_FRAME; i++ ) - { - PMT( "GSC FIX point to be done here" ) - exc_diffQ[i] *= max_eq; - } - } - else -#endif - { - freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame ); - } + + freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame ); } /*--------------------------------------------------------------------------------------* @@ -1432,7 +1227,6 @@ void gsc_dec_ivas_fx( Word16 *Q_exc ) { Word16 i, j, bit, nb_subbands, pvq_len; -#if 1 // def ADD_LRTD Word16 bitallocation_band[MBANDS_GN_BITALLOC16k]; Word16 bitallocation_exc[2]; Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k]; @@ -1441,19 +1235,10 @@ void gsc_dec_ivas_fx( Word16 bits_per_bands[MBANDS_GN_BITALLOC16k]; Word16 concat_out[L_FRAME16k]; Word16 max_eq, max_eq_val; -#else - Word16 bitallocation_band[MBANDS_GN]; - Word16 bitallocation_exc[2]; - Word16 Ener_per_bd_iQ[MBANDS_GN]; - Word16 max_ener_band[MBANDS_GN]; - Word16 exc_diffQ[L_FRAME]; - Word16 bits_per_bands[MBANDS_GN]; - Word16 concat_out[L_FRAME]; -#endif Word16 inpulses_fx[NB_SFM]; Word16 imaxpulse_fx[NB_SFM]; Word16 mean_gain; - Word16 Mbands_gn = 16; + Word16 Mbands_gn = MBANDS_GN; Word16 Qexc_diffQ = Q_PVQ_OUT; Word32 L_tmp; Word16 Q_tmp; @@ -1461,8 +1246,8 @@ void gsc_dec_ivas_fx( GSC_DEC_HANDLE hGSCDec; hGSCDec = st_fx->hGSCDec; - move16(); // for Mbands_gn - move16(); // for Qexc_diffQ + move16(); /* for Mbands_gn */ + move16(); /* for Qexc_diffQ */ set16_fx( inpulses_fx, 0, NB_SFM ); set16_fx( imaxpulse_fx, 0, NB_SFM ); @@ -1471,7 +1256,7 @@ void gsc_dec_ivas_fx( *--------------------------------------------------------------------------------------*/ bit = bits_used; move16(); -#if 1 // def ADD_LRTD + test(); test(); test(); @@ -1485,7 +1270,7 @@ void gsc_dec_ivas_fx( Mbands_gn = MBANDS_GN16k; /* Q0 */ move16(); } -#endif + set16_fx( exc_diffQ, 0, st_fx->L_frame ); /*--------------------------------------------------------------------------------------* @@ -1509,8 +1294,6 @@ void gsc_dec_ivas_fx( } ELSE { - -#if 1 // def ADD_LRTD i = 0; move16(); WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) ) @@ -1532,9 +1315,6 @@ void gsc_dec_ivas_fx( } mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ -#else - mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); -#endif st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ move16(); } @@ -1560,17 +1340,17 @@ void gsc_dec_ivas_fx( * reduce spectral dynamic * save spectrum *--------------------------------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + max_eq = 32767; move16(); -#endif + test(); IF( EQ_16( st_fx->last_good, INACTIVE_CLAS ) || EQ_16( st_fx->Last_GSC_noisy_speech_flag, 1 ) ) { FOR( i = 0; i < st_fx->L_frame; i++ ) { L_tmp = L_shr( L_mult( Random( &hGSCDec->seed_tcx ), 26214 ), 5 ); /*Q10*/ - L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); /* Q10 */ + L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); /*Q10*/ hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp ); /*Q10*/ move16(); } @@ -1594,27 +1374,24 @@ void gsc_dec_ivas_fx( max_ener_band, bits_per_bands, &nb_subbands, NULL, NULL, &pvq_len, coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); -#if 1 // def ADD_LRTD IF( bit == 0 ) { set16_fx( concat_out, 0, L_FRAME16k ); } -#endif - { - pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); + + pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); #ifdef MSAN_FIX - IF( nb_subbands > 0 ) - { - Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ - } -#else + IF( nb_subbands > 0 ) + { Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ -#endif } +#else + Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ +#endif + seed_init = 0; move16(); -#if 1 // def ADD_LRTD max_eq = 0; move16(); max_eq_val = 32767; /* 1.0f in Q15 */ @@ -1626,7 +1403,6 @@ void gsc_dec_ivas_fx( IF( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( coder_type, UNVOICED ) ) { j = maximum_fx( concat_out, imult1616( nb_subbands, 16 ), &max_eq ); - // max_eq = max_eq_val / (abs_s(concat_out[j]) + 328 /*0.01f*/ ); Word16 temp_max_eq = add( abs_s( concat_out[j] ), 10 ) /*0.01f in Q10*/; if ( LE_16( temp_max_eq, ONE_IN_Q10 ) ) { @@ -1641,7 +1417,7 @@ void gsc_dec_ivas_fx( max_eq = shl( max_eq, exp ); /* Q15 */ } } -#endif + /* Reorder Q bands */ FOR( j = 0; j < nb_subbands; j++ ) { @@ -1701,7 +1477,7 @@ void gsc_dec_ivas_fx( * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal * Gain is based on the inter-correlation gain between the pulses found and residual signal *--------------------------------------------------------------------------------------*/ -#if 1 // def ADD_LRTD + test(); test(); test(); @@ -1710,8 +1486,6 @@ void gsc_dec_ivas_fx( { FOR( i = 64; i < st_fx->L_frame; i++ ) { - // PMT("GSC FIX point to be done here") - // exc_diffQ[i] *= max_eq; exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq ); /* Q_PVQ_OUT */ move16(); } @@ -1720,14 +1494,11 @@ void gsc_dec_ivas_fx( { FOR( i = 0; i < L_FRAME; i++ ) { - // PMT("GSC FIX point to be done here") - // exc_diffQ[i] *= max_eq; exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq ); /* Q_PVQ_OUT */ move16(); } } ELSE -#endif { freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame ); } @@ -1768,17 +1539,11 @@ void GSC_dec_init( move16(); move16(); -#ifdef ADD_LRTD - set16_fx( hGSCDec->Last_GSC_spectrum_fx, 0, L_FRAME16k ); - set16_fx( hGSCDec->last_exc_dct_in_fx, 0, L_FRAME16k ); - set16_fx( hGSCDec->lt_ener_per_band_fx, 4096, MBANDS_GN_BITALLOC16k ); - set16_fx( hGSCDec->old_y_gain_fx, 0, MBANDS_GN_BITALLOC16k ); -#else set16_fx( hGSCDec->Last_GSC_spectrum_fx, 0, L_FRAME ); set16_fx( hGSCDec->last_exc_dct_in_fx, 0, L_FRAME ); set16_fx( hGSCDec->old_y_gain_fx, 0, MBANDS_GN ); set16_fx( hGSCDec->lt_ener_per_band_fx, 4096, MBANDS_GN ); /*Q12*/ -#endif + hGSCDec->last_ener_fx = 0; move16(); set16_fx( hGSCDec->last_bitallocation_band, 0, 6 ); diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c index ef65c4fcd..1ab1efe8f 100644 --- a/lib_dec/inov_dec_fx.c +++ b/lib_dec/inov_dec_fx.c @@ -113,7 +113,7 @@ void inov_decode_fx( move16(); bitcnt = s_and( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 15 ); // Q0 move16(); - // PMT("CONDITION above is missing -> idchan") + FOR( i = 0; i < wordcnt; i++ ) { indexing_indices[i] = extract_l( get_next_indice_fx( st_fx, 16 ) ); // Q0 @@ -298,7 +298,7 @@ void inov_decode_ivas_fx( move16(); bitcnt = s_and( ACELP_FIXED_CDK_BITS( st_fx->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ), 15 ); // Q0 move16(); - // PMT("CONDITION above is missing -> idchan") + FOR( i = 0; i < wordcnt; i++ ) { indexing_indices[i] = get_next_indice_fx( st_fx, 16 ); // Q0 diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index 50b5ec341..becf60759 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -664,12 +664,7 @@ void lsf_end_dec_fx( test(); test(); -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - test(); - IF( ( EQ_16( coder_type_org, GENERIC ) ) && ( EQ_32( st->sr_core, INT_FS_16k ) ) && ( mode2_flag == 0 ) && ( st->idchan == 0 ) ) -#else IF( ( EQ_16( coder_type_org, GENERIC ) ) && ( EQ_32( st->sr_core, INT_FS_16k ) ) && ( mode2_flag == 0 ) ) -#endif { /* this bit is used only for primary channel or mono */ coder_type = (Word16) get_next_indice_fx( st, 1 ); /* Q0 */ diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c index b72c2bae1..1d3e96497 100644 --- a/lib_dec/pit_dec_fx.c +++ b/lib_dec/pit_dec_fx.c @@ -333,11 +333,6 @@ Word16 pit_decode_fx( /* o : floating pitch value Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ const Word16 L_subfr /* i : subframe length */ -#ifdef ADD_LRTD - , - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -#endif ) { Word16 pitch; /*Q2*/ @@ -458,57 +453,6 @@ Word16 pit_decode_fx( /* o : floating pitch value pit_Q_dec_fx( 0, pitch_index, nBits, 4, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); } -#ifdef ADD_LRTD - ELSE IF( EQ_16( st_fx->idchan, 1 ) && ( EQ_16( tdm_Pitch_reuse_flag, 1 ) || EQ_16( nBits, 4 ) ) ) - { - test(); - test(); - /*-------------------------------------------------------* - * Pitch decoding with reusing of primary channel information - *-------------------------------------------------------*/ - Word16 loc_T0, loc_frac, delta, pit_tmp1, pit_tmp2, isubfridx; - - delta = 4; - pit_flag = L_SUBFR; - move16(); - move16(); - isubfridx = shr( i_subfr, 6 ); - IF( EQ_16( L_subfr, 2 * L_SUBFR ) ) - { - move16(); - move16(); - pit_tmp1 = tdm_Pri_pitch_buf[isubfridx]; /*tdm_Pri_pitch_buf in Q6 ->pit_tmp1 and 2 in Q6 too */ - pit_tmp2 = tdm_Pri_pitch_buf[shr( add( i_subfr, 1 ), 6 )]; - /*loc_T0 = (int16_t)(0.5f * tdm_Pri_pitch_buf[i_subfr / L_SUBFR] + 0.5f * tdm_Pri_pitch_buf[(i_subfr + L_SUBFR) / L_SUBFR]);*/ - loc_T0 = mac_r( L_mult( 16384, pit_tmp1, 16384, pit_tmp2 ) ); - /*loc_frac = (int16_t)(((0.5f * tdm_Pri_pitch_buf[i_subfr / L_SUBFR] + 0.5f * tdm_Pri_pitch_buf[(i_subfr + L_SUBFR) / L_SUBFR]) - loc_T0) * 4.0f);*/ - } - ELSE - { - /*loc_T0 = (int16_t)tdm_Pri_pitch_buf[i_subfr / L_SUBFR];*/ - loc_T0 = tdm_Pri_pitch_buf[isubfridx]; /*Q6*/ - /*loc_frac = (int16_t)((tdm_Pri_pitch_buf[i_subfr / L_SUBFR] - loc_T0) * 4.0f);*/ - } - loc_frac = shr(sub(loc_T0, shl(shr(loc_T0, 6), 6)), 4)); /* Final result in Q 2*/ - loc_T0 = shr( loc_T0, 6 ); /*Q6 -> Q0*/ - - - limit_T0_fx( L_FRAME, delta, pit_flag, *limit_flag, loc_T0, loc_frac, T0_min, T0_max ); - - IF( nBits > 0 ) - { - pit_Q_dec_fx( 0, pitch_index, nBits, delta, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); - } - ELSE - { - *T0 = loc_T0; - *T0_frac = loc_frac; - move16(); - move16(); - } - printf( "function not tested yet\n" ); - } -#endif ELSE { /*-------------------------------------------------------* diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 3c1065c24..530cd41d0 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -529,32 +529,17 @@ typedef struct tcx_dec_structure typedef struct gsc_dec_structure { - Word16 seed_tcx; /* AC mode (GSC) - seed for noise fill */ - - Word16 cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ - // Word16 cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ - - Word16 old_y_gain_fx[MBANDS_GN16k]; /* AC mode (GSC) - AR mem for low rate gain quantization */ - - Word16 noise_lev; /* AC mode (GSC) - noise level */ - // Word16 noise_lev; /* AC mode (GSC) - noise level Q0*/ - + Word16 seed_tcx; /* AC mode (GSC) - seed for noise fill */ + Word16 cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ + Word16 old_y_gain_fx[MBANDS_GN16k]; /* AC mode (GSC) - AR mem for low rate gain quantization */ + Word16 noise_lev; /* AC mode (GSC) - noise level */ Word16 lt_ener_per_band_fx[MBANDS_GN16k]; /* Q12 */ - - Word32 Last_frame_ener_fx; /* AC mode (GSC) - last frame energy */ - - Word16 Last_GSC_spectrum_fx[L_FRAME16k]; /* AC mode (GSC) - Last good GSC spectrum */ - - Word16 Last_GSC_pit_band_idx; /* AC mode (GSC) - Last pitch band index */ - // Word16 Last_GSC_pit_band_idx; /* AC mode (GSC) - Last pitch band index Q0*/ - - Word16 last_exc_dct_in_fx[L_FRAME16k]; /* AC mode (GSC) - previous excitation */ - - Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ - - Word16 last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ - // Word16 last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ - + Word32 Last_frame_ener_fx; /* AC mode (GSC) - last frame energy */ + Word16 Last_GSC_spectrum_fx[L_FRAME16k]; /* AC mode (GSC) - Last good GSC spectrum */ + Word16 Last_GSC_pit_band_idx; /* AC mode (GSC) - Last pitch band index */ + Word16 last_exc_dct_in_fx[L_FRAME16k]; /* AC mode (GSC) - previous excitation */ + Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ + Word16 last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ } GSC_DEC_DATA, *GSC_DEC_HANDLE; @@ -566,10 +551,8 @@ typedef struct gsc_dec_structure typedef struct WI_dec_structure { Word16 old_exc2_fx[L_EXC_MEM]; /* FEC - old excitation2 used in fast recovery */ - Word16 old_syn2_fx[L_EXC_MEM]; /* FEC - old syn speech used in fast recovery */ - } WI_DEC_DATA, *WI_DEC_HANDLE; diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index a294d12da..dcee88325 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -39,14 +39,10 @@ ivas_error acelp_core_enc_fx( Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn*/ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ Word16 *unbits_fx, /* o : number of unused bits Q0*/ + STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ + const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new, - const Word16 shift -#ifdef ADD_LRTD - , - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -#endif -) + const Word16 shift ) { Word16 nBits; /* reserved bits */ Word16 i; @@ -113,6 +109,8 @@ ivas_error acelp_core_enc_fx( * Initialization *------------------------------------------------------------------*/ + (void) tdm_lsfQ_PCh; + Es_pred_fx = 0; move16(); @@ -206,16 +204,14 @@ ivas_error acelp_core_enc_fx( /* TD stereo */ test(); -#ifdef ADD_LRTD IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) { tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; - tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf; + tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf_fx; } ELSE -#endif { tdm_lp_reuse_flag = 0; tdm_low_rate_mode = 0; @@ -453,78 +449,8 @@ ivas_error acelp_core_enc_fx( if ( !tdm_lp_reuse_flag ) { -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); -#else lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new ); -#endif } -#ifdef ADD_LRTD - else - { - const float *pt_interp_2; -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - if ( st->active_cnt != 1 ) - { - int16_t beta_index; - float lsf_wgts[M]; - - /* intra_frame prediction for the LSFs */ - lsp2lsf( lsp_new, lsf_new, M, 12800 ); - - Unified_weighting( &st->Bin_E[L_FFT / 2], lsf_new, lsf_wgts, st->bwidth == NB, st->coder_type == UNVOICED, st->sr_core, M ); - - tdm_SCh_lsf_reuse( ENC, st->element_brate, lsf_new, lsp_new, tdm_lsfQ_PCh, lsf_wgts, &beta_index ); - - push_indice( hBstr, IND_IC_LSF_PRED, beta_index, TDM_IC_LSF_PRED_BITS ); - } -#endif - pt_interp_2 = interpol_frac_12k8; - if ( tdm_low_rate_mode == 1 && st->coder_type > UNVOICED ) - { - pt_interp_2 = interpol_frac2; - } -#ifndef LSF_RE_USE_SECONDARY_CHANNEL - if ( st->active_cnt == 1 ) - { - mvr2r( lsp_new, st->lsp_old, M ); - lsp2lsf( lsp_new, st->lsf_old, M, st->sr_core ); - lsp2lsf( lsp_new, lsf_new, M, st->sr_core ); - } -#endif - /* LSP interpolation and conversion of LSPs to A(z) */ - int_lsp( st->L_frame, st->lsp_old, lsp_new, Aq, M, pt_interp_2, 0 ); - - /* Check LSF stability (distance between old LSFs and current LSFs) */ - st->stab_fac = lsf_stab( lsf_new, st->lsf_old, 0, st->L_frame ); - } - if ( st->last_core == HQ_CORE && st->element_mode > EVS_MONO ) - { - /* Prepare ACB memory from last HQ frame */ - tmpF = hLPDmem->old_exc[0]; - preemph( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF ); - mvr2r( hLPDmem->old_exc + st->L_frame - M, hLPDmem->mem_syn, M ); - residu( Aq, M, hLPDmem->old_exc, old_exc, st->L_frame ); - } - - if ( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO ) - { - /* Prepare ACB memory of old_bwe_exc */ -#ifdef CR_FIX_639_HQ_ACELP_TRANSITION - if ( st->L_frame == L_FRAME ) - { - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); - } - else - { - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * 2, L_EXC_MEM_DEC ); - } -#else - lerp( old_exc, old_bwe_exc, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); -#endif - } -#endif - /*---------------------------------------------------------------* * Calculation of LP residual (filtering through A[z] filter) @@ -566,26 +492,12 @@ ivas_error acelp_core_enc_fx( *------------------------------------------------------------*/ test(); test(); -#ifdef ADD_LRTD - if ( tdm_low_rate_mode ) /* tdm stereo low rate mode */ + IF( hSC_VBR->nelp_mode ) { - if ( st->coder_type <= UNVOICED ) - { - tdm_low_rate_enc( st, Aq, res, syn, exc, pitch_buf, voice_factors, bwe_exc, 0 /*attack_flag*/, lsf_new, &tmp_noise ); - } - else /* GENERIC */ - { - encod_gen_2sbfr( st, inp, Aw, Aq, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); - } + /* SC-VBR - NELP frames */ + encod_nelp_fx( st_fx, inp_fx, Aw_fx, Aq_fx, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf_fx, + voice_factors_fx, bwe_exc_fx, Q_new, shift ); } - else -#endif - IF( hSC_VBR->nelp_mode ) - { - /* SC-VBR - NELP frames */ - encod_nelp_fx( st_fx, inp_fx, Aw_fx, Aq_fx, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf_fx, - voice_factors_fx, bwe_exc_fx, Q_new, shift ); - } ELSE IF( EQ_16( coder_type, UNVOICED ) ) { /* UNVOICED frames (Gauss. excitation) */ @@ -621,11 +533,8 @@ ivas_error acelp_core_enc_fx( st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); /* redo LSF quantization */ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); -#else lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new ); -#endif + /* recalculation of LP residual (filtering through A[z] filter) */ calc_residu_fx( st_fx, inp_fx, res_fx, Aq_fx ); diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 7188bcbad..15cc1a9e7 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -338,11 +338,7 @@ void CNG_enc_fx( } ELSE { -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 100, 0, 0, NULL, Q_new ); -#else lsf_enc_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 100, 0, 0, Q_new ); -#endif } /* Reset CNG history if CNG frame length is changed */ test(); diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index e03db0c47..18948a93f 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -329,7 +329,7 @@ void enc_pit_exc_fx( inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); - // PMT("code to be validated") + /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ @@ -811,10 +811,9 @@ void enc_pit_exc_ivas_fx( * Innovation encoding *-----------------------------------------------------------------*/ - inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); - // PMT("code to be validated") + /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 0be344d72..2a621f1d5 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -115,10 +115,11 @@ void encod_unvoiced_fx( /*----------------------------------------------------------------* * Unvoiced subframe processing in two stages *----------------------------------------------------------------*/ - // PMT("The code below needs validation, never been tested") + /* No adaptive codebook (UC) */ set16_fx( y1, 0, L_SUBFR ); set16_fx( exc_fx + i_subfr, 0, L_SUBFR ); + /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure * or in case of floating point encoder & fixed p. decoder diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 3005edd6e..6970597c8 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -282,12 +282,7 @@ ivas_error evs_enc_fx( IF( EQ_16( st->core, ACELP_CORE ) ) { acelp_core_enc_fx( st, inp, ener, A, Aw, epsP_h, epsP_l, lsp_new, lsp_mid, vad_hover_flag, - attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, Q_new, shift -#ifdef ADD_LRTD - , - NULL, NULL -#endif - ); + attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, NULL, Q_new, shift ); } /*---------------------------------------------------------------------* * HQ core encoding diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 162fc41fa..f927940ae 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -2059,12 +2059,6 @@ void gain_enc_lbr_fx( move16(); /* Compute scalar product */ -#ifdef DEBUG - if ( L_subfr != L_SUBFR ) - { - PMT( "Entire function needs review to accommode for L_subfr > L_SUBFR" ); - } -#endif coeff[2] = extract_h( Dot_product12( y2, y2, L_subfr, &exp ) ); move16(); exp_coeff[2] = add( sub( exp, 18 ), shl( Q_xn, 1 ) ); /* -18 (y2 Q9) */ @@ -2272,15 +2266,11 @@ void gain_enc_lbr_fx( move16(); IF( EQ_16( nBits, 7 ) ) { -#ifdef IVAS_CODE cdbk = gp_gamma_3sfr_7b_fx; if ( clip_gain == 1 ) { size -= 28; } -#else - // PMT("gp_gamma_3sfr_7b_fx is missing") -#endif } ELSE { @@ -2375,15 +2365,11 @@ void gain_enc_lbr_fx( move16(); IF( EQ_16( nBits, 7 ) ) { -#ifdef IVAS_CODE cdbk = gp_gamma_4sfr_7b_fx; if ( clip_gain == 1 ) { size -= 25; } -#else - // PMT("gp_gamma_4sfr_7b_fx is missing") -#endif } ELSE { diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index a804c1311..8ed7e9d6c 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -785,10 +785,6 @@ void gsc_enc_fx( Word16 imaxpulse_fx[NB_SFM]; Word16 Q_tmp; Word16 seed_init; -#ifdef ADD_LRTD - Word16 max_eq_val; - Word32 max_eq; -#endif GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -896,18 +892,6 @@ void gsc_enc_fx( move16(); set16_fx( bitallocation_band, 0, MBANDS_GN_BITALLOC16k ); -#ifdef ADD_LRTD - max_eq = 0; - max_eq_val = 1.0f; - - IF( ( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( st_fx->coder_type, UNVOICED ) ) || GE_16( st_fx->GSC_IVAS_mode, 1 ) ) - { - j = emaximum( concat_out, nb_subbands * 16, &max_eq ); - max_eq = max_eq_val / ( fabsf( concat_out[j] ) + 0.01f ); - max_eq = min( max_eq_val, max_eq ); - } -#endif - FOR( j = 0; j < nb_subbands; j++ ) { Copy( concat_out + j * 16, exc_diffQ + max_ener_band[j] * 16, 16 ); /*Q12*/ @@ -963,26 +947,7 @@ void gsc_enc_fx( * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal * Gain is based on the inter-correlation gain between the pulses found and residual signal *--------------------------------------------------------------------------------------*/ -#ifdef ADD_LRTD - test(); - test(); - test(); - IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) - { - FOR( i = 64; i < st->L_frame; i++ ) - { - exc_diffQ[i] *= max_eq; - } - } - ELSE IF( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) && LE_16( st_fx->coder_type, UNVOICED ) ) - { - FOR( i = 0; i < L_FRAME; i++ ) - { - exc_diffQ[i] *= max_eq; - } - } - else -#endif + { freq_dnw_scaling_fx( hGSCEnc->cor_strong_limit, st_fx->coder_type, hGSCEnc->noise_lev, st_fx->core_brate, exc_diffQ, Q_PVQ_OUT, st_fx->L_frame ); } diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index ca8b70ca2..5de4e8e92 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -35,9 +35,8 @@ ivas_error init_encoder_fx( move16(); ISM_MODE ism_mode = ISM_MODE_NONE; ivas_error error; - // PMT("ism_mode, idchan, vad_only_flag to be move to function header") - error = IVAS_ERR_OK; + error = IVAS_ERR_OK; /*-----------------------------------------------------------------* * General signal buffers @@ -409,7 +408,7 @@ ivas_error init_encoder_fx( /*-----------------------------------------------------------------* * Noise estimator *-----------------------------------------------------------------*/ - // PMT("deal with idchan ") + test(); test(); IF( /*idchan == 0 ||*/ EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || st_fx->element_mode == EVS_MONO ) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index b4ca63bac..1f2fee684 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1410,9 +1410,6 @@ static ivas_error configureEncoder_fx( IF( EQ_16( hEncoderConfig->ivas_format, MONO_FORMAT ) ) { hIvasEnc->hCoreCoder = st_ivas->hSCE[0]->hCoreCoder[0]; /* Note: this is needed for switching in EVS mono */ - //#ifndef EVS_FLOAT_ENC - // hIvasEnc->hCoreCoder_fx = st_ivas->hSCE[0]->hCoreCoder_fx[0]; - //#endif } ELSE { diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 45a4e014a..de5e474a0 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -72,18 +72,12 @@ void lsf_enc_fx( const Word16 Nb_ACELP_frames, const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ -#endif const Word16 Q_new ) { Word16 nBits = 0; Word16 int_fs; Word16 force_sf = 0; Word16 fec_lsf[M], stab, i; -#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING - (void) tdm_low_rate_mode; -#endif #ifdef IVAS_CODE Word16 param_lpc[NPRM_LPC_NEW]; #endif @@ -191,13 +185,10 @@ void lsf_enc_fx( /*-------------------------------------------------------------------------------------* * Frame end LSF quantization *-------------------------------------------------------------------------------------*/ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - lsf_end_enc_fx( st_fx, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2, - force_sf, NULL, NULL, NULL, st_fx->coder_type_raw_fxtdm_lsfQ_PCh ); -#else + lsf_end_enc_fx( st_fx, lsf_new, lsf_new, nBits, coder_type, Q_new + QSCALE - 2, force_sf, NULL, NULL, NULL, st_fx->coder_type_raw ); -#endif + /* convert quantized LSFs back to LSPs */ lsf2lsp_fx( lsf_new, lsp_new, M, int_fs ); @@ -296,11 +287,10 @@ void lsf_enc_fx( } /* LSP interpolation and conversion of LSPs to A(z) */ -#ifdef ADD_LRTD test(); IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( coder_type, UNVOICED ) ) { - IF( EQ_16( st_fx->active_cnt_fx, 1 ) ) + IF( EQ_16( st_fx->active_cnt, 1 ) ) { Copy( lsp_mid, st_fx->lsp_old_fx, M ); lsp2lsf_fx( lsp_mid, st_fx->lsf_old_fx, M, int_fs ); @@ -311,7 +301,6 @@ void lsf_enc_fx( int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); } ELSE -#endif { int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, 0 ); } @@ -885,10 +874,6 @@ void lsf_end_enc_fx( Word16 *no_indices, Word16 *bits_param_lpc, Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - , - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -#endif ) { Word16 i; @@ -922,10 +907,6 @@ void lsf_end_enc_fx( Word16 tmp; Word16 flag_1bit_gran; BSTR_ENC_HANDLE hBstr = st->hBstr; -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - Word16 pred3[M]; - Word16 dummy, dummy_v[5]; -#endif flag_1bit_gran = (Word16) GT_16( st->element_mode, EVS_MONO ); @@ -935,11 +916,7 @@ void lsf_end_enc_fx( test(); test(); test(); -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->codec_mode, MODE1 ) && ( st->idchan == 0 ) ) /* this bit is used only for primary channel or mono */ -#else IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->codec_mode, MODE1 ) ) -#endif { IF( EQ_16( coder_type_raw, VOICED ) ) { @@ -1014,16 +991,7 @@ void lsf_end_enc_fx( pred1[i] = add( ModeMeans_fx[mode_lvq][i], mult_r( MU_MA_FX, st->mem_MA_fx[i] ) ); move16(); } -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - /* TD stereo SCh: perform intra-frame prediction with pulling-to-mean */ - if ( st->tdm_LRTD_flag == 0 && st->idchan == 1 && tdm_lsfQ_PCh != NULL ) - { - /* if secondary channel predmode is set to be > 2 */ - predmode += 3; - tdm_SCh_LSF_intra_pred( st->element_brate, tdm_lsfQ_PCh, pred3 ); - } -#endif IF( predmode == 0 ) { /* Subtract only mean */ @@ -1048,183 +1016,112 @@ void lsf_end_enc_fx( move16(); } ELSE -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - PMT( "LSF_RE_USE_SECONDARY_CHANNEL CODE IS MISSING " ) { - if ( predmode == 2 ) -#endif - { - /* Adaptive scaling factor (multiplier) is updated in order to reduce the amount of consecutive predictive frames in + /* Adaptive scaling factor (multiplier) is updated in order to reduce the amount of consecutive predictive frames in case of possible frame erasure. AR-predictive usage for VOICED mode is allowed to be higher than other modes. */ - test(); - test(); - test(); - IF( ( ( GT_16( st->pstreaklen, ( STREAKLEN + 3 ) ) ) && ( EQ_16( coder_type, VOICED ) ) ) || ( ( GT_16( st->pstreaklen, ( STREAKLEN ) ) ) && ( NE_16( coder_type, VOICED ) ) ) ) + test(); + test(); + test(); + IF( ( ( GT_16( st->pstreaklen, ( STREAKLEN + 3 ) ) ) && ( EQ_16( coder_type, VOICED ) ) ) || ( ( GT_16( st->pstreaklen, ( STREAKLEN ) ) ) && ( NE_16( coder_type, VOICED ) ) ) ) + { + /* update the adaptive scaling factor to become smaller with increasing number of concecutive predictive frames. */ + st->streaklimit_fx = mult( st->streaklimit_fx, STREAKMULT_FX ); + move16(); + } + + IF( st->pstreaklen == 0 ) + { + /* reset the consecutive AR-predictor multiplier */ + st->streaklimit_fx = 32767; /*1.0 in Q15 */ + move16(); + } + + /* VOICED_WB@16kHz */ + test(); + IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, VOICED ) && flag_1bit_gran == 0 ) + { + /* Subtract mean and AR prediction */ + Copy( ModeMeans_fx[mode_lvq], pred0, M ); + /* subtract only mean */ + Vr_subt( lsf, pred0, Tmp, M ); + + FOR( i = 0; i < M; i++ ) { - /* update the adaptive scaling factor to become smaller with increasing number of concecutive predictive frames. */ - st->streaklimit_fx = mult( st->streaklimit_fx, STREAKMULT_FX ); - move16(); + /* subtract mean and AR prediction */ + pred2[i] = mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ); + Tmp2[i] = sub( Tmp[i], pred2[i] ); + pred2[i] = add( pred2[i], pred0[i] ); } - IF( st->pstreaklen == 0 ) + /* select safety_net or predictive */ + safety_net = qlsf_Mode_Select_fx( wghts, Tmp2, st->streaklimit_fx, OP_LOOP_THR_HVO ); + IF( EQ_16( force_sf, 1 ) ) { - /* reset the consecutive AR-predictor multiplier */ - st->streaklimit_fx = 32767; /*1.0 in Q15 */ + safety_net = 1; move16(); } - /* VOICED_WB@16kHz */ - test(); - IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( coder_type, VOICED ) && flag_1bit_gran == 0 ) + IF( safety_net ) { - /* Subtract mean and AR prediction */ - Copy( ModeMeans_fx[mode_lvq], pred0, M ); - /* subtract only mean */ - Vr_subt( lsf, pred0, Tmp, M ); - - FOR( i = 0; i < M; i++ ) - { - /* subtract mean and AR prediction */ - pred2[i] = mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ); - Tmp2[i] = sub( Tmp[i], pred2[i] ); - pred2[i] = add( pred2[i], pred0[i] ); - } - - /* select safety_net or predictive */ - safety_net = qlsf_Mode_Select_fx( wghts, Tmp2, st->streaklimit_fx, OP_LOOP_THR_HVO ); - IF( EQ_16( force_sf, 1 ) ) - { - safety_net = 1; - move16(); - } - - IF( safety_net ) - { - /* Safety-net - BC-TCQ quantization : SN */ - Err[0] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net ); - st->pstreaklen = 0; - move16(); - } - ELSE - { - /* predictive - BC-TCQ quantization : AR */ - Err[1] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp2, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net ); - st->pstreaklen = add( st->pstreaklen, 1 ); - } + /* Safety-net - BC-TCQ quantization : SN */ + Err[0] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net ); + st->pstreaklen = 0; + move16(); } - /* all other frames (not VOICED@16kHz) */ ELSE { - /* Subtract mean and AR prediction */ - Copy( ModeMeans_fx[mode_lvq], pred0, M ); - /* subtract only mean */ - Vr_subt( lsf, pred0, Tmp, M ); - - FOR( i = 0; i < M; i++ ) - { - /* subtract mean and AR prediction */ - pred2[i] = add( pred0[i], mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ) ); - Tmp2[i] = sub( lsf[i], pred2[i] ); - } - - /* safety-net */ - Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); - /* Predictive quantizer is calculated only if it can be selected */ - test(); - IF( !force_sf || GT_32( Err[0], abs_threshold ) ) - { - Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, - st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, &resq[M], &lsfq[M] ); - } - test(); - test(); - /* Select whether to use safety-net (non-predictive) or predictive LSF quantizer. The decision is based on following: - if the non-predictive (safety-net) quantization error (Err[0]) is low enough (spectral distortion is low) it is selected - or if the predictively quantized error (Err[1]) is by at least adaptive margin smaller than non-predictive quantizer. - or if the in case of frame erasure the resulting concealed predictive LSF would be unstable safety-net is selected */ - IF( force_sf || LT_32( Mult_32_16( Err[0], ( st->streaklimit_fx ) ), L_add( Err[1], Mult_32_16( Err[1], PREFERSFNET_FX ) ) ) || LT_32( Err[0], abs_threshold ) ) - { - safety_net = 1; - move16(); - st->pstreaklen = 0; - move16(); /* Reset the consecutive predictive frame counter */ - } - ELSE - { - safety_net = 0; - move16(); /* Increase the consecutive predictive frame counter by one */ - st->pstreaklen = add( st->pstreaklen, 1 ); - } + /* predictive - BC-TCQ quantization : AR */ + Err[1] = qlsf_ARSN_tcvq_Enc_16k_fx( Tmp2, lsfq, TCQIdx0, wghts, sub( nBits, 1 ), safety_net ); + st->pstreaklen = add( st->pstreaklen, 1 ); } } -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - PMT( "LSF_RE_USE_SECONDARY_CHANNEL CODE IS MISSING " ) - else /* of "if (predmode==2)" */ + /* all other frames (not VOICED@16kHz) */ + ELSE { - mvr2r( ModeMeans[mode_lvq], pred0, M ); - - if ( predmode == 4 ) - { - mode_lvq_p = 9; /* force to Generic WB with AR*/ - } + /* Subtract mean and AR prediction */ + Copy( ModeMeans_fx[mode_lvq], pred0, M ); + /* subtract only mean */ + Vr_subt( lsf, pred0, Tmp, M ); - for ( i = 0; i < M; i++ ) + FOR( i = 0; i < M; i++ ) { /* subtract mean and AR prediction */ - pred2[i] = pred0[i] + Predictors[mode_lvq_p][i] * ( st->mem_AR[i] - pred0[i] ); - Tmp[i] = lsf[i] - pred2[i]; - Tmp2[i] = lsf[i] - pred3[i]; + pred2[i] = add( pred0[i], mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ) ); + Tmp2[i] = sub( lsf[i], pred2[i] ); } - /* Adaptive scaling factor (multiplier) is updated in order to reduce the amount of consecutive predictive frames in - case of possible frame erasure. AR-predictive usage for VOICED mode is allowed to be higher than other modes. */ - if ( st->pstreaklen > ( STREAKLEN ) ) + /* safety-net */ + Err[0] = vq_lvq_lsf_enc( 0, mode_lvq, Tmp, levels0, stages0, wghts, Idx0, lsf, pred0, st->offset_scale1_fx, st->offset_scale2_fx, st->no_scales_fx, resq, lsfq ); + /* Predictive quantizer is calculated only if it can be selected */ + test(); + IF( !force_sf || GT_32( Err[0], abs_threshold ) ) { - /* update the adaptive scaling factor to become smaller with increasing number of concecutive predictive frames. */ - st->streaklimit *= STREAKMULT; + Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp2, levels1, stages1, wghts, Idx1, lsf, pred2, + st->offset_scale1_p_fx, st->offset_scale2_p_fx, st->no_scales_p_fx, &resq[M], &lsfq[M] ); } - - if ( st->pstreaklen == 0 ) + test(); + test(); + /* Select whether to use safety-net (non-predictive) or predictive LSF quantizer. The decision is based on following: + if the non-predictive (safety-net) quantization error (Err[0]) is low enough (spectral distortion is low) it is selected + or if the predictively quantized error (Err[1]) is by at least adaptive margin smaller than non-predictive quantizer. + or if the in case of frame erasure the resulting concealed predictive LSF would be unstable safety-net is selected */ + IF( force_sf || LT_32( Mult_32_16( Err[0], ( st->streaklimit_fx ) ), L_add( Err[1], Mult_32_16( Err[1], PREFERSFNET_FX ) ) ) || LT_32( Err[0], abs_threshold ) ) { - /* reset the adaptive scaling factor */ - st->streaklimit = 1.0f; + safety_net = 1; + move16(); + st->pstreaklen = 0; + move16(); /* Reset the consecutive predictive frame counter */ } - - /* intra pred */ - /* use G AR pred for the intra mode (as a safety mode, this is why the indexes 0/1 are interchanged)*/ - - lsf_allocate( nBits - 1, mode_lvq, 9, &stages1, &stages0, levels1, levels0, bits1, bits0 ); - - Err[0] = vq_lvq_lsf_enc( 2, 9, Tmp2, levels0, stages0, wghts, Idx0, lsf, pred3, &resq[M], &lsfq[M] ); - - if ( force_sf ) + ELSE { - safety_net = 1; /* intra-frame prediction */ - st->pstreaklen = 0; /* Reset the consecutive predictive frame counter */ - } - else - { /* try also the inter frame prediction */ - - /* AR inter-frame prediction */ - lsf_allocate( nBits - 1, mode_lvq, mode_lvq_p, &dummy, &stages1, dummy_v, levels1, dummy_v, bits1 ); - - - Err[1] = vq_lvq_lsf_enc( 2, mode_lvq_p, Tmp, levels1, stages1, wghts, Idx1, lsf, pred2, resq, lsfq ); - - if ( Err[0] * ( st->streaklimit ) < PREFERSFNET * Err[1] ) - { - safety_net = 1; - st->pstreaklen = 0; /* Reset the consecutive predictive frame counter */ - } - else - { - safety_net = 0; - ( st->pstreaklen )++; /* Increase the consecutive predictive frame counter by one */ - } + safety_net = 0; + move16(); /* Increase the consecutive predictive frame counter by one */ + st->pstreaklen = add( st->pstreaklen, 1 ); } } } -#endif /*--------------------------------------------------------------------------* \ + + /*--------------------------------------------------------------------------* \ * Write indices to array \ *--------------------------------------------------------------------------*/ @@ -1232,22 +1129,14 @@ void lsf_end_enc_fx( { /* write coder_type bit for VOICED@16kHz or GENERIC@16kHz */ test(); -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) && ( st->idchan == 0 ) ) -#else IF( EQ_16( coder_type_org, GENERIC ) && EQ_32( st->sr_core, INT_FS_16k ) ) -#endif { /* VOICED =2 and GENERIC=3, so "coder_type-2" means VOICED =0 and GENERIC=1*/ push_indice_fx( hBstr, IND_LSF_PREDICTOR_SELECT_BIT, sub( coder_type, 2 ), 1 ); } /* write predictor selection bit */ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - IF( GE( predmode, 2 ) ) -#else IF( EQ_16( predmode, 2 ) ) -#endif { push_indice_fx( st->hBstr, IND_LSF_PREDICTOR_SELECT_BIT, safety_net, 1 ); } @@ -1267,11 +1156,7 @@ void lsf_end_enc_fx( { cumleft = nBits; move16(); -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - IF( GE( predmode, 2 ) ) -#else IF( EQ_16( predmode, 2 ) ) -#endif { /* subtract predictor selection bit */ cumleft = sub( nBits, 1 ); @@ -1434,16 +1319,6 @@ void lsf_end_enc_fx( } ELSE { -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - if ( st->tdm_LRTD_flag == 0 && st->idchan == 1 && tdm_lsfQ_PCh != NULL ) - { - /* intra mode*/ - vq_dec_lvq( 0, qlsf, &indice[0], stages0, M, 9, /*mode_lvq_p,*/ levels0[stages0 - 1] ); - v_add( qlsf, pred3, qlsf, M ); - v_sub( qlsf, pred1, st->mem_MA, M ); - } - else -#endif { vq_dec_lvq_fx( 1, qlsf, &indice[0], stages0, M, mode_lvq, levels0[stages0 - 1], &st->offset_scale1_fx[0][0], &st->offset_scale2_fx[0][0], &st->offset_scale1_p_fx[0][0], &st->offset_scale2_p_fx[0][0], @@ -2122,7 +1997,7 @@ static void first_VQstages( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ @@ -2312,7 +2187,7 @@ static void first_VQstages_ivas_fx( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 80e144743..d53e2eb6e 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -268,48 +268,6 @@ Word16 pit_encode_fx( /* o : Fractional pitc pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); } -#ifdef ADD_LRTD - else if ( tdm_Pitch_reuse_flag == 1 || nBits == 4 ) - { - /*-------------------------------------------------------* - * Pitch encoding with reusing primary channel information - *-------------------------------------------------------*/ - int16_t loc_T0, loc_frac; - - delta = 4; - - pit_flag = L_SUBFR; - - if ( L_subfr == 2 * L_SUBFR ) - { - loc_T0 = (int16_t) ( 0.5f * tdm_Pri_pitch_buf[i_subfr / L_SUBFR] + 0.5f * tdm_Pri_pitch_buf[( i_subfr + L_SUBFR ) / L_SUBFR] ); - loc_frac = (int16_t) ( ( ( 0.5f * tdm_Pri_pitch_buf[i_subfr / L_SUBFR] + 0.5f * tdm_Pri_pitch_buf[( i_subfr + L_SUBFR ) / L_SUBFR] ) - loc_T0 ) * 4.0f ); - } - else - { - loc_T0 = (int16_t) tdm_Pri_pitch_buf[i_subfr / L_SUBFR]; - loc_frac = (int16_t) ( ( tdm_Pri_pitch_buf[i_subfr / L_SUBFR] - loc_T0 ) * 4.0f ); - } - - /* pitch lag search limitation */ - limit_T0( L_FRAME, delta, pit_flag, *limit_flag, loc_T0, loc_frac, T0_min, T0_max ); - if ( nBits > 0 ) - { - /* search and encode the closed loop pitch period */ - *T0 = pitch_fr4( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR ); - if ( delta == 8 ) - { - *T0_frac = 0; - } - pit_Q_enc( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); - } - else - { - *T0 = loc_T0; - *T0_frac = loc_frac; - } - } -#endif ELSE { /*-------------------------------------------------------* diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 2e151df8f..c3e9d1b4c 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -61,14 +61,13 @@ ivas_error acelp_core_enc_fx( Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn*/ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ Word16 *unbits_fx, /* o : number of unused bits Q0*/ + STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ + const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new, const Word16 shift -#ifdef ADD_LRTD - , - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -#endif + ); + void analy_lp_ivas_fx( const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ const Word16 L_frame, /* i :(q0) length of the frame */ @@ -906,10 +905,6 @@ void lsf_end_enc_fx( Word16 *no_indices, Word16 *bits_param_lpc, Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - , - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -#endif ); void lsf_end_enc_ivas_fx( @@ -923,10 +918,10 @@ void lsf_end_enc_ivas_fx( Word16 *lpc_param, Word16 *no_indices, Word16 *bits_param_lpc, - Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/ - , + Word16 coder_type_raw, /* i : Coder type (LSF coder_type have some special cases)*/ const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); + void Mode2_abs_pit_enc_fx( Word16 T0, /* i : integer pitch lag */ Word16 T0_frac, /* i : pitch fraction */ @@ -1853,9 +1848,6 @@ void lsf_enc_fx( const Word16 Nb_ACELP_frames, const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ -#ifdef LSF_RE_USE_SECONDARY_CHANNEL - const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ -#endif const Word16 Q_new ); void lsf_enc_ivas_fx( @@ -1868,6 +1860,7 @@ void lsf_enc_ivas_fx( const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new ); + void Es_pred_enc_fx( Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ Word16 *indice, /* o : indice of quantization Q0*/ -- GitLab From 7bf5394675814ab272299e098bd3bbcb7ee1920f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 10:28:15 +0100 Subject: [PATCH 24/97] remove redundant code under IVAS_CODE_CNG --- lib_com/fd_cng_com_fx.c | 5 - lib_com/prot_fx.h | 13 - lib_dec/cng_dec_fx.c | 52 +- lib_dec/dec_acelp_tcx_main_fx.c | 22 +- lib_dec/fd_cng_dec_fx.c | 814 +------------------------------- lib_enc/fd_cng_enc_fx.c | 58 +-- 6 files changed, 9 insertions(+), 955 deletions(-) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index f4468bd0b..e04a13fdf 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -566,11 +566,6 @@ void minimum_statistics( Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ Word16 *msPeriodogBufPtr, /* i/o: Counter */ HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -#ifdef IVAS_CODE_CNG - , - const Word16 enc_dec, /* i : encoder/decoder indicator */ - const Word16 element_mode /* i : IVAS element mode type */ -#endif ) { Word16 i, j, k, s, s1, s2, s3; diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 6f5519f68..cb7416eb3 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7588,15 +7588,6 @@ void perform_noise_estimation_dec_fx( float *power_spectrum, #endif HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ -#ifdef IVAS_CODE_CNG - , - const Word16 element_mode, /* i : element mode */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 L_frame, /* i : frame length at internal Fs */ - const Word16 last_L_frame, /* i : frame length of the last frame at internal Fs */ - const Word32 last_core_brate, /* i : previous frame core bitrate */ - const Word16 VAD /* i : VAD flag in the decoder */ -#endif ); void perform_noise_estimation_dec_ivas_fx( @@ -8725,10 +8716,6 @@ Word16 dec_acelp_tcx_frame_fx( Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */ Word16 *voice_factors, /* o : voicing factors */ Word16 pitch_buf[] /* o : floating pitch for each subframe */ -#ifdef IVAS_CODE_CNG - , - STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */ -#endif ); // dec_LPD_fx.c diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index 3590dae71..e3401739e 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -1513,12 +1513,6 @@ static void shb_CNG_decod_fx( } ELSE { -#ifdef IVAS_CODE_CNG - /* de-quantization of SHB CNG parameters */ To be verified - L_tmp = L_mult( idx_ener_fx, 17615 ); /*Q13*/ - st_fx->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 147962 ), 5 ) ); /*Q8 */ - move16(); -#endif } } } @@ -1549,9 +1543,6 @@ static void shb_CNG_decod_fx( Copy_Scale_sig( shb_lpcCNG_fx, shb_lpcCNG_fx, LPC_SHB_ORDER + 1, sub( norm_s( shb_lpcCNG_fx[0] ), 2 ) ); /* Q12 */ -#ifdef IVAS_CODE_CNG - // mvr2r(shb_lpcCNG, st->hTdCngDec->shb_lpcCNG, LPC_SHB_ORDER + 1); -#endif /* SHB energy estimation */ wb_ener_fx = L_deposit_l( 1 ); /*Q1 */ FOR( i = 0; i < L_FRAME32k; i++ ) @@ -1695,9 +1686,7 @@ static void shb_CNG_decod_fx( 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 */ -#ifdef IVAS_CODE_CNG - st->hTdCngDec->shb_cng_gain = ener_fx; -#endif + 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 */ @@ -1726,11 +1715,8 @@ static void shb_CNG_decod_fx( { interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, st_fx->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 ); } -#ifdef IVAS_CODE_CNG - ResetSHBbuffer_Dec( st->hBWE_TD, st->extl ); -#else + ResetSHBbuffer_Dec_fx( st_fx ); -#endif return; } @@ -2037,20 +2023,6 @@ void td_cng_dec_init_fx( move16(); hTdCngDec->last_allow_cn_step = 0; move16(); -#ifdef IVAS_CODE_CNG - // mvr2r(st->lsp_old, st->lspCNG, M); - // hTdCngDec->shb_cng_ener = -6.02f; - IF( st->element_mode != EVS_MONO ) - { - // set_f(hTdCngDec->shb_lpcCNG, 0.0f, LPC_SHB_ORDER + 1); - // hTdCngDec->shb_lpcCNG[0] = 1.0f; - // hTdCngDec->shb_cng_gain = -82.0; /* a dB value approximately corresponding to shb index 0(used as index -15) */ - } - // hTdCngDec->wb_cng_ener = -6.02f; - // hTdCngDec->last_wb_cng_ener = -6.02f; - // hTdCngDec->last_shb_cng_ener = -6.02f; - // hTdCngDec->swb_cng_seed = RANDOM_INITSEED; -#endif hTdCngDec->ho_hist_ptr = -1; move16(); hTdCngDec->ho_sid_bw = L_deposit_l( 0 ); @@ -2081,26 +2053,6 @@ void td_cng_dec_init_fx( set16_fx( hTdCngDec->exc_mem_fx, 0, 24 ); set16_fx( hTdCngDec->exc_mem1_fx, 0, 30 ); set32_fx( hTdCngDec->old_env_fx, 0, NUM_ENV_CNG ); -#ifdef IVAS_CODE_CNG - // st->CNG_mode = -1; - // for (i = 0; i < LPC_SHB_ORDER; i++) - //{ - // IF (st->element_mode != EVS_MONO) - // { - // hTdCngDec->lsp_shb_prev[i] = 0.5f * ((float)(i + 1)) / ((float)(LPC_SHB_ORDER + 1)); - // } - // else - // { - // hTdCngDec->lsp_shb_prev[i] = 0.5f * ((float)i) / ((float)LPC_SHB_ORDER); - // } - // hTdCngDec->lsp_shb_prev_prev[i] = hTdCngDec->lsp_shb_prev[i]; - // } - - // hTdCngDec->shb_dtx_count = 0; - // hTdCngDec->trans_cnt = 0; - // hTdCngDec->last_shb_ener = 0.001f; - // set_f(hTdCngDec->interpol_3_2_cng_dec, 0.0f, INTERP_3_2_MEM_LEN); -#endif hTdCngDec->burst_cnt = 0; move16(); diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index 7edd23549..04a41ed46 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -10,12 +10,7 @@ #include "stat_com.h" #include "prot_fx.h" #include "basop_util.h" -static void decode_frame_type_fx( Decoder_State *st -#ifdef IVAS_CODE_CNG - , - STEREO_CNG_DEC_HANDLE hStereoCng -#endif -) +static void decode_frame_type_fx( Decoder_State *st ) { Word32 L_tmp; Word16 num_bits; @@ -259,9 +254,7 @@ static void decode_frame_type_fx( Decoder_State *st IF( EQ_16( st->m_frame_type, SID_FRAME ) && NE_16( st->hFdCngDec->hFdCngCom->frame_type_previous, ACTIVE_FRAME ) ) { lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth, st->hFdCngDec->hFdCngCom->olapBufferSynth, st->L_frame * 2, st->last_L_frame * 2 ); -#ifdef IVAS_CODE_CNG - lerp( hStereoCng->olapBufferSynth22, hStereoCng->olapBufferSynth22, st->L_frame * 2, st->last_L_frame * 2 ); -#endif + IF( EQ_16( st->L_frame, L_FRAME ) ) { FOR( n = 0; n < shl( st->L_frame, 1 ); n++ ) @@ -311,10 +304,6 @@ Word16 dec_acelp_tcx_frame_fx( Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation Q0 */ Word16 *voice_factors, /* o : voicing factors Q15 */ Word16 pitch_buf[] /* o : floating pitch for each subframe Q6 */ -#ifdef IVAS_CODE_CNG - , - STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */ -#endif ) { Word16 num_bits; @@ -366,12 +355,7 @@ Word16 dec_acelp_tcx_frame_fx( Word32 total_brate = st->last_total_brate; move32(); - decode_frame_type_fx( st -#ifdef IVAS_CODE_CNG - , - hStereoCng -#endif - ); + decode_frame_type_fx( st ); st->force_lpd_reset = 0; move16(); diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 70c4760ae..c509d5d10 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -279,30 +279,6 @@ void initFdCngDec_fx( hFdCngDec->smoothed_psd_exp = 0; move16(); -#ifdef IVAS_CODE_CNG - set_f( hFdCngDec->hFdCngCom->sidNoiseEstLp, 0.0f, NPART ); - - set_f( hFdCngDec->smoothed_psd, 0.0f, L_FRAME16k ); - set_f( hFdCngDec->msPeriodog_ST, 0.0f, NPART_SHAPING ); - - hFdCngDec->ms_last_inactive_bwidth = NB; - hFdCngDec->ms_cnt_bw_up = 0; - - hFdCngDec->cna_LR_LT = 0.5f; - hFdCngDec->cna_ILD_LT = 0.0f; - hFdCngDec->first_cna_noise_updated = 0; - hFdCngDec->first_cna_noise_update_cnt = 0; - hFdCngDec->cna_nbands = 6; - mvs2s( cna_init_bands, hFdCngDec->cna_band_limits, MAX_CNA_NBANDS + 1 ); - hFdCngDec->cna_act_fact = 1.0f; - hFdCngDec->cna_rescale_fact = 0.0f; - hFdCngDec->cna_seed = 5687; - set_zero( hFdCngDec->cna_cm, STEREO_DFT_BAND_MAX ); - set_zero( hFdCngDec->cna_g_state, STEREO_DFT_BAND_MAX ); - - st->CNG_mode = -1; - mvr2r( st->lsp_old, st->lspCNG, M ); -#endif return; } /* @@ -1032,12 +1008,6 @@ Word16 ApplyFdCng_fx( hFdCngCom->psize_inv, hFdCngDec->partNoiseShape, &hFdCngDec->partNoiseShape_exp ); -#ifdef IVAS_CODE_CNG - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - Copy( hFdCngDec->hFdCngCom->sidNoiseEst, hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART ); - } -#endif } IF( EQ_16( st->m_frame_type, SID_FRAME ) ) @@ -1054,11 +1024,8 @@ Word16 ApplyFdCng_fx( { if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { -#ifdef IVAS_CODE_CNG - sidNoiseEst = hFdCngCom->sidNoiseEstLp; - move16(); -#endif } + /* Interpolate the CLDFB band levels from the SID (partition) levels */ IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) ) { @@ -1136,24 +1103,7 @@ Word16 ApplyFdCng_fx( move16(); } } -#ifdef IVAS_CODE_CNG - else if ( st->element_mode == IVAS_CPE_DFT ) - { - if ( !( hFdCngCom->msFrCnt_init_counter < hFdCngCom->msFrCnt_init_thresh ) ) - { - sidNoiseEst = hFdCngCom->sidNoiseEstLp; - j = 0; - for ( k = 0; k < hFdCngCom->nFFTpart; k++ ) - { - factor = ( sidNoiseEst[k] + DELTA ) / ( hFdCngDec->partNoiseShape[k] + DELTA ); - for ( ; j <= hFdCngCom->part[k]; j++ ) - { - cngNoiseLevel[j] = hFdCngDec->bandNoiseShape[j] * factor; - } - } - } - } -#endif + IF( EQ_16( st->codec_mode, MODE2 ) ) { /* Generate comfort noise during SID or zero frames */ @@ -1866,15 +1816,6 @@ void perform_noise_estimation_dec_fx( float *power_spectrum, #endif HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ -#ifdef IVAS_CODE_CNG - , - const int16_t element_mode, /* i : element mode */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t L_frame, /* i : frame length at internal Fs */ - const int16_t last_L_frame, /* i : frame length of the last frame at internal Fs */ - const int32_t last_core_brate, /* i : previous frame core bitrate */ - const int16_t VAD /* i : VAD flag in the decoder */ -#endif ) { Word16 i, tmp_r, tmp_i, fac, fftBuffer_exp; @@ -1883,10 +1824,6 @@ void perform_noise_estimation_dec_fx( Word16 *part, *psize_inv, *psize_norm; Word32 tmp, *fftBuffer, *periodog, *ptr_per, *ptr_r, *ptr_i; -#ifdef IVAS_CODE_CNG - PMT( "lots of code related to IVAS needs to be done " ) -#endif - /* pointer initialization */ periodog = hFdCngDec->hFdCngCom->periodog; /*Q31 - hFdCngDec->hFdCngCom->periodog_exp*/ @@ -1919,238 +1856,7 @@ void perform_noise_estimation_dec_fx( AnalysisSTFT( timeDomainInput, Q, fftBuffer, &fftBuffer_exp, hFdCngDec->hFdCngCom ); #endif fftBuffer_exp = add( fftBuffer_exp, WORD16_BITS - 1 ); -#ifdef IVAS_CODE_CNG - if ( element_mode == IVAS_CPE_TD || element_mode == IVAS_CPE_DFT ) - { - /* Calculate periodogram (squared magnitude in each FFT bin) */ - if ( startBand == 0 ) - { - ( *ptr_per ) = fftBuffer[0] * fftBuffer[0]; - ptr_per++; - ptr_r = fftBuffer + 2; - } - else - { - ptr_r = fftBuffer + 2 * startBand; - } - - ptr_i = ptr_r + 1; - - for ( ; ptr_per < periodog + stopFFTbin - startBand; ptr_per++ ) - { - ( *ptr_per ) = ( *ptr_r ) * ( *ptr_r ) + ( *ptr_i ) * ( *ptr_i ); - ptr_r += 2; - ptr_i += 2; - } - - /* Rescale to get energy/sample: it should be 2*(1/N)*(2/N), parseval relation with 1/N,*2 for nrg computed till Nyquist only, 2/N as windowed samples correspond to half a frame*/ - v_multc( periodog, 4.f / (float) ( hFdCngDec->hFdCngCom->fftlen * hFdCngDec->hFdCngCom->fftlen ), periodog, stopFFTbin - startBand ); - - /* Combine bins of power spectrum into partitions */ - i = 0; - for ( p = 0; p < npart; p++ ) - { - - /* calculate mean over all bins in power partition */ - temp = 0; - for ( ; i <= part[p]; i++ ) - { - temp += periodog[i]; - } - msPeriodog[p] = temp * psize_inv[p]; - } - - /* compensate for the loss of variance - don't do when first noise update is not completed yet due to risk of msPeriodog[p] < 0 */ - if ( hFdCngDec->first_cna_noise_updated ) - { - i = 0; - for ( p = 0; p < npart; p++ ) - { - /* calculate variance over all bins in power partition */ - temp = 0; - for ( ; i <= part[p]; i++ ) - { - delta = periodog[i] - msPeriodog[p]; - temp += delta * delta; - } - temp *= psize_inv[p]; - - /* compensate for the loss of variance */ - msPeriodog[p] = (float) ( msPeriodog[p] + sqrt( temp ) * rand_gauss( &ftemp, &hFdCngDec->cna_seed ) ); - - if ( msPeriodog[p] < 1e-5f ) - { - msPeriodog[p] = 1e-5f; - } - } - } - - /* calculate total energy (short-term and long-term) */ - enr_tot = sum_f( msPeriodog, npart ) + EPSILON; - enr_tot0 = sum_f( msNoiseEst, npart ) + EPSILON; - - /* update short-term periodogram on larger partitions */ - for ( p = CNA_ACT_DN_LARGE_PARTITION; p < npart; p++ ) - { - if ( L_frame != last_L_frame || last_core_brate <= SID_2k40 ) - { - /* core Fs has changed or last frame was SID/NO_DATA -> re-initialize short-term periodogram */ - hFdCngDec->msPeriodog_ST[p] = msPeriodog[p]; - } - else - { - hFdCngDec->msPeriodog_ST[p] = (float) ( ST_PERIODOG_FACT * hFdCngDec->msPeriodog_ST[p] + ( 1 - ST_PERIODOG_FACT ) * msPeriodog[p] ); - } - } - - /* core Fs has changed -> partitions have changed -> re-calculate long-term periodogram */ - /* part L_FRAME16k L_FRAME */ - /* ... */ - /* [55] 146 146 */ - /* [56] 174 160 */ - /* [57] 210 174 */ - /* [58] 254 190 */ - /* [59] 306 210 */ - /* [60] 317 230 */ - /* [61] 253 */ - - if ( last_L_frame == L_FRAME16k && L_frame == L_FRAME ) - { - msNoiseEst[61] = msNoiseEst[58]; - msNoiseEst[60] = min( msNoiseEst[58], msNoiseEst[57] ); - msNoiseEst[59] = msNoiseEst[57]; - msNoiseEst[58] = msNoiseEst[56]; - msNoiseEst[57] = msNoiseEst[56]; - msNoiseEst[56] = min( msNoiseEst[56], msNoiseEst[55] ); - } - else if ( last_L_frame == L_FRAME && L_frame == L_FRAME16k ) - { - msNoiseEst[56] = min( msNoiseEst[56], msNoiseEst[57] ); - msNoiseEst[57] = min( msNoiseEst[58], msNoiseEst[59] ); - msNoiseEst[58] = min( msNoiseEst[60], msNoiseEst[61] ); - msNoiseEst[59] = 0.0f; - msNoiseEst[60] = 0.0f; - msNoiseEst[61] = 0.0f; - - hFdCngDec->ms_cnt_bw_up = FIRST_CNA_NOISE_UPD_FRAMES; - } - - /* Smooth with IIR filter */ - if ( !hFdCngDec->first_cna_noise_updated ) - { - if ( !VAD ) - { - /* background noise update with moving average */ - alpha = 1.0f / ( hFdCngDec->first_cna_noise_update_cnt + 1 ); - for ( p = 0; p < npart; p++ ) - { - msNoiseEst[p] = ( 1 - alpha ) * msNoiseEst[p] + alpha * msPeriodog[p]; - } - - /* check, if we reached the required number of first CNA noise update frames */ - if ( hFdCngDec->first_cna_noise_update_cnt < FIRST_CNA_NOISE_UPD_FRAMES - 1 ) - { - hFdCngDec->first_cna_noise_update_cnt++; - } - else - { - hFdCngDec->first_cna_noise_updated = 1; - if ( hFdCngDec->hFdCngCom->msFrCnt_init_counter == 0 ) - { - hFdCngDec->hFdCngCom->msFrCnt_init_counter = 1; - } - } - } - else - { - hFdCngDec->first_cna_noise_update_cnt = 0; - } - } - else - { - hFdCngDec->hFdCngCom->msFrCnt_init_counter = 1; - if ( VAD ) - { - /* no updates during active frames except for significant energy drops */ - enr_ratio = enr_tot / enr_tot0; - if ( enr_ratio < 0.5f ) - { - /* total energy significantly decreases during active frames -> downward update */ - wght = lin_interp( enr_ratio, 0.0f, 0.8f, 0.5f, 0.95f, 1 ); - for ( p = 0; p < npart; p++ ) - { - if ( msPeriodog[p] < msNoiseEst[p] ) - { - msNoiseEst[p] = wght * msNoiseEst[p] + ( 1 - wght ) * msPeriodog[p]; - } - } - } - else - { - /* energy significantly decreases in one of the larger partitions during active frames -> downward update */ - for ( p = CNA_ACT_DN_LARGE_PARTITION; p < npart; p++ ) - { - if ( hFdCngDec->msPeriodog_ST[p] < msNoiseEst[p] ) - { - msNoiseEst[p] = (float) ( CNA_ACT_DN_FACT * msNoiseEst[p] + ( 1 - CNA_ACT_DN_FACT ) * hFdCngDec->msPeriodog_ST[p] ); - } - } - } - } - else - { - - if ( bwidth >= WB && hFdCngDec->ms_last_inactive_bwidth == NB ) - { - /* bandwidth increased -> set counter for fast initilization */ - hFdCngDec->ms_cnt_bw_up = FIRST_CNA_NOISE_UPD_FRAMES; - } - hFdCngDec->ms_last_inactive_bwidth = bwidth; - /* update background noise during inactive frames */ - ptr_per = msNoiseEst; - for ( p = 0; p < npart; p++ ) - { - enr = msPeriodog[p]; - alpha = 0.95f; - /* bandwidth increased -> do fast re-initilization */ - if ( hFdCngDec->ms_cnt_bw_up > 0 && p > 55 ) - { - alpha = 1.0f / ( hFdCngDec->ms_cnt_bw_up + 1 ); - } - else if ( enr < *ptr_per && part[p] == 1 ) - { - /* faster downward update for single-bin partitions */ - alpha = 0.8f; - } - else if ( enr > 2.0f * ( *ptr_per ) ) - { - /* prevent abrupt upward updates */ - enr = 2.0f * ( *ptr_per ); - } - - /* IIR smoothing */ - *ptr_per *= alpha; - *ptr_per += ( 1 - alpha ) * enr; - ptr_per++; - } - - if ( hFdCngDec->ms_cnt_bw_up > 0 ) - { - hFdCngDec->ms_cnt_bw_up--; - } - } - } - - mvr2r( msNoiseEst, hFdCngDec->msPsd, npart ); - - /* Expand partitions into bins of power spectrum */ - scalebands( msNoiseEst, part, nFFTpart, hFdCngDec->midband_shaping, nFFTpart, stopFFTbin - startBand, hFdCngDec->bandNoiseShape, 1 ); - mvr2r( hFdCngDec->bandNoiseShape, &hFdCngDec->smoothed_psd[startBand], stopFFTbin - startBand ); - set_zero( &hFdCngDec->smoothed_psd[stopFFTbin], L_FRAME16k - stopFFTbin ); - } - else -#endif { #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT if ( element_mode == IVAS_CPE_MDCT && power_spectrum != NULL ) @@ -2302,12 +2008,7 @@ void perform_noise_estimation_dec_fx( hFdCngDec->msNewMinFlag, hFdCngDec->msPeriodogBuf, &( hFdCngDec->msPeriodogBufPtr ), - hFdCngDec->hFdCngCom -#ifdef IVAS_CODE_CNG - , - DEC, element_mode -#endif - ); + hFdCngDec->hFdCngCom ); /* Expand MS outputs */ expand_range( hFdCngDec->msLogNoiseEst, hFdCngDec->msNoiseEst, &hFdCngDec->msNoiseEst_exp, npart ); @@ -2347,10 +2048,6 @@ void perform_noise_estimation_dec_ivas_fx( Word16 q_shift; Word32 max_l; Word16 norm_shift; -#ifdef IVAS_CODE_CNG - PMT( "lots of code related to IVAS needs to be done " ) -#endif - /* pointer initialization */ periodog = hFdCngDec->hFdCngCom->periodog; /*Q31 - hFdCngDec->hFdCngCom->periodog_exp*/ @@ -6303,508 +6000,3 @@ void FdCngDecodeDiracMDCTStereoSID_fx( return; } - - -#ifdef IVAS_CODE_CNG - -/*------------------------------------------------------------------- - * generate_stereo_masking_noise() - * - * Generate additional comfort noise (kind of noise filling) - *-------------------------------------------------------------------*/ - -void generate_stereo_masking_noise( - float *syn, /* i/o: time-domain signal */ - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ - const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ - const int16_t fadeOut, /* i : only fade out of previous state */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ -) -{ - HANDLE_FD_CNG_COM hFdCngCom; - float gamma, scale, SP_ratio; - float Np[L_FRAME16k]; - float Ns[L_FRAME16k]; - float N1[L_FRAME16k]; - float N2[L_FRAME16k]; - int16_t i; - - if ( st->idchan == 0 ) - { - hFdCngCom = st->hFdCngDec->hFdCngCom; - mvr2r( hFdCngCom->olapBufferSynth2, Np, hFdCngCom->frameSize / 2 ); - mvr2r( hStereoCng->olapBufferSynth22, Ns, hFdCngCom->frameSize / 2 ); - set_f( &Np[hFdCngCom->frameSize / 2], 0.0f, hFdCngCom->frameSize / 2 ); - set_f( &Ns[hFdCngCom->frameSize / 2], 0.0f, hFdCngCom->frameSize / 2 ); - - if ( !fadeOut ) - { - generate_masking_noise_fx( N1, hFdCngCom, hFdCngCom->frameSize, 0, 1, 0, st->element_mode, hStereoCng, nchan_out ); - /* Generate masking noise for secondary channel */ - if ( flag_sec_CNA ) - { - generate_masking_noise_fx( N2, hFdCngCom, hFdCngCom->frameSize, 0, 1, 1, st->element_mode, hStereoCng, nchan_out ); - gamma = hStereoCng->c_PS_LT * hStereoCng->c_PS_LT; - scale = 1.0f; - if ( gamma < 0.9f ) - { - gamma = gamma / ( 1 - gamma ); - gamma = (float) sqrt( gamma + 1 ) - (float) sqrt( gamma ); - scale = 1.0f / (float) sqrt( 1 + gamma * gamma ); - } - else - { - gamma = 0.0f; - } - - for ( i = 0; i < 2 * hFdCngCom->frameSize / 4; i++ ) - { - Np[i] += scale * ( N1[i] + gamma * N2[i] ); - Ns[i] += scale * sign( hStereoCng->c_PS_LT ) * ( N1[i] - gamma * N2[i] ); - } - for ( ; i < hFdCngCom->frameSize; i++ ) - { - Np[i] = scale * ( N1[i] + gamma * N2[i] ); - Ns[i] = scale * sign( hStereoCng->c_PS_LT ) * ( N1[i] - gamma * N2[i] ); - } - scale *= (float) ( hFdCngCom->fftlen / 2 ); - for ( i = 0; i < hFdCngCom->frameSize / 2; i++ ) - { - hFdCngCom->olapBufferSynth2[i] = scale * ( hFdCngCom->olapBufferSynth2[i + 5 * hFdCngCom->frameSize / 4] + gamma * hStereoCng->olapBufferSynth22[i + 5 * hFdCngCom->frameSize / 4] ); - hStereoCng->olapBufferSynth22[i] = sign( hStereoCng->c_PS_LT ) * scale * ( hFdCngCom->olapBufferSynth2[i + 5 * hFdCngCom->frameSize / 4] - gamma * hStereoCng->olapBufferSynth22[i + 5 * hFdCngCom->frameSize / 4] ); - } - } - else - { - for ( i = 0; i < hFdCngCom->frameSize / 2; i++ ) - { - Np[i] += N1[i]; - } - mvr2r( &N1[hFdCngCom->frameSize / 2], &Np[hFdCngCom->frameSize / 2], hFdCngCom->frameSize / 2 ); - scale = (float) ( hFdCngCom->fftlen / 2 ); - for ( i = 0; i < hFdCngCom->frameSize; i++ ) - { - hFdCngCom->olapBufferSynth2[i] = scale * hFdCngCom->olapBufferSynth2[i + 5 * hFdCngCom->frameSize / 4]; - } - } - } - else - { - set_f( hFdCngCom->olapBufferSynth2, 0.0f, hFdCngCom->frameSize / 2 ); - set_f( hStereoCng->olapBufferSynth22, 0.0f, hFdCngCom->frameSize / 2 ); - } - if ( flag_sec_CNA ) - { - mvr2r( Ns, hStereoCng->maskingNoiseS, hFdCngCom->frameSize ); - hStereoCng->enableSecCNA = 1; - } - else - { - set_f( hStereoCng->olapBufferSynth22, 0.0f, hFdCngCom->frameSize ); - } - - /* add masking noise */ - v_add( Np, syn, syn, hFdCngCom->frameSize ); - } - else if ( hStereoCng->enableSecCNA ) - { - SP_ratio = hStereoTD->SP_ratio_LT; /* Use long-term SP ratio based on L/R synthesis */ - /* scale and add masking noise */ - for ( i = 0; i < *hStereoCng->frameSize / 4; i++ ) - { - scale = ( ( hStereoTD->prevSP_ratio * ( *hStereoCng->frameSize / 4 - (float) i ) + SP_ratio * (float) i ) / ( *hStereoCng->frameSize / 4 ) ); - syn[i] += scale * hStereoCng->maskingNoiseS[i]; - } - for ( ; i < *hStereoCng->frameSize / 2; i++ ) - { - syn[i] += SP_ratio * hStereoCng->maskingNoiseS[i]; - } - for ( ; i < *hStereoCng->frameSize; i++ ) - { - syn[i] += SP_ratio * hStereoCng->maskingNoiseS[i]; - } - hStereoTD->prevSP_ratio = SP_ratio; - } - - return; -} - -/*------------------------------------------------------------------- - * generate_masking_noise_hf_cldfb() - * - * Generate additional comfort noise (kind of noise filling) - *-------------------------------------------------------------------*/ - -void generate_masking_noise_dirac( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ - float *Cldfb_RealBuffer, /* o : CLDFD real buffer */ - float *Cldfb_ImagBuffer, /* o : CLDFD imaginary buffer */ - const int16_t slot_index, /* i : CLDFB slot index */ - const int16_t cna_flag, /* i : CNA flag for LB and HB */ - const int16_t fd_cng_flag /* i : FD-CNG flag for HB */ -) -{ - int16_t i; - float *cngNoiseLevel = hFdCngCom->cngNoiseLevel; - float *fftBuffer = hFdCngCom->fftBuffer; - float *ptr_r; - float *ptr_i; - float *ptr_level; - int16_t *seed = &( hFdCngCom->seed ); - float scale; - - wmops_sub_start( "fd_cng_dirac" ); - - /* Init */ - scale = 0.f; - - /* Resample CLDFB memories if necessary*/ - if ( ( h_cldfb->no_channels * h_cldfb->no_col ) != hFdCngCom->frameSize ) - { - resampleCldfb( h_cldfb, hFdCngCom->frameSize * FRAMES_PER_SEC ); - } - - set_zero( Cldfb_RealBuffer, CLDFB_NO_CHANNELS_MAX ); - set_zero( Cldfb_ImagBuffer, CLDFB_NO_CHANNELS_MAX ); - - /*LB CLDFB - CNA from STFT*/ -#ifdef DEBUG_MODE_DIRAC - { - int16_t tmp_s; - tmp_s = (int16_t) ( 32768.f * 0.5f * hFdCngCom->likelihood_noisy_speech * cna_flag + 0.5f ); - dbgwrite( &tmp_s, sizeof( int16_t ), 1, hFdCngCom->frameSize / 16, "./res/ivas_dirac_likelihood_noisy.pcm" ); - } -#endif - if ( cna_flag ) - { - /* skip noise generating if level is very low, to avoid problems with possibly running into denormals */ - if ( hFdCngCom->likelihood_noisy_speech > DELTA_MASKING_NOISE ) - { - /* Compute additional CN level */ - for ( i = 0; i < 15; i++ ) - { - if ( ( hFdCngCom->CngBandwidth == scaleTable_cn_dirac[i].bwmode ) && - ( hFdCngCom->CngBitrate >= scaleTable_cn_dirac[i].bitrateFrom ) && - ( hFdCngCom->CngBitrate < scaleTable_cn_dirac[i].bitrateTo ) ) - { - break; - } - } - - scale = (float) pow( 10.f, -scaleTable_cn_dirac[i].scale / 10.f ) - 1.f; - scale *= hFdCngCom->likelihood_noisy_speech; - } - } - - /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/ - if ( cna_flag && tdBuffer != NULL ) - { - if ( scale != 0 ) - { - /*Generate LF comfort noise only at first slot, for the whole frame*/ - if ( slot_index == 0 ) - { - ptr_level = cngNoiseLevel; - - /* Generate Gaussian random noise in real and imaginary parts of the FFT bins - Amplitudes are adjusted to the estimated noise level cngNoiseLevel in each bin */ - if ( hFdCngCom->startBand == 0 ) - { - rand_gauss( &fftBuffer[0], seed ); - ptr_r = fftBuffer + 2; - fftBuffer[0] *= (float) sqrt( scale * *ptr_level ); /* DC component in FFT */ - ptr_level++; - } - else - { - fftBuffer[0] = 0.f; - set_f( fftBuffer + 2, 0.0f, 2 * ( hFdCngCom->startBand - 1 ) ); - ptr_r = fftBuffer + 2 * hFdCngCom->startBand; - } - ptr_i = ptr_r + 1; - - for ( ; ptr_level < cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; ptr_level++ ) - { - /* Real part in FFT bins */ - rand_gauss( ptr_r, seed ); - ( *ptr_r ) *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); - ptr_r += 2; - /* Imaginary part in FFT bins */ - rand_gauss( ptr_i, seed ); - ( *ptr_i ) *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); - ptr_i += 2; - } - - /* Remaining FFT bins are set to zero */ - set_f( fftBuffer + 2 * hFdCngCom->stopFFTbin, 0.0f, hFdCngCom->fftlen - 2 * hFdCngCom->stopFFTbin ); - /* Nyquist frequency is discarded */ - fftBuffer[1] = 0.f; - - /* Perform STFT synthesis */ - SynthesisSTFT( fftBuffer, tdBuffer, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn, 0, hFdCngCom, X, Y, -1, -1 ); - -#ifdef DEBUG_MODE_DIRAC - { - int16_t tmp[1000]; - - for ( i = 0; i < hFdCngCom->frameSize; i++ ) - { - tmp[i] = (int16_t) ( tdBuffer[i] + 0.5f ); - } - dbgwrite( tmp, sizeof( int16_t ), hFdCngCom->frameSize, 1, "./res/ivas_dirac_cna_fft.pcm" ); - } -#endif - } - - /* LF CLDFB*/ - cldfbAnalysis_ts( &( tdBuffer[hFdCngCom->numCoreBands * slot_index] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, hFdCngCom->numCoreBands, h_cldfb ); - } - else - { - if ( slot_index == 0 ) - { - /* very low level case - update random seeds */ - generate_masking_noise_update_seed_fx( hFdCngCom ); - - set_f( fftBuffer, 0.f, hFdCngCom->fftlen ); - - /* Perform STFT synthesis */ - SynthesisSTFT( fftBuffer, tdBuffer, hFdCngCom->olapBufferSynth2, hFdCngCom->olapWinSyn, 0, hFdCngCom, X, Y, -1, -1 ); - -#ifdef DEBUG_MODE_DIRAC - { - int16_t tmp[1000]; - - for ( i = 0; i < hFdCngCom->frameSize; i++ ) - { - tmp[i] = (int16_t) ( tdBuffer[i] + 0.5f ); - } - dbgwrite( tmp, sizeof( int16_t ), hFdCngCom->frameSize, 1, "./res/ivas_dirac_cna_fft.pcm" ); - } -#endif - } - - /* LB ana CLDFB*/ - cldfbAnalysis_ts( &( tdBuffer[hFdCngCom->numCoreBands * slot_index] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, hFdCngCom->numCoreBands, h_cldfb ); - } - } - - /*HF CLDFB - CNA and/or FD-CNG*/ - if ( fd_cng_flag ) - { - scale += 1.f; - } - if ( scale != 0 ) - { - scale *= CLDFB_SCALING_FLT * ( h_cldfb->scale * h_cldfb->scale * 8.f ); - ptr_level = hFdCngCom->cngNoiseLevel + hFdCngCom->stopFFTbin - hFdCngCom->startBand; - - for ( i = hFdCngCom->numCoreBands; i < hFdCngCom->regularStopBand; i++ ) - { - /* Real part in CLDFB band */ - rand_gauss( &Cldfb_RealBuffer[i], seed ); - Cldfb_RealBuffer[i] *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); - /* Imaginary part in CLDFB band */ - rand_gauss( &Cldfb_ImagBuffer[i], seed ); - Cldfb_ImagBuffer[i] *= (float) sqrt( ( scale * *ptr_level ) * 0.5f ); - - ptr_level++; - } - } - - wmops_sub_end(); - - return; -} - - -/*------------------------------------------------------------------- - * FdCngDecodeMDCTStereoSID() - * - * Decode FD-Cng parameters for CNG in MDCT-Stereo mode from the bitstream - * - *-------------------------------------------------------------------*/ - -void FdCngDecodeMDCTStereoSID( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -) -{ - DEC_CORE_HANDLE sts[CPE_CHANNELS]; - HANDLE_FD_CNG_COM hFdCngCom; - float *ms_ptr[CPE_CHANNELS]; - float *lr_ptr[CPE_CHANNELS]; - float logNoiseEst[CPE_CHANNELS][NPART]; - float gain[CPE_CHANNELS]; - int16_t indices[FD_CNG_stages_37bits]; - int16_t N, i, ch, p, stages; - int16_t is_out_ms; - - is_out_ms = 0; - if ( hCPE->hCoreCoder[0]->cng_sba_flag ) - { - is_out_ms = 1; - } - - N = 0; /* to avoid compilation warning */ - - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - ms_ptr[ch] = &logNoiseEst[ch][0]; - lr_ptr[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; - } - - /* decode noise shapes and gains */ - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - hFdCngCom = ( sts[ch]->hFdCngDec )->hFdCngCom; - N = hFdCngCom->npart; - hFdCngCom->sid_frame_counter++; - - if ( ch ) - { - stages = FD_CNG_JOINT_stages_25bits; - } - else - { - stages = FD_CNG_stages_37bits; - } - - /* read bitstream */ - for ( i = 0; i < stages; i++ ) - { - indices[i] = get_next_indice( sts[ch], bits_37bits[i] ); - } - { - gain[ch] = ( (float) get_next_indice( sts[ch], 7 ) - GAIN_Q_OFFSET_IVAS ) / 1.5f; - } - - /* MSVQ decoder */ - msvq_dec( cdk_37bits_ivas, NULL, NULL, stages, N, FD_CNG_maxN_37bits, indices, ms_ptr[ch], NULL ); - } - - if ( sts[0]->hFdCngDec->hFdCngCom->no_side_flag ) - { - set_zero( ms_ptr[1], NPART ); - } - - if ( is_out_ms == 0 ) - { - inverseMS( N, ms_ptr[0], ms_ptr[1], 1.f ); - } - - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom; - for ( p = 0; p < N; p++ ) - { - lr_ptr[ch][p] = powf( 10.f, ( ms_ptr[ch][p] + gain[ch] ) / 10.f ); - } - - scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel, 1 ); - - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); - } - - if ( hCPE->nchan_out == 1 && hCPE->last_element_brate <= IVAS_SID_4k4 ) - { - /* create proper M noise shape in channel zero after gains have been applied */ - for ( p = 0; p < N; p++ ) - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = 0.5f * ( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] + sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p] ); - } - } - - return; -} - - -/*------------------------------------------------------------------- - * FdCngDecodeDiracMDCTStereoSID() - * - * Decode FD-Cng parameters for CNG in 2TC DirAC mode from the bitstream - *-------------------------------------------------------------------*/ - -void FdCngDecodeDiracMDCTStereoSID( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -) -{ - DEC_CORE_HANDLE sts[CPE_CHANNELS]; - HANDLE_FD_CNG_COM hFdCngCom; - float *ms_ptr[CPE_CHANNELS]; - float *lr_ptr[CPE_CHANNELS]; - float logNoiseEst[CPE_CHANNELS][NPART]; - float gain[CPE_CHANNELS]; - int16_t indices[FD_CNG_stages_37bits]; - int16_t N, i, ch, p; - - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - sts[ch] = hCPE->hCoreCoder[ch]; - ms_ptr[ch] = &logNoiseEst[ch][0]; - lr_ptr[ch] = &sts[ch]->hFdCngDec->hFdCngCom->sidNoiseEst[0]; - ( sts[ch]->hFdCngDec )->hFdCngCom->sid_frame_counter++; - } - - /* decode noise shapes and gains */ - hFdCngCom = ( sts[0]->hFdCngDec )->hFdCngCom; - N = hFdCngCom->npart; - - /* read bitstream */ - for ( i = 0; i < FD_CNG_stages_37bits; i++ ) - { - indices[i] = get_next_indice( sts[0], bits_37bits[i] ); - } - gain[0] = ( (float) get_next_indice( sts[0], 7 ) - GAIN_Q_OFFSET_IVAS ) / 1.5f; - gain[1] = gain[0]; - - /* MSVQ decoder */ - msvq_dec( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, ms_ptr[0], NULL ); - mvr2r( ms_ptr[0], ms_ptr[1], N ); - - /*inverseMS( N, ms_ptr[0], ms_ptr[1], 1.f );*/ - - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - hFdCngCom = sts[ch]->hFdCngDec->hFdCngCom; - for ( p = 0; p < N; p++ ) - { - lr_ptr[ch][p] = powf( 10.f, ( ms_ptr[ch][p] + gain[ch] ) / 10.f ); - } - - /* NB last band energy compensation */ - if ( hFdCngCom->CngBandwidth == NB ) - { - lr_ptr[ch][N - 1] *= NB_LAST_BAND_SCALE; - } - else if ( hFdCngCom->CngBandwidth == SWB && hFdCngCom->CngBitrate <= ACELP_13k20 ) - { - lr_ptr[ch][N - 1] *= SWB_13k2_LAST_BAND_SCALE; - } - - scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, hFdCngCom->stopBand - hFdCngCom->startBand, hFdCngCom->cngNoiseLevel, 1 ); - - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, sts[ch]->preemph_fac ); - } - sts[0]->hFdCngDec->hFdCngCom->coherence = 0.0f; - sts[1]->hFdCngDec->hFdCngCom->coherence = 0.0f; - - if ( hCPE->nchan_out == 1 ) - { - /* create proper M noise shape in channel zero after gains have been applied */ - for ( p = 0; p < N; p++ ) - { - sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] = 0.5f * ( sts[0]->hFdCngDec->hFdCngCom->sidNoiseEst[p] + sts[1]->hFdCngDec->hFdCngCom->sidNoiseEst[p] ); - } - sts[0]->hFdCngDec->hFdCngCom->coherence = 0.0f; - sts[1]->hFdCngDec->hFdCngCom->coherence = 0.0f; - } - - return; -} -#endif diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 50f479d8d..97db8d2a0 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -1058,19 +1058,6 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru BSTR_ENC_HANDLE hBstr = corest->hBstr; HANDLE_FD_CNG_COM st; Word16 maxC_37bits = FD_CNG_maxC_37bits, stages_37bits = FD_CNG_stages_37bits, maxN_37bits = FD_CNG_maxN_37bits; -#ifdef IVAS_CODE_CNG - float *invTrfMatrix; - float tmpRAM[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - float dct_target[FDCNG_VQ_DCT_MAXTRUNC]; - float tot_sig_ext[FDCNG_VQ_MAX_LEN]; - const float gain_q_offset = ( st->element_mode == EVS_MONO ) ? GAIN_Q_OFFSET_EVS : GAIN_Q_OFFSET_IVAS; - /* Init */ - N = hFdCngEnc->npartDec; - - invTrfMatrix = (float *) tmpRAM; /* dynamically filled */ - set_zero( v, FDCNG_VQ_MAX_LEN ); -#endif - /* Init */ st = stenc->hFdCngCom; @@ -1120,29 +1107,6 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru v16[i] = extract_h( L_sub( v[i], gain ) ); } -#ifdef IVAS_CODE_CNG - IF( st->element_mode != EVS_MONO ) - { - /* DCT domain compressed/truncated indices used for first stage */ - /* quantization with stage1 stored in DCT24 domain, stages 2 through 6 directly dearched - in FDCNG band domain - */ - if ( N == FDCNG_VQ_MAX_LEN_WB ) - { - create_IDCT_N_Matrix( invTrfMatrix, N, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); - /* truncated DCT21 analysis */ - dctT2_N_apply_matrix( (const float *) v, dct_target, FDCNG_VQ_DCT_MAXTRUNC, N, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, DCT_T2_21_XX ); - /* truncated IDCT21 extension to 24 bands */ - extend_dctN_input( v, dct_target, N, tot_sig_ext, FDCNG_VQ_MAX_LEN, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, IDCT_T2_XX_21 ); - - mvr2r( tot_sig_ext, v, FDCNG_VQ_MAX_LEN ); /* write extended result as input to VQ stage #1 */ - } - create_IDCT_N_Matrix( invTrfMatrix, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); - msvq_enc_fx( cdk_37bits_ivas, NULL, NULL, v, levels_37bits, FD_CNG_maxC_37bits, FD_CNG_stages_37bits, w, N, FD_CNG_maxN_37bits, 1, invTrfMatrix, indices ); - msvq_dec( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix, v, NULL ); - } - ELSE -#endif { /* MSVQ encoder */ msvq_encoder( cdk_37bits, v16, levels_37bits, maxC_37bits, stages_37bits, N, maxN_37bits, indices ); @@ -1166,28 +1130,14 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru /* Apply bitrate-dependant scale */ -#ifdef IVAS_CODE_CNG - if ( st->element_mode > EVS_MONO ) - { - apply_scale( &gain, hFdCngCom->CngBandwidth, hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); - } - else -#endif { apply_scale( &gain, st->CngBandwidth, st->CngBitrate, scaleTableMono, SIZE_SCALE_TABLE_MONO ); } -#ifdef IVAS_CODE_CNG - /* Quantize gain, Q14.23 format */ - gain = L_add( gain, L_shr( gain, 1 ) ); - gain = L_add( gain, gain_q_offset /*gain_q_offset+.5 Q23*/ ); - index = extract_l( L_shr( gain, WORD32_BITS - 1 - 8 ) ); -#else /* Quantize gain, Q14.23 format */ gain = L_add( gain, L_shr( gain, 1 ) ); gain = L_add( gain, 507510784l /*60.5 Q23*/ ); index = extract_l( L_shr( gain, WORD32_BITS - 1 - 8 ) ); -#endif if ( index < 0 ) { @@ -1200,17 +1150,11 @@ void FdCng_encodeSID_fx( HANDLE_FD_CNG_ENC stenc, /* i/o: pointer to FD_CNG stru index = 127; move16(); } -#ifndef IVAS_CODE_CNG + /* gain Q14.23 format */ gain = L_shl( L_deposit_l( index ), WORD32_BITS - 1 - 8 ); gain = L_sub( gain, 503316480l /*60.0 Q23*/ ); gain = Mpy_32_16_1( gain, 21845 /*2.0f/3.0f Q15*/ ); -#else - /* gain Q14.23 format */ - gain = L_shl( L_deposit_l( index ), WORD32_BITS - 1 - 8 ); - gain = L_sub( gain, gain_q_offset /*60.0 Q23*/ ); - gain = Mpy_32_16_1( gain, 21845 /*2.0f/3.0f Q15*/ ); -#endif /* Apply gain and undo log */ -- GitLab From b2d415f2fd3b80ac464075000c7c571f9b886706 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 15:49:55 +0530 Subject: [PATCH 25/97] Partial fix for 3GPP issue 1303: Obvious spectral discrepencies between signals decoded from fixed- and floating-point encoded bitstreams at 13.2kbps with -16LKFS FOA input sampled at 48kHz and optimizations Link #1303 --- lib_enc/cod_tcx_fx.c | 106 +++++++++++++-------------------------- lib_enc/swb_bwe_enc_fx.c | 4 +- 2 files changed, 37 insertions(+), 73 deletions(-) diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 93c1dc58d..de9763df0 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -5379,13 +5379,13 @@ void TNSAnalysisStereo_fx( ) { Word16 ch, k, L_spec, L_frame, nSubframes, iFilter; - Word32 *spectrum_fx; + Word32 *spectrum_fx, sum; Encoder_State *st = NULL; TCX_ENC_HANDLE hTcxEnc = NULL; Word16 individual_decision[NB_DIV]; Word32 maxPredictionGain_fx = 0, meanPredictionGain_fx; move32(); - Word16 maxPredictionGain_e = Q31, meanPredictionGain_e; + Word16 maxPredictionGain_e = 0, meanPredictionGain_e; move16(); Word16 sum_e = 0; move16(); @@ -5544,31 +5544,21 @@ void TNSAnalysisStereo_fx( */ meanPredictionGain_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( pFilter[0]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[0]->predictionGain_e, Mpy_32_16_1( pFilter[1]->predictionGain32, 16384 /*0.5f Q15*/ ), pFilter[1]->predictionGain_e, &meanPredictionGain_e ); // meanPredictionGain_e - Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, meanPredictionGain_fx, meanPredictionGain_e ); - IF( flag < 0 ) + + /* maxPredictionGain = max( maxPredictionGain, meanPredictionGain );*/ + IF( GT_32( meanPredictionGain_fx, L_shl_sat( maxPredictionGain_fx, sub( maxPredictionGain_e, meanPredictionGain_e ) ) ) ) /* exp: meanPredictionGain_e */ { maxPredictionGain_fx = meanPredictionGain_fx; maxPredictionGain_e = meanPredictionGain_e; move32(); move16(); } - flag = BASOP_Util_Cmp_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } - Word16 flag_1 = BASOP_Util_Cmp_Mant32Exp( pFilter[1]->predictionGain32, pFilter[1]->predictionGain_e, L_deposit_h( pTnsParameters[1]->minPredictionGain ), PRED_GAIN_E ); - if ( flag_1 < 0 ) - { - flag_1 = 0; - move16(); - } + test(); test(); test(); - IF( flag && LT_32( sts[0]->element_brate, IVAS_80k ) && - flag_1 && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + IF( GT_32( pFilter[0]->predictionGain32, L_shl_sat( L_deposit_h( pTnsParameters[0]->minPredictionGain ), sub( PRED_GAIN_E, pFilter[0]->predictionGain_e ) ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) && + GT_32( pFilter[1]->predictionGain32, L_shl_sat( L_deposit_h( pTnsParameters[1]->minPredictionGain ), sub( PRED_GAIN_E, pFilter[1]->predictionGain_e ) ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) { pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ move32(); @@ -5578,39 +5568,29 @@ void TNSAnalysisStereo_fx( move16(); pFilter[0]->predictionGain = pFilter[1]->predictionGain = shl_sat( extract_h( meanPredictionGain_fx ), sub( meanPredictionGain_e, PRED_GAIN_E ) ); /* Q7 */ move16(); - move16(); - } - flag = BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ), meanPredictionGain_e, L_abs( BASOP_Util_Add_Mant32Exp( pFilter[0]->predictionGain32, pFilter[0]->predictionGain_e, L_negate( pFilter[1]->predictionGain32 ), pFilter[1]->predictionGain_e, &sum_e ) ), sum_e ); - if ( flag < 0 ) - { - flag = 0; - move16(); } - test(); - IF( flag && + sum_e = s_max( pFilter[0]->predictionGain_e, pFilter[1]->predictionGain_e ); + sum = L_abs( L_sub_sat( L_shl( pFilter[0]->predictionGain32, sub( pFilter[0]->predictionGain_e, sum_e ) ), L_shl( pFilter[1]->predictionGain32, sub( pFilter[1]->predictionGain_e, sum_e ) ) ) ); // sum_e + + IF( LT_32( L_shl_sat( sum, sub( sum_e, meanPredictionGain_e ) ), Mpy_32_16_1( meanPredictionGain_fx, SIMILAR_TNS_THRESHOLD_FX_IN_Q15 ) ) && ( EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) ) { Word16 maxAvgSqrCoef_fx = s_max( pFilter[0]->avgSqrCoef, pFilter[1]->avgSqrCoef ); // Q15 Word16 meanLtpGain_fx = add( shr( sts[0]->hTcxEnc->tcxltp_gain, 1 ), shr( sts[1]->hTcxEnc->tcxltp_gain, 1 ) ); - // maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); - flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, meanPredictionGain_fx, meanPredictionGain_e ); - IF( flag < 0 ) + + /* maxPredGain_fx = L_max( maxPredGain_fx, meanPredictionGain_fx ); */ + IF( GT_32( meanPredictionGain_fx, L_shl_sat( maxPredGain_fx, sub( maxPredGain_e, maxPredictionGain_e ) ) ) ) /* exp: meanPredictionGain_e */ { maxPredGain_fx = meanPredictionGain_fx; maxPredGain_e = meanPredictionGain_e; move32(); move16(); } - flag = BASOP_Util_Cmp_Mant32Exp( meanPredictionGain_fx, meanPredictionGain_e, L_deposit_h( pTnsParameters[0]->minPredictionGain ), PRED_GAIN_E ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } + test(); test(); - IF( flag || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) + IF( GT_32( meanPredictionGain_fx, L_shl_sat( L_deposit_h( pTnsParameters[0]->minPredictionGain ), sub( PRED_GAIN_E, meanPredictionGain_e ) ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) { test(); test(); @@ -5813,16 +5793,13 @@ void TNSAnalysisStereo_fx( move16(); } } - Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } + test(); test(); test(); - IF( !bWhitenedDomain && individual_decision[k] == 0 && flag && NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && individual_decision[k] == 0 && + LT_32( L_shl_sat( maxPredGain_fx, sub( maxPredGain_e, PRED_GAIN_E ) ), TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && + NE_16( sts[0]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[0]->hTcxEnc->bTnsOnWhithenedSpectra[k] = 1; move16(); @@ -5842,9 +5819,9 @@ void TNSAnalysisStereo_fx( ClearTnsFilterCoefficients( sts[1]->hTcxEnc->tnsData[k].filter + iFilter ); } } - // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); - flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); - IF( flag < 0 ) + + /* maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); */ + IF( GT_32( maxPredGain_fx, L_shl_sat( maxPredictionGain_fx, sub( maxPredictionGain_e, maxPredGain_e ) ) ) ) /* exp: maxPredGain_e */ { maxPredictionGain_fx = maxPredGain_fx; maxPredictionGain_e = maxPredGain_e; @@ -5902,22 +5879,16 @@ void TNSAnalysisStereo_fx( pTnsParameters = sts[ch]->hTcxCfg->pCurrentTnsConfig->pTnsParameters + iFilter; // maxPredGain_fx = L_max( maxPredGain_fx, pFilter->predictionGain32 ); - Word16 flag = BASOP_Util_Cmp_Mant32Exp( maxPredGain_fx, maxPredGain_e, pFilter->predictionGain32, pFilter->predictionGain_e ); - IF( flag < 0 ) + IF( GT_32( pFilter->predictionGain32, L_shl_sat( maxPredGain_fx, sub( maxPredGain_e, pFilter->predictionGain_e ) ) ) ) /* pFilter->predictionGain_e */ { maxPredGain_fx = pFilter->predictionGain32; - move32(); maxPredGain_e = pFilter->predictionGain_e; + move32(); move16(); } - flag = BASOP_Util_Cmp_Mant32Exp( pFilter->predictionGain32, pFilter->predictionGain_e, L_deposit_h( pTnsParameters->minPredictionGain ), PRED_GAIN_E ); - if ( flag < 0 ) - { - flag = 0; - move16(); - } + test(); - IF( flag || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) + IF( GT_32( pFilter->predictionGain32, L_shl_sat( L_deposit_h( pTnsParameters->minPredictionGain ), sub( PRED_GAIN_E, pFilter->predictionGain_e ) ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) { test(); test(); @@ -5980,24 +5951,17 @@ void TNSAnalysisStereo_fx( } } - IF( ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) ) - { - sts[ch]->hTcxEnc->fUseTns[k] = 1; - } - ELSE - { - sts[ch]->hTcxEnc->fUseTns[k] = 0; - } + sts[ch]->hTcxEnc->fUseTns[k] = 0; move16(); - Word16 flag = BASOP_Util_Cmp_Mant32Exp( TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23, PRED_GAIN_E, maxPredGain_fx, maxPredGain_e ); - if ( flag < 0 ) + if ( sts[ch]->hTcxEnc->tnsData[k].nFilters > 0 ) { - flag = 0; + sts[ch]->hTcxEnc->fUseTns[k] = 1; move16(); } + test(); test(); - IF( !bWhitenedDomain && flag && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) + IF( !bWhitenedDomain && LT_32( L_shl_sat( maxPredGain_fx, sub( maxPredGain_e, PRED_GAIN_E ) ), TNS_GAIN_THRESHOLD_FOR_WHITE_FX_IN_Q23 ) && NE_16( sts[ch]->hTcxEnc->transform_type[k], TCX_5 ) ) { sts[ch]->hTcxEnc->fUseTns[k] = 0; move16(); @@ -6012,9 +5976,9 @@ void TNSAnalysisStereo_fx( move16(); } } + // maxPredictionGain_fx = L_max( maxPredictionGain_fx, maxPredGain_fx ); - flag = BASOP_Util_Cmp_Mant32Exp( maxPredictionGain_fx, maxPredictionGain_e, maxPredGain_fx, maxPredGain_e ); - IF( flag < 0 ) + IF( GT_32( maxPredGain_fx, L_shl_sat( maxPredictionGain_fx, sub( maxPredictionGain_e, maxPredGain_e ) ) ) ) /* maxPredGain_e */ { maxPredictionGain_fx = maxPredGain_fx; maxPredictionGain_e = maxPredGain_e; diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 01ac8383f..639ec9dca 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -3205,7 +3205,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( tmp = i_mult2( n_band, L ); FOR( i = 0; i < L; i++ ) { - WB_tenv_syn_fx = L_add( WB_tenv_syn_fx, L_shr( L_mult0( synth_fx[i + tmp], synth_fx[i + tmp] ), 7 ) ); /*2*st_fx->Q_syn2 - 7 */ + WB_tenv_syn_fx = L_add( WB_tenv_syn_fx, L_shr( L_mult0( synth_fx[i + tmp], synth_fx[i + tmp] ), 7 ) ); /*2*Q_insig_lp-7 */ WB_tenv_orig_fx = L_add( WB_tenv_orig_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*2*Q_insig_lp - 7 */ } @@ -3239,7 +3239,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( #else den = round_fx( L_shl( WB_tenv_syn_fx, expd ) ); #endif - expd = sub( sub( 30, expd ), sub( shl( st_fx->Q_syn2, 1 ), 7 ) ); + expd = sub( sub( 30, expd ), sub( shl( Q_insig_lp, 1 ), 7 ) ); scale = shr( sub( den, num ), 15 ); num = shl( num, scale ); -- GitLab From ebf10d0b6924fb45346d9e863aed1397d3871066 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 11:20:20 +0100 Subject: [PATCH 26/97] review and remove redundant code under IVAS_CODE --- lib_com/bits_alloc_fx.c | 3 +- lib_dec/acelp_core_dec_fx.c | 313 +---------------- lib_dec/dec_higher_acelp_fx.c | 8 +- lib_dec/evs_dec_fx.c | 4 - lib_dec/gs_dec_fx.c | 11 +- lib_dec/init_dec_fx.c | 8 - lib_dec/lsf_dec_fx.c | 2 - lib_enc/acelp_core_enc_fx.c | 1 - lib_enc/amr_wb_enc_fx.c | 10 +- lib_enc/cng_enc_fx.c | 60 +--- lib_enc/core_switching_enc_fx.c | 49 --- lib_enc/dtx_fx.c | 55 +-- lib_enc/enc_higher_acelp_fx.c | 15 - lib_enc/fd_cng_enc_fx.c | 5 - lib_enc/find_uv_fx.c | 51 +-- lib_enc/gain_enc_fx.c | 5 - lib_enc/inov_enc_fx.c | 83 +---- lib_enc/long_enr_fx.c | 60 +--- lib_enc/lsf_enc_fx.c | 32 -- lib_enc/nois_est_fx.c | 103 +----- lib_enc/pre_proc_fx.c | 22 +- lib_enc/prot_fx_enc.h | 21 +- lib_enc/speech_music_classif_fx.c | 68 +--- lib_enc/stat_enc.h | 535 +----------------------------- lib_enc/updt_enc_fx.c | 28 +- lib_enc/vad_fx.c | 12 +- 26 files changed, 61 insertions(+), 1503 deletions(-) diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index f2a074ba5..88b276126 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -408,7 +408,7 @@ static Word16 BITS_ALLOC_adjust_acelp_fixed_cdk( return bitsused; } -/*#ifdef IVAS_CODE Below basop operators are missing */ + /*-------------------------------------------------------------------* * fcb_table() * @@ -3271,4 +3271,3 @@ Word16 set_ACELP_flag_IVAS( return 0; } } -/*#endif IVAS_CODE*/ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 903a37163..1d59d1269 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -143,66 +143,6 @@ ivas_error acelp_core_dec_fx( return error; } - -#ifdef IVAS_CODE - output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); - - /*----------------------------------------------------------------* - * stereo SID and CNG frames processing - *----------------------------------------------------------------*/ - - if ( st->core_brate <= SID_2k40 && st->element_mode == IVAS_CPE_DFT && nchan_out == 2 ) - { - if ( st->cng_type == FD_CNG ) - { - configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); - - /* Only run parameter decoding in SID frames */ - if ( st->core_brate == SID_2k40 ) - { - FdCng_decodeSID_fx( st ); - } - - for ( i = 0; i < NPART; i++ ) - { - st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = STEREO_DFT_FD_FILT * st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] + ( 1 - STEREO_DFT_FD_FILT ) * st->hFdCngDec->hFdCngCom->sidNoiseEst[i]; - } - -#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT - ApplyFdCng_fx( NULL, NULL, NULL, NULL, st, 0, 0 ); -#else - ApplyFdCng_fx( NULL, NULL, NULL, NULL, st, 0, 0 ); -#endif - } - else - { - configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); - - /* decode CNG parameters */ - CNG_dec( st, last_element_mode, Aq, lsp_new, lsf_new, &allow_cn_step, sid_bw, q_env ); - - /* comfort noise generation */ - CNG_exc( st->core_brate, st->L_frame, &st->hTdCngDec->Enew, &st->hTdCngDec->cng_seed, NULL, NULL, &st->lp_ener, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), NULL, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->hTdCngDec->num_ho, q_env, st->hTdCngDec->lp_env, st->hTdCngDec->old_env, st->hTdCngDec->exc_mem, st->hTdCngDec->exc_mem1, sid_bw, &st->hTdCngDec->cng_ener_seed1, NULL, st->Opt_AMR_WB, st->element_mode ); - - mvr2r( Aq, st->Aq_cng, M + 1 ); - - /* update old LSP and LSF vector */ - mvr2r( lsf_new, st->lsf_old, M ); - mvr2r( lsp_new, st->lsp_old, M ); - } - - set_f( output, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ - set_f( synth, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ - - /* CN generation done in DFT domain */ - wmops_sub_end(); - return error; - } - - /*----------------------------------------------------------------* - * Active frames processing - *----------------------------------------------------------------*/ -#endif FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); @@ -265,13 +205,7 @@ ivas_error acelp_core_dec_fx( move32(); } } -#ifdef IVAS_CODE - if ( st->hFdCngDec != NULL && ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) ) - { - set_zero( st->hFdCngDec->hFdCngCom->olapBufferSynth2, FFTLEN ); - set_zero( hStereoCng->olapBufferSynth22, FFTLEN ); - } -#endif + st_fx->clas_dec = st_fx->last_good; move16(); enr_q_fx = 0; @@ -413,7 +347,7 @@ ivas_error acelp_core_dec_fx( Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); // Qlog2(2.56) } set16_fx( st_fx->mem_MA_fx, 0, M ); -#if 1 // def IVAS_CODE + dec = DEC; move16(); IF( NE_16( st_fx->element_mode, EVS_MONO ) ) @@ -424,9 +358,7 @@ ivas_error acelp_core_dec_fx( /* update synthesis filter memories */ synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec ); -#else - synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, DEC ); -#endif + Copy( st_fx->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); // Q_exc Copy_Scale_sig( st_fx->mem_syn2_fx, st_fx->mem_syn1_fx, M, sub( -1, st_fx->Q_syn ) ); /*Q-1*/ @@ -591,7 +523,7 @@ ivas_error acelp_core_dec_fx( { tc_subfr_fx = tc_classif_fx( st_fx, st_fx->L_frame ); } -#if 1 // def IVAS_CODE + /*----------------------------------------------------------------* * Decoding of GSC IVAS mode *----------------------------------------------------------------*/ @@ -611,7 +543,7 @@ ivas_error acelp_core_dec_fx( move16(); } } -#endif + /*----------------------------------------------------------------* * Decoding of inactive CNG frames *----------------------------------------------------------------*/ @@ -623,22 +555,13 @@ ivas_error acelp_core_dec_fx( { CNG_dec_fx( st_fx, st_fx->last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env ); -#ifdef IVAS_CODE - local_element_mode = st_fx->element_mode; - move16(); - IF( ( EQ_16( nchan_out, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st_fx->masa_sid_format, 1 ) ) - { - local_element_mode = IVAS_SCE; /* For DFT Stereo mono decoding, run CNG_exc as in SCE */ - move16(); - } -#endif + /* comfort noise generation */ CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate, &st_fx->first_CNG, &( st_fx->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step_fx, &st_fx->hTdCngDec->last_allow_cn_step, st_fx->prev_Q_exc, st_fx->Q_exc, st_fx->hTdCngDec->num_ho, q_env, st_fx->hTdCngDec->lp_env_fx, st_fx->hTdCngDec->old_env_fx, st_fx->hTdCngDec->exc_mem_fx, st_fx->hTdCngDec->exc_mem1_fx, sid_bw, &st_fx->hTdCngDec->cng_ener_seed1, exc3_fx, st_fx->Opt_AMR_WB, st_fx->element_mode ); -#if 1 // def IVAS_CODE + Copy( Aq_fx, st_fx->Aq_cng, M + 1 ); // Q12 -#endif } ELSE { @@ -649,32 +572,7 @@ ivas_error acelp_core_dec_fx( *sid_bw = 0; move16(); } -#ifdef IVAS_CODE - if ( st->element_mode == IVAS_CPE_DFT ) - { - assert( nchan_out == 1 ); - for ( i = 0; i < NPART; i++ ) - { - st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = STEREO_DFT_FD_FILT * st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] + ( 1 - STEREO_DFT_FD_FILT ) * st->hFdCngDec->hFdCngCom->sidNoiseEst[i]; - } -#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT - ApplyFdCng_fx( syn, 0, NULL, realBuffer, imagBuffer, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#else - ApplyFdCng_fx( syn, realBuffer, imagBuffer, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#endif - } - if ( !read_sid_info ) - { - float noise_lvl_highest; - - noise_lvl_highest = st->hFdCngDec->hFdCngCom->cngNoiseLevel[st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand - 1]; - for ( int16_t b = st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand; b < st->hFdCngDec->hFdCngCom->stopBand; b++ ) - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest; - } - } -#endif generate_comfort_noise_dec_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 2, -1 ); FdCng_exc( st_fx->hFdCngDec->hFdCngCom, &st_fx->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx, st_fx->first_CNG, st_fx->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); @@ -809,10 +707,6 @@ ivas_error acelp_core_dec_fx( move16(); st_fx->last_nq_preQ = 0; move16(); -#ifdef IVAS_CODE - st_fx->last_code_preq = 0; - move16(); -#endif } st_fx->use_acelp_preq = 0; @@ -1409,103 +1303,8 @@ ivas_error acelp_core_dec_fx( #endif } /* CNA: Generate additional comfort noise to mask potential coding artefacts */ - -#ifdef IVAS_CODE - if ( !st->cna_dirac_flag ) - { - /* CNA: Generate additional comfort noise to mask potential coding artefacts */ - if ( st->flag_cna && !( st->coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) ) - { - if ( st->element_mode == IVAS_CPE_TD && nchan_out == 2 ) - { - if ( hStereoCng->flag_cna_fade ) - { - generate_stereo_masking_noise( syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out ); - hStereoCng->flag_cna_fade = 0; - } - else - { - if ( st->element_mode != last_element_mode && st->idchan == 0 ) - { - /* Clear memory for secondary channel CNA */ - set_f( hStereoCng->olapBufferSynth22, 0.0f, st->hFdCngDec->hFdCngCom->frameSize / 2 ); - } - - generate_stereo_masking_noise( syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out ); - } - } - else if ( st->element_mode != IVAS_CPE_DFT ) - { - if ( st->idchan == 0 ) - { - if ( st->element_mode != last_element_mode ) - { - set_f( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0.0f, st->hFdCngDec->hFdCngCom->fftlen ); - } - generate_masking_noise_fx( syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); - } - } - } - else if ( st->flag_cna && st->coder_type == AUDIO && ( ( st->last_core == ACELP_CORE && !( st->last_coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || st->last_core == TCX_20_CORE ) ) - { - if ( st->element_mode == IVAS_CPE_TD && nchan_out == 2 ) - { - generate_stereo_masking_noise( syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out ); - hStereoCng->flag_cna_fade = 1; - } - else - { - v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->hFdCngDec->hFdCngCom->frameSize / 4, (float) ( st->hFdCngDec->hFdCngCom->fftlen / 2 ), temp_buf, st->hFdCngDec->hFdCngCom->frameSize / 2 ); - v_add( temp_buf, syn, syn, st->hFdCngDec->hFdCngCom->frameSize / 2 ); - } - } - else - { - if ( hStereoCng != NULL ) - { - hStereoCng->flag_cna_fade = 1; - hStereoCng->enableSecCNA = 0; - } - } - - if ( st->element_mode == IVAS_CPE_TD ) - { - /*Noise estimate*/ - if ( st->idchan == 0 && ( nchan_out == 2 || ( st->core_brate != FRAME_NO_DATA && st->core_brate != SID_2k40 ) ) ) - { -#ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT - ApplyFdCng_fx( syn, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#else - ApplyFdCng_fx( syn, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); -#endif - } - } - } -#endif } -#ifdef IVAS_CODE - if ( !st->cna_dirac_flag ) - { - if ( st->flag_cna == 0 && st->L_frame == L_FRAME16k && st->last_flag_cna == 1 && ( ( st->last_core == ACELP_CORE && !( st->last_coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || st->last_core == AMR_WB_CORE ) ) - { - v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2 ); - v_add( temp_buf, syn, syn, st->L_frame / 2 ); - } - - if ( st->flag_cna == 0 || ( st->coder_type == AUDIO && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) ) - { - if ( st->idchan == 0 ) - { - set_f( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0.f, st->hFdCngDec->hFdCngCom->fftlen ); - } - if ( hStereoCng != NULL && st->idchan == 0 ) - { - set_f( hStereoCng->olapBufferSynth22, 0.f, st->hFdCngDec->hFdCngCom->fftlen ); - } - } - } -#else test(); test(); test(); @@ -1522,29 +1321,6 @@ ivas_error acelp_core_dec_fx( move16(); } } -#endif - -#ifndef IVAS_CODE - test(); - test(); - test(); - test(); - test(); - IF( st_fx->flag_cna == 0 && EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( st_fx->last_flag_cna, 1 ) && ( ( st_fx->last_core == ACELP_CORE && NE_16( st_fx->last_coder_type, AUDIO ) ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) - { - FOR( i = 0; i < st_fx->L_frame / 2; i++ ) - { - syn_fx[i] = add( syn_fx[i], shr_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4], negate( st_fx->Q_syn ) ) ); - move16(); - } - } - - test(); - IF( st_fx->flag_cna == 0 || EQ_16( st_fx->coder_type, AUDIO ) ) - { - set16_fx( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec->hFdCngCom->fftlen ); - } -#endif } /*----------------------------------------------------------------* @@ -1589,20 +1365,6 @@ ivas_error acelp_core_dec_fx( test(); IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) { -#ifdef IVAS_CODE - float realBufferSave[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float imagBufferSave[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float *pRealSave[CLDFB_NO_COL_MAX], *pImagSave[CLDFB_NO_COL_MAX]; - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - pRealSave[i] = realBufferSave[i]; - pImagSave[i] = imagBufferSave[i]; - } - if ( st->p_bpf_noise_buf ) - { - mvr2r( bpf_error_signal, st->p_bpf_noise_buf, st->L_frame ); - } -#endif /* analysis of the synthesis at internal sampling rate */ cldfbAnalysisFiltering( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn_fx, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX, workBuffer ); @@ -1663,40 +1425,6 @@ ivas_error acelp_core_dec_fx( /* synthesis of the combined signal */ st_fx->Q_syn2 = st_fx->Q_syn; move16(); -#ifdef IVAS_CODE - if ( save_hb_synth != NULL ) - { - /* save and then zero-out lowband */ - for ( int16_t j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - realBufferSave[i][j] = realBuffer[i][j]; - imagBufferSave[i][j] = imagBuffer[i][j]; - if ( j < st->hFdCngDec->hFdCngCom->numCoreBands && i < st->hFdCngDec->hFdCngCom->numSlots ) - { - realBuffer[i][j] = 0.0f; - imagBuffer[i][j] = 0.0f; - } - } - } - - cldfbSynthesis( realBuffer, imagBuffer, save_hb_synth, -1, st->cldfbSynHB ); - - /* restore lowband */ - for ( int16_t j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - for ( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - realBuffer[i][j] = realBufferSave[i][j]; - imagBuffer[i][j] = imagBufferSave[i][j]; - } - } - - cldfbSynthesis( pRealSave, pImagSave, synth, -1, st->cldfbSyn ); - } - else -#endif { cldfbSynthesisFiltering( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer ); } @@ -1708,34 +1436,7 @@ ivas_error acelp_core_dec_fx( /* save synthesis - needed in case of core switching */ Copy( synth_out, st_fx->previoussynth_fx, output_frame ); } -#ifdef IVAS_CODE - ELSE - { - int16_t nSamples = NS2SA( st->L_frame * FRAMES_PER_SEC, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ - - /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ - cldfbAnalysis( syn + st->L_frame - nSamples, realBuffer, imagBuffer, nSamples, st->cldfbAna ); - - /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */ - addBassPostFilter( bpf_error_signal + st->L_frame - nSamples, st->bpf_off ? 0 : nSamples, realBuffer, imagBuffer, st->cldfbBPF ); - /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ - cldfbSynthesis( realBuffer, imagBuffer, synth /*dummy*/, NS2SA( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), st->cldfbSyn ); - - if ( st->p_bpf_noise_buf ) - { - mvr2r( bpf_error_signal, st->p_bpf_noise_buf, st->L_frame ); - } - - set_f( synth, 0.0f, output_frame ); - } - - /* Copy output signal */ - if ( st->element_mode > EVS_MONO ) - { - mvr2r( syn, output, st->L_frame ); - } -#endif /*-----------------------------------------------------------------* * Bandwidth extension 6kHz-7kHz *-----------------------------------------------------------------*/ diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index b1cb2b516..aff7e5656 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -8,7 +8,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ -#define IVAS_CODE #define IVAS_CODE_AVQ /*-----------------------------------------------------------------* * transf_cdbk_dec() @@ -36,7 +35,6 @@ void transf_cdbk_dec_fx( Flag Overflow = 0; move32(); #endif -#ifdef IVAS_CODE Word16 avq_bit_sFlag; Word16 trgtSvPos; Word16 Nsv; @@ -50,7 +48,7 @@ void transf_cdbk_dec_fx( move16(); avq_bit_sFlag = 1; } -#endif + /*--------------------------------------------------------------* * Set bit-allocation *--------------------------------------------------------------*/ @@ -112,7 +110,7 @@ void transf_cdbk_dec_fx( *gain_preQ = round_fx( L_tmp ); /* Q2*/ move16(); } -#ifdef IVAS_CODE + trgtSvPos = sub( Nsv, 1 ); test(); test(); @@ -126,7 +124,7 @@ void transf_cdbk_dec_fx( move16(); move16(); } -#endif + /*--------------------------------------------------------------* * Demultiplex and decode subvectors from bit-stream *--------------------------------------------------------------*/ diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 5a12d1a2c..60e13dd8f 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -36,11 +36,7 @@ ivas_error evs_dec_fx( Word16 exp, fra; Word16 tmp_buffer_fx[L_FRAME48k]; Word16 tmp16, tmp16_2; -#ifdef IVAS_CODE Word16 synth_fx[L_FRAME48k]; -#else - Word16 synth_fx[L_FRAME48k + HQ_DELTA_MAX * HQ_DELAY_COMP]; -#endif Word16 fb_exc_fx[L_FRAME16k]; Word16 pitch_buf_fx[NB_SUBFR16k] = { 0 }; Word16 Q_fb_exc; diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index a80cfe796..385339664 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -370,11 +370,8 @@ void decod_audio_fx( tmp_nb_bits_tot = st_fx->next_bit_pos; /* Q0 */ move16(); -#ifdef IVAS_CODE - if ( st_fx->extl_brate_fx_orig > 0 ) -#else + if ( st_fx->extl_brate > 0 ) -#endif { /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */ tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */ @@ -873,17 +870,13 @@ void decod_audio_ivas_fx( tmp_nb_bits_tot = st_fx->next_bit_pos; /* Q0 */ move16(); -#if 1 // def IVAS_CODE + if ( st_fx->extl_brate_orig > 0 ) -#else - if ( st_fx->extl_brate > 0 ) -#endif { /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */ tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */ } - test(); test(); if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 ) diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index caa164df9..5d8aee302 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -20,10 +20,6 @@ ivas_error init_decoder_fx( Decoder_State *st_fx, /* o: Decoder static variables structure */ const Word16 idchan /* i : channel ID */ -#ifdef IVAS_CODE - , - const MC_MODE mc_mode /* i : MC mode */ -#endif ) { Word16 i; @@ -778,11 +774,7 @@ ivas_error init_decoder_fx( resampleCldfb( st_fx->cldfbBPF, newCldfbBands, st_fx->L_frame, 1 ); test(); -#ifdef IVAS_CODE - IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) && NE_16( mc_mode, MC_MODE_MCT ) && NE_16( mc_mode, MC_MODE_PARAMUPMIX ) ) // TBV Fixed point missing -#else IF( ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) || idchan == 0 ) /*&& mc_mode != MC_MODE_MCT && mc_mode != MC_MODE_PARAMUPMIX*/ ) -#endif { /* Create FD_CNG instance */ diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index becf60759..d263e6dd3 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -195,7 +195,6 @@ void lsf_dec_fx( /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/ st_fx->seed_acelp = extract_l( L_add( imult3216( 31821L /* Q0 */, add( shr( ( st_fx->seed_acelp ), 1 ), param_lpc[i] ) ), 13849L /* Q0 */ ) ); /* Q0 */ move16(); - // PMTE() /*IVAS_CODE to be completed */ } } IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) @@ -449,7 +448,6 @@ void lsf_dec_ivas_fx( /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/ st_fx->seed_acelp = extract_l( L_add( imult3216( 31821L /* Q0 */, add( shr( ( st_fx->seed_acelp ), 1 ), param_lpc[i] ) ), 13849L /* Q0 */ ) ); /* Q0 */ move16(); - // PMTE() /*IVAS_CODE to be completed */ } } IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index dcee88325..94d7f0471 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -329,7 +329,6 @@ ivas_error acelp_core_enc_fx( { IF( hTdCngEnc != NULL ) { - /*IVAS_CODE CNG_att is missing */ enr = cng_energy_fx( st_fx->element_mode, st_fx->bwidth, hDtxEnc->CNG_mode, /*st_fx->hTdCngEnc->CNG_att*/ 0, exc_fx, st_fx->L_frame, Q_new ); // Q8 /* calculate the energy quantization index */ diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index d7dd47256..90bdc74a5 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -351,12 +351,7 @@ void amr_wb_enc_fx( high_lpn_flag = 0; move16(); /* Q0 flag */ - long_enr_fx( st, Etot, localVAD_HE_SAD, high_lpn_flag -#ifdef IVAS_CODE - , - NULL, 1, NULL, NULL -#endif - ); + long_enr_fx( st, Etot, localVAD_HE_SAD, high_lpn_flag ); relE = sub( Etot, st->lp_speech_fx ); /* Q8 */ IF( NE_16( st->bwidth, NB ) ) @@ -441,9 +436,6 @@ void amr_wb_enc_fx( noise_est_fx( st, old_pitch1, tmpN, epsP_h, epsP_l, Etot, relE, corr_shift, tmpE, fr_bands, &cor_map_sum, NULL, &sp_div, &Q_sp_div, &non_staX, &harm_flag, lf_E, &hNoiseEst->harm_cor_cnt, hNoiseEst->Etot_l_lp_fx, hNoiseEst->Etot_v_h2_fx, &hNoiseEst->bg_cnt, st->lgBin_E_fx, Q_new, Le_min_scaled, &sp_floor, NULL, -#ifdef IVAS_CODE - NULL, NULL, -#endif st->ini_frame ); /*----------------------------------------------------------------* diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 15cc1a9e7..179d0230b 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -727,11 +727,6 @@ void CNG_enc_fx( test(); IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - // PMT("Code to be completed") -#ifdef IVAS_CODE - att = powf( 10.0f, hTdCngEnc->CNG_att / 20.0f ); - v_multc( res1, att, res1, st->L_frame ); -#endif } ELSE IF( NE_16( st_fx->bwidth, NB ) ) { @@ -909,9 +904,6 @@ void CNG_enc_fx( test(); IF( EQ_16( st_fx->element_mode, IVAS_SCE ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) { - // PMT("CNG IVAS_SCE and IVAS_CPE_DFT code missing") - // IVAS_CODE - // enr += hTdCngEnc->CNG_att * FAC_LOG2 / 10.0f; } ELSE IF( NE_16( st_fx->bwidth, NB ) ) { @@ -2415,14 +2407,6 @@ void swb_CNG_enc_fx( } ELSE IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && EQ_32( st_fx->core_brate, SID_2k40 ) ) { - // PMT("CNG IVAS_CPE_DFT code not implemented") -#ifdef IVAS_CODE - /* LF-boost not used in DFT-stereo, instead the bandwidth is transmitted */ - delete_indice( st->hBstr, IND_CNG_ENV1 ); - push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); - push_indice( st->hBstr, IND_UNUSED, 0, 4 ); - push_indice( st->hBstr, IND_SID_BW, 1, 1 ); -#endif } } hTdCngEnc->last_vad = 0; @@ -2450,9 +2434,6 @@ static void shb_CNG_encod_fx( Word16 idx_ener_fx; TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; -#ifdef IVAS_CODE - Word16 ener_mid_dec_thr; -#endif idx_ener_fx = 0; move16(); @@ -2484,41 +2465,15 @@ static void shb_CNG_encod_fx( { idx_ener_fx = s_max( idx_ener_fx, 0 ); } -#ifdef IVAS_CODE - /* prevent toggling of idx_ener by adding small dead-zone interval around decision thresholds */ - if ( st->element_mode != EVS_MONO ) - { - if ( abs( idx_ener - st->hTdCngEnc->last_idx_ener ) == 1 ) - { - ener_mid_dec_thr = 0.5f * ( ( st->hTdCngEnc->last_idx_ener / 0.7f - 6.0f ) / 0.1f ) * (float) log10( 2.0f ); - ener_mid_dec_thr += 0.5f * ( ( idx_ener / 0.7f - 6.0f ) / 0.1f ) * (float) log10( 2.0f ); - - if ( fabs( st->hTdCngEnc->mov_shb_cng_ener - ener_mid_dec_thr ) / ener_mid_dec_thr < ENER_MID_DEAD_ZONE ) - { - idx_ener = st->hTdCngEnc->last_idx_ener; - } - } - } - st->hTdCngEnc->last_idx_ener = idx_ener; -#endif push_indice_fx( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4 ); push_indice_fx( hBstr, IND_SID_BW, 1, 1 ); -#ifndef IVAS_CODE - hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_CNG_ENV1].nb_bits ); - hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1; - move16(); - move16(); -#else delete_indice( hBstr, IND_CNG_ENV1 ); -#endif -#ifdef IVAS_CODE - if ( st->element_mode == IVAS_CPE_DFT ) + + if ( st_fx->element_mode == IVAS_CPE_DFT ) { - push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); } else -#endif { push_indice_fx( hBstr, IND_UNUSED, 0, 2 ); } @@ -2633,13 +2588,7 @@ static Word16 shb_DTX_fx( allow_cn_step_fx = 1; move16(); } -#ifdef IVAS_CODE - /* Also allow step if shb energy has dropped 12 dB */ - if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( ( hTdCngEnc->mov_shb_cng_ener - log_shb_ener ) > 12.0f ) ) - { - allow_cn_step = 1; - } -#endif + IF( EQ_16( allow_cn_step_fx, 1 ) ) { hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; @@ -2759,13 +2708,10 @@ void calculate_hangover_attenuation_gain_fx( 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 */ { -#ifdef IVAS_CODE if ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) { - *att = powf( 10.0f, ( st->hTdCngEnc->CNG_att / 160.0f ) * st->hTdCngEnc->burst_ho_cnt ); } else -#endif { offset = 5; move16(); diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 6fa341a7b..dc3062298 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -373,31 +373,6 @@ void core_switching_pre_enc_fx( st_fx->EnergyLT_fx_exp = 30; move16(); /* Set to a High Exponent so it is 1^-30 */ } - /*---------------------------------------------------------------------* - * band-width switching from WB -> SWB/FB - *---------------------------------------------------------------------*/ -#ifdef IVAS_CODE - IF( GT_16( st_fx->element_mode, EVS_MONO ) ) - { - IF( st_fx->bwidth_sw_cnt_fx == 0 ) - { - IF( GE_16( st_fx->bwidth, SWB ) && EQ_16( st_fx->last_bwidth, WB ) ) - { - st_fx->bwidth_sw_cnt_fx = add( st_fx->bwidth_sw_cnt_fx, 1 ); - } - } - ELSE - { - st_fx->bwidth_sw_cnt_fx = add( st_fx->bwidth_sw_cnt_fx, 1 ); - - IF( EQ_16( st_fx->bwidth_sw_cnt_fx, BWS_TRAN_PERIOD ) ) - { - st_fx->bwidth_sw_cnt_fx = 0; - move16(); - } - } - } -#endif return; } @@ -483,22 +458,6 @@ void core_switching_post_enc_fx( set16_fx( hBWE_TD->state_ana_filt_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); -#ifdef IVAS_CODE - set16_fx( hBWE_TD->mem_shb_res_fx, 0, MAX_LEN_MA_FILTER ); - set16_fx( hBWE_TD->old_EnvSHBres_fx, 0, L_FRAME4k ); - hBWE_TD->old_mean_EnvSHBres_fx = 0; - hBWE_TD->prev_enr_EnvSHBres_fx = 32767; /*Q15 ??? */ - hBWE_TD->prev_shb_env_tilt_fx = 0; - hBWE_TD->prev_pow_exc16kWhtnd_fx = 32767; /*Q15 ??? */ - hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 ??? */ - hBWE_TD->prev_Env_error_fx = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); -#endif swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) ); @@ -531,14 +490,6 @@ void core_switching_post_enc_fx( hBWE_TD->fb_tbe_demph_fx = 0; fb_tbe_reset_enc_fx( hBWE_TD->elliptic_bpf_2_48k_mem_fx, &hBWE_TD->prev_fb_energy_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, &hBWE_TD->prev_fb_energy_fx_Q ); } - /* Fade towards init value for non HQ_CORE */ - IF( st_fx->hHQ_core != NULL ) - { -#ifdef IVAS_CODE - st_fx->hHQ_core->crest_lp = HQ_CREST_FAC_SM * ( st_fx->hHQ_core->crest_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * HQ_CREST_THRESHOLD; - st_fx->hHQ_core->crest_mod_lp = HQ_CREST_FAC_SM * ( st_fx->hHQ_core->crest_mod_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * HQ_CREST_MOD_THRESHOLD; -#endif - } } return; diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index be4368f69..a6b9e0aa4 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -662,11 +662,7 @@ void dtx_fx( move32(); #endif -#ifdef IVAS_CODE IF( st_fx->dtx_sce_sba != 0 ) -#else - if ( 0 ) -#endif { last_br_cng_flag = 1; last_br_flag = 1; @@ -770,9 +766,8 @@ void dtx_fx( /*------------------------------------------------------------------------* * Select SID or FRAME_NO_DATA frame if DTX is enabled *------------------------------------------------------------------------*/ -#ifdef IVAS_CODE + if ( st_fx->dtx_sce_sba == 0 ) -#endif { br_dtx_flag = LE_32( st_fx->total_brate, ACELP_24k40 ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->total_brate, ACELP_32k ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st_fx->element_brate, IVAS_64k ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) ) ); @@ -836,20 +831,7 @@ void dtx_fx( st_fx->core_brate = SID_2k40; move32(); } - // PMT("dtx_sce_sba code is missing") -#ifdef IVAS_CODE - IF( ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->cng_type, FD_CNG ) ) && EQ_16( st_fx->dtx_sce_sba, 1 ) ) - { - st_fx->cng_type = FD_CNG; - move16(); - if ( EQ_16( st_fx->element_mode, EVS_MONO ) && ( EQ_32( st_fx->total_brate, ACELP_9k60 ) || EQ_32( st_fx->total_brate, ACELP_16k40 ) || EQ_32( st_fx->total_brate, ACELP_24k40 ) || EQ_32( st_fx->total_brate, ACELP_48k ) || EQ_32( st_fx->total_brate, HQ_96k ) || EQ_32( st_fx->total_brate, HQ_128k ) ) ) - { - st_fx->codec_mode = MODE2; - move16(); - } - } - ELSE -#endif + { test(); test(); @@ -879,7 +861,6 @@ void dtx_fx( } } -#if 1 // def IVAS_CODE /* reset the bitstream (IVAS format signalling was already written) */ IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) { @@ -889,7 +870,6 @@ void dtx_fx( reset_indices_enc( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); #endif } -#endif } /*------------------------------------------------------------------------* @@ -932,32 +912,6 @@ void dtx_fx( { IF( EQ_16( st_fx->element_mode, IVAS_SCE ) ) { -#ifdef IVAS_CODE - Word16 lp_thresh, fd_thresh; - PMT( "lp_thresh scaling is to be found" ) - test(); - IF( st_fx->Opt_DTX_ON && EQ_16( st_fx->dtx_sce_sba, 1 ) ) - { - lp_thresh = 5.f; - fd_thresh = 2.f; - } - ELSE - - { - lp_thresh = 10.f; - fd_thresh = 5.f; - } - - /*More conservative selection of LP-CNG for SCE*/ - if ( st->cng_type == LP_CNG && ( st->bckr_tilt_lt > lp_thresh ) ) - { - st->cng_type = FD_CNG; - } - else if ( st->cng_type == FD_CNG && ( st->bckr_tilt_lt < fd_thresh ) && ( st->lp_noise > 2.f ) ) - { - st->cng_type = LP_CNG; - } -#endif } ELSE { @@ -1630,11 +1584,6 @@ void td_cng_enc_init_fx( move16(); move16(); -#ifdef IVAS_CODE - hTdCngEnc->CNG_att_fx = 0; - hTdCngEnc->last_idx_ener_fx = 0; -#endif - hTdCngEnc->cng_buf_cnt = 0; diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index c4c544469..a01550978 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -324,22 +324,7 @@ void transf_cdbk_enc_fx( } st_fx->last_nq_preQ = nq[7]; move16(); -#ifdef IVAS_CODE - /* TD pre-quantizer: in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */ - if ( st->element_mode > EVS_MONO && st->coder_type != INACTIVE && st->core_brate >= MIN_BRATE_AVQ_EXC && st->core_brate <= MAX_BRATE_AVQ_EXC_TD && !harm_flag_acelp && code_preQ[0] != 0 ) - { - if ( (float) abs( st->last_code_preq ) > 16.0f * (float) fabs( code_preQ[0] ) ) - { - st->mem_preemp_preQ /= 16; - } - else if ( (float) abs( st->last_code_preq ) > 8.0f * (float) fabs( code_preQ[0] ) ) - { - st->mem_preemp_preQ /= 8; - } - } - st->last_code_preq = (int16_t) code_preQ[L_SUBFR - 1]; -#endif PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) ); /*--------------------------------------------------------------* diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 97db8d2a0..9cb2cd8e0 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -2083,12 +2083,7 @@ Word16 cng_energy_fx( test(); IF( EQ_16( element_mode, IVAS_CPE_DFT ) || EQ_16( element_mode, IVAS_CPE_TD ) ) { - // PMT(" IVAS CNG ener computing is missing") -#ifdef IVAS_CODE - enr += CNG_att * FAC_LOG2 / 10.0f; -#else (void) CNG_att; -#endif } ELSE IF( NE_16( bwidth, NB ) ) { diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 200e538e4..79dc78c6d 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -93,21 +93,14 @@ Word16 find_uv_fx( /* o : coding type */ 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*/ -#ifdef IVAS_CODE - Word32 *dE1X, /* o : sudden energy increase for S/M classifier */ -#endif - 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 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*/ -#ifdef IVAS_CODE - , - STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier structure */ -#endif ) { Word16 coder_type, i; @@ -202,25 +195,7 @@ Word16 find_uv_fx( /* o : coding type */ pt_enr_ssf++; pt_enr_ssf1++; } -#ifdef IVAS_CODE - IF( hStereoClassif != NULL ) - { - IF( st_fx->idchan == 0 ) - { - hStereoClassif->dE1_ch1 = dE1; - } - ELSE - { - hStereoClassif->dE1_ch2 = dE1; - } - } - if ( dE1X != NULL ) - { - *dE1X = dE1; - move32(); - } -#endif /*-----------------------------------------------------------------* * Average spectral tilt * Average voicing (normalized correlation) @@ -564,24 +539,6 @@ Word16 find_uv_fx( /* o : coding type */ } } } -#ifdef IVAS_CODE - /*-----------------------------------------------------------------* - * UNCLR classifier - *-----------------------------------------------------------------*/ - - if ( hStereoClassif != NULL ) - { - if ( st->element_mode > EVS_MONO && ( coder_type == GENERIC || coder_type == UNVOICED || coder_type == INACTIVE || st->localVAD == 0 ) && hStereoClassif->unclr_sw_enable_cnt[st->idchan] < MAX_UV_CNT ) - { - hStereoClassif->unclr_sw_enable_cnt[st->idchan]++; - } - else - { - hStereoClassif->unclr_sw_enable_cnt[st->idchan] = 0; - } - } -#endif - /*-----------------------------------------------------------------* * Updates diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index f927940ae..6af068bae 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -467,11 +467,6 @@ void gain_enc_mless_fx( qua_table = gain_qua_mless_6b_fx; if ( element_mode > EVS_MONO ) { -#ifdef IVAS_CODE - qua_table = gain_qua_mless_6b_stereo; -#else - // PMTE() -#endif } move16(); if ( EQ_16( clip_gain, 1 ) ) diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 7964df4a8..7bb13239f 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -274,83 +274,7 @@ Word16 inov_encode_fx( IF( !Opt_AMR_WB ) { IF( st_fx->acelp_cfg.fcb_mode ) - { // PMTE() -#ifdef IVAS_CODE - if ( st->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] < ACELP_FIXED_CDK_NB ) - { - int16_t wordcnt, bitcnt; - int16_t prm[8]; - - if ( st->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr] >= 0 ) - { - if ( L_subfr == 2 * L_SUBFR ) - { - nBits = st->acelp_cfg.fixed_cdk_index[i_subfr / L_subfr]; - - if ( nBits == 8 ) - { - acelp_1t64( hBstr, dn, h1, code, y2, L_subfr ); - } - else - { - acelp_fast( hBstr, nBits, dn, cn, h1, code, y2, L_subfr ); - } - } - else if ( ( st->idchan == 1 && st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 7 ) || ( st->idchan == 0 && st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 3 ) ) - { - if ( st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] == 0 ) - { - acelp_1t64( hBstr, dn, h1, code, y2, L_subfr ); - } - else - { - acelp_fast( hBstr, st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], dn, cn, h1, code, y2, L_SUBFR ); - } - } - else - { - E_ACELP_4t( dn, cn, h1, Rw, acelpautoc, code, st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], prm, L_frame, last_L_frame, st->total_brate, i_subfr, cmpl_flag ); - - wordcnt = ACELP_FIXED_CDK_BITS( st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) >> 4; - bitcnt = ACELP_FIXED_CDK_BITS( st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] ) & 15; - - for ( i = 0; i < wordcnt; i++ ) - { - push_indice( hBstr, IND_ALG_CDBK_4T64, prm[i], 16 ); - } - if ( bitcnt ) - { - push_indice( hBstr, IND_ALG_CDBK_4T64, prm[i], bitcnt ); - } - - /* Generate weighted code */ - set_f( y2, 0.0f, L_SUBFR ); - for ( i = 0; i < L_SUBFR; i++ ) - { - /* Code is sparse, so check which samples are non-zero */ - if ( code[i] != 0 ) - { - for ( k = 0; k < L_SUBFR - i; k++ ) - { - y2[i + k] += code[i] * h1[k]; - } - } - } - } - } - else - { - set_f( code, 0.0f, L_SUBFR ); - set_f( y2, 0.0f, L_SUBFR ); - } - } -#ifdef DEBUGGING - else - { - IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "invalid mode for acelp frame!\n" ); - } -#endif -#endif + { } ELSE { @@ -656,9 +580,7 @@ Word16 inov_encode_ivas_fx( IF( !Opt_AMR_WB ) { IF( st_fx->acelp_cfg.fcb_mode ) - { // PMTE() -#if 1 - //#ifdef IVAS_CODE + { Word16 idx = 0, idx2 = 0; move16(); move16(); @@ -748,7 +670,6 @@ Word16 inov_encode_ivas_fx( { IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "invalid mode for acelp frame!\n" ); } -#endif #endif } ELSE diff --git a/lib_enc/long_enr_fx.c b/lib_enc/long_enr_fx.c index 0916b2b09..5fe465f29 100644 --- a/lib_enc/long_enr_fx.c +++ b/lib_enc/long_enr_fx.c @@ -150,18 +150,13 @@ void ivas_long_enr_fx( *-----------------------------------------------------------------*/ return; } + + void long_enr_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 Etot, /* i : total channel E (see lib_enc\analy_sp.c) */ const Word16 localVAD_HE_SAD, /* i : HE-SAD flag without hangover */ Word16 high_lpn_flag /* i : sp/mus LPN flag */ -#ifdef IVAS_CODE - , - FRONT_VAD_ENC_HANDLE hFrontVad[CPE_CHANNELS], /* i/o: front-VAD handles */ - const int16_t n_chan, /* i : number of channels */ - const int16_t localVAD_HE_SAD_LR[CPE_CHANNELS], /* i : HE-SAD flag without hangover LR channels */ - const float Etot_LR[CPE_CHANNELS] /* i : total channel energy LR channels */ -#endif ) { Word16 tmp; @@ -172,58 +167,7 @@ void long_enr_fx( * Compute long term estimate of total noise energy * and total active speech energy *-----------------------------------------------------------------*/ -#ifdef IVAS_CODE - Word16 n; - if ( hFrontVad != NULL ) - { - if ( hFrontVad[0]->ini_frame < 4 ) - { - for ( n = 0; n < n_chan; n++ ) - { - hFrontVad[n]->lp_noise = hFrontVad[n]->hNoiseEst->totalNoise; - tmp = hFrontVad[n]->lp_noise + 10.0f; - - if ( hFrontVad[n]->lp_speech < tmp ) - { - hFrontVad[n]->lp_speech = tmp; - } - } - } - else - { - float smooth_prev, smooth_curr; - - if ( hFrontVad[0]->ini_frame < 150 ) - { - smooth_prev = 0.95f; - smooth_curr = 0.05f; - } - else - { - smooth_prev = 0.98f; - smooth_curr = 0.02f; - } - for ( n = 0; n < n_chan; n++ ) - { - hFrontVad[n]->lp_noise = smooth_prev * hFrontVad[n]->lp_noise + smooth_curr * hFrontVad[n]->hNoiseEst->totalNoise; - - if ( localVAD_HE_SAD_LR[n] && !high_lpn_flag ) - { - if ( ( hFrontVad[n]->lp_speech - Etot_LR[n] ) < 10.0f ) - { - hFrontVad[n]->lp_speech = 0.98f * hFrontVad[n]->lp_speech + 0.02f * Etot_LR[n]; - } - else - { - hFrontVad[n]->lp_speech = hFrontVad[n]->lp_speech - 0.05f; - } - } - } - } - } - else -#endif { IF( LT_16( st_fx->ini_frame, 4 ) ) { diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index de5e474a0..96ab40547 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -78,9 +78,6 @@ void lsf_enc_fx( Word16 int_fs; Word16 force_sf = 0; Word16 fec_lsf[M], stab, i; -#ifdef IVAS_CODE - Word16 param_lpc[NPRM_LPC_NEW]; -#endif Word32 L_tmp; Word16 coder_type, ppp_mode, nelp_mode; @@ -199,19 +196,6 @@ void lsf_enc_fx( Copy( lsf_new, st_fx->lsf_old_fx, M ); } /* set seed_acelp used in UC mode */ -#ifdef IVAS_CODE - test(); - IF( EQ_16( coder_type, UNVOICED ) && GT_16( st_fx->element_mode, EVS_MONO ) ) - { - st_fx->seed_acelp = 0; - move16(); - FOR( i = no_param_lpc - 1; i >= 0; i-- ) - { - /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/ - st->seed_acelp = (int16_t) ( ( ( ( st->seed_acelp ) >> 1 ) + param_lpc[i] ) * 31821L + 13849L ); - } - } -#endif IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) { /* return if SID frame (conversion to A(z) done in the calling function) */ @@ -3534,14 +3518,6 @@ static void lsf_mid_enc_fx( move16(); BREAK; } -#ifdef IVAS_CODE - case 1: - { - ratio = tbl_mid_voi_wb_1b_fx; - move16(); - BREAK; - } -#endif } } ELSE IF( EQ_16( coder_type, UNVOICED ) ) @@ -3559,14 +3535,6 @@ static void lsf_mid_enc_fx( move16(); BREAK; } -#ifdef IVAS_CODE - case 4: - { - ratio = tbl_mid_gen_wb_4b_fx; - move16(); - BREAK; - } -#endif case 2: { ratio = tbl_mid_gen_wb_2b_fx; diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 27a48652a..68eed3d65 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -192,11 +192,11 @@ void noise_est_init_fx( hNoiseEst->totalNoise_fx = 0; move16(); hNoiseEst->first_noise_updt = 0; - // hNoiseEst->first_noise_updt_cnt_fx = 0; IVAS_CODE ?? move16(); hNoiseEst->aEn = 6; - // hNoiseEst->aEn_inac_cnt = 0; IVAS_CODE + move16(); + hNoiseEst->aEn_inac_cnt = 0; move16(); hNoiseEst->harm_cor_cnt = 0; @@ -269,21 +269,7 @@ void noise_est_init_ivas_fx( ) { Word16 i; -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - hNoiseEst->first_noise_updt = 0; - hNoiseEst->first_noise_updt_cnt = 0; - move16(); - move16(); - hNoiseEst->aEn = 6; - hNoiseEst->aEn_inac_cnt = 0; - hNoiseEst->harm_cor_cnt = 0; - hNoiseEst->bg_cnt = 0; - hNoiseEst->low_tn_track_cnt = 0; - move16(); - move16(); - move16(); - move16(); -#endif + FOR( i = 0; i < NB_BANDS; i++ ) { hNoiseEst->fr_bands1_fx[i] = 1; @@ -312,13 +298,14 @@ void noise_est_init_ivas_fx( hNoiseEst->totalNoise_fx = 0; move16(); hNoiseEst->first_noise_updt = 0; - // hNoiseEst->first_noise_updt_cnt_fx = 0; IVAS_CODE ?? + move16(); + hNoiseEst->first_noise_updt_cnt = 0; move16(); hNoiseEst->aEn = 6; - // hNoiseEst->aEn_inac_cnt = 0; IVAS_CODE move16(); - + hNoiseEst->aEn_inac_cnt = 0; + move16(); hNoiseEst->harm_cor_cnt = 0; move16(); hNoiseEst->bg_cnt = 0; @@ -890,11 +877,7 @@ void noise_est_fx( const Word32 Le_min_scaled, /*i : Minimum energy value in Q_new + Q_SCALE */ Word16 *sp_floor, /* o : noise floor estimate Q7 */ Word16 S_map[], /* o : short-term correlation map Q7 */ -#ifdef IVAS_CODE - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - FRONT_VAD_ENC_HANDLE hFrontVad, /* i/o: front-VAD handle */ -#endif - const Word16 ini_frame /* i : Frame number (init) */ + const Word16 ini_frame /* i : Frame number (init) */ ) { Word16 alpha, alpha2, alpha2m1, alpham1; @@ -939,14 +922,8 @@ void noise_est_fx( #ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) ( ncharX ); #endif + /* Check if LR-VAD */ -#ifdef IVAS_CODE - IF( hFrontVad != NULL ) - { - hNoiseEst = hFrontVad->hNoiseEst; - } - ELSE -#endif { hNoiseEst = st_fx->hNoiseEst; } @@ -964,9 +941,6 @@ void noise_est_fx( move16(); /*st_fx->ener_RAT = 10.0f * (float)log10( mean(lf_E, 8));*/ -#ifdef IVAS_CODE - IF( hFrontVad == NULL ) -#endif { IF( hSpMusClas != NULL ) { @@ -1069,9 +1043,7 @@ void noise_est_fx( /*-----------------------------------------------------------------* * Multi-harmonic analysis *-----------------------------------------------------------------*/ -#ifdef IVAS_CODE - IF( hFrontVad == NULL ) -#endif + { IF( st_fx->hSpMusClas != NULL ) { @@ -1166,12 +1138,7 @@ void noise_est_fx( Ltmp2 = sum32_fx( &fr_bands[10], sub( st_fx->max_band, 9 ) ); wtmp = shl_o( 1, sub( add( Q_new, QSCALE ), 1 ), &Overflow ); -#ifdef IVAS_CODE - IF( ncharX != NULL ) - { - *ncharX = ftemp2 / ( ftemp + 1e-5f ); - } -#endif + test(); IF( L_msu( Ltmp, 100, wtmp ) < 0 || L_msu( Ltmp2, 100, wtmp ) < 0 ) { @@ -1332,9 +1299,6 @@ void noise_est_fx( move32(); /* calculation of non-stationarity measure for speech/music classification */ -#ifdef IVAS_CODE - IF( hFrontVad == NULL ) -#endif { test(); test(); @@ -1707,39 +1671,6 @@ void noise_est_fx( hNoiseEst->aEn = s_min( hNoiseEst->aEn, 6 ); hNoiseEst->aEn = s_max( hNoiseEst->aEn, 0 ); -#ifdef IVAS_CODE - /*-----------------------------------------------------------------* - * Stereo classifier - save raw aEn - *-----------------------------------------------------------------*/ - - if ( hStereoClassif != NULL ) - { - if ( ( non_sta > th_sta ) || - ( tmp_pc < TH_PC ) || - ( 0.5f * ( st->voicing[0] + st->voicing[1] ) > cor_max ) || - ( epsP[2] / epsP[16] > th_eps ) || - ( ( hNoiseEst->act_pred > 0.8f ) && ( non_sta2 > th_sta ) ) ) - { - /* active signal present - increment counter */ - hStereoClassif->aEn_raw[st->idchan] = add( hStereoClassif->aEn_raw[st->idchan], 2 ); - } - else - { - /* background noise present - decrement counter */ - hStereoClassif->aEn_raw[st->idchan] = sub( hStereoClassif->aEn_raw[st->idchan], 1 ); - } - - if ( GT_16( hStereoClassif->aEn_raw[st->idchan], 6 ) ) - { - hStereoClassif->aEn_raw[st->idchan] = 6; - } - else if ( hStereoClassif->aEn_raw[st->idchan] < 0 ) - { - hStereoClassif->aEn_raw[st->idchan] = 0; - } - } -#endif - /* Additional NNE detectors */ @@ -2192,18 +2123,6 @@ void noise_est_fx( move16(); } -#ifdef IVAS_CODE - IF( st_fx->element_mode > EVS_MONO ) - { - test(); - IF( hNoiseEst->first_noise_updt_cnt_fx > 0 && LT_16( hNoiseEst->first_noise_updt_cnt_fx, 100 ) ) - { - hNoiseEst->first_noise_updt_cnt_fx = add( hNoiseEst->first_noise_updt_cnt_fx, 1 ); - move16(); - } - } -#endif - return; } diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index bd3d4cb34..5a8f4aa7c 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -214,7 +214,7 @@ void pre_proc_fx( * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ Word16 Q_new_inp, mem_decim_size; // TO be removed - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* @@ -497,9 +497,6 @@ void pre_proc_fx( noise_est_fx( st, old_pitch1, tmpN, epsP_h, epsP_l, *Etot, relE, corr_shift, tmpE, fr_bands, &cor_map_sum, NULL, &sp_div, &Q_sp_div, &non_staX, &loc_harm, lf_E, &hNoiseEst->harm_cor_cnt, hNoiseEst->Etot_l_lp_fx, hNoiseEst->Etot_v_h2_fx, &hNoiseEst->bg_cnt, st->lgBin_E_fx, *Q_new, Le_min_scaled, &sp_floor, NULL, -#ifdef IVAS_CODE - NULL, NULL, -#endif st->ini_frame ); /*------------------------------------------------------------------* @@ -516,15 +513,7 @@ void pre_proc_fx( st->max_band, hp_E, st->codec_mode, *Q_new, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, -#ifdef IVAS_CODE - NULL, -#endif - corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig -#ifdef IVAS_CODE - , - NULL -#endif - ); + corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig ); /*----------------------------------------------------------------* * channel aware mode configuration * @@ -598,12 +587,7 @@ void pre_proc_fx( speech_music_classif_fx( st, new_inp_12k8, inp_12k8, localVAD_HE_SAD, lsp_new, cor_map_sum, epsP, PS, *Etot, old_cor, attack_flag, non_staX, relE, Q_esp, *Q_new, &high_lpn_flag, flag_spitch ); - long_enr_fx( st, *Etot, localVAD_HE_SAD, high_lpn_flag -#ifdef IVAS_CODE - , - NULL, 1, NULL, NULL -#endif - ); /* has to be after after sp_music classfier */ + long_enr_fx( st, *Etot, localVAD_HE_SAD, high_lpn_flag ); /* has to be after after sp_music classfier */ /*----------------------------------------------------------------* * Rewrite the VAD flag by VAD flag with DTX hangover for further processing) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index c3e9d1b4c..0a058740b 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -286,21 +286,14 @@ Word16 find_uv_fx( /* o : coding type 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*/ -#ifdef IVAS_CODE - Word32 *dE1X, /* o : sudden energy increase for S/M classifier */ -#endif - 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 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*/ -#ifdef IVAS_CODE - , - STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier structure */ -#endif ); void fine_gain_quant_fx( @@ -401,11 +394,7 @@ void noise_est_fx( const Word32 Le_min_scaled, /*i : Minimum energy value in Q_new + Q_SCALE */ Word16 *sp_floor, /* o : noise floor estimate Q7 */ Word16 S_map[], /* o : short-term correlation map Q7 */ -#ifdef IVAS_CODE - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - FRONT_VAD_ENC_HANDLE hFrontVad, /* i/o: front-VAD handle */ -#endif - const Word16 ini_frame /* i : Frame number (init) */ + const Word16 ini_frame /* i : Frame number (init) */ ); void noise_est_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 295cff8a1..04f02d860 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -55,16 +55,7 @@ static void tonal_context_improv_fx( Encoder_State *st_fx, const Word32 PS[], co static void var_cor_calc_fx( const Word16 old_corr, Word16 *mold_corr, Word16 var_cor_t[], Word16 *high_stable_cor ); -static Word16 attack_det_fx( const Word16 *inp, const Word16 Qx, const Word16 last_clas, const Word16 localVAD, const Word16 coder_type, const Word32 total_brate -#ifdef IVAS_CODE - , - const Word16 element_mode, - const Word16 clas, - Word32 finc_prev[], - Word32 *lt_finc, - Word16 *last_strong_attack -#endif -); +static Word16 attack_det_fx( const Word16 *inp, const Word16 Qx, const Word16 last_clas, const Word16 localVAD, const Word16 coder_type, const Word32 total_brate ); static void order_spectrum_fx( Word16 *vec, Word16 len ); @@ -1336,12 +1327,7 @@ static void sp_mus_classif_2nd_fx( var_cor_calc_fx( st->old_corr_fx, &hSpMusClas->mold_corr_fx, hSpMusClas->var_cor_t_fx, &hSpMusClas->high_stable_cor ); /* attack detection */ - attack = attack_det_fx( inp, Qx, st->clas, st->localVAD, st->coder_type, st->total_brate -#ifdef IVAS_CODE - , - EVS_MONO, st->clas, hSpMusClas->finc_prev, &hSpMusClas->lt_finc, &hSpMusClas->last_strong_attack -#endif - ); + attack = attack_det_fx( inp, Qx, st->clas, st->localVAD, st->coder_type, st->total_brate ); test(); test(); @@ -1487,22 +1473,11 @@ static Word16 attack_det_fx( /* o : attack flag const Word16 localVAD, /* i : local VAD flag */ const Word16 coder_type, /* i : coder type */ const Word32 total_brate /* i : total bitrate */ -#ifdef IVAS_CODE - , - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 clas, /* i : signal class */ - Word32 finc_prev[], /* i/o: previous finc */ - Word32 *lt_finc, /* i/o: long-term mean finc */ - Word16 *last_strong_attack /* i/o: last strong attack flag */ -#endif ) { Word16 i, j, tmp, tmp1, attack, exp1; Word32 L_tmp, etmp, etmp2, finc[ATT_NSEG]; Word16 att_3lsub_pos; -#ifdef IVAS_CODE - Word16 attack1; -#endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -1531,10 +1506,6 @@ static Word16 attack_det_fx( /* o : attack flag } attack = maximum_32_fx( finc, ATT_NSEG, &etmp ); -#ifdef IVAS_CODE - attack1 = attack; - move16(); -#endif move16(); test(); IF( EQ_16( localVAD, 1 ) && EQ_16( coder_type, GENERIC ) ) @@ -1600,37 +1571,6 @@ static Word16 attack_det_fx( /* o : attack flag } } } -#ifdef IVAS_CODE - test(); - test(); - test(); - IF( attack == 0 && GT_16( element_mode, EVS_MONO ) && ( LT_16( clas, VOICED_TRANSITION ) || EQ_16( clas, ONSET ) ) ) - { - Copy32( finc, finc_prev, attack1 ); - - /* compute mean energy before the attack */ - etmp = L_shr( sum32_fx( finc_prev, ATT_NSEG ), 5 ); /*ATT_NSEG == 32*/ - - etmp2 = finc[attack1]; - move32(); - test(); - test(); - if ( ( LT_32( L_shl( etmp, 4 ), etmp2 ) ) || ( LT_32( L_mult0( etmp, 12 ), etmp2 ) && EQ_16( last_clas, UNVOICED_CLAS ) ) ) - { - attack = attack1; - move16(); - } - PMT( "Size of lf_finc not verified yet" ) - test(); - if ( GT_32( L_mult0( 20, *lt_finc ), etmp2 ) || *last_strong_attack ) /*lt_finc assumes same Q as etmp2, TBV!!!! */ - { - attack = 0; - move16(); - } - } - *last_strong_attack = attack; - move16(); -#endif } ELSE IF( attack > 0 ) { @@ -1647,10 +1587,6 @@ static Word16 attack_det_fx( /* o : attack flag BREAK; } } -#ifdef IVAS_CODE - *last_strong_attack = 0; - move16(); -#endif } return attack; diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 6292c4b33..7421921f0 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1780,9 +1780,10 @@ typedef struct enc_core_structure Word16 is_ism_format; /* Indication whether the codec operates in ISM format */ Word16 dtx_sce_sba; /* enable use of FD CNG with transform domain cores in SCE SBA */ - /*----------------------------------------------------------------------------------* - * Fixed point only variables - *----------------------------------------------------------------------------------*/ + + /*----------------------------------------------------------------------------------* + * Fixed point only variables + *----------------------------------------------------------------------------------*/ Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ @@ -1813,534 +1814,6 @@ typedef struct enc_core_structure } Encoder_State, *ENC_CORE_HANDLE; -// typedef struct Encoder_State_fx -//{ -// -// /*----------------------------------------------------------------------------------* -// * Common parameters - -// *----------------------------------------------------------------------------------*/ -// /*----------------------------------------------------------------------------------* -// * Stereo/IVAS parameters -// *----------------------------------------------------------------------------------*/ -// Word16 flag_ACELP16k; /* flag indicating use of ACELP core at 16kHz internal sampling rate */ -// -// Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */ -// Word16 cna_dirac_flag; /* CNA in DirAC flag */ -// Word16 cng_sba_flag; /* CNG in SBA flag */ -// Word16 idchan; /* channel ID (audio channel number) */ -// Word16 element_mode; /* element mode */ -// Word16 last_element_mode; /* element mode */ -// Word16 low_rate_mode; /* low-rate mode flag */ -// MCT_CHAN_MODE mct_chan_mode; -// Word16 GSC_IVAS_mode; -// Word16 is_ism_format; /* Indication whether the codec operates in ISM format */ -// Word16 dtx_sce_sba; /* enable use of FD CNG with transform domain cores in SCE SBA */ -// -// -// //#ifdef IVAS_CODE -// -// #ifdef DEBUGGING -// Word16 id_element; /* element ID */ -// #endif -// Word32 element_brate; /* element bitrate */ -// Word16 extl_orig; /* extension layer */ -// Word32 extl_brate_orig; /* extension layer bitrate */ -// /*----------------------- End of IVAS specific--------------------------------------*/ -// -// -// Word16 codec_mode; /* MODE1 or MODE2 */ -// Word16 last_codec_mode; /* Previous Codec Mode*/ -// Word16 last_codec_mode_cng; /* Codec Mode of the last inactive frame*/ -// Word16 mdct_sw_enable; /* MDCT switching enable flag */ -// Word16 mdct_sw; /* MDCT switching indicator */ -// Word16 last_enerBuffer_exp; -// Word16 next_bit_pos_fx; /* position of the next bit to be written in the bitstream */ -// Word16 bitstreamformat; /* Bitstream format flag (G.192/MIME) */ -// -// BSTR_ENC_HANDLE hBstr; /* encoder bitstream handle */ -// -// -// LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ -// -// -// Word32 input_Fs_fx; /* input signal sampling frequency in Hz */ -// Word32 total_brate_fx; /* total bitrate in kbps of the codec */ -// Word32 last_total_brate_fx; /* total bitrate in kbps of the codec */ -// Word32 last_total_brate_cng_fx; /* total bitrate in kbps of the last inactive frame */ -// Word16 core_fx; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ -// Word32 core_brate_fx; /* core bitrate */ -// Word32 last_core_brate_fx; /* previous frame core bitrate */ -// Word16 input_frame_fx; /* Frame lenght (function of input_Fs) */ -// Word16 extl_fx; /* extension layer */ -// Word16 last_extl_fx; /* previous extension layer */ -// Word32 extl_brate_fx; /* extension layer bitrate */ -// Word16 input_bwidth_fx; /* input signal bandwidth */ -// Word16 last_input_bwidth_fx; /* input signal bandwidth in the previous frame */ -// Word16 bwidth_fx; /* encoded bandwidth NB, WB, SWB or FB */ -// Word16 max_bwidth_fx; /* maximum encoded bandwidth */ -// Word16 last_bwidth_fx; /* input signal bandwidth in the previous frame */ -// Word16 last_bwidth_cng_fx; /* input signal bandwidth in the previous inactive frame */ -// Word16 L_frame_fx; /* ACELP core internal frame length */ -// Word16 Opt_AMR_WB_fx; /* flag indicating AMR-WB IO mode */ -// Word16 Opt_DTX_ON_fx; /* flag indicating DTX operation */ -// Word16 cng_type_fx; /* flag indicating LP or CLDFB based SID/CNG */ -// Word16 active_fr_cnt_fx; /* counter of active frames */ -// Word16 Opt_SC_VBR_fx; /* flag indicating SC-VBR mode */ -// Word16 last_Opt_SC_VBR_fx; /* flag indicating SC-VBR mode in the last frame */ -// /*----------------------------------------------------------------------------------* -// * ACELP core parameters -// *----------------------------------------------------------------------------------*/ -// -// Word16 clas_fx; /* current frame clas */ -// Word16 last_clas_fx; /* previous frame signal classification */ -// Word32 Bin_E_fx[L_FFT]; /* Q_new + Q_SCALE -2 per bin energy of two frames */ -// -// /*----------------------------------------------------------------------------------* -// * General signal buffers -// *----------------------------------------------------------------------------------*/ -// Word16* input_buff; -// /*Word16* input; -// Word16* old_input_signal;*/ -// -// SIGNAL_BUFFERS_ENC_HANDLE hSignalBuf; -// -// Word32* Bin_E_old_fx; /* per bin energy of old 2nd frames */ -// Word16* mem_decim_fx; /* decimation filter memory */ -// Word16* mem_decim16k_fx; /* ACELP@16kHz - decimation filter memory @16kHz */ -// Word16* old_inp_12k8_fx; /* memory of input signal at 12.8kHz */ -// Word16* old_inp_16k_fx; /* ACELP@16kHz - memory of input signal @16 kHz */ -// -// Word16* buf_speech_enc_pe; -// Word16* buf_synth; /*can be reduced to PIT_MAX_MAX+L_FRAME_MAX if no rate switching*/ -// Word16* buf_speech_enc; -// Word16* buf_wspeech_enc; -// -// -// Word16 lsp_old1_fx[M]; /* old unquantized LSP vector at the end of the frame */ -// Word16 lsf_old1_fx[M]; /* old LSF vector at the end of the frame */ -// Word16 lsp_old_fx[M]; /* old LSP vector at the end of the frame */ -// Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame */ -// Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz */ -// Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz */ -// Word16 pstreaklen_fx; /* LSF quantizer */ -// Word16 streaklimit_fx; /* LSF quantizer */ -// Word32 offset_scale1_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 1st 8-dim subvector*/ -// Word32 offset_scale2_fx[MAX_NO_MODES + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure 2nd 8-dim subvector*/ -// Word32 offset_scale1_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 1st 8-dim subvector*/ -// Word32 offset_scale2_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 2nd 8-dim subvector*/ -// Word16 no_scales_fx[MAX_NO_MODES][2]; /* LSF LVQ structure Q0*/ -// Word16 no_scales_p_fx[MAX_NO_MODES_p][2]; /* LSF LVQ structure Q0*/ -// Word16 stab_fac_fx; /* LSF stability factor */ -// Word16 mem_deemph_fx; /* deemphasis filter memory */ -// Word16 mem_preemph_fx; /* preemphasis filter memory */ -// Word32 mem_hp20_in_fx[5]; /* HP filter memory for AMR-WB IO */ -// Word16 old_wsp_fx[L_WSP_MEM]; /* old weighted signal vector */ -// /*Word16 old_exc_fx[L_EXC_MEM];*/ /* old excitation vector */ -// Word16 old_wsp2_fx[(L_WSP_MEM - L_INTERPOL) / OPL_DECIM]; /* old decimated weighted signal vector qwsp */ -// -// /*----------------------------------------------------------------------------------* -// * Noise estimation -// *----------------------------------------------------------------------------------*/ -// -// NOISE_EST_HANDLE hNoiseEst; -// -// Word16 mem_wsp_fx; /* weighted signal vector memory */ -// Word16 mem_decim2_fx[3]; /* weighted signal decimation filter memory qwsp */ -// Word16 clip_var_fx[6]; -// Word16 mem_AR_fx[M]; /* AR memory of LSF quantizer (past quantized LSFs without mean) */ -// Word16 mem_MA_fx[M]; /* MA memory of LSF quantizer (past quantized residual) (used also in AMR-WB IO mode) */ -// Word16 mCb1_fx; /* LSF quantizer - counter of stationary frames after a transition frame */ -// Word16 coder_type_raw_fx; -// Word16 last_coder_type_raw_fx; /* raw last_coder_type (coming from the sigal classification) */ -// Word16 last_coder_type; /*Q0 previous coding type */ -// Word16 ini_frame_fx; /* initialization frames counter */ -// Word16 old_thres_fx; /* normalized correlation weighting in open-loop pitch Q15 */ -// Word16 old_corr_fx; /* normalized correlation in previous frame (mean value) Q15 */ -// Word16 old_pitch; /* previous pitch for open-loop pitch search Q0 */ -// Word16 delta_pit_fx; /* open-loop pitch extrapolation correction Q0 */ -// Word32 ee_old_fx; -// Word16 min_band_fx; /* Q0 minimum critical band of useful bandwidth */ -// Word16 max_band_fx; /* Q0 maximum critical band of useful bandwidth */ -// Word16 tc_cnt_fx; /* TC frame counter */ -// Word16 audio_frame_cnt_fx; /* Counter of relative presence of audio frames */ -// Word32 old_dE1_fx; /* Maximum energy increase in previous frame */ -// Word16 old_ind_deltaMax_fx; /* Index of the sub-subframe of maximum energy in previous frame */ -// Word32 old_enr_ssf_fx[2 * NB_SSF]; /* Maxima of energies per sub-subframes of previous frame */ -// Word16 spike_hyst_fx; /* Hysteresis to prevent UC after sharp energy spike */ -// Word16 music_hysteresis_fx; /* Counter of frames after AUDIO coding mode to prevent UC */ -// Word16 last_harm_flag_acelp_fx; /* harmonicity flag for ACELP @32kbps rate */ -// Word16 old_Aq_12_8_fx[M + 1]; /* Q12 old Aq[] for core switching */ -// Word16 old_Es_pred_fx; /* Q8 old Es_pred for core switching */ -// -// GSC_ENC_HANDLE hGSCEnc; -// -// -// Word16 GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ -// -// SP_MUS_CLAS_HANDLE hSpMusClas; -// -// Word16 lgBin_E_fx[L_FFT / 2]; /* Q8 per bin energy of two frames */ -// -// /* speech/music classifier improvement parameters */ -// Word16 last_vad_spa_fx; -// -// -// Word16 Last_pulse_pos_fx; /* FEC - last position of the first glotal pulse in the frame */ -// Word16 lsfoldbfi0_fx[M]; /* FEC - LSF vector of the previous frame */ -// Word16 lsfoldbfi1_fx[M]; /* FEC - LSF vector of the past previous frame */ -// Word16 lsf_adaptive_mean_fx[M]; /* FEC - adaptive mean LSF vector for FEC */ -// Word16 next_force_safety_net_fx; /* FEC - flag to force safety net in next frame */ -// -// -// /*----------------------------------------------------------------------------------* -// * VAD/DTX/CNG -// *----------------------------------------------------------------------------------*/ -// -// VAD_HANDLE hVAD; -// -// VAD_CLDFB_HANDLE hVAD_CLDFB; -// Word16 lp_speech_fx; -// Word16 Opt_HE_SAD_ON_fx; -// Word16 nb_active_frames_HE_SAD_fx; -// -// -// -// -// Word16 voicing_old_fx; -// -// -// Word32 bckr_tilt_lt; -// -// -// TD_CNG_ENC_HANDLE hTdCngEnc; -// -// DTX_ENC_HANDLE hDtxEnc; -// Word16 var_SID_rate_flag_fx; /* CNG and DTX - flag for variable SID rate */ -// Word16 interval_SID_fx; /* CNG and DTX - interval of SID update, default 8 */ -// -// Word16 lp_noise_fx; /* CNG and DTX - LP filtered total noise estimation */ -// -// Word16 uv_count; /*Q0*/ /* Stationary noise UV modification - unvoiced counter */ -// Word16 act_count; /*Q0*/ /* Stationary noise UV modification - activation counter */ -// Word32 ge_sm_fx; /* Stationary noise UV modification - smoothed excitation gain */ -// Word16 lspold_s_fx[M]; /*Q15*/ /* Stationary noise UV modification - old LSP vector */ -// Word16 noimix_seed; /*Q0*/ /* Stationary noise UV modification - mixture seed */ -// Word16 min_alpha_fx; /*Q15*/ /* Stationary noise UV modification - minimum alpha */ -// Word16 exc_pe_fx; /* Stationary noise UV modification - memory of the preemphasis filter */ -// -// Word16 last_L_frame_fx; /* ACELP@16kHz - last L_frame value */ -// Word16 mem_preemph16k_fx; /* ACELP@16kHz - preemphasis filter memory @16kHz */ -// Word16 mem_deemp_preQ_fx; /* ACELP@16kHz - prequantizer deemhasis memory */ -// Word16 mem_preemp_preQ_fx; /* ACELP@16kHz - prequantizer preemhasis memory */ -// Word16 last_nq_preQ; /* ACELP@16kHz - AVQ subquantizer number of the last sub-band of the last subframe */ -// Word16 use_acelp_preq; /* ACELP@16kHz - flag of prequantizer usage */ -// -// Word16 bpf_off_fx; -// Word16 old_pitch_buf_fx[2 * NB_SUBFR16k]; /*Q6 Bass post-filter - buffer of old subframe pitch values */ -// -// -// /* stable short pitch detection */ -// Word16 voicing0_sm_fx; -// Word16 voicing_sm_fx; -// Word16 LF_EnergyRatio_sm_fx; -// Word16 predecision_flag_fx; -// Word32 diff_sm_fx; -// Word32 energy_sm_fx; -// -// Word16 last_ener_fx; /* AC mode (GSC) - previous energy */ -// -// /*----------------------------------------------------------------------------------* -// * AMR-WB IO handle -// *----------------------------------------------------------------------------------*/ -// HANDLE_CLDFB_FILTER_BANK cldfbAna_Fx; -// -// AMRWB_IO_ENC_HANDLE hAmrwb_IO; /* AMR-WB IO encoder handle */ -// -// /*----------------------------------------------------------------------------------* -// * CLDFB analysis -// *----------------------------------------------------------------------------------*/ -// HANDLE_CLDFB_FILTER_BANK cldfbAna_Fx; -// -// HANDLE_CLDFB_FILTER_BANK cldfbSyn_Fx; -// -// /*----------------------------------------------------------------------------------* -// * FD CNG handle -// *----------------------------------------------------------------------------------*/ -// HANDLE_FD_CNG_ENC_FX hFdCngEnc_fx; -// Word16 fd_cng_reset_flag; -// Word16 last_totalNoise_fx; -// Word16 totalNoise_increase_hist_fx[TOTALNOISE_HIST_SIZE]; -// Word16 totalNoise_increase_len_fx; -// /*----------------------------------------------------------------------------------* -// * SC-VBR parameters -// *----------------------------------------------------------------------------------*/ -// -// /*----------------------------------------------------------------------------------* -// * SC-VBR parameters -// *----------------------------------------------------------------------------------*/ -// -// SC_VBR_ENC_HANDLE hSC_VBR; -// -// /*----------------------------------------------------------------------------------* -// * HQ core parameters -// *----------------------------------------------------------------------------------*/ -// Word16 * input; -// Word16 * old_input_signal_fx; -// Word16 Q_old_wtda; -// Word16 old_hpfilt_in_fx; -// Word16 old_hpfilt_out_fx; -// Word32 EnergyLT_fx; -// Word32 Energy_Old_fx; -// Word16 TransientHangOver_fx; -// Word16 last_core_fx; -// -// HQ_ENC_HANDLE hHQ_core; /* HQ core encoder handle */ -// -// Word16 Nb_ACELP_frames_fx; -// -// PVQ_ENC_HANDLE hPVQ; -// -// /*----------------------------------------------------------------------------------* -// * TD BWE parameters -// *----------------------------------------------------------------------------------*/ -// -// TD_BWE_ENC_HANDLE hBWE_TD; -// -// /*----------------------------------------------------------------------------------* -// * FD BWE parameters -// *----------------------------------------------------------------------------------*/ -// -// FD_BWE_ENC_HANDLE hBWE_FD; -// -// /*----------------------------------------------------------------------------------* -// * WB, SWB and FB bandwidth detector -// *----------------------------------------------------------------------------------*/ -// -// Word16 lt_mean_NB_fx; -// Word16 lt_mean_WB_fx; -// Word16 lt_mean_SWB_fx; -// Word16 count_WB_fx; -// Word16 count_SWB_fx; -// Word16 count_FB_fx; -// -// RF_ENC_HANDLE hRF; /* RF encoder handle */ -// -// Word16 rf_mode; -// Word16 rf_target_bits_write; -// Word16 rf_mode_last; -// Word16 last_rf_mode_cng; -// Word16 Opt_RF_ON; -// Word16 rf_fec_offset; -// Word16 rf_fec_indicator; -// -// /*----------------------------------------------------------------------------------* -// * Fixed point only variables -// *----------------------------------------------------------------------------------*/ -// -// Word16 prev_Q_bwe_exc; -// Word16 prev_Q_bwe_syn; -// Word16 Q_stat_noise_ge; -// Word16 Q_stat_noise; -// Word16 Q_syn2; -// Word16 Q_syn; -// Word16 Q_max[L_Q_MEM]; -// Word16 Q_max_16k[L_Q_MEM]; -// Word16 Q_old; -// Word16 prev_Q_old; -// Word16 old_wsp_max; /* Last weigthed speech maximal value */ -// Word16 old_wsp_shift; /* Last wsp scaling */ -// Word16 prev_Q_new; -// Word16 prev_Q_shb; -// -// /*----------------------------------------------------------------------------------* -// * -// *----------------------------------------------------------------------------------*/ -// -// Word16 EnergyLT_fx_exp; -// Word16 prev_lsp_wb_fx[LPC_SHB_ORDER_WB]; -// Word16 prev_lpc_wb_fx[LPC_SHB_ORDER_WB]; -// Word16 prev_lsp_wb_temp_fx[LPC_SHB_ORDER_WB]; -// -// Word16 frame_size_index; /* 0-FRAME_SIZE_NB-1: index determining the frame size */ -// Word16 bits_frame_nominal; /* avg bits per frame on active frame */ -// Word16 bits_frame; /* total bits per frame */ -// Word16 bits_frame_core; /* bits per frame for the core */ -// Word8 narrowBand; -// -// /*ACELP config*/ -// ACELP_config acelp_cfg; /* configuration set for each frame */ -// -// ACELP_config acelp_cfg_rf; /* configuration for RF frame */ -// -// Word16 mode_index; /* Mode Index for LPD core */ -// -// /*TCX config*/ -// TCX_CONFIG_HANDLE hTcxCfg; -// /*----------------------------------------------------------------------------------* -// * TCX core encoder handle -// *----------------------------------------------------------------------------------*/ -// -// TCX_ENC_HANDLE hTcxEnc; -// -// /* cod_main.c */ -// Word16 mem_preemph_enc; /* speech preemph filter memory (at encoder-sampling-rate) */ -// -// -// Word16 *speech_enc; -// Word16 *speech_enc_pe; -// Word16 *new_speech_enc; -// Word16 *new_speech_enc_pe; -// Word16 *wspeech_enc; -// Word16 *synth; -// /* Core Signal Analysis Outputs */ -// -// Word8 enableTcxLpc; /* global toggle for the TCX LPC quantizer */ -// Word16 envWeighted; /* are is{p,f}_old_q[] weighted or not? */ -// -// Word8 acelpEnabled; /* Flag indicating if ACELP can be used */ -// Word8 tcx10Enabled; /* Flag indicating if TCX 10 can be used */ -// Word8 tcx20Enabled; /* Flag indicating if TCX 20 can be used */ -// -// -// Word16 mem_wsp_enc; /* wsp vector memory */ -// -// Word16 nb_bits_header_ace; /* number of bits for the header */ -// Word16 nb_bits_header_tcx; /* number of bits for the header */ -// -// /*Added by fcs : restrict the possible in EVS: 0 base 10 = d.c.b.a base 2*/ -// /* a = 0/1 : ACELP on/off*/ -// /* b = 0/1 : TCX20 on/off*/ -// /* c = 0/1 : TCX40 on/off*/ -// /* d = 0/1 : TCX80 on/off*/ -// Word16 restrictedMode; -// -// /* Framing */ -// Word16 nb_subfr; -// -// Word16 preemph_fac; /*Preemphasis factor*/ -// -// Word16 gamma; -// Word16 inv_gamma; -// -// TransientDetection transientDetection; -// Word16 transient_info[3]; -// -// Word16 acelpFramesCount; /* Acelp frame counter. Counts upto 50 only !!! */ -// -// Word16 prevTempFlatness_fx; /* exponent is AVG_FLAT_E */ -// -// Word32 prevEnergyHF_fx; -// Word32 currEnergyHF_fx; -// Word16 currEnergyHF_e_fx; /* exponent of currEnergyHF and prevEnergyHF */ -// Word32 energyCoreLookahead_Fx; -// Word16 sf_energyCoreLookahead_Fx; -// -// /* lsf quantizer*/ -// Word16 parcorr[2]; -// Word16 parcorr_mid[2]; -// -// Word16 lpcQuantization; -// Word16 numlpc; -// Word16 encoderLookahead_enc; -// Word16 encoderPastSamples_enc; -// Word16 encoderLookahead_FB; -// -// /* pitch_ol for adaptive lag window */ -// Word16 old_pitch_la; /* past open loop pitch lag from look-ahead */ -// Word16 old_voicing_la; /* past open loop pitch gain from look-ahead */ -// -// Word32 band_energies[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor MODE2_E_MIN */ -// Word16 band_energies_exp; /* exponent for energy in critical bands without minimum noise floor MODE2_E_MIN */ -// -// Word8 tcxonly; -// -// Word16 Q_max_enc[2]; -// -// Word16 finalVAD; -// Word8 flag_noisy_speech_snr; /*encoder detector for noisy speech*/ -// Word16 Pos_relE_cnt; /* Number of frames between positive relE */ -// -// Word16 fscale; -// Word32 sr_core; -// Word32 last_sr_core; -// Word8 acelp_autocorr; /* Optimize acelp in 0 covariance or 1 correlation domain */ -// -// Word16 pit_min; -// Word16 pit_fr1; -// Word16 pit_fr1b; -// Word16 pit_fr2; -// Word16 pit_max; -// Word16 pit_res_max; /* goes from 1 upto 6 (see core_enc_init.c: init_acelp()) */ -// -// /* for FAC */ -// Word16 L_frame_past; -// -// /*Adaptive BPF*/ -// Word16 bpf_gain_param; -// Word16 bpf_T[NB_SUBFR16k]; -// Word16 bpf_gainT[NB_SUBFR16k]; -// -// struct MEM_BPF -// { -// Word16 noise_buf[2 * L_FILT16k]; -// Word16 error_buf[L_FILT16k]; -// Word32 lp_error; -// Word32 lp_error_ener; -// Word16 noise_shift_old; -// } mem_bpf; -// -// -// -// Word8 glr; -// Word16 glr_idx[2]; -// Word32 gain_code[NB_SUBFR16k]; -// Word32 mean_gc[2]; -// Word16 prev_lsf4_mean; -// Word16 last_stab_fac; -// Word8 glr_reset; -// -// /*for rate switching*/ -// Word16 rate_switching_reset; /*Rate switching flag requiring a reset of memories at least partially */ -// Word16 rate_switching_reset_16kHz; -// -// Word16 enablePlcWaveadjust; -// Word16 Tonal_SideInfo; -// -// IGF_ENC_INSTANCE_HANDLE hIGFEnc; /* IGF encoder handle */ -// Word16 igf; -// -// Word16 seed_acelp; -// -// PLC_ENC_EVS_HANDLE hPlcExt; -// -// Word16 tec_tfa; -// TEC_ENC_HANDLE hTECEnc; /* TEC encoder handle */ -// Word16 tec_flag; -// Word16 tfa_flag; -// Word32 tfa_enr[N_TEC_TFA_SUBFR]; -// -// Word16 nTimeSlots; /* for CLDFB */ -// -// T_CldfbVadState_fx vad_st; -// -// -// Word16 pitch_fx[3]; -// Word16 voicing_fx[3]; -// Word16 sp_aud_decision0; /* 1st stage speech/music classification */ -// Word16 sp_aud_decision1; /* 1st stage speech/music classification */ -// Word16 sp_aud_decision2; /* 2nd stage speech/music classification */ -// Word16 coder_type; /* coder type */ -// Word16 vad_flag; -// Word16 sharpFlag; /* formant sharpening flag */ -// Word16 localVAD; -// -// Word16 tdm_pc; -// Word16 prev_fmerit; -// Word16 fmerit_dt; -// -// -// } Encoder_State, * ENC_CORE_HANDLE_FX; typedef struct GainItemStr { diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index 77d7f538f..fb2a6215b 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -332,7 +332,7 @@ void updt_IO_switch_enc_fx( * * Common updates for MODE1 and MODE2 *-------------------------------------------------------------------*/ -#if 1 + void updt_enc_common_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 Etot, /* i : total energy */ @@ -343,27 +343,24 @@ void updt_enc_common_fx( * Updates - main main codec parameters *---------------------------------------------------------------------*/ - st->last_sr_core = st->sr_core; //## + st->last_sr_core = st->sr_core; move32(); st->last_codec_mode = st->codec_mode; move16(); - st->last_L_frame = st->L_frame; // + st->last_L_frame = st->L_frame; move16(); st->last_core = st->core; move16(); st->last_core_brate = st->core_brate; move32(); -#ifdef IVAS_CODE - st->last_bits_frame_nominal_fx = st->bits_frame_nominal; -#endif st->last_total_brate = st->total_brate; move32(); - st->last_extl = st->extl; // + st->last_extl = st->extl; move16(); - st->last_input_bwidth = st->input_bwidth; //## + st->last_input_bwidth = st->input_bwidth; move16(); - st->last_bwidth = st->bwidth; //## + st->last_bwidth = st->bwidth; move16(); st->hNoiseEst->Etot_last_fx = Etot; move16(); @@ -425,18 +422,12 @@ void updt_enc_common_fx( move16(); move16(); -#ifdef IVAS_CODE test(); test(); test(); IF( ( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GE_16( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) ) { - st->hTdCngEnc->CNG_att_fx = 0; - move16(); - - apply_scale( &st->hTdCngEnc->CNG_att, st->hFdCngEnc->hFdCngCom->CngBandwidth, st->hFdCngEnc->hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); } -#endif } } @@ -550,17 +541,14 @@ void updt_enc_common_fx( /*---------------------------------------------------------------------* * Other updates *---------------------------------------------------------------------*/ -#ifdef IVAS_CODE + test(); IF( GT_16( st->element_mode, EVS_MONO ) && st->hTcxEnc != NULL ) { - st->hTcxEnc->tcxltp_norm_corr_mem = st->hTcxEnc->tcxltp_norm_corr_past; - move16(); } -#endif return; } -#endif + void updt_enc_common_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 12ec31933..1fdcb94fa 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -1296,19 +1296,9 @@ Word16 wb_vad_fx( L_tmp = L_shl( L_mult( sub( hNoiseEst->Etot_v_h2_fx, nv_ofs ), nv ), 7 ); /* Q8+Q8+1 +7 --> Q24 */ L_tmp = L_mac( L_tmp, nc, (Word16) 32767 ); /* Q8+Q15+1 = Q24 */ thr1 = mac_r( L_tmp, lp_snr, nk ); /* Q8+Q15+1 - 16 --> Q8 */ -#ifdef IVAS_CODE - IF( st->element_mode > EVS_MONO && LT_16( hNoiseEst->first_noise_updt_cnt, 100 ) ) - { - /* lower threshold during warmup time */ - thr1 -= 10.0f; - vad_thr = 0.f; - } -#endif + IF( GT_16( lp_snr, (Word16) 20 * ( 1 << 8 ) ) ) /* if (lp_snr > 20.0f )*/ { -#ifdef IVAS_CODE - IF( st->element_mode == EVS_MONO || GT_16( hNoiseEst->first_noise_updt_cnt, 100 ) ) -#endif { /* thr1 = thr1 + 0.3f * (lp_snr - 20.0f); */ thr1 = add( thr1, mult( 9830, sub( lp_snr, (Word16) 20 * ( 1 << 8 ) ) ) ); /* Q15*Q8+1 -16 --> Q8 */ -- GitLab From 65df1d250d03b1181a37b3149b1f67285ae5f266 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 15:57:17 +0530 Subject: [PATCH 27/97] Clang formatting changes --- lib_enc/swb_bwe_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 639ec9dca..3ca3f3f3f 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -3205,7 +3205,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( tmp = i_mult2( n_band, L ); FOR( i = 0; i < L; i++ ) { - WB_tenv_syn_fx = L_add( WB_tenv_syn_fx, L_shr( L_mult0( synth_fx[i + tmp], synth_fx[i + tmp] ), 7 ) ); /*2*Q_insig_lp-7 */ + WB_tenv_syn_fx = L_add( WB_tenv_syn_fx, L_shr( L_mult0( synth_fx[i + tmp], synth_fx[i + tmp] ), 7 ) ); /*2*Q_insig_lp-7 */ WB_tenv_orig_fx = L_add( WB_tenv_orig_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*2*Q_insig_lp - 7 */ } -- GitLab From e46fb7a4a262cabfb315c91d213c418e14358ec7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 11:27:53 +0100 Subject: [PATCH 28/97] review and remove redundant code under IVAS_CODE_SWITCHING --- lib_com/prot_fx.h | 18 +-- lib_dec/core_switching_dec_fx.c | 279 ++------------------------------ lib_dec/evs_dec_fx.c | 10 +- 3 files changed, 16 insertions(+), 291 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index cb7416eb3..0371f747a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8011,22 +8011,12 @@ ivas_error core_switching_pre_dec_fx( ); ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ -#ifdef IVAS_CODE_SWITCHING - float *output, /* i/o: LB synth/upsampled LB synth */ - float output_mem[], /* i : OLA memory from last TCX/HQ frame */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ -#endif + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ -#ifdef IVAS_CODE_SWITCHING - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - const Word16 nchan_out, /* i : number of output channels */ -#endif - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ ); ivas_error core_switching_post_dec_ivas_fx( diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index f984f2ce9..17b3f9fbc 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -16,10 +16,6 @@ * * *---------------------------------------------------------------------*/ -#ifdef IVAS_CODE_SWITCHING -static void core_switch_lb_upsamp( Decoder_State *st, float *output ); -static void smoothTransitionDtxToTcx( float synth[], const int16_t output_frame, const int16_t delay_comp ); -#endif static void smoothTransitionDtxToTcx_fx( Word16 synth[], const Word16 output_frame, const Word16 delay_comp ); static void core_switch_lb_upsamp_fx( Decoder_State *st, Word32 *output ); @@ -189,30 +185,11 @@ void bw_switching_pre_proc_fx( Flag Overflow = 0; move32(); #endif -#ifdef IVAS_CODE_SWITCHING + IF( st_fx->element_mode > EVS_MONO ) { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st_fx->core, ACELP_CORE ) && !( EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) && - st_fx->hBWE_FD != NULL && !( LE_16( st_fx->core_brate, SID_2k40 ) && EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) && - !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st_fx->idchan, 1 ) && LE_16( last_element_brate, IVAS_SID_4k4 ) ) ) - { - /* Calculate tilt of the ACELP core synthesis - needed in SWB BWE decoding */ - calc_tilt_bwe( old_syn_12k8_16k, &st->tilt_wb, st->L_frame ); - } - - return; } -#endif + test(); test(); IF( EQ_16( st_fx->core, ACELP_CORE ) && !( EQ_16( st_fx->bfi, 1 ) && EQ_16( st_fx->con_tcx, 1 ) ) ) @@ -321,149 +298,7 @@ void bw_switching_pre_proc_fx( return; } -#ifdef IVAS_CODE_SWITCHING - - -/*---------------------------------------------------------------------* - * core_switch_lb_upsamp() - * - * Resample HQ/TCX-LB to the output sampling rate (8/16/32/48 kHz) - *---------------------------------------------------------------------*/ - -static void core_switch_lb_upsamp( - Decoder_State *st, /* i/o: Decoder state */ - float *output /* i/o: LB synth/upsampled LB synth */ -) -{ - int16_t i; - float *realBuffer[CLDFB_OVRLP_MIN_SLOTS], *imagBuffer[CLDFB_OVRLP_MIN_SLOTS]; - float realBufferTmp[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; - float imagBufferTmp[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; - - /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - for ( i = 0; i < CLDFB_OVRLP_MIN_SLOTS; i++ ) - { - set_f( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - set_f( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer[i] = realBufferTmp[i]; - imagBuffer[i] = imagBufferTmp[i]; - } - - /* check if the CLDFB works on the right sample rate */ - if ( ( st->cldfbAna->no_channels * st->cldfbAna->no_col ) != st->L_frame ) - { - resampleCldfb( st->cldfbAna, st->L_frame * FRAMES_PER_SEC ); - - if ( st->cldfbBPF != NULL && st->L_frame <= L_FRAME16k ) - { - resampleCldfb( st->cldfbBPF, st->L_frame * FRAMES_PER_SEC ); - } - - if ( st->ini_frame > 0 ) - { - st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels; - } - } - - /* analysis of the synthesis at internal sampling rate */ - cldfbAnalysis( output, realBuffer, imagBuffer, CLDFB_OVRLP_MIN_SLOTS * st->cldfbAna->no_channels, st->cldfbAna ); - - /* analysis and add the BPF error signal */ - if ( st->p_bpf_noise_buf ) - { - addBassPostFilter( st->p_bpf_noise_buf, st->bpf_off ? 0 : CLDFB_OVRLP_MIN_SLOTS * st->cldfbBPF->no_channels, realBuffer, imagBuffer, st->cldfbBPF ); - } - - /* set output mask for upsampling */ - if ( st->bwidth == NB ) - { - /* set NB mask for upsampling */ - st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - 10; - } - else if ( st->cldfbSyn->bandsToZero != st->cldfbSyn->no_channels - st->cldfbAna->no_channels ) - { - /* in case of BW switching, re-init to default */ - st->cldfbSyn->bandsToZero = st->cldfbSyn->no_channels - st->cldfbAna->no_channels; - } - - /* synthesis of the combined signal */ - cldfbSynthesis( realBuffer, imagBuffer, output, CLDFB_OVRLP_MIN_SLOTS * st->cldfbSyn->no_channels, st->cldfbSyn ); - - /* save synthesis - needed in case of core switching */ - if ( st->hTcxDec != NULL ) - { - mvr2r( output, st->previoussynth, st->hTcxDec->L_frameTCX ); - } - - return; -} - -/*---------------------------------------------------------------------* - * smoothTransitionMdctStereoDtx() - * - * apply smoothing to the transition part for MDCT-Stereo DTX - *---------------------------------------------------------------------*/ - -#define TRANSITION_SMOOTHING_LEN_16k 15 -#define TRANSITION_SMOOTHING_LEN_32k 31 -#define TRANSITION_SMOOTHING_LEN_48k 47 - -static void smoothTransitionMdctStereoDtx( - float synth[], /* i/o: synthesis */ - const int16_t output_frame, /* i : output frame length */ - const int16_t delay_comp /* i : delay compensation in samples */ -) -{ - int16_t i, filter_len; - float w, mem, step, fade_in; - float smoothing_input_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; - float smoothing_out_buffer[2 * NS2SA( 48000, DELAY_CLDFB_NS ) + TRANSITION_SMOOTHING_LEN_48k]; - - filter_len = TRANSITION_SMOOTHING_LEN_16k; - if ( output_frame == L_FRAME32k ) - { - filter_len = TRANSITION_SMOOTHING_LEN_32k; - } - else if ( output_frame == L_FRAME48k ) - { - filter_len = TRANSITION_SMOOTHING_LEN_48k; - } - - /* prepare buffer */ - for ( i = 0; i < filter_len / 2; i++ ) - { - smoothing_input_buffer[i] = synth[0]; - } - mvr2r( synth, smoothing_input_buffer + filter_len / 2, 2 * delay_comp + filter_len / 2 ); - - /* apply Mean filter */ - w = 1.f / filter_len; - mem = sum_f( smoothing_input_buffer, filter_len ); - for ( i = 0; i < 2 * delay_comp; i++ ) - { - smoothing_out_buffer[i] = w * mem; - mem = mem - smoothing_input_buffer[i] + smoothing_input_buffer[i + filter_len]; - } - /* apply fades around transition */ - step = 1.f / delay_comp; - fade_in = 0.f; - for ( i = 0; i < delay_comp; i++ ) - { - synth[i] = smoothing_out_buffer[i] * fade_in + synth[i] * ( 1 - fade_in ); - fade_in += step; - } - - fade_in = 0.f; - for ( ; i < 2 * delay_comp; i++ ) - { - synth[i] = synth[i] * fade_in + smoothing_out_buffer[i] * ( 1 - fade_in ); - fade_in += step; - } - - return; -} -#endif /*---------------------------------------------------------------------* * core_switching_pre_dec_fx() * @@ -738,13 +573,7 @@ ivas_error core_switching_pre_dec_fx( test(); test(); - IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) - //#ifdef IVAS_CODE_SWITCHING - // || ((EQ_16(st_fx->element_mode, IVAS_CPE_DFT) || EQ_16(st_fx->element_mode, IVAS_CPE_TD) || - // (EQ_16(st_fx->element_mode, IVAS_CPE_MDCT) && last_element_mode == IVAS_CPE_DFT)) && EQ_16(nchan_out,2) && - // NE_16(st_fx->core_brate, SID_2k40) && NE_16(st_fx->core_brate, FRAME_NO_DATA) && (EQ_16(last_core_brate_st0, FRAME_NO_DATA) || EQ_16(last_core_brate_st0, SID_2k40))) - //#endif - ) + IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) ) { test(); IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) @@ -770,14 +599,7 @@ ivas_error core_switching_pre_dec_fx( lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX ); } -#ifdef IVAS_CODE_SWITCHING - if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && nchan_out == 2 && st->core_brate > SID_2k40 && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) && st->hTcxDec != NULL ) - { - /* Last frame was Stereo CNG and the synthesis memory is outdated -- reset */ - set_f( st->hTcxDec->old_syn_Overl, 0.0f, L_FRAME32k / 2 ); - set_f( st->hFdCngDec->hFdCngCom->olapBufferAna, 0.0f, FFTLEN ); - } -#endif + set16_fx( st_fx->agc_mem_fx, 0, 2 ); st_fx->mem_deemph_fx = 0; move16(); @@ -876,47 +698,7 @@ ivas_error core_switching_pre_dec_fx( set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA_FX2( 16000, DELAY_FD_BWE_ENC_NS ) ); } } -#ifdef IVAS_CODE_SWITCHING - if ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && ( st->last_core == TCX_20_CORE || st->last_core == TCX_10_CORE ) ) - { - if ( st->hBWE_TD != NULL ) - { - st->hBWE_TD->bwe_non_lin_prev_scale = 0.0f; - set_f( st->hBWE_TD->old_bwe_exc, 0, PIT16k_MAX * 2 ); - } - - st->tilt_code = 0.0f; - st->gc_threshold = 0.0f; - set_f( st->dispMem, 0, 8 ); - - st->last_coder_type = GENERIC; - - fer_energy( output_frame, UNVOICED_CLAS, st->previoussynth, -1, &st->enr_old, 1 ); - st->lp_gainp = 0.0f; - st->lp_gainc = (float) sqrt( st->lp_ener ); - - st->last_voice_factor = 0; - st->Last_GSC_noisy_speech_flag = 0; - - if ( st->output_Fs >= 16000 && st->hBWE_zero != NULL ) - { - hf_synth_reset( st->hBWE_zero ); - } - if ( st->hBWE_FD != NULL ) - { - set_f( st->hBWE_FD->old_syn_12k8_16k, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); - } - - if ( nchan_out == 1 && st->element_mode == IVAS_CPE_DFT && st->element_brate <= IVAS_24k4 && last_element_brate > IVAS_24k4 ) - { - /* update cldbf state with previous frame TCX synthesis when going from a bitrate with residual coding to a bitrate without it */ - int16_t offset; - offset = st->cldfbAna->p_filter_length - st->cldfbAna->no_channels; - mvr2r( st->hTcxDec->old_synthFB + st->hTcxDec->old_synth_lenFB - offset, st->cldfbAna->cldfb_state, offset ); - } - } -#endif test(); test(); test(); @@ -941,40 +723,16 @@ ivas_error core_switching_pre_dec_fx( { set32_fx( hHQ_core->prev_coeff_out_fx, 0, L_HQ_WB_BWE ); } -#ifdef IVAS_CODE_SWITCHING - if ( st->element_mode != EVS_MONO ) - { - /* Estimate mem_env_delta to reinit env_stab */ - tmp = max( 0, ENV_STAB_EST1 + ( ENV_STAB_EST2 * st->stab_fac_smooth_lt ) + ( ENV_STAB_EST3 * st->log_energy_diff_lt ) ); - st->hHQ_core->mem_env_delta = (int16_t) min( MAX16B, (int32_t) ( tmp * ( 1 << 12 ) ) ); /* Convert to Q12 and handle saturation */ - - if ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE ) - { - set_f( st->hHQ_core->old_out, 0, output_frame ); - set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k ); - } - st->hHQ_core->no_att_hangover = 0; - st->hHQ_core->energy_lt = 300.0f; - - set_s( st->hHQ_core->old_is_transient, 0, 3 ); - set_f( st->hHQ_core->prev_noise_level, 0.0f, 2 ); - st->hHQ_core->prev_R = 0; - set_s( st->hHQ_core->mem_norm + 1, 39, SFM_N_ENV_STAB - 1 ); - st->hHQ_core->prev_hqswb_clas = HQ_NORMAL; - st->hHQ_core->prev_ni_ratio = 0.5f; - set_f( st->hHQ_core->prev_En_sb, 0.0f, NB_SWB_SUBBANDS ); + if ( st_fx->element_mode != EVS_MONO ) + { } else -#endif { set16_fx( hHQ_core->old_out_fx, 0, output_frame ); hHQ_core->Q_old_wtda_LB = 15; hHQ_core->Q_old_wtda = 15; move16(); -#ifdef IVAS_CODE_SWITCHING - set_f( st->hHQ_core->old_outLB, 0, L_FRAME16k ); -#endif } } @@ -1081,12 +839,10 @@ ivas_error core_switching_pre_dec_fx( IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) && LE_16( st_fx->L_frame, L_FRAME16k ) && LE_16( st_fx->last_L_frame, L_FRAME16k ) ) { test(); -#ifdef IVAS_CODE_SWITCHING IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->last_L_frame, st_fx->hFdCngDec->hFdCngCom->olapBufferAna + st_fx->L_frame, st_fx->L_frame, st_fx->last_L_frame ); } -#endif + lerp( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st_fx->L_frame, 1 ), shl( st_fx->last_L_frame, 1 ) ); test(); IF( LE_32( st_fx->total_brate, SID_2k40 ) && LE_32( st_fx->last_total_brate, SID_2k40 ) ) @@ -1122,22 +878,12 @@ ivas_error core_switching_pre_dec_fx( *---------------------------------------------------------------------*/ ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ -#ifdef IVAS_CODE_SWITCHING - float *output, /* i/o: LB synth/upsampled LB synth */ - float output_mem[], /* i : OLA memory from last TCX/HQ frame */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ -#endif + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth*/ const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ -#ifdef IVAS_CODE_SWITCHING - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - const Word16 nchan_out, /* i : number of output channels */ -#endif - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ ) { Word16 i, delay_comp, delta; @@ -1152,9 +898,6 @@ ivas_error core_switching_post_dec_fx( HQ_DEC_HANDLE hHQ_core; ivas_error error; -#ifdef IVAS_CODE_SWITCHING - int16_t offset; -#endif #ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING (void) ( last_element_mode ); #endif diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 60e13dd8f..a5a5ba6d9 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -360,15 +360,7 @@ ivas_error evs_dec_fx( * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ - if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, -#ifdef IVAS_CODE_SWITCHING - output, output_mem[], IVAS_FORMAT ivas_format, use_cldfb_for_dft, -#endif - output_frame, core_switching_flag, -#ifdef IVAS_CODE_SWITCHING - sba_dirac_stereo_flag, nchan_out, -#endif - st_fx->last_element_mode, &Qpostd ) ) != IVAS_ERR_OK ) + if ( ( error = core_switching_post_dec_fx( st_fx, synth_fx, output_frame, core_switching_flag, st_fx->last_element_mode, &Qpostd ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From d716d99ff0cda5fd84edb3c30aacb7d92c45ee25 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 11:29:26 +0100 Subject: [PATCH 29/97] remove redundant code under IVAS_CODE_FCB --- lib_dec/dec4t64_fx.c | 235 ------------------------------------------- 1 file changed, 235 deletions(-) diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c index 58f9048c4..ee6ef65a6 100644 --- a/lib_dec/dec4t64_fx.c +++ b/lib_dec/dec4t64_fx.c @@ -793,242 +793,7 @@ void D_ACELP_decode_43bit_fx( UWord16 idxs[], Word16 code[], Word16 *pulsestrack return; } -#ifdef IVAS_CODE_FCB -/*-------------------------------------------------------* - * dec_1p_N1() - * - * Decode 1 pulse with N+1 bits - *-------------------------------------------------------*/ - -static void dec_1p_N1_L_subfr( - const int32_t index, /* i : quantization index */ - const int16_t nb_pos, /* i : number of positions */ - const int16_t N, /* i : nb. of bits */ - int16_t pos[] /* o : pulse position */ -) -{ - int16_t i, pos1; - int32_t mask; - - mask = ( ( 1 << N ) - 1 ); - pos1 = (int16_t) ( index & mask ); - i = (int16_t) ( index >> N ) & 1; - - if ( i == 1 ) - { - pos1 += nb_pos; - } - - pos[0] = pos1; - - return; -} - -/*-------------------------------------------------------* - * add_pulses() - * - * Add decoded pulses to the codeword - *-------------------------------------------------------*/ - -static void add_pulses_L_subfr( - const int16_t nb_pos, /* i : number of positions */ - const int16_t pos[], /* i : pulse position */ - const int16_t nb_pulse, /* i : nb. of pulses */ - const int16_t track, /* i : no. of the tracks */ - float code[] /* i/o: decoded codevector */ -) -{ - int16_t i, k; - - for ( k = 0; k < nb_pulse; k++ ) - { - i = ( ( pos[k] & ( nb_pos - 1 ) ) * NB_TRACK_FCB_4T ) + track; - if ( ( pos[k] & nb_pos ) == 0 ) - { - code[i] += 1.0f; - } - else - { - code[i] -= 1.0f; - } - } - - return; -} - -/*----------------------------------------------------------------------------------* - * dec_acelp_fast() - * - * fast algebraic codebook decoder - *----------------------------------------------------------------------------------*/ - -void dec_acelp_fast( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t cdk_index, /* i : codebook index */ - float code[], /* o : algebraic (fixed) codebook excitation */ - const int16_t L_subfr /* i : subframe length */ -) -{ - int16_t k, pos[7], skip_track; - int32_t L_index; - PulseConfig config; - - skip_track = -1; - set_f( code, 0.0f, L_subfr ); - - if ( L_subfr == L_SUBFR ) - { - config = PulseConfTable[cdk_index]; - - if ( cdk_index == 2 ) - { - dec_acelp_2t32( st, code ); - } - else if ( config.nb_pulse == 2 ) - { - /* 10 bits, 2 pulses, 4 tracks 1010 (used only even tracks) */ - for ( k = 0; k < NB_TRACK_FCB_4T - 1; k += 2 ) - { - L_index = get_next_indice( st, 5 ); - dec_1p_N1( L_index, 4, 0, pos ); - add_pulses( pos, 1, k, code ); - } - } - else if ( config.nb_pulse == 3 ) - { - if ( config.codetrackpos == TRACKPOS_FIXED_FIRST ) - { - /* 15 bits, 3 pulses, 4 tracks 1110 fixed track to first ? */ - for ( k = 0; k < NB_TRACK_FCB_4T - 1; k++ ) - { - L_index = get_next_indice( st, 5 ); - dec_1p_N1( L_index, 4, 0, pos ); - add_pulses( pos, 1, k, code ); - } - } - else if ( config.codetrackpos == TRACKPOS_FREE_THREE ) - { - /* 17 bits, 3 pulses, 4 tracks (used all tracks) - 1110, 1101, 1011, 0111 */ - skip_track = get_next_indice( st, 2 ); - for ( k = 0; k < NB_TRACK_FCB_4T; k++ ) - { - if ( k != skip_track ) - { - L_index = get_next_indice( st, 5 ); - dec_1p_N1( L_index, 4, 0, pos ); - add_pulses( pos, 1, k, code ); - } - } - } - } - else - { - if ( config.bits == 20 ) - { - skip_track = -1; - } - else if ( config.codetrackpos == TRACKPOS_FIXED_FIRST ) - { - skip_track = 0; - } - else if ( config.codetrackpos == TRACKPOS_FREE_ONE ) - { - skip_track = get_next_indice( st, 2 ); - } - - for ( k = 0; k < NB_TRACK_FCB_4T; k++ ) - { - if ( k == skip_track ) - { - L_index = get_next_indice( st, 9 ); - dec_2p_2N1( L_index, 4, 0, pos ); - add_pulses( pos, 2, k, code ); - } - else - { - L_index = get_next_indice( st, 5 ); - dec_1p_N1( L_index, 4, 0, pos ); - add_pulses( pos, 1, k, code ); - } - } - } - } - else /* L_subfr == 2*L_SUBFR */ - { - config.bits = cdk_index; - - if ( cdk_index == 14 ) - { - /* 14 bits, 2 pulses, 2 tracks: 11 (used all tracks) */ - int16_t index, i0, i1; - - index = get_next_indice( st, 14 ); - - i0 = ( ( index >> 7 ) & ( NB_POS_FCB_2T_128 - 1 ) ) * NB_TRACK_FCB_2T; - i1 = ( ( index & ( NB_POS_FCB_2T_128 - 1 ) ) * NB_TRACK_FCB_2T ) + 1; - - code[i0] = -1.0f; - if ( ( index & 0x2000 ) == 0 ) - { - code[i0] = 1.0f; - } - - code[i1] = -1.0f; - if ( ( index & 0x40 ) == 0 ) - { - code[i1] = 1.0f; - } - } - else if ( cdk_index == 12 ) - { - /* 12 bits, 2 pulses, 4 tracks: 1010 (used only even tracks) */ - for ( k = 0; k < NB_TRACK_FCB_4T - 1; k += 2 ) - { - L_index = get_next_indice( st, 6 ); - dec_1p_N1_L_subfr( L_index, NB_POS_FCB_4T_128, 5, pos ); - add_pulses_L_subfr( NB_POS_FCB_4T_128, pos, 1, k, code ); - } - } - else if ( cdk_index == 18 ) - { - /* 18 bits, 3 pulses, 4 tracks: 1110 (used first three tracks) */ - for ( k = 0; k < NB_TRACK_FCB_4T - 1; k++ ) - { - L_index = get_next_indice( st, 6 ); - dec_1p_N1_L_subfr( L_index, NB_POS_FCB_4T_128, 5, pos ); - add_pulses_L_subfr( NB_POS_FCB_4T_128, pos, 1, k, code ); - } - } - else if ( cdk_index == 20 ) - { - /* 20 bits, 3 pulses, 4 tracks (used all tracks): 1110, 1101, 1011, 0111 */ - skip_track = get_next_indice( st, 2 ); - for ( k = 0; k < NB_TRACK_FCB_4T; k++ ) - { - if ( k != skip_track ) - { - L_index = get_next_indice( st, 6 ); - dec_1p_N1_L_subfr( L_index, NB_POS_FCB_4T_128, 5, pos ); - add_pulses_L_subfr( NB_POS_FCB_4T_128, pos, 1, k, code ); - } - } - } - else if ( cdk_index == 24 ) - { - /* 24 bits, 4 pulses, 4 tracks: 1111 */ - for ( k = 0; k < NB_TRACK_FCB_4T; k++ ) - { - L_index = get_next_indice( st, 6 ); - dec_1p_N1_L_subfr( L_index, NB_POS_FCB_4T_128, 5, pos ); - add_pulses_L_subfr( NB_POS_FCB_4T_128, pos, 1, k, code ); - } - } - } - - return; -} -#endif /*-------------------------------------------------------* * dec_1p_N1() -- GitLab From 3c022b6dac418d2aa99a2d0c7779a63d18c6ea4b Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 11:34:25 +0100 Subject: [PATCH 30/97] remove redundant code under IVAS_CODE_CPE, IVAS_CODE_DFT, and IVAS_CODE_BWD --- lib_enc/amr_wb_enc_fx.c | 6 +----- lib_enc/analy_sp_fx.c | 24 ++---------------------- lib_enc/bw_detect_fx.c | 11 +++-------- lib_enc/pre_proc_fx.c | 6 +----- lib_enc/prot_fx_enc.h | 4 ---- 5 files changed, 7 insertions(+), 44 deletions(-) diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 90bdc74a5..5a3aec3f4 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -292,11 +292,7 @@ void amr_wb_enc_fx( * Detect NB spectrum in a 16kHz-sampled input *----------------------------------------------------------------*/ - analy_sp_fx( st->element_mode, -#ifdef IVAS_CODE_CPE - hCPE, -#endif - st->input_Fs, inp, Q_new, fr_bands, lf_E, &Etot, st->min_band, st->max_band, Le_min_scaled, Scale_fac, st->Bin_E_fx, + analy_sp_fx( st->element_mode, inp, Q_new, fr_bands, lf_E, &Etot, st->min_band, st->max_band, Le_min_scaled, Scale_fac, st->Bin_E_fx, st->Bin_E_old_fx, PS, st->lgBin_E_fx, st->band_energies, fft_buff ); noise_est_pre_fx( Etot, st->ini_frame, hNoiseEst, 0, EVS_MONO, EVS_MONO ); diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index d5333ae13..185bac26b 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -19,9 +19,7 @@ static void find_enr( Word16 data[], Word32 band[], Word32 *ptE, Word32 *LEtot, const Word16 min_band, const Word16 max_band, const Word16 Q_new2, const Word32 e_min, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies ); static void ivas_find_enr( Word16 *data, Word16 q_data, Word32 *band, Word16 *q_band, Word32 *ptE, Word16 *q_ptE, Word64 *LEtot, const Word16 min_band, const Word16 max_band, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies ); -#ifdef IVAS_CODE_CPE -static void find_enr_dft( CPE_ENC_HANDLE hCPE, const int32_t input_Fs, float DFT_past_DMX[], float band[], float *ptE, float *Etot, const int16_t min_band, const int16_t max_band, float *Bin_E, float *band_ener ); -#endif + /*-------------------------------------------------------------------* * analy_sp_fx() @@ -31,10 +29,6 @@ static void find_enr_dft( CPE_ENC_HANDLE hCPE, const int32_t input_Fs, float DFT void analy_sp_fx( const Word16 element_mode, /* i : element mode */ -#ifdef IVAS_CODE_CPE - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ -#endif - const Word32 input_Fs, /* i : input sampling rate */ Word16 *speech, /* i : speech buffer Q_new - preemph_bits */ const Word16 Q_new, /* i : current scaling exp Q0 */ Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE */ @@ -60,9 +54,7 @@ void analy_sp_fx( Word16 Min_val, Max_val; Word16 Scale_fac2; Word16 fft_temp[L_FFT]; -#ifndef IVAS_CODE_CPE - (void) input_Fs; -#endif + /*-----------------------------------------------------------------* * Compute spectrum * find energy per critical frequency band and total energy in dB @@ -134,18 +126,6 @@ void analy_sp_fx( pt_fft += L_FFT; } } -#ifdef IVAS_CODE_CPE - ELSE - { - /* find energy per critical band */ - find_enr_dft( hCPE, input_Fs, hCPE->hStereoDft->DFT[0], pt_bands, lf_E, Etot, min_band, max_band, Bin_E, band_ener ); - mvr2r( lf_E, lf_E + VOIC_BINS, VOIC_BINS ); - mvr2r( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 ); - mvr2r( band_ener, band_ener + NB_BANDS, NB_BANDS ); - mvr2r( pt_bands, pt_bands + NB_BANDS, NB_BANDS ); - *Etot *= 2.f; - } -#endif /* Average total log energy over both half-frames */ frac_etot = 0; diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 931b175ff..2e9b2c5db 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -67,12 +67,6 @@ void bw_detect_fx( const Word32 *pt32; Word32 max_NB32, max_WB32, max_SWB32, max_FB32, mean_NB32, mean_WB32, mean_SWB32, mean_FB32; /* Q11*/ /* we need Word32 for the new cldfb energy vectors */ Word16 bwd_count_wider_bw; -#ifdef IVAS_CODE_DFT - Word16 l_frame; -#endif -#ifndef IVAS_CODE_BWD - (void) spectrum; -#endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -1046,7 +1040,7 @@ void set_bw_fx( move16(); } } -//#ifdef IVAS_CODE_BWD + /*-------------------------------------------------------------------* * set_bw_stereo() @@ -1093,7 +1087,8 @@ void set_bw_stereo_fx( return; } -//#endif + + /*-------------------------------------------------------------------* * set_bw_mct() * diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 5a8f4aa7c..7c17e76d8 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -254,11 +254,7 @@ void pre_proc_fx( * Spectral analysis *--------------------------------------------------------------------------*/ - analy_sp_fx( -1, -#ifdef IVAS_CODE_CPE - NULL, -#endif - st->input_Fs, inp_12k8, *Q_new, fr_bands, lf_E, Etot, st->min_band, st->max_band, Le_min_scaled, Scale_fac, st->Bin_E_fx, st->Bin_E_old_fx, + analy_sp_fx( -1, inp_12k8, *Q_new, fr_bands, lf_E, Etot, st->min_band, st->max_band, Le_min_scaled, Scale_fac, st->Bin_E_fx, st->Bin_E_old_fx, PS, st->lgBin_E_fx, st->band_energies, fft_buff ); st->band_energies_exp = sub( sub( WORD32_BITS - 1, *Q_new ), QSCALE ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 0a058740b..02f8344d1 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2190,10 +2190,6 @@ void stat_noise_uv_enc_ivas_fx( void analy_sp_fx( const Word16 element_mode, /* i : element mode */ -#ifdef IVAS_CODE_CPE - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ -#endif - const Word32 input_Fs, /* i : i sampling rate */ Word16 *speech, /* i : speech buffer Q_new - preemph_bits */ const Word16 Q_new, /* i : current scaling exp Q0 */ Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE */ -- GitLab From 510e8af8c52190ec433eafe94526aa07e37e6ab0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 11:55:26 +0100 Subject: [PATCH 31/97] clang-format --- lib_com/gs_bitallocation_fx.c | 56 +++++++++++++++++------------------ lib_enc/lsf_enc_fx.c | 8 ++--- lib_enc/pre_proc_fx.c | 2 +- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c index e8f32c804..87ba794d4 100644 --- a/lib_com/gs_bitallocation_fx.c +++ b/lib_com/gs_bitallocation_fx.c @@ -230,9 +230,9 @@ void bands_and_bit_alloc_fx( nb_bands = shr( *pvq_len, 4 ); /*------------------------------------------------------------------------ - * Ajustement of the maximum number of bands in function of the - * dynamics of the spectrum (more or less speech like) - *-----------------------------------------------------------------------*/ + * Ajustement of the maximum number of bands in function of the + * dynamics of the spectrum (more or less speech like) + *-----------------------------------------------------------------------*/ test(); test(); test(); @@ -268,8 +268,8 @@ void bands_and_bit_alloc_fx( } /*------------------------------------------------------------------------ - * Find extra number of band to code according to bit rate availables - *-----------------------------------------------------------------------*/ + * Find extra number of band to code according to bit rate availables + *-----------------------------------------------------------------------*/ test(); WHILE( GE_16( bit_tmp, bit_new_bands ) && LE_16( nb_bands, sub( nb_bands_max, 1 ) ) ) { @@ -279,15 +279,15 @@ void bands_and_bit_alloc_fx( } /*------------------------------------------------------------------------ - * Fractional bits to distribute on the first x bands - *-----------------------------------------------------------------------*/ + * Fractional bits to distribute on the first x bands + *-----------------------------------------------------------------------*/ { bit_fracf = L_mult( div_s( 1, st_band ), shl( bit_tmp, 2 ) ); /* Q18 */ } /*------------------------------------------------------------------------ - * Complete the bit allocation per frequency band - *-----------------------------------------------------------------------*/ + * Complete the bit allocation per frequency band + *-----------------------------------------------------------------------*/ imax = 5; move16(); @@ -315,8 +315,8 @@ void bands_and_bit_alloc_fx( } /*-------------------------------------------------------------------------- - * Complete the bit allocation per frequency band for 16kHz high brate mode - *--------------------------------------------------------------------------*/ + * Complete the bit allocation per frequency band for 16kHz high brate mode + *--------------------------------------------------------------------------*/ { FOR( j = st_band; j < nb_bands; j++ ) @@ -327,9 +327,9 @@ void bands_and_bit_alloc_fx( } /*-------------------------------------------------------------------------- - * Compute a maximum band (band offset) for the search on maximal energy - * This is function of the spectral dynamic and the bitrate - *--------------------------------------------------------------------------*/ + * Compute a maximum band (band offset) for the search on maximal energy + * This is function of the spectral dynamic and the bitrate + *--------------------------------------------------------------------------*/ bandoffset = sub( nb_tot_bands, add( nb_bands, 2 ) ); @@ -351,10 +351,10 @@ void bands_and_bit_alloc_fx( bandoffset = s_max( bandoffset, 0 ); /*-------------------------------------------------------------------------- - * Initiazed sorted vector - * For the first x bands to be included in th final sorted vector - * Sort the remaining bands in decrease energy order - *--------------------------------------------------------------------------*/ + * Initiazed sorted vector + * For the first x bands to be included in th final sorted vector + * Sort the remaining bands in decrease energy order + *--------------------------------------------------------------------------*/ FOR( j = 0; j < nb_tot_bands; j++ ) { max_ener_band[j] = -10; @@ -432,10 +432,10 @@ void bands_and_bit_alloc_fx( } } /*-------------------------------------------------------------------------- - * Bit sum verification for GSC inactive at very high rate - * The maximum number of bits per band of length 16 is 112 - * Redistribute the overage bits if needed - *--------------------------------------------------------------------------*/ + * Bit sum verification for GSC inactive at very high rate + * The maximum number of bits per band of length 16 is 112 + * Redistribute the overage bits if needed + *--------------------------------------------------------------------------*/ sum_bit = 0; move16(); j = 0; @@ -468,8 +468,8 @@ void bands_and_bit_alloc_fx( } } /*-------------------------------------------------------------------------- - * second step of bit sum verification, normally sum_bit == *bit - *--------------------------------------------------------------------------*/ + * second step of bit sum verification, normally sum_bit == *bit + *--------------------------------------------------------------------------*/ w_sum_bit = 0; move16(); FOR( i = 0; i < nb_bands; i++ ) @@ -497,15 +497,15 @@ void bands_and_bit_alloc_fx( } /*-------------------------------------------------------------------------- - * Recompute the real number/length of frequency bands to encode - *--------------------------------------------------------------------------*/ + * Recompute the real number/length of frequency bands to encode + *--------------------------------------------------------------------------*/ *nb_subbands = nb_bands; move16(); *pvq_len = shl( *nb_subbands, 4 ); /*-------------------------------------------------------------------------- - * Concatenate bands (encoder only) - *--------------------------------------------------------------------------*/ + * Concatenate bands (encoder only) + *--------------------------------------------------------------------------*/ IF( exc_diff != NULL ) { FOR( j = 0; j < nb_bands; j++ ) diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 96ab40547..709bb47e0 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -1106,8 +1106,8 @@ void lsf_end_enc_fx( } /*--------------------------------------------------------------------------* \ - * Write indices to array \ - *--------------------------------------------------------------------------*/ + * Write indices to array \ + *--------------------------------------------------------------------------*/ IF( EQ_16( st->codec_mode, MODE1 ) && EQ_16( st->core, ACELP_CORE ) ) { @@ -1981,7 +1981,7 @@ static void first_VQstages( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ @@ -2171,7 +2171,7 @@ static void first_VQstages_ivas_fx( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 7c17e76d8..4ce9403a6 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -214,7 +214,7 @@ void pre_proc_fx( * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ Word16 Q_new_inp, mem_decim_size; // TO be removed - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ), &Q_new_inp, &mem_decim_size ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* -- GitLab From eb283286d62fcac0cad5bda9d4f4512f09d43af1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 14:20:53 +0100 Subject: [PATCH 32/97] fix build-codec-linux-make --- lib_com/frame_ener.c | 333 ------------------ lib_com/frame_ener_fx.c | 39 +++ lib_com/get_gain.c | 170 ---------- lib_com/gs_preech.c | 381 --------------------- lib_com/hp50.c | 728 ---------------------------------------- lib_com/hp50_fx.c | 10 - 6 files changed, 39 insertions(+), 1622 deletions(-) delete mode 100644 lib_com/frame_ener.c delete mode 100644 lib_com/get_gain.c delete mode 100644 lib_com/gs_preech.c delete mode 100644 lib_com/hp50.c diff --git a/lib_com/frame_ener.c b/lib_com/frame_ener.c deleted file mode 100644 index e89c4dfad..000000000 --- a/lib_com/frame_ener.c +++ /dev/null @@ -1,333 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" -/*----------------------------------------------------------------------------------* - * fer_energy() - * - * Estimation of pitch-synchronous (voiced sounds) or half-frame energy - *----------------------------------------------------------------------------------*/ - -#ifndef IVAS_FLOAT_FIXED -void fer_energy( - const int16_t L_frame, /* i : frame length */ - const int16_t clas, /* i : frame classification */ - const float *synth, /* i : synthesized speech at Fs = 12k8 Hz */ - const float pitch, /* i : pitch period */ - float *enr, /* o : pitch-synchronous or half_frame energy */ - const int16_t offset /* i : speech pointer offset (0 or L_frame) */ -) -{ - int16_t len; - const float *pt_synth; - - if ( clas == VOICED_CLAS || clas == ONSET || clas == SIN_ONSET ) /* Voiced or Onset current frame */ - { - len = (int16_t) ( pitch + 0.5f ); /* pitch value */ - - pt_synth = synth; - if ( offset != 0 ) - { - pt_synth = synth + L_frame - len; - } - - emaximum( pt_synth, len, enr ); /* pitch synchronous E */ - } - else - { - pt_synth = synth; - if ( offset != 0 ) - { - pt_synth = synth + L_frame / 2; - } - - *enr = dotp( pt_synth, pt_synth, L_frame / 2 ); - *enr /= (float) ( L_frame / 2 ); - } - return; -} -#endif - -void fer_energy_fx( - const Word16 L_frame, /* i : frame length */ - const Word16 clas, /* i : frame classification */ - const Word32 *synth, /* i : synthesized speech at Fs = 12k8 Hz Q(q_synth) */ - const Word16 q_synth, /* i : synthesized speech at Fs = 12k8 Hz */ - const Word16 pitch, /* i : pitch period Q0 */ - Word32 *enr, /* o : pitch-synchronous or half_frame energy Q0 */ - const Word16 offset /* i : speech pointer offset (0 or L_frame) */ -) -{ - Word16 len, shift, exp; - const Word32 *pt_synth; - Word16 enr_tmp, i; - Word64 W_tmp; - - test(); - test(); - IF( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, ONSET ) || EQ_16( clas, SIN_ONSET ) ) /* Voiced or Onset current frame */ - { - len = ( pitch ); /* pitch value */ - move16(); - - pt_synth = synth; - IF( offset != 0 ) - { - pt_synth = synth + sub( L_frame, len ); - } - - emaximum_32fx( q_synth, pt_synth, len, enr ); /* pitch synchronous E */ - } - ELSE - { - pt_synth = synth; - IF( offset != 0 ) - { - pt_synth = synth + shr( L_frame, 1 ); - } - - W_tmp = 0; - move64(); - FOR( i = 0; i < L_frame / 2; i++ ) - { - W_tmp = W_add( W_tmp, W_mult0_32_32( pt_synth[i], pt_synth[i] ) ); // Q = q_synth * 2 - } - shift = W_norm( W_tmp ); - W_tmp = W_shl( W_tmp, shift ); // Q = q_synth * 2 + shift - *enr = W_extract_h( W_tmp ); // Q = q_synth * 2 + shift - 32 - move32(); - - enr_tmp = BASOP_Util_Divide3216_Scale( *enr, shr( L_frame, 1 ) /*Q0*/, &exp ); - *enr = L_shr( L_deposit_l( enr_tmp ), sub( sub( sub( shift, 32 ), exp ), 1 ) ); /*Q0*/ - move32(); - } - return; -} - - -/*----------------------------------------------------------------------------------* - * frame_ener() - * - * Estimation of pitch-synchronous (voiced) or mean half-frame (unvoiced) energy - *----------------------------------------------------------------------------------*/ -Word16 frame_ener_fx( - const Word16 L_frame, /* i : length of the frame */ - const Word16 clas, /* i : frame classification */ - const Word16 *synth, /* i : synthesized speech at Fs = 12k8 Hz Q_new */ - const Word16 pitch, /* i : pitch period Q0 */ - Word32 *enr_q, /* o : pitch-synchronous or half_frame energy Q0 */ - const Word16 offset, /* i : speech pointer offset (0 or L_FRAME) */ - const Word16 Q_new, /* i : Scaling factor */ - Word16 shift, /* i : Shift need to obtain 12 bits vectors */ - const Word16 enc /* i : Encoder/decoder */ -) -{ - Word16 len, exp_enrq, exp_tmp, pos; - Word16 i; - const Word16 *pt_synth; - Word32 Ltmp; - - exp_enrq = 0; - move16(); - test(); - test(); - IF( ( EQ_16( clas, VOICED_CLAS ) ) || ( EQ_16( clas, ONSET ) ) || ( EQ_16( clas, SIN_ONSET ) ) ) /* current frame is voiced */ - { - /* current frame is voiced */ - len = pitch; - move16(); /* pitch value at the end of frame */ - pt_synth = synth; - if ( offset != 0 ) - { - pt_synth = synth + sub( L_frame, len ); - } - emaximum_fx( Q_new, pt_synth, len, enr_q ); - IF( enc != 0 ) - { - exp_enrq = norm_l( *enr_q ); - *enr_q = L_shl( *enr_q, exp_enrq ); - move32(); - exp_enrq = sub( exp_enrq, 2 ); - } - } - ELSE - { - /* current frame is unvoiced */ - Word16 L_frame2, exp2, enr_q_tmp; - - L_frame2 = shr( L_frame, 1 ); - pos = 0; - move16(); - - if ( offset != 0 ) - { - pos = sub( L_frame, L_frame2 ); - } - Ltmp = L_mult_sat( synth[pos], synth[pos] ); /*2 * Qnew + 1*/ - FOR( i = 1; i < L_frame2; i++ ) - { - Ltmp = L_mac_sat( Ltmp, synth[pos + i], synth[pos + i] ); /*2 * Qnew + 1*/ - } - test(); - IF( EQ_32( Ltmp, MAX_32 ) || enc != 0 ) - { - /* scale down when overflow occurs */ - *enr_q = Energy_scale( synth + pos, L_frame2, shift, &exp_enrq ); - move32(); - } - ELSE - { - shift = 0; - move16(); - /* Normalize acc in Q31 (energy already calculated) */ - pos = norm_l( Ltmp ); - Ltmp = L_shl( Ltmp, pos ); - exp_enrq = sub( 30, pos ); /* exponent = 0..30 */ - *enr_q = Ltmp; - move32(); - } - - /* enr2 = 1.0f/L_FRAME2 * dot_product(synth, synth, L_FRAME2) */ - exp_enrq = sub( exp_enrq, shl( shift, 1 ) ); - - IF( enc != 0 ) - { - assert( L_frame == 256 || L_frame == 320 ); - - exp_tmp = add( shl( Q_new, 1 ), -2 + 7 ); /* L_subfr == L_SUBFR */ - exp_enrq = sub( exp_enrq, exp_tmp ); - exp_enrq = sub( 31, exp_enrq ); - - IF( EQ_16( L_frame, 320 ) ) - { - *enr_q = Mult_32_16( *enr_q, 26214 ); /*x 0.8 to get /160*/ - move32(); - i = norm_l( *enr_q ); - *enr_q = L_shl( *enr_q, i ); - move32(); - exp_enrq = add( i, exp_enrq ); - } - } - ELSE - { - exp_enrq = sub( exp_enrq, add( Q_new, Q_new ) ); - enr_q_tmp /*Q30 exp2+exp_enrq*/ = BASOP_Util_Divide3216_Scale( *enr_q /*Q31*/, L_frame2 /*Q0*/, &exp2 ); - *enr_q = L_shr( L_deposit_l( enr_q_tmp ), sub( 30, add( exp2, exp_enrq ) ) ); /*Q0*/ - move32(); - *enr_q = L_add( *enr_q, 1 ); - move32(); - exp_enrq = 0; - move16(); - } - } - - return exp_enrq; -} - -/*------------------------------------------------------------------------* - * frame_energy() - * - * Compute pitch-synchronous energy at the frame end - *------------------------------------------------------------------------*/ -Word16 frame_energy_fx( /* o : Frame energy in Q8 */ - Word16 L_frame, - const Word16 *pitch, /* i : pitch values for each subframe Q6 */ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_syn*/ - const Word16 lp_speech, /* i : long term active speech energy average Q8 */ - Word16 *frame_ener, /* o : pitch-synchronous energy at frame end Q8 */ - const Word16 Q_syn /* i : Synthesis scaling */ -) -{ - Word32 Ltmp; - const Word16 *pt1; - Word16 tmp16, exp1, exp2, tmp1, tmp2; - Word16 len, enern; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - - - /* len = (0.5f * (pitch[2]/64.0 + pitch[3]/64.0) + 0.5f) */ - len = mult_r( add_o( pitch[2], pitch[3], &Overflow ), 256 ); - - if ( LT_16( len, L_SUBFR ) ) - { - len = shl( len, 1 ); - } - pt1 = speech + sub( L_frame, len ); - - /* *frame_ener = 10.0f * log10(dot_product(pt1, pt1, len) / (float)len) */ - - tmp1 = norm_s( len ); - tmp2 = shl( len, tmp1 ); - tmp1 = sub( 15, tmp1 ); - - Ltmp = Dot_productSq16HQ( 0, pt1, len, &exp1 ); - exp1 = sub( exp1, shl( Q_syn, 1 ) ); - exp1 = sub( exp1, 1 ); /* compensation of leftshift caused by mac operation in dot_productSq16HQ */ - tmp16 = BASOP_Util_Divide3216_Scale( Ltmp, len, &exp2 ); - - exp1 = add( exp1, exp2 ); - exp1 = add( exp1, 1 ); /* compensate result of division Q-1 */ - - - tmp2 = norm_s( tmp16 ); - Ltmp = L_shl( L_deposit_h( tmp16 ), tmp2 ); /*Q16, (exp1-tmp2) = Q31, exp1-tmp2+15*/ - - Ltmp = BASOP_Util_Log2( Ltmp ); /*Q(31-6) = Q25*/ - exp1 = sub( 15 + exp1, tmp2 ); - - /*add ld(2^exp1)=exp1 but check format, first*/ - tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ - Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ - exp2 = shr( exp1, tmp16 ); /*Q0 , tmp16*/ - Ltmp = L_add_o( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ), &Overflow ); /*Q25, tmp16, normalized*/ - - /*make 10*log10 out of log2*/ - Ltmp = Mpy_32_16_1( Ltmp, LG10 ); /*Q25,tmp16 * Q13 = Q23, tmp16*/ - *frame_ener = extract_h( L_shl_o( Ltmp, add( tmp16, 1 ), &Overflow ) ); /*Q8*/ - move16(); - enern = sub_o( *frame_ener, lp_speech, &Overflow ); /*Q8*/ - - return enern; -} diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index 4428c0796..7ee58371a 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -47,6 +47,45 @@ * Estimation of pitch-synchronous (voiced sounds) or half-frame energy *----------------------------------------------------------------------------------*/ +void fer_energy( + const int16_t L_frame, /* i : frame length */ + const int16_t clas, /* i : frame classification */ + const float *synth, /* i : synthesized speech at Fs = 12k8 Hz */ + const float pitch, /* i : pitch period */ + float *enr, /* o : pitch-synchronous or half_frame energy */ + const int16_t offset /* i : speech pointer offset (0 or L_frame) */ +) +{ + int16_t len; + const float *pt_synth; + + if ( clas == VOICED_CLAS || clas == ONSET || clas == SIN_ONSET ) /* Voiced or Onset current frame */ + { + len = (int16_t) ( pitch + 0.5f ); /* pitch value */ + + pt_synth = synth; + if ( offset != 0 ) + { + pt_synth = synth + L_frame - len; + } + + emaximum( pt_synth, len, enr ); /* pitch synchronous E */ + } + else + { + pt_synth = synth; + if ( offset != 0 ) + { + pt_synth = synth + L_frame / 2; + } + + *enr = dotp( pt_synth, pt_synth, L_frame / 2 ); + *enr /= (float) ( L_frame / 2 ); + } + return; +} + + void fer_energy_fx( const Word16 L_frame, /* i : frame length */ const Word16 clas, /* i : frame classification */ diff --git a/lib_com/get_gain.c b/lib_com/get_gain.c deleted file mode 100644 index 89b5fa3de..000000000 --- a/lib_com/get_gain.c +++ /dev/null @@ -1,170 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*----------------------------------------------------------------------------------* - * get_gain() - * - * - *----------------------------------------------------------------------------------*/ - -#ifndef IVAS_FLOAT_FIXED -/*! r: codebook gain (adaptive or fixed) */ -float get_gain_flt( - const float x[], /* i : target signal */ - const float y[], /* i : filtered codebook excitation */ - const int16_t n, /* i : segment length */ - float *en_y /* o : energy of y (sum of y[]^2, optional) */ -) -{ - float corr = 0.0f, ener = 1e-6f; - int16_t i; - - for ( i = 0; i < n; i++ ) - { - corr += x[i] * y[i]; - ener += y[i] * y[i]; - } - - if ( en_y ) - { - *en_y = ener; - } - - return ( corr / ener ); -} -#endif - -Word32 get_gain( /* output: codebook gain (adaptive or fixed) Q16 */ - const Word16 x[], /* input : target signal Qx */ - const Word16 y[], /* input : filtered codebook excitation Qx */ - const Word16 n /* input : segment length */ -) -{ - Word32 tcorr, tener, Lgain; - Word16 exp_c, exp_e, exp, tmp; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - - - tcorr = L_deposit_l( 0 ); - tener = L_deposit_l( 0 ); - - - /*----------------------------------------------------------------* - * Find gain based on inter-correlation product - *----------------------------------------------------------------*/ - - tcorr = Dot_product16HQ( 0, x, y, n, &exp_c ); - tener = Dot_productSq16HQ( 0, y, n, &exp_e ); - - BASOP_Util_Divide_MantExp( round_fx_o( tcorr, &Overflow ), exp_c, s_max( round_fx_o( tener, &Overflow ), 1 ), exp_e, &tmp, &exp ); - Lgain = L_shl_o( L_deposit_l( tmp ) /*Q15*/, add( 1, exp ), &Overflow ) /*Q16*/; - - return Lgain; -} - -Word32 get_gain2( /* output: codebook gain (adaptive or fixed) Q16 */ - const Word16 x[], /* input : target signal */ - const Word16 y[], /* input : filtered codebook excitation */ - const Word16 n /* input : segment length */ -) -{ - Word32 tcorr, tener, Lgain; - Word16 m_corr, m_ener, negative, Q_corr, Q_ener; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - - negative = 0; - move16(); - - /*----------------------------------------------------------------* - * Find gain based on inter-correlation product - *----------------------------------------------------------------*/ - tcorr = Dot_product16HQ( 0, x, y, n, &Q_corr ); - tener = Dot_productSq16HQ( 0, y, n, &Q_ener ); - - tener = L_max( tener, 1 ); - - if ( tcorr <= 0 ) - { - negative = 1; - move16(); - } - BASOP_SATURATE_WARNING_OFF_EVS /*tcorr max be negative maxvall - not critical*/ - tcorr = L_abs( tcorr ); - BASOP_SATURATE_WARNING_ON_EVS - - m_corr = extract_h( tcorr ); - - m_ener = extract_h( tener ); - - IF( GT_16( m_corr, m_ener ) ) - { - m_corr = shr( m_corr, 1 ); - Q_corr = add( Q_corr, 1 ); - } - if ( m_ener == 0 ) - { - move16(); - m_corr = 0x7FFF; - } - IF( m_ener != 0 ) - { - m_corr = div_s( m_corr, m_ener ); - } - - Q_corr = sub( Q_corr, Q_ener ); - - Lgain = L_shl_o( L_deposit_l( m_corr ), add( Q_corr, 1 ), &Overflow ); /* Lgain in Q16 */ - - if ( negative != 0 ) - { - Lgain = L_negate( Lgain ); /* Lgain in Q16 */ - } - - - return Lgain; -} diff --git a/lib_com/gs_preech.c b/lib_com/gs_preech.c deleted file mode 100644 index 58b49172d..000000000 --- a/lib_com/gs_preech.c +++ /dev/null @@ -1,381 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -#define ATT_LENGHT16k 80 -#ifndef IVAS_FLOAT_FIXED -#define INV_L_FRAME16k ( 1.0f / L_FRAME16k ) -#endif - -#define ATT_LENGHT 64 -#define ATT_SEG_LEN ( L_FRAME / ATT_LENGHT ) - -#ifndef IVAS_FLOAT_FIXED -#define INV_ATT_SEG_LEN ( 1.0f / ATT_SEG_LEN ) -#define INV_L_FRAME ( 1.0f / L_FRAME ) -#endif - -#ifndef IVAS_FLOAT_FIXED -/*-------------------------------------------------------------------* - * pre_echo_att() - * - * Attenuation of the pre-echo when encoder specifies an attack - *-------------------------------------------------------------------*/ - -void pre_echo_att( - float *Last_frame_ener, /* i/o: Energy of the last frame */ - float *exc, /* i/o: Excitation of the current frame */ - const int16_t attack_flag, /* i : attack flag (GSC or TC) */ - const int16_t last_coder_type, /* i : Last coder type */ - const int16_t L_frame /* i : frame length */ -) -{ - float etmp; - float etmp1; - float finc[ATT_LENGHT16k], ratio_float, inv_l_frame; - int16_t att_len; - int16_t attack_pos, i; - - if ( attack_flag > 0 && last_coder_type == AUDIO ) - { - /*-------------------------------------------------------------------------* - * Find where the onset (attack) occurs by computing the energy per section - * The inverse weighting aims to favor the first maxima in case of - * gradual onset - *-------------------------------------------------------------------------*/ - - att_len = ATT_LENGHT; - if ( L_frame == L_FRAME16k ) - { - att_len = ATT_LENGHT16k; - } - for ( i = 0; i < att_len; i++ ) - { - finc[i] = sum2_f( exc + i * ATT_SEG_LEN, ATT_SEG_LEN ) * ( (float) ( att_len - i ) / ( att_len ) ); - } - etmp = -1; - attack_pos = maximum( finc, att_len, &etmp ); - - /* Scaled the maximum energy and allowed 6 dB increase*/ - etmp *= INV_ATT_SEG_LEN; - etmp1 = etmp; - *Last_frame_ener *= 4.0f; - - /* If the maximum normalized energy > last frame energy + 6dB */ - if ( etmp > *Last_frame_ener && attack_pos > 0 ) - { - /* Find the average energy before the attack */ - etmp = sum_f( finc, attack_pos ) + 0.01f; - etmp /= ( attack_pos * ATT_SEG_LEN ); - - /* Find the correction factor and apply it before the attack */ - ratio_float = (float) sqrt( *Last_frame_ener / etmp ); - - - /* Pre-echo atttenuation should never increase the energy */ - ratio_float = min( ratio_float, 1.0f ); - for ( i = 0; i < attack_pos * ATT_SEG_LEN; i++ ) - { - exc[i] *= ratio_float; - } - } - *Last_frame_ener = etmp1; - } - else - { - /*-------------------------------------------------------* - * In normal cases, just compute the energy of the frame - *-------------------------------------------------------*/ - - etmp = sum2_f( exc, L_frame ) + 0.01f; - inv_l_frame = INV_L_FRAME; - if ( L_frame == L_FRAME16k ) - { - inv_l_frame = INV_L_FRAME16k; - } - etmp *= inv_l_frame; - *Last_frame_ener = etmp; - } - - return; -} -#endif - -void pre_echo_att_fx( - Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ - Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ - const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ - const Word16 Q_new, - const Word16 last_coder_type, /* i : Last coding mode Q0*/ - const Word16 L_frame /* i : Frame length Q0*/ -) -{ - Word32 etmp_fx; - Word32 finc_fx[ATT_LENGHT16k] = { 0 }; - move16(); - Word16 ratio_fx; - Word16 attack_pos_fx, i; - Word32 L_tmp, L_tmp1; - Word16 tmp, n1, n2, exp, frac1, frac2; - Word32 etmp1_fx; - Word16 att_len; - - test(); - IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */ - { - /*-------------------------------------------------------------------------* - * Find where the onset (attack) occurs by computing the energy per section - * The inverse weighting aims to favor the first maxima in case of - * gradual onset - *-------------------------------------------------------------------------*/ - att_len = ATT_LENGHT; /* Q0 */ - move16(); - if ( EQ_16( L_frame, L_FRAME16k ) ) - { - att_len = ATT_LENGHT16k; /* Q0 */ - move16(); - } - FOR( i = 0; i < att_len; i++ ) - { - L_tmp = sum2_fx( &exc_fx[i * 4], ATT_SEG_LEN ); /*2*Q_new+1, //ATT_SEG_LEN=(L_FRAME/ATT_LENGHT)=4(=shl(x,2))*/ - tmp = div_s( sub( att_len, i ), att_len ); /*Q15 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /*2*Q_new+1 */ - finc_fx[i] = L_tmp; - move32(); /*2*Q_new+1 */ - } - - attack_pos_fx = maximum_32_fx( finc_fx, att_len, &etmp_fx ); - - /* Scaled the maximum energy and allowed 6 dB increase*/ - etmp_fx = L_shr( etmp_fx, add( 2 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */ - etmp1_fx = etmp_fx; - move32(); - *Last_frame_ener_fx = L_shl_sat( *Last_frame_ener_fx, 2 ); - move32(); /*2*Q_new+1 */ - - /* If the maximum normalized energy > last frame energy + 6dB */ - test(); - IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 ) - { - /* Find the average energy before the attack */ - L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */ - L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */ - tmp = round_fx( Isqrt( L_tmp1 ) ); /*Q15 */ - L_tmp = L_shr( L_tmp, 2 ); /*Q1 ; ATT_SEG_LEN=4 */ - etmp_fx = Mult_32_16( L_tmp, tmp ); /*Q1 */ - - etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */ - /* Find the correction factor and apply it before the attack */ - /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/ - /* = isqrt(etmp/(*Last_frame_ener)) */ - etmp_fx = L_max( etmp_fx, 1 ); - *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 ); - move32(); - n1 = norm_l( etmp_fx ); - n2 = norm_l( *Last_frame_ener_fx ); - - n1 = sub( n1, 1 ); - exp = sub( n1, n2 ); - - frac1 = round_fx( L_shl( etmp_fx, n1 ) ); - frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) ); - L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */ - L_tmp = L_shr( L_tmp, exp ); /* add exponent */ - - L_tmp = Isqrt( L_tmp ); - ratio_fx = round_fx( L_shl( L_tmp, 9 ) ); /* Q13 */ - - /* Pre-echo atttenuation should never increase the energy */ - ratio_fx = s_min( ratio_fx, 8192 /* 1 in Q13 */ ); /* Q13 */ - FOR( i = 0; i < attack_pos_fx * ATT_SEG_LEN; i++ ) - { - /*exc_fx[i] *= ratio_fx;*/ - exc_fx[i] = round_fx( L_shl( L_mac( -8192, exc_fx[i], ratio_fx ), 2 ) ); - move16(); - } - } - *Last_frame_ener_fx = etmp1_fx; /*2*Q_new+1*/ - move32(); - } - ELSE - { - /*-------------------------------------------------------* - * In normal cases, just compute the energy of the frame - *-------------------------------------------------------*/ - - etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */ -#ifdef ADD_LRTD - PMTE() - etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ -#else - etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ -#endif - *Last_frame_ener_fx = etmp_fx; - move32(); /*2*Q_new+1*/ - } - - return; -} - - -void pre_echo_att_ivas_fx( - Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ - Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ - const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ - const Word16 Q_new, - const Word16 last_coder_type, /* i : Last coding mode Q0*/ - const Word16 L_frame /* i : Frame length Q0*/ -) -{ - Word32 etmp_fx; - Word32 finc_fx[ATT_LENGHT16k] = { 0 }; - move16(); - Word16 ratio_fx; - Word16 attack_pos_fx, i; - Word32 L_tmp, L_tmp1; - Word16 tmp, n1, n2, exp, frac1, frac2; - Word32 etmp1_fx; - Word16 att_len; - - test(); - IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */ - { - /*-------------------------------------------------------------------------* - * Find where the onset (attack) occurs by computing the energy per section - * The inverse weighting aims to favor the first maxima in case of - * gradual onset - *-------------------------------------------------------------------------*/ - att_len = ATT_LENGHT; /* Q0 */ - move16(); - if ( EQ_16( L_frame, L_FRAME16k ) ) - { - att_len = ATT_LENGHT16k; /* Q0 */ - move16(); - } - FOR( i = 0; i < att_len; i++ ) - { - L_tmp = sum2_fx( &exc_fx[i * 4], ATT_SEG_LEN ); /*2*Q_new+1, //ATT_SEG_LEN=(L_FRAME/ATT_LENGHT)=4(=shl(x,2))*/ - tmp = div_s( sub( att_len, i ), att_len ); /*Q15 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /*2*Q_new+1 */ - finc_fx[i] = L_tmp; - move32(); /*2*Q_new+1 */ - } - - attack_pos_fx = maximum_32_fx( finc_fx, att_len, &etmp_fx ); - - /* Scaled the maximum energy and allowed 6 dB increase*/ - etmp_fx = L_shr( etmp_fx, add( 2 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */ - etmp1_fx = etmp_fx; - move32(); - *Last_frame_ener_fx = L_shl_sat( *Last_frame_ener_fx, 2 ); - move32(); /*2*Q_new+1 */ - - /* If the maximum normalized energy > last frame energy + 6dB */ - test(); - IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 ) - { - /* Find the average energy before the attack */ - L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */ - L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */ - tmp = round_fx( Isqrt( L_tmp1 ) ); /*Q15 */ - L_tmp = L_shr( L_tmp, 2 ); /*Q1 ; ATT_SEG_LEN=4 */ - etmp_fx = Mult_32_16( L_tmp, tmp ); /*Q1 */ - - etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */ - /* Find the correction factor and apply it before the attack */ - /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/ - /* = isqrt(etmp/(*Last_frame_ener)) */ - etmp_fx = L_max( etmp_fx, 1 ); - *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 ); - move32(); - n1 = norm_l( etmp_fx ); - n2 = norm_l( *Last_frame_ener_fx ); - - n1 = sub( n1, 1 ); - exp = sub( n1, n2 ); - - frac1 = round_fx( L_shl( etmp_fx, n1 ) ); - frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) ); - L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */ - L_tmp = L_shr( L_tmp, exp ); /* add exponent */ - - L_tmp = Isqrt( L_tmp ); - ratio_fx = round_fx( L_shl( L_tmp, 9 ) ); - - /* Pre-echo atttenuation should never increase the energy */ - ratio_fx = s_min( ratio_fx, 8192 /* 1 in Q13 */ ); /* Q13 */ - FOR( i = 0; i < attack_pos_fx * ATT_SEG_LEN; i++ ) - { - /*exc_fx[i] *= ratio_fx;*/ - exc_fx[i] = round_fx( L_shl( L_mac( -8192, exc_fx[i], ratio_fx ), 2 ) ); - move16(); - } - } - *Last_frame_ener_fx = etmp1_fx; /* 2 * Q_new + 1 */ - move32(); - } - ELSE - { - /*-------------------------------------------------------* - * In normal cases, just compute the energy of the frame - *-------------------------------------------------------*/ - Word16 exp_etmp = sub( 15, Q_new ); - etmp_fx = sum2_16_exp_fx( exc_fx, L_frame, &exp_etmp, 7 ); /* Q = 31-exp_etmp */ - - etmp_fx = L_shr( etmp_fx, 8 ); /*31-exp_etmp//INV_L_FRAME = 1/256*/ - - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - etmp_fx = Mpy_32_16_1( etmp_fx, 26214 /* 0.8 in Q15 */ ); /*31 - exp_etmp*/ - } - *Last_frame_ener_fx = L_shl( etmp_fx, sub( shl( Q_new, 1 ), sub( 30 /*31-1*/, exp_etmp ) ) ); /*2*Q_new+1*/ - move32(); /*2*Q_new+1*/ - } - - return; -} diff --git a/lib_com/hp50.c b/lib_com/hp50.c deleted file mode 100644 index 6920063d4..000000000 --- a/lib_com/hp50.c +++ /dev/null @@ -1,728 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include -#include "options.h" -#include "prot.h" -#include "wmc_auto.h" -#include "prot_fx.h" - -/* - * hp20 - * - * Function: - * 2nd order high pass filter with nominal cut off frequency at 20 Hz. - * - * Returns: - * void - */ - -#ifndef IVAS_FLOAT_FIXED -void hp20_flt( - Float32 signal[], - const Word16 lg, - Float32 mem[], - const Word32 Fs ) -{ - Word16 i; - Float32 x0, x1, x2, y0, y1, y2; - Float32 a1, a2, b1, b2; - - y1 = mem[0]; - y2 = mem[1]; - x0 = mem[2]; - x1 = mem[3]; - - if ( Fs == 8000 ) - { - /* hp filter 20Hz at 3dB for 8000KHz input sampling rate - [b,a] = butter(2, 20.0/4000.0, 'high'); - b = [0.988954248067140 -1.977908496134280 0.988954248067140] - a =[1.000000000000000 -1.977786483776764 0.978030508491796]*/ - a1 = 1.977786483776764f; - a2 = -0.978030508491796f; - b1 = -1.977908496134280f; - b2 = 0.988954248067140f; - } - else if ( Fs == 16000 ) - { - /* hp filter 20Hz at 3dB for 16000KHz sampling rate - [b,a] = butter(2, 20.0/8000.0, 'high'); - b =[ 0.994461788958195 -1.988923577916390 0.994461788958195] - a =[1.000000000000000 -1.988892905899653 0.988954249933127] */ - a1 = 1.988892905899653f; - a2 = -0.988954249933127f; - b1 = -1.988923577916390f; - b2 = 0.994461788958195f; - } - else if ( Fs == 32000 ) - { - /* hp filter 20Hz at 3dB for 32000KHz sampling rate - [b,a] = butter(2, 20.0/16000.0, 'high'); - b =[0.997227049904470 -1.994454099808940 0.997227049904470] - a =[1.000000000000000 -1.994446410541927 0.994461789075954]*/ - a1 = 1.994446410541927f; - a2 = -0.994461789075954f; - b1 = -1.994454099808940f; - b2 = 0.997227049904470f; - } - else - { - /* hp filter 20Hz at 3dB for 48000KHz sampling rate - [b,a] = butter(2, 20.0/24000.0, 'high'); - b =[ 0.998150511190452 -1.996301022380904 0.998150511190452] - a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ - a1 = 1.996297601769122f; - a2 = -0.996304442992686f; - b1 = -1.996301022380904f; - b2 = 0.998150511190452f; - } - - for ( i = 0; i < lg; i++ ) - { - x2 = x1; - x1 = x0; - x0 = signal[i]; - y0 = ( y1 * a1 ) + ( y2 * a2 ) + ( x0 * b2 ) + ( x1 * b1 ) + ( x2 * b2 ); - signal[i] = y0; - y2 = y1; - y1 = y0; - } - - mem[0] = ( ( y1 > 1e-10 ) | ( y1 < -1e-10 ) ) ? y1 : 0; - mem[1] = ( ( y2 > 1e-10 ) | ( y2 < -1e-10 ) ) ? y2 : 0; - mem[2] = ( ( x0 > 1e-10 ) | ( x0 < -1e-10 ) ) ? x0 : 0; - mem[3] = ( ( x1 > 1e-10 ) | ( x1 < -1e-10 ) ) ? x1 : 0; - - return; -} -#endif - - -#define HP20_COEFF_SCALE ( 2 ) -/* - * hp20 - * - * Function: - * 2nd order high pass filter with nominal cut off frequency at 20 Hz. - * - * Returns: - * void - */ - -static Word32 HP50_Mode2_Mpy_32_16_fix( Word32 a, Word16 b ) -{ - Word32 result = Mpy_32_16_1( a, b ); - /* perform rounding towards lower value for negative results */ - if ( result < 0 ) - result = L_add( result, 1 ); - return result; -} - -static Word32 HP50_Mpy_32_32_fix( Word32 a, Word32 b ) -{ - Word32 result = Mpy_32_32( a, b ); - /* perform rounding towards lower value for negative results */ - if ( result < 0 ) - result = L_add( result, 1 ); - return result; -} - - -static void filter_2nd_order( - Word16 signal[], - const Word16 stride, - const Word16 prescale, - const Word16 lg, - Word32 mem[4], - Word32 a1, - Word32 a2, - Word32 b1, - Word32 b2 ) -{ - - Word16 i; - Word16 x2, x1; - Word32 L_sum, L_y1, L_y2; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; -#endif - - - /* - * Saturation: The states of the filter, namely L_y1 and L_y2 shall - * never saturate, because that causes error in the filter feedback. - * The final output written into signal[] might saturate because of - * unavoidable filter overshoot. - */ - - /* Execute first 2 iterations with 32-bit x anx y memory values */ - BASOP_SATURATE_ERROR_ON_EVS - L_sum = HP50_Mpy_32_32_fix( b2, mem[2] ); /* b2*x2 */ - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( b1, mem[3] ) ); /* b1*x1 */ - x2 = shr( signal[0], prescale ); - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x2 ) ); /* b2*x0 */ - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[0], a2 ) ); /* y2*a2 */ - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a1 ) ); /* y1*a1 */ - - L_y2 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); - BASOP_SATURATE_ERROR_OFF_EVS - BASOP_SATURATE_WARNING_OFF_EVS - signal[0] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow ); - BASOP_SATURATE_WARNING_ON_EVS - - BASOP_SATURATE_ERROR_ON_EVS - L_sum = HP50_Mpy_32_32_fix( b2, mem[3] ); /* b2*x2 */ - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b1, x2 ) ); /* b1*x1 */ - x1 = shr( signal[stride], prescale ); - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x1 ) ); /* b2*x0 */ - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a2 ) ); /* y2*a2 */ - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) ); /* y1*a1 */ - - L_y1 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); - BASOP_SATURATE_ERROR_OFF_EVS - BASOP_SATURATE_WARNING_OFF_EVS - signal[stride] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow ); - BASOP_SATURATE_WARNING_ON_EVS - move16(); - - /* New we use a trick and toggle x1/x2 and L_y1/L_y2 to save a few cycles unrolling the loop by 2 */ - FOR( i = 2; i < lg; i += 2 ) - { - /* y[i+0] = b2*x[i-2] + b1*x[i-1] + b2*x[i-0] + a2*y[i-2] + a1*y[i-1]; */ - BASOP_SATURATE_ERROR_ON_EVS - L_sum = HP50_Mode2_Mpy_32_16_fix( b2, x2 ); - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b1, x1 ) ); - x2 = shr( signal[i * stride], prescale ); - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x2 ) ); - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a2 ) ); - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y1, a1 ) ); - - L_y2 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); - BASOP_SATURATE_ERROR_OFF_EVS - BASOP_SATURATE_WARNING_OFF_EVS - signal[i_mult( i, stride )] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow ); - BASOP_SATURATE_WARNING_ON_EVS - /* y[i+1] = b2*x[i-1] + b1*x[i-0] + b2*x[i+1] + a2*y[i-1] + a1*y[i+0]; */ - BASOP_SATURATE_ERROR_ON_EVS - L_sum = HP50_Mode2_Mpy_32_16_fix( b2, x1 ); - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b1, x2 ) ); - x1 = shr( signal[( i + 1 ) * stride], prescale ); - L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b2, x1 ) ); - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y1, a2 ) ); - L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) ); - - L_y1 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow ); - BASOP_SATURATE_ERROR_OFF_EVS - BASOP_SATURATE_WARNING_OFF_EVS - signal[i_mult( add( i, 1 ), stride )] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow ); - BASOP_SATURATE_WARNING_ON_EVS - move16(); - } - /* update static filter memory from variables */ - mem[0] = L_y2; - move32(); - mem[1] = L_y1; - move32(); - mem[2] = L_deposit_h( x2 ); - move32(); - mem[3] = L_deposit_h( x1 ); - move32(); - - - return; -} - - -void hp20( Word16 signal[], /* i/o: signal to filter any */ - const Word16 stride, /* i : stride to be applied accessing signal */ - const Word16 lg, /* i : length of signal (integer) Q0 */ - Word32 mem[5], /* i/o: static filter memory with this layout: */ - /* mem[0]: y[-2] (32-bit) */ - /* mem[1]; y[-1] (32-bit) */ - /* mem[2]: x[-2] << 16 */ - /* mem[3]: x[-1] << 16 */ - /* Note: mem[0..3] need to be scaled per frame */ - /* mem[4]: states scale */ - const Word32 sFreq ) /* i : input sampling rate Q0 */ -{ - Word32 a1, b1, a2, b2; - Word16 prescale, prescaleOld, diff; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; -#endif - - - prescale = getScaleFactor16( signal, lg ); - prescaleOld = extract_l( mem[4] ); - diff = norm_l( L_shl_sat( mem[2], prescaleOld ) ); - if ( mem[2] != 0 ) - { - prescale = s_min( prescale, diff ); - } - diff = norm_l( L_shl_o( mem[3], prescaleOld, &Overflow ) ); - if ( mem[3] != 0 ) - { - prescale = s_min( prescale, diff ); - } - /* Take into account the left shift performed into the loop + 1 bit headroom*/ - prescale = s_max( -12, sub( 1 + HP20_COEFF_SCALE, prescale ) ); - IF( prescale != prescaleOld ) - { - diff = sub( prescale, prescaleOld ); - mem[0] = L_shr_o( mem[0], diff, &Overflow ); - move32(); - mem[1] = L_shr_o( mem[1], diff, &Overflow ); - move32(); - mem[2] = L_shr_o( mem[2], diff, &Overflow ); - move32(); - mem[3] = L_shr_o( mem[3], diff, &Overflow ); - move32(); - mem[4] = L_deposit_l( prescale ); - } - - IF( EQ_32( sFreq, 8000 ) ) - { - /* hp filter 20Hz at 3dB for 8000 Hz input sampling rate - [b,a] = butter(2, 20.0/4000.0, 'high'); - b = [0.988954248067140 -1.977908496134280 0.988954248067140] - a = [1.000000000000000 -1.977786483776764 0.978030508491796]*/ - a1 = 1061816033l /* 1.977786483776764 Q29*/; - move32(); - a2 = -525076131l /*-0.978030508491796 Q29*/; - move32(); - b1 = -1061881538l /*-1.977908496134280 Q29*/; - move32(); - b2 = 530940769l /* 0.988954248067140 Q29*/; - move32(); - } - ELSE IF( EQ_32( sFreq, 16000 ) ) - { - /* hp filter 20Hz at 3dB for 16000KHz sampling rate - [b,a] = butter(2, 20.0/8000.0, 'high'); - b = [0.994461788958195 -1.988923577916390 0.994461788958195] - a = [1.000000000000000 -1.988892905899653 0.988954249933127] */ - a1 = 1067778748l /* 1.988892905899653 Q29*/; - move32(); - a2 = -530940770l /*-0.988954249933127 Q29*/; - move32(); - b1 = -1067795215l /*-1.988923577916390 Q29*/; - move32(); - b2 = 533897608l /* 0.994461788958195 Q29*/; - move32(); - } - ELSE IF( EQ_32( sFreq, 32000 ) ) - { - /* hp filter 20Hz at 3dB for 32000KHz sampling rate - [b,a] = butter(2, 20.0/16000.0, 'high'); - b = [0.997227049904470 -1.994454099808940 0.997227049904470] - a = [1.000000000000000 -1.994446410541927 0.994461789075954]*/ - a1 = 1070760263l /* 1.994446410541927 Q29*/; - move32(); - a2 = -533897608l /*-0.994461789075954 Q29*/; - move32(); - b1 = -1070764392l /*-1.994454099808940 Q29*/; - move32(); - b2 = 535382196l /* 0.997227049904470 Q29*/; - move32(); - } - ELSE - { - assert( sFreq == 48000 ); - /* hp filter 20Hz at 3dB for 48000KHz sampling rate - [b,a] = butter(2, 20.0/24000.0, 'high'); - b =[0.998150511190452 -1.996301022380904 0.998150511190452] - a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ - a1 = 1071754114l /* 1.996297601769122 Q29*/; - move32(); - a2 = -534886875l /*-0.996304442992686 Q29*/; - move32(); - b1 = -1071755951l /*-1.996301022380904 Q29*/; - move32(); - b2 = 535877975l /* 0.998150511190452 Q29*/; - move32(); - } - - - filter_2nd_order( signal, stride, prescale, lg, - mem, a1, a2, b1, b2 ); - - return; -} - - -#ifdef HP20_FIX32_RECODING -void hp20_fx_32( - Word32 signal_fx[], - const Word16 lg, - Word32 mem_fx[], - const Word32 Fs ) -{ - Word32 i; - Word32 a1_fx, a2_fx, b1_fx, b2_fx; - Word32 diff_pos, diff_neg; - Flag Overflow = 0; - Word16 prescale, prescaleOld, prescale_current_frame, diff; - - prescale = getScaleFactor32( signal_fx, lg ); - prescale_current_frame = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) ); - - - prescaleOld = extract_l( mem_fx[4] ); - - diff_pos = norm_l( L_shl_o( L_max( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) ); - diff_neg = norm_l( L_shl_o( L_min( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) ); - - diff = L_max( diff_pos, diff_neg ); - - IF( NE_16( diff, 0 ) ) - { - prescale = s_min( prescale, diff ); - } - - prescale = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) ); - - diff = sub( prescale, prescaleOld ); - mem_fx[0] = L_shr_o( mem_fx[0], diff, &Overflow ); - move32(); - mem_fx[1] = L_shr_o( mem_fx[1], diff, &Overflow ); - move32(); - mem_fx[2] = L_shr_o( mem_fx[2], diff, &Overflow ); - move32(); - mem_fx[3] = L_shr_o( mem_fx[3], diff, &Overflow ); - move32(); - mem_fx[4] = L_deposit_l( prescale_current_frame ); - move32(); - - IF( EQ_32( Fs, 8000 ) ) - { - /* hp filter 20Hz at 3dB for 8000KHz input sampling rate - [b,a] = butter(2, 20.0/4000.0, 'high'); - b = [0.988954248067140 -1.977908496134280 0.988954248067140] - a =[1.000000000000000 -1.977786483776764 0.978030508491796]*/ - a1_fx = 1061816033l /* 1.977786483776764 Q29*/; - a2_fx = -525076131l /*-0.978030508491796 Q29*/; - b1_fx = -1061881538l /*-1.977908496134280 Q29*/; - b2_fx = 530940769l /* 0.988954248067140 Q29*/; - } - ELSE IF( EQ_32( Fs, 16000 ) ) - { - /* hp filter 20Hz at 3dB for 16000KHz sampling rate - [b,a] = butter(2, 20.0/8000.0, 'high'); - b =[ 0.994461788958195 -1.988923577916390 0.994461788958195] - a =[1.000000000000000 -1.988892905899653 0.988954249933127] */ - a1_fx = 1067778748l /* 1.988892905899653 Q29*/; - a2_fx = -530940770l /*-0.988954249933127 Q29*/; - b1_fx = -1067795215l /*-1.988923577916390 Q29*/; - b2_fx = 533897608l /* 0.994461788958195 Q29*/; - } - ELSE IF( EQ_32( Fs, 32000 ) ) - { - /* hp filter 20Hz at 3dB for 32000KHz sampling rate - [b,a] = butter(2, 20.0/16000.0, 'high'); - b =[0.997227049904470 -1.994454099808940 0.997227049904470] - a =[1.000000000000000 -1.994446410541927 0.994461789075954]*/ - a1_fx = 1070760263l /* 1.994446410541927 Q29*/; - a2_fx = -533897608l /*-0.994461789075954 Q29*/; - b1_fx = -1070764392l /*-1.994454099808940 Q29*/; - b2_fx = 535382196l /* 0.997227049904470 Q29*/; - } - ELSE - { - /* hp filter 20Hz at 3dB for 48000KHz sampling rate - [b,a] = butter(2, 20.0/24000.0, 'high'); - b =[ 0.998150511190452 -1.996301022380904 0.998150511190452] - a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ - a1_fx = 1071754114l /* 1.996297601769122 Q29*/; - a2_fx = -534886875l /*-0.996304442992686 Q29*/; - b1_fx = -1071755951l /*-1.996301022380904 Q29*/; - b2_fx = 535877975l /* 0.998150511190452 Q29*/; - } - move32(); - move32(); - move32(); - move32(); - Word64 W_sum, W_y0, W_y1, W_y2; - Word32 x0, x1, x2; - - W_sum = W_mult_32_32( b2_fx, mem_fx[2] ); /* b2*x2 */ - W_sum = W_mac_32_32( W_sum, b1_fx, mem_fx[3] ); /* b1*x1 */ - x2 = L_shr( signal_fx[0], prescale ); - W_sum = W_mac_32_32( W_sum, b2_fx, x2 ); /* b2*x0 */ - W_sum = W_mac_32_32( W_sum, mem_fx[0], a2_fx ); /* y2*a2 */ - W_sum = W_mac_32_32( W_sum, mem_fx[1], a1_fx ); /* y1*a1 */ - W_y2 = W_shl( W_sum, HP20_COEFF_SCALE ); - signal_fx[0] = W_extract_h( W_shl( W_y2, prescale ) ); - move32(); - - W_sum = W_mult_32_32( b2_fx, mem_fx[3] ); /* b2*x2 */ - W_sum = W_mac_32_32( W_sum, b1_fx, x2 ); /* b1*x1 */ - x1 = L_shr( signal_fx[1], prescale ); - W_sum = W_mac_32_32( W_sum, b2_fx, x1 ); /* b2*x0 */ - W_sum = W_mac_32_32( W_sum, mem_fx[1], a2_fx ); /* y2*a2 */ - W_sum = W_mac_32_32( W_sum, W_extract_h( W_y2 ), a1_fx ); /* y1*a1 */ - W_y1 = W_shl( W_sum, HP20_COEFF_SCALE ); - signal_fx[1] = W_extract_h( W_shl( W_y1, prescale ) ); - move32(); - - diff = sub( prescale_current_frame, prescale ); - W_y1 = W_shr( W_y1, diff ); - W_y2 = W_shr( W_y2, diff ); - x2 = L_shr( x2, diff ); - x1 = L_shr( x1, diff ); - - FOR( i = 2; i < lg; i++ ) - { - W_sum = W_mult_32_32( b2_fx, x2 ); /* b2*x2 */ - W_sum = W_mac_32_32( W_sum, b1_fx, x1 ); /* b1*x1 */ - x0 = L_shr( signal_fx[i], prescale_current_frame ); - W_sum = W_mac_32_32( W_sum, b2_fx, x0 ); /* b2*x0 */ - W_sum = W_mac_32_32( W_sum, W_extract_h( W_y2 ), a2_fx ); /* y2*a2 */ - W_sum = W_mac_32_32( W_sum, W_extract_h( W_y1 ), a1_fx ); /* y1*a1 */ - W_y0 = W_shl( W_sum, HP20_COEFF_SCALE ); - - signal_fx[i] = W_extract_h( W_shl( W_y0, prescale_current_frame ) ); - move32(); - - x2 = x1; - x1 = x0; - W_y2 = W_y1; - W_y1 = W_y0; - - move32(); - move32(); - move64(); - move64(); - } - - mem_fx[0] = W_extract_h( W_y2 ); - mem_fx[1] = W_extract_h( W_y1 ); - mem_fx[2] = x2; - mem_fx[3] = x1; - - move32(); - move32(); - move32(); - move32(); - - return; -} -#else -void hp20_fx_32( - Word32 signal_fx[], - const Word16 lg, - Word32 mem_fx[], - const Word32 Fs ) -{ - Word16 i; - Word32 a1_fx, a2_fx, b1_fx, b2_fx; - Word16 Qx0, Qx1, Qx2, Qy1, Qprev_y1, Qy2, Qprev_y2, Qmin; - Word64 x0_fx64, x1_fx64, x2_fx64, y0_fx64, y1_fx64, y2_fx64, R1, R2, R3, R4, R5; - - IF( EQ_32( Fs, 8000 ) ) - { - /* hp filter 20Hz at 3dB for 8000KHz input sampling rate - [b,a] = butter(2, 20.0/4000.0, 'high'); - b = [0.988954248067140 -1.977908496134280 0.988954248067140] - a =[1.000000000000000 -1.977786483776764 0.978030508491796]*/ - a1_fx = 1061816033l /* 1.977786483776764 Q29*/; - a2_fx = -525076131l /*-0.978030508491796 Q29*/; - b1_fx = -1061881538l /*-1.977908496134280 Q29*/; - b2_fx = 530940769l /* 0.988954248067140 Q29*/; - } - ELSE IF( EQ_32( Fs, 16000 ) ) - { - /* hp filter 20Hz at 3dB for 16000KHz sampling rate - [b,a] = butter(2, 20.0/8000.0, 'high'); - b =[ 0.994461788958195 -1.988923577916390 0.994461788958195] - a =[1.000000000000000 -1.988892905899653 0.988954249933127] */ - a1_fx = 1067778748l /* 1.988892905899653 Q29*/; - a2_fx = -530940770l /*-0.988954249933127 Q29*/; - b1_fx = -1067795215l /*-1.988923577916390 Q29*/; - b2_fx = 533897608l /* 0.994461788958195 Q29*/; - } - ELSE IF( EQ_32( Fs, 32000 ) ) - { - /* hp filter 20Hz at 3dB for 32000KHz sampling rate - [b,a] = butter(2, 20.0/16000.0, 'high'); - b =[0.997227049904470 -1.994454099808940 0.997227049904470] - a =[1.000000000000000 -1.994446410541927 0.994461789075954]*/ - a1_fx = 1070760263l /* 1.994446410541927 Q29*/; - a2_fx = -533897608l /*-0.994461789075954 Q29*/; - b1_fx = -1070764392l /*-1.994454099808940 Q29*/; - b2_fx = 535382196l /* 0.997227049904470 Q29*/; - } - ELSE - { - /* hp filter 20Hz at 3dB for 48000KHz sampling rate - [b,a] = butter(2, 20.0/24000.0, 'high'); - b =[ 0.998150511190452 -1.996301022380904 0.998150511190452] - a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ - a1_fx = 1071754114l /* 1.996297601769122 Q29*/; - a2_fx = -534886875l /*-0.996304442992686 Q29*/; - b1_fx = -1071755951l /*-1.996301022380904 Q29*/; - b2_fx = 535877975l /* 0.998150511190452 Q29*/; - } - move32(); - move32(); - move32(); - move32(); - - Qprev_y1 = extract_l( mem_fx[4] ); - Qprev_y2 = extract_l( mem_fx[5] ); - y1_fx64 = W_deposit32_l( mem_fx[0] ); - y2_fx64 = W_deposit32_l( mem_fx[1] ); - x0_fx64 = W_deposit32_l( mem_fx[2] ); - x1_fx64 = W_deposit32_l( mem_fx[3] ); - - FOR( i = 0; i < lg; i++ ) - { - x2_fx64 = x1_fx64; - move64(); - x1_fx64 = x0_fx64; - move64(); - x0_fx64 = W_deposit32_l( signal_fx[i] ); - - Qy1 = W_norm( y1_fx64 ); - if ( y1_fx64 == 0 ) - { - Qy1 = 62; - move16(); - } - Qy1 = sub( Qy1, 34 ); - R1 = W_mult0_32_32( W_extract_l( W_shl( y1_fx64, Qy1 ) ), a1_fx ); - Qy1 = add( Qy1, Qprev_y1 ); - - Qy2 = W_norm( y2_fx64 ); - if ( y2_fx64 == 0 ) - { - Qy2 = 62; - move16(); - } - Qy2 = sub( Qy2, 34 ); - R2 = W_mult0_32_32( W_extract_l( W_shl( y2_fx64, Qy2 ) ), a2_fx ); - Qy2 = add( Qy2, Qprev_y2 ); - - Qx0 = W_norm( x0_fx64 ); - if ( x0_fx64 == 0 ) - { - Qx0 = 62; - move16(); - } - Qx0 = sub( Qx0, 34 ); - R3 = W_mult0_32_32( W_extract_l( W_shl( x0_fx64, Qx0 ) ), b2_fx ); - - Qx1 = W_norm( x1_fx64 ); - if ( x1_fx64 == 0 ) - { - Qx1 = 62; - move16(); - } - Qx1 = sub( Qx1, 34 ); - R4 = W_mult0_32_32( W_extract_l( W_shl( x1_fx64, Qx1 ) ), b1_fx ); - - Qx2 = W_norm( x2_fx64 ); - if ( x2_fx64 == 0 ) - { - Qx2 = 62; - move16(); - } - Qx2 = sub( Qx2, 34 ); - R5 = W_mult0_32_32( W_extract_l( W_shl( x2_fx64, Qx2 ) ), b2_fx ); - - Qmin = s_min( Qy1, Qy2 ); - - y0_fx64 = W_add( W_shr( R1, sub( Qy1, Qmin ) ), W_shr( R2, sub( Qy2, Qmin ) ) ); - - Qmin = s_min( Qmin, Qx0 ); - Qmin = s_min( Qmin, Qx1 ); - Qmin = s_min( Qmin, Qx2 ); - - y0_fx64 = W_add( W_shr( y0_fx64, sub( s_min( Qy1, Qy2 ), Qmin ) ), W_add( W_shr( R3, sub( Qx0, Qmin ) ), W_add( W_shr( R4, sub( Qx1, Qmin ) ), W_shr( R5, sub( Qx2, Qmin ) ) ) ) ); - - y0_fx64 = W_shr( y0_fx64, 29 ); - - signal_fx[i] = W_extract_l( W_shr( y0_fx64, Qmin ) ); - move32(); - IF( signal_fx[i] < 0 ) - { - signal_fx[i] = L_add( signal_fx[i], 1 ); - move32(); - } - - y2_fx64 = y1_fx64; - y1_fx64 = y0_fx64; - Qprev_y2 = Qprev_y1; - Qprev_y1 = Qmin; - move64(); - move64(); - move16(); - move16(); - } - - Qy1 = W_norm( y1_fx64 ); - test(); - IF( y1_fx64 != 0 && LT_16( Qy1, 32 ) ) - { - y1_fx64 = W_shr( y1_fx64, sub( 32, Qy1 ) ); - Qprev_y1 = sub( Qprev_y1, sub( 32, Qy1 ) ); - } - - Qy2 = W_norm( y2_fx64 ); - test(); - IF( y2_fx64 != 0 && LT_16( Qy2, 32 ) ) - { - y2_fx64 = W_shr( y2_fx64, sub( 32, Qy2 ) ); - Qprev_y2 = sub( Qprev_y2, sub( 32, Qy2 ) ); - } - - mem_fx[0] = W_extract_l( y1_fx64 ); - mem_fx[1] = W_extract_l( y2_fx64 ); - mem_fx[2] = W_extract_l( x0_fx64 ); - mem_fx[3] = W_extract_l( x1_fx64 ); - mem_fx[4] = Qprev_y1; - mem_fx[5] = Qprev_y2; - move32(); - move32(); - move32(); - move32(); - move32(); - move32(); - - return; -} -#endif diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index d13835f4c..9820eb3c8 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -41,16 +41,6 @@ #include "wmc_auto.h" #include "prot_fx.h" -/* - * hp20 - * - * Function: - * 2nd order high pass filter with nominal cut off frequency at 20 Hz. - * - * Returns: - * void - */ - #define HP20_COEFF_SCALE ( 2 ) /* -- GitLab From d46773e421e8e5ef085eefa98fcf63cbaa9e7c76 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 14:26:18 +0100 Subject: [PATCH 33/97] remove unused function --- lib_com/frame_ener_fx.c | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index 7ee58371a..4428c0796 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -47,45 +47,6 @@ * Estimation of pitch-synchronous (voiced sounds) or half-frame energy *----------------------------------------------------------------------------------*/ -void fer_energy( - const int16_t L_frame, /* i : frame length */ - const int16_t clas, /* i : frame classification */ - const float *synth, /* i : synthesized speech at Fs = 12k8 Hz */ - const float pitch, /* i : pitch period */ - float *enr, /* o : pitch-synchronous or half_frame energy */ - const int16_t offset /* i : speech pointer offset (0 or L_frame) */ -) -{ - int16_t len; - const float *pt_synth; - - if ( clas == VOICED_CLAS || clas == ONSET || clas == SIN_ONSET ) /* Voiced or Onset current frame */ - { - len = (int16_t) ( pitch + 0.5f ); /* pitch value */ - - pt_synth = synth; - if ( offset != 0 ) - { - pt_synth = synth + L_frame - len; - } - - emaximum( pt_synth, len, enr ); /* pitch synchronous E */ - } - else - { - pt_synth = synth; - if ( offset != 0 ) - { - pt_synth = synth + L_frame / 2; - } - - *enr = dotp( pt_synth, pt_synth, L_frame / 2 ); - *enr /= (float) ( L_frame / 2 ); - } - return; -} - - void fer_energy_fx( const Word16 L_frame, /* i : frame length */ const Word16 clas, /* i : frame classification */ -- GitLab From 54426a49982dbc40bdac0a07ee514d7c711fbd5a Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 14:34:47 +0100 Subject: [PATCH 34/97] fix build-codec-linux-debugging-make --- lib_rend/lib_rend.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 698c652e5..493979e30 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -45,6 +45,9 @@ #include #include #include "wmc_auto.h" +#ifdef DEBUGGING +#include "debug.h" +#endif /*-------------------------------------------------------------------* -- GitLab From 1afe839586e76766c822080214a21ec9cd7c1d51 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 16:02:36 +0100 Subject: [PATCH 35/97] remove ADD_IVAS_BWE --- lib_com/prot_fx.h | 35 ++++--------- lib_dec/decision_matrix_dec_fx.c | 4 +- lib_dec/evs_dec_fx.c | 20 +------- lib_dec/init_dec_fx.c | 6 +-- lib_dec/swb_bwe_dec_fx.c | 84 +++++--------------------------- lib_dec/swb_tbe_dec_fx.c | 5 +- lib_enc/cng_enc_fx.c | 7 +-- 7 files changed, 32 insertions(+), 129 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 0371f747a..51fbb12d5 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6057,10 +6057,7 @@ void TBEreset_dec_fx( void td_bwe_dec_init_fx( Decoder_State *st_fx, /* i/o: SHB decoder structure */ TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ -#ifdef ADD_IVAS_BWE - const Word16 extl, /* i : BWE extension layer */ -#endif - const Word32 output_Fs /* i : output sampling rate */ + const Word32 output_Fs /* i : output sampling rate */ ); // lsf_dec_fx.c @@ -7700,19 +7697,12 @@ Word16 WB_BWE_gain_deq_fx( ); Word16 wb_bwe_dec_fx( -#ifdef ADD_IVAS_BWE - const Word16 output[], /* i : suntehsis @ internal Fs */ -#endif - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ -#ifdef ADD_IVAS_BWE - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ -#endif + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ const Word16 output_frame, /* i : frame length */ Word16 *voice_factors_fx, /* i : voicing factors Q15 */ const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ - Decoder_State *st_fx /* i/o: decoder state structure */ - , + Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *Qpost ); Word16 swb_bwe_gain_deq_fx( /* o : BWE class */ @@ -7724,18 +7714,11 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class const Word16 hqswb_clas /* i : HQ BWE class */ ); -Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ -#ifdef ADD_IVAS_BWE - const Word16 output[], /* i : suntehsis @ internal Fs */ -#endif - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ -#ifdef ADD_IVAS_BWE - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ -#endif - const Word16 output_frame /* i : frame length */ - , +Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ Word16 *Qpost ); void fd_bwe_dec_init( diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index a83de038a..f9833e80a 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -681,12 +681,12 @@ void decision_matrix_dec_fx( st->nb_subfr = NB_SUBFR16k; move16(); } -#if 1 // def ADD_IVAS_BWE 0> NEEDED for IO with conf_acelp1 + st->extl_orig = st->extl; move16(); st->extl_brate_orig = st->extl_brate; move32(); -#endif + test(); IF( EQ_32( st->output_Fs, 8000 ) ) { diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index a5a5ba6d9..aa997d4c0 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -383,15 +383,7 @@ ivas_error evs_dec_fx( ELSE IF( EQ_16( st_fx->extl, WB_BWE ) && st_fx->bws_cnt == 0 ) { /* WB BWE decoder */ - hb_synth_fx_exp = wb_bwe_dec_fx( -#ifdef ADD_IVAS_BWE - NULL, -#endif - synth_fx, hb_synth_fx, -#ifdef ADD_IVAS_BWE - 0, -#endif - output_frame, voice_factors_fx, pitch_buf_fx, st_fx, &Qpostd ); /*Q0*/ + hb_synth_fx_exp = wb_bwe_dec_fx( synth_fx, hb_synth_fx, output_frame, voice_factors_fx, pitch_buf_fx, st_fx, &Qpostd ); /*Q0*/ } /*---------------------------------------------------------------------* @@ -434,15 +426,7 @@ ivas_error evs_dec_fx( ( GE_32( st_fx->output_Fs, 32000 ) && EQ_16( st_fx->core, ACELP_CORE ) && GT_16( st_fx->bwidth, NB ) && st_fx->bws_cnt > 0 && !st_fx->ppp_mode_dec && !( EQ_16( st_fx->nelp_mode_dec, 1 ) && EQ_16( st_fx->bfi, 1 ) ) ) ) { /* SWB BWE decoder */ - hb_synth_fx_exp = swb_bwe_dec_fx( -#ifdef ADD_IVAS_BWE - NULL, -#endif - st_fx, synth_fx, hb_synth_fx, -#ifdef ADD_IVAS_BWE - 0, -#endif - output_frame, &Qpostd ); /*Q0*/ + hb_synth_fx_exp = swb_bwe_dec_fx( st_fx, synth_fx, hb_synth_fx, output_frame, &Qpostd ); /*Q0*/ } ELSE IF( EQ_16( st_fx->extl, SWB_BWE_HIGHRATE ) || EQ_16( st_fx->extl, FB_BWE_HIGHRATE ) ) { diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 5d8aee302..4f1db90ff 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -532,11 +532,7 @@ ivas_error init_decoder_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - td_bwe_dec_init_fx( st_fx, st_fx->hBWE_TD, -#ifdef ADD_IVAS_BWE - st_fx->extl, -#endif - st_fx->output_Fs ); + td_bwe_dec_init_fx( st_fx, st_fx->hBWE_TD, st_fx->output_Fs ); #ifdef MSAN_FIX st_fx->hBWE_TD->prev_hb_synth_fx_exp = 31; diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index d15a97821..b91dcdf32 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -505,19 +505,12 @@ Word16 ivas_wb_bwe_dec_fx( /* o : } Word16 wb_bwe_dec_fx( -#ifdef ADD_IVAS_BWE - const Word16 output[], /* i : suntehsis @ internal Fs */ -#endif - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ -#ifdef ADD_IVAS_BWE - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ -#endif + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ const Word16 output_frame, /* i : frame length */ Word16 *voice_factors_fx, /* i : voicing factors Q15 */ const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ - Decoder_State *st_fx /* i/o: decoder state structure */ - , + Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *Qpost ) { Word16 mode; @@ -538,18 +531,7 @@ Word16 wb_bwe_dec_fx( new_input_fx_exp = *Qpost; move16(); -#ifdef ADD_IVAS_BWE - if ( st->element_mode == IVAS_CPE_DFT && !use_cldfb_for_dft ) - { - /* IVAS_fmToDo: wtda() does not support L_FRAME length; thus temporarily resample the signal */ - /* IVAS_fmToDo: delay output[] by 1.25ms ? */ - lerp( output, ysynth, L_FRAME16k, st->L_frame ); - wtda( ysynth, wtda_synth, hBWE_FD->old_wtda_swb, ALDO_WINDOW, ALDO_WINDOW, /*st->L_frame*/ L_FRAME16k ); - direct_transform( wtda_synth, ysynth, 0, /*st->L_frame*/ L_FRAME16k, st->element_mode ); - } - else -#endif { wtda_fx( synth_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, &hBWE_FD->old_wtda_swb_fx_exp, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */ @@ -574,11 +556,7 @@ Word16 wb_bwe_dec_fx( Q_syn = add( sub( new_input_fx_exp, 16 ), scl ); IF( !st_fx->bfi ) { -#ifdef ADD_IVAS_BWE - IF( st_fx->extl_brate > 0 ) -#else IF( EQ_32( st_fx->total_brate, ACELP_13k20 ) ) -#endif { /* de-quantization */ mode = WB_BWE_gain_deq_fx( st_fx, WB_fenv_fx ); @@ -654,20 +632,15 @@ Word16 wb_bwe_dec_fx( window_ola_fx( t_audio32_tmp, hb_synth_fx, &Q_syn_hb, hBWE_FD->mem_imdct_fx, &hBWE_FD->mem_imdct_exp_fx, output_frame, ALDO_WINDOW, ALDO_WINDOW, 0, 0, 0 ); -#ifdef ADD_IVAS_BWE - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) - { - /* add HB synth from hf_synth() */ - v_add( hb_synth, synth, hb_synth, output_frame ); - } -#endif hBWE_FD->prev_mode = mode; move16(); st_fx->prev_Q_synth = Q_syn; move16(); + return Q_syn_hb; } + + /*-------------------------------------------------------------------* * swb_bwe_gain_deq() * @@ -910,18 +883,11 @@ Word16 swb_bwe_gain_deq_fx( /* o : BWE class * * SWB BWE decoder *-------------------------------------------------------------------*/ -Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ -#ifdef ADD_IVAS_BWE - const Word16 output[], /* i : suntehsis @ internal Fs */ -#endif - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ -#ifdef ADD_IVAS_BWE - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ -#endif - const Word16 output_frame /* i : frame length */ - , +Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ Word16 *Qpost ) { Word16 i, l_subfr; @@ -957,19 +923,7 @@ Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ /* windowing of the ACELP core synthesis */ new_input_fx_exp = *Qpost; move16(); -#ifdef ADD_IVAS_BWE - if ( st->element_mode == IVAS_CPE_DFT && !use_cldfb_for_dft ) - { - /* IVAS_fmToDo: wtda() does not support L_FRAME length; thus temporarily resample the signal */ - /* IVAS_fmToDo: delay output[] by 1.25ms ? */ - lerp( output, ysynthIfx, L_FRAME16k, st_fx->L_frame ); - wtda_fx( ysynth_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, - &hBWE_FD->old_wtda_swb_fx_exp, ALDO_WINDOW, ALDO_WINDOW, /*st->L_frame*/ L_FRAME16k ); - direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, /*st->L_frame*/ L_FRAME16k, &new_input_fx_exp, st_fx->element_mode ); - } - else -#endif { wtda_fx( synth_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, &hBWE_FD->old_wtda_swb_fx_exp, @@ -1112,12 +1066,7 @@ Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ } fb_band_begin = FB_BAND_BEGIN; move16(); -#ifdef ADD_IVAS_BWE - IF( st_fx->L_frame == L_FRAME ) - { - fb_band_begin = FB_BAND_BEGIN_12k8; - } -#endif + FOR( i = fb_band_begin; i < add( fb_band_begin, DE_OFFSET1 ); i++ ) { tmp = sub( 32767, i_mult( j, 1024 ) ); @@ -1193,14 +1142,7 @@ Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ move16(); } } -#ifdef ADD_IVAS_BWE - test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) - { - /* add HB synth from hf_synth() */ - v_add( hb_synth, synth, hb_synth, output_frame ); - } -#endif + hBWE_FD->prev_frica_flag = frica_flag; move16(); hBWE_FD->prev_mode = mode; diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index a37ebf9d9..bc8ef03cb 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -5236,10 +5236,7 @@ void td_bwe_dec_init_ivas_fx( void td_bwe_dec_init_fx( Decoder_State *st_fx, /* i/o: SHB decoder structure */ TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ -#ifdef ADD_IVAS_BWE - const Word16 extl, /* i : BWE extension layer */ -#endif - const Word32 output_Fs /* i : output sampling rate */ + const Word32 output_Fs /* i : output sampling rate */ ) { Word16 i; diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 179d0230b..1721476b4 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -2446,8 +2446,6 @@ static void shb_CNG_encod_fx( } ELSE { - /*idx_ener = (int16_t)(0.7f * (0.1f * st->hTdCngEnc->mov_shb_cng_ener / (float)log10(2.0f) + 6.0f) + 0.5f);*/ - // PMT("shb_CNG_encod_fx quantization in missing") } if ( LT_16( st_fx->bwidth, SWB ) ) @@ -2468,7 +2466,10 @@ static void shb_CNG_encod_fx( push_indice_fx( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4 ); push_indice_fx( hBstr, IND_SID_BW, 1, 1 ); - delete_indice( hBstr, IND_CNG_ENV1 ); + hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_CNG_ENV1].nb_bits ); + hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1; + move16(); + move16(); if ( st_fx->element_mode == IVAS_CPE_DFT ) { -- GitLab From 95009451fea95fac053b01d04e25afef3f8dfd11 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Mar 2025 16:17:42 +0100 Subject: [PATCH 36/97] fix --- lib_dec/acelp_core_dec_fx.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 1d59d1269..c0ad52a48 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1321,6 +1321,26 @@ ivas_error acelp_core_dec_fx( move16(); } } + + test(); + test(); + test(); + test(); + test(); + IF( st_fx->flag_cna == 0 && EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( st_fx->last_flag_cna, 1 ) && ( ( st_fx->last_core == ACELP_CORE && NE_16( st_fx->last_coder_type, AUDIO ) ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) + { + FOR( i = 0; i < st_fx->L_frame / 2; i++ ) + { + syn_fx[i] = add( syn_fx[i], shr_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4], negate( st_fx->Q_syn ) ) ); + move16(); + } + } + + test(); + IF( st_fx->flag_cna == 0 || EQ_16( st_fx->coder_type, AUDIO ) ) + { + set16_fx( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec->hFdCngCom->fftlen ); + } } /*----------------------------------------------------------------* -- GitLab From 726b69f070b295ddd2c65a28eeb3e76757de6606 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 21:03:44 +0530 Subject: [PATCH 37/97] Optimizations for multichannel file decoded with binaural rendering ivas_binRenderer_filterModule_fx - 3.96 WMOPS improvement matrix_product_mant_exp - 9.631 WMOPS improvement BASOP_Util_Add_Mant32Exp - 15.926 WMOPS improvement --- lib_com/ivas_prot_fx.h | 14 ++ lib_com/ivas_tools_fx.c | 238 +++++++++++++++++-- lib_com/options.h | 1 + lib_dec/ivas_binRenderer_internal_fx.c | 78 +++++- lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 159 ++++++++++++- lib_dec/ivas_mc_param_dec_fx.c | 4 + lib_rend/ivas_stat_rend.h | 4 + 7 files changed, 466 insertions(+), 32 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 79ba75b81..3c01bebfd 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1314,6 +1314,20 @@ Word16 matrix_diag_product_fx( Word32 *Z, /* o : resulting matrix after the matrix multiplication */ Word16 *Z_e ); +#ifdef OPT_BASOP_ADD_v1 +Word16 matrix_diag_product_fx_2( + const Word32 *X, /* i : left hand matrix Q31 - X_e*/ + const Word16 X_e, + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements Q31 - Y_e*/ + const Word16 *Y_e, + const Word16 entriesY, /* i : number of entries in the diagonal Q0*/ + Word32 *Z, /* o : resulting matrix after the matrix multiplication Q31 - Z_e*/ + Word16 *Z_e ); +#endif /* OPT_BASOP_ADD_v1 */ + Word16 matrix_diag_product_fx_1( const Word32 *X, /* i : left hand matrix */ const Word16 *X_e, diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index d55766928..9cd1a063e 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -980,7 +980,9 @@ Word16 matrix_product_mant_exp_fx( Word16 out_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; Word16 *Zp_fx_e = out_e; Word16 row, col; +#ifndef OPT_BASOP_ADD_v1 Word16 x_idx, y_idx; +#endif /* OPT_BASOP_ADD_v1 */ Word64 temp; Word16 temp_e; Word16 prod_e = add( X_fx_e, Y_fx_e ); @@ -1007,9 +1009,13 @@ Word16 matrix_product_mant_exp_fx( FOR( k = 0; k < rowsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + temp = W_mac_32_32( temp, X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ); // X_fx_e + Y_fx_e +#else /* OPT_BASOP_ADD_v1 */ x_idx = k + i * rowsX; y_idx = k + j * rowsY; temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e +#endif /* OPT_BASOP_ADD_v1 */ } /* Maximize accumulated value to 32-bit */ temp_e = W_norm( temp ); @@ -1047,9 +1053,13 @@ Word16 matrix_product_mant_exp_fx( move64(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + temp = W_mac_32_32( temp, X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ); // X_fx_e + Y_fx_e +#else /* OPT_BASOP_ADD_v1 */ x_idx = i + k * rowsX; y_idx = j + k * rowsY; temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e +#endif /* OPT_BASOP_ADD_v1 */ } /* Maximize accumulated value to 32-bit */ temp_e = W_norm( temp ); @@ -1087,9 +1097,13 @@ Word16 matrix_product_mant_exp_fx( move64(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + temp = W_mac_32_32( temp, X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ); // X_fx_e + Y_fx_e +#else /* OPT_BASOP_ADD_v1 */ x_idx = k + i * rowsX; y_idx = j + k * rowsY; temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e +#endif /* OPT_BASOP_ADD_v1 */ } /* Maximize accumulated value to 32-bit */ temp_e = W_norm( temp ); @@ -1128,9 +1142,13 @@ Word16 matrix_product_mant_exp_fx( move64(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + temp = W_mac_32_32( temp, X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ); // X_fx_e + Y_fx_e +#else /* OPT_BASOP_ADD_v1 */ x_idx = i + k * rowsX; y_idx = k + j * rowsY; - temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e + temp = W_mac_32_32( temp, X_fx[x_idx], Y_fx[y_idx] ); // X_fx_e + Y_fx_e +#endif /* OPT_BASOP_ADD_v1 */ } /* Maximize accumulated value to 32-bit */ temp_e = W_norm( temp ); @@ -1188,7 +1206,9 @@ Word16 matrix_product_fx( ) { Word16 i, j, k; +#ifndef OPT_BASOP_ADD_v1 Word16 x_idx, y_idx; +#endif /* OPT_BASOP_ADD_v1 */ Word32 *Zp_fx = Z_fx; /* Processing */ @@ -1209,9 +1229,13 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < rowsX; ++k ) { - x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ - y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ - ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#ifdef OPT_BASOP_ADD_v1 + ( *Zp_fx ) = Madd_32_32( *Zp_fx, X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ); /*Qx + Qy - 31*/ +#else /* OPT_BASOP_ADD_v1 */ + x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ + y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ + ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp_fx++; @@ -1232,9 +1256,13 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ - y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ - ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#ifdef OPT_BASOP_ADD_v1 + ( *Zp_fx ) = Madd_32_32( *Zp_fx, X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ); /*Qx + Qy - 31*/ +#else /* OPT_BASOP_ADD_v1 */ + x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ + y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ + ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp_fx++; @@ -1255,9 +1283,13 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < colsX; ++k ) { - x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ - y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ - ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#ifdef OPT_BASOP_ADD_v1 + ( *Zp_fx ) = Madd_32_32( *Zp_fx, X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ); /*Qx + Qy - 31*/ +#else /* OPT_BASOP_ADD_v1 */ + x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ + y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ + ( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } @@ -1280,9 +1312,13 @@ Word16 matrix_product_fx( move32(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + ( *Zp_fx ) = L_add_sat( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); /*Qx + Qy - 31*/ +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ ( *Zp_fx ) = L_add_sat( *Zp_fx, Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); /*Qx + Qy - 31*/ +#endif /* OPT_BASOP_ADD_v1 */ // TODO: overflow of Z_fx to be checked move32(); } @@ -1307,7 +1343,9 @@ Word16 matrix_product_q30_fx( ) { Word16 i, j, k; +#ifndef OPT_BASOP_ADD_v1 Word16 x_idx, y_idx; +#endif /* OPT_BASOP_ADD_v1 */ Word32 *Zp_fx = Z_fx; Word64 W_tmp; @@ -1330,10 +1368,14 @@ Word16 matrix_product_q30_fx( move64(); FOR( k = 0; k < rowsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) ); // Q56 +#else /* OPT_BASOP_ADD_v1 */ //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) ); x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56 +#endif /* OPT_BASOP_ADD_v1 */ } W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ @@ -1357,10 +1399,14 @@ Word16 matrix_product_q30_fx( move64(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); // Q56 +#else /* OPT_BASOP_ADD_v1 */ //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56 +#endif /* OPT_BASOP_ADD_v1 */ } W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ @@ -1384,9 +1430,11 @@ Word16 matrix_product_q30_fx( move64(); FOR( k = 0; k < colsX; ++k ) { +#ifndef OPT_BASOP_ADD_v1 //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ +#endif /* OPT_BASOP_ADD_v1 */ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); // Q56 } @@ -1413,10 +1461,14 @@ Word16 matrix_product_q30_fx( move64(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); // Q56 +#else /* OPT_BASOP_ADD_v1 */ //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[x_idx], Y_fx[y_idx] ) ); // Q56 +#endif /* OPT_BASOP_ADD_v1 */ } W_tmp = W_shl( W_tmp, 6 ); /*Q62*/ ( *Zp_fx ) = W_round64_L( W_tmp ); /*Q30*/ @@ -1449,7 +1501,9 @@ Word16 matrix_product_mant_exp( Word16 *Zp_e = Z_e; Word32 L_tmp; Word16 tmp_e; +#ifndef OPT_BASOP_ADD_v1 Word16 x_idx, y_idx; +#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ test(); @@ -1471,11 +1525,16 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < rowsX; ++k ) { - x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ - y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ +#ifdef OPT_BASOP_ADD_v1 + L_tmp = Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/ + tmp_e = add( X_e[k + i * rowsX], Y_e[k + j * rowsY] ); +#else /* OPT_BASOP_ADD_v1 */ + x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ + y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ //( *Zp ) += X[k + i * rowsX] * Y[k + j * rowsY]; L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/ tmp_e = add( X_e[x_idx], Y_e[y_idx] ); +#endif /* OPT_BASOP_ADD_v1 */ ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); move32(); @@ -1503,11 +1562,16 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + L_tmp = Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/ + tmp_e = add( X_e[i + k * rowsX], Y_e[j + k * rowsY] ); +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ //( *Zp ) += X_fx[i + k * rowsX] * Y_fx[j + k * rowsY]; L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/ tmp_e = add( X_e[x_idx], Y_e[y_idx] ); +#endif /* OPT_BASOP_ADD_v1 */ ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); ( *Zp_e ) = tmp_e; @@ -1534,11 +1598,16 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + L_tmp = Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/ + tmp_e = add( X_e[k + i * rowsX], Y_e[j + k * rowsY] ); +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( k, imult1616( i, rowsX ) ); /*Q0*/ y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ //( *Zp ) += X_fx[k + i * rowsX] * Y_fx[j + k * rowsY]; L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/ tmp_e = add( X_e[x_idx], Y_e[y_idx] ); +#endif /* OPT_BASOP_ADD_v1 */ ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); move32(); @@ -1568,11 +1637,16 @@ Word16 matrix_product_mant_exp( move16(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + L_tmp = Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/ + tmp_e = add( X_e[i + k * rowsX], Y_e[k + j * rowsY] ); +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( i, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ //( *Zp ) += X_fx[i + k * rowsX] * Y_fx[k + j * rowsY]; L_tmp = Mpy_32_32( X_fx[x_idx], Y_fx[y_idx] ); /*Q31 - (X_e + Y_e)*/ tmp_e = add( X_e[x_idx], Y_e[y_idx] ); +#endif /* OPT_BASOP_ADD_v1 */ ( *Zp ) = BASOP_Util_Add_Mant32Exp( *Zp, *Zp_e, L_tmp, tmp_e, &tmp_e ); move32(); @@ -1603,7 +1677,9 @@ Word16 matrix_diag_product_fx( { Word16 i, j; Word32 *Zp = Z; +#ifndef OPT_BASOP_ADD_v1 Word16 tmp; +#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ IF( EQ_16( transpX, 1 ) ) /* We use X transpose */ @@ -1616,8 +1692,12 @@ Word16 matrix_diag_product_fx( { FOR( i = 0; i < colsX; ++i ) { +#ifdef OPT_BASOP_ADD_v1 + *( Zp ) = Mpy_32_32( X[j + i * rowsX], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ tmp = add( j, imult1616( i, rowsX ) ); - *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ + *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); Zp++; } @@ -1648,6 +1728,100 @@ Word16 matrix_diag_product_fx( return EXIT_SUCCESS; } +#ifdef OPT_BASOP_ADD_v1 +Word16 matrix_diag_product_fx_2( + const Word32 *X, /* i : left hand matrix Q31 - X_e*/ + const Word16 X_e, + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y, /* i : right hand diagonal matrix as vector containing the diagonal elements Q31 - Y_e*/ + const Word16 *Y_e, + const Word16 entriesY, /* i : number of entries in the diagonal Q0*/ + Word32 *Z, /* o : resulting matrix after the matrix multiplication Q31 - Z_e*/ + Word16 *Z_e ) +{ + Word16 i, j; + Word32 *Zp = Z; + Word16 *Z_ep = Z_e; + Word16 tmp; + Word16 max_exp = -31; + move16(); + + /* Processing */ + IF( EQ_16( transpX, 1 ) ) /* We use X transpose */ + { + IF( NE_16( rowsX, entriesY ) ) + { + return EXIT_FAILURE; + } + FOR( j = 0; j < entriesY; ++j ) + { + FOR( i = 0; i < colsX; ++i ) + { + tmp = j + i * rowsX; /*Q0*/ + *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ + move32(); + Zp++; + *( Z_ep ) = add( X_e, Y_e[j] ); + move16(); + max_exp = s_max( max_exp, *Z_ep ); // Find the max exp + Z_ep++; + } + } + + Zp = Z; + Z_ep = Z_e; + FOR( j = 0; j < entriesY; ++j ) + { + FOR( i = 0; i < colsX; ++i ) + { + *Zp = L_shr( *Zp, sub( max_exp, *Z_ep ) ); + *Z_ep = max_exp; + Zp++; + Z_ep++; + } + } + } + ELSE /* Regular case */ + { + IF( NE_16( colsX, entriesY ) ) + { + return EXIT_FAILURE; + } + + FOR( j = 0; j < entriesY; ++j ) + { + FOR( i = 0; i < rowsX; ++i ) + { + *( Zp ) = Mpy_32_32( *( X ), Y[j] ); /*Q31 - (X_e + Y_e)*/ + move32(); + Zp++; + *( Z_ep ) = add( X_e, Y_e[j] ); + move16(); + max_exp = s_max( max_exp, *Z_ep ); // Find the max exp + Z_ep++; + X++; + } + } + Zp = Z; + Z_ep = Z_e; + FOR( j = 0; j < entriesY; ++j ) + { + FOR( i = 0; i < rowsX; ++i ) + { + *Zp = L_shr( *Zp, sub( max_exp, *Z_ep ) ); + *Z_ep = max_exp; + Zp++; + Z_ep++; + } + } + } + + return EXIT_SUCCESS; +} +#endif /* OPT_BASOP_ADD_v1 */ + Word16 matrix_diag_product_fx_1( const Word32 *X, /* i : left hand matrix Q31 - X_e*/ const Word16 *X_e, @@ -1663,7 +1837,9 @@ Word16 matrix_diag_product_fx_1( Word16 i, j; Word32 *Zp = Z; Word16 *Z_ep = Z_e; +#ifndef OPT_BASOP_ADD_v1 Word16 tmp; +#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ IF( EQ_16( transpX, 1 ) ) /* We use X transpose */ @@ -1676,11 +1852,19 @@ Word16 matrix_diag_product_fx_1( { FOR( i = 0; i < colsX; ++i ) { +#ifdef OPT_BASOP_ADD_v1 + *( Zp ) = Mpy_32_32( X[j + i * rowsX], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ tmp = add( j, imult1616( i, rowsX ) ); /*Q0*/ *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); Zp++; +#ifdef OPT_BASOP_ADD_v1 + *( Z_ep ) = add( X_e[j + i * rowsX], Y_e[j] ); +#else /* OPT_BASOP_ADD_v1 */ *( Z_ep ) = add( X_e[tmp], Y_e[j] ); +#endif /* OPT_BASOP_ADD_v1 */ move16(); Z_ep++; } @@ -1726,7 +1910,9 @@ Word16 diag_matrix_product_fx( { Word16 i, j; Word32 *Zp = Z; +#ifndef OPT_BASOP_ADD_v1 Word16 tmp; +#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ IF( EQ_16( transpX, 1 ) ) /* We use X transpose */ @@ -1739,8 +1925,12 @@ Word16 diag_matrix_product_fx( { FOR( j = 0; j < entriesY; ++j ) { - tmp = add( i, imult1616( j, rowsX ) ); /*Q0*/ - *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#ifdef OPT_BASOP_ADD_v1 + *( Zp ) = Mpy_32_32( X[i + j * rowsX], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ + tmp = add( i, imult1616( j, rowsX ) ); /*Q0*/ + *( Zp ) = Mpy_32_32( X[tmp], Y[j] ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); Zp++; } @@ -1786,7 +1976,9 @@ Word16 matrix_product_diag_fx( { Word16 j, k; Word32 *Zp = Z; +#ifndef OPT_BASOP_ADD_v1 Word16 y_idx, x_idx; +#endif /* OPT_BASOP_ADD_v1 */ /* Processing */ test(); @@ -1805,9 +1997,13 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < rowsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + ( *Zp ) = Madd_32_32( ( *Zp ), X[k + j * rowsX], Y[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( k, imult1616( j, rowsX ) ); /*Q0*/ y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp++; @@ -1825,9 +2021,13 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + ( *Zp ) = Madd_32_32( ( *Zp ), X[j + k * rowsX], Y[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( j, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp++; @@ -1847,9 +2047,13 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + ( *Zp ) = Madd_32_32( ( *Zp ), X[k + j * rowsX], Y[j + k * rowsY] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( k, imult1616( j, rowsX ) ); /*Q0*/ y_idx = add( j, imult1616( k, rowsY ) ); /*Q0*/ ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } @@ -1869,9 +2073,13 @@ Word16 matrix_product_diag_fx( move32(); FOR( k = 0; k < colsX; ++k ) { +#ifdef OPT_BASOP_ADD_v1 + ( *Zp ) = Madd_32_32( ( *Zp ), X[j + k * rowsX], Y[k + j * rowsY] ); /*Q31 - (X_e + Y_e)*/ +#else /* OPT_BASOP_ADD_v1 */ x_idx = add( j, imult1616( k, rowsX ) ); /*Q0*/ y_idx = add( k, imult1616( j, rowsY ) ); /*Q0*/ ( *Zp ) = L_add( ( *Zp ), Mpy_32_32( X[x_idx], Y[y_idx] ) ); /*Q31 - (X_e + Y_e)*/ +#endif /* OPT_BASOP_ADD_v1 */ move32(); } Zp++; diff --git a/lib_com/options.h b/lib_com/options.h index 59698f78e..b2f44bfe9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -174,4 +174,5 @@ #define NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH /* FhG: issue 708: fix crash in OSBA BR switching with long test vectors */ //#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ #define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ +#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ #endif diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 748bdec38..a6e03eee3 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -68,9 +68,17 @@ static void ivas_binRenderer_filterModule_fx( { Word16 bandIdx, k, chIdx, tapIdx; Word32 *filterStatesLeftRealPtr_fx, *filterStatesLeftImagPtr_fx; +#ifdef OPT_BASOP_ADD_v1 + Word16 Q_filterStates; +#else /* OPT_BASOP_ADD_v1 */ Word16 *Q_filterStates; +#endif /* OPT_BASOP_ADD_v1 */ const Word32 *filterTapsLeftRealPtr_fx, *filterTapsLeftImagPtr_fx, *filterTapsRightRealPtr_fx, *filterTapsRightImagPtr_fx; Word16 shift_q; +#ifdef OPT_BASOP_ADD_v1 + Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStatesLeft; + move16(); +#endif /* OPT_BASOP_ADD_v1 */ FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -78,7 +86,9 @@ static void ivas_binRenderer_filterModule_fx( { filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx][0] ); filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx][0] ); +#ifndef OPT_BASOP_ADD_v1 Q_filterStates = (Word16 *) &( hBinRenderer->hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx][0] ); +#endif /* OPT_BASOP_ADD_v1 */ filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 @@ -100,39 +110,59 @@ static void ivas_binRenderer_filterModule_fx( filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; move32(); +#ifndef OPT_BASOP_ADD_v1 shift_q = sub( Q_filterStates[tapIdx], Q_filterStates[tapIdx - 1] ); outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); outRealRight_fx = W_shr( outRealRight_fx, shift_q ); outImagRight_fx = W_shr( outImagRight_fx, shift_q ); +#endif /* OPT_BASOP_ADD_v1 */ - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates[tapIdx - 1] - - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); - outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsRightImagPtr_fx[tapIdx] ); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); + outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates +#ifndef OPT_BASOP_ADD_v1 Q_filterStates[tapIdx] = Q_filterStates[tapIdx - 1]; move16(); +#endif /* OPT_BASOP_ADD_v1 */ } + +#ifdef OPT_BASOP_ADD_v1 + shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); +#else /* OPT_BASOP_ADD_v1 */ shift_q = add( sub( Q_filterStates[1], Q_curr ), 1 ); - outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); - outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); - outRealRight_fx = W_shr( outRealRight_fx, shift_q ); - outImagRight_fx = W_shr( outImagRight_fx, shift_q ); +#endif /* OPT_BASOP_ADD_v1 */ + +#ifdef OPT_BASOP_ADD_v1 + IF( shift_q != 0 ) + { +#endif /* OPT_BASOP_ADD_v1 */ + outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr + outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr + outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr + outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr +#ifdef OPT_BASOP_ADD_v1 + hBinRenderer->hBinRenConvModule->Q_filterStatesLeft = Q_curr; + move16(); + } +#endif /* OPT_BASOP_ADD_v1 */ filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; move32(); filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; move32(); +#ifndef OPT_BASOP_ADD_v1 Q_filterStates[0] = Q_curr; move16(); +#endif /* OPT_BASOP_ADD_v1 */ /* Left Real and Imag */ @@ -318,10 +348,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -335,10 +367,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft[bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { @@ -352,10 +386,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ } } /* set memories */ @@ -400,7 +436,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( /* set the memories to zero */ set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); +#ifdef OPT_BASOP_ADD_v1 + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); +#else /* OPT_BASOP_ADD_v1 */ set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); +#endif /* OPT_BASOP_ADD_v1 */ IF( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; @@ -414,7 +455,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( /* set the memories to zero */ set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); +#ifdef OPT_BASOP_ADD_v1 + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); +#else /* OPT_BASOP_ADD_v1 */ set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); +#endif /* OPT_BASOP_ADD_v1 */ IF( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; @@ -1279,8 +1325,10 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx] = NULL; +#ifndef OPT_BASOP_ADD_v1 free( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx] ); hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx] = NULL; +#endif /* OPT_BASOP_ADD_v1 */ } free( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx] ); @@ -1289,8 +1337,10 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[bandIdx] = NULL; +#ifndef OPT_BASOP_ADD_v1 free( hBinRenConvModule->Q_filterStatesLeft[bandIdx] ); hBinRenConvModule->Q_filterStatesLeft[bandIdx] = NULL; +#endif /* OPT_BASOP_ADD_v1 */ } free( hBinRenConvModule->filterStatesLeftReal_fx ); @@ -1299,8 +1349,10 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx ); hBinRenConvModule->filterStatesLeftImag_fx = NULL; +#ifndef OPT_BASOP_ADD_v1 free( hBinRenConvModule->Q_filterStatesLeft ); hBinRenConvModule->Q_filterStatesLeft = NULL; +#endif /* OPT_BASOP_ADD_v1 */ free( ( *hBinRenderer )->hBinRenConvModule ); ( *hBinRenderer )->hBinRenConvModule = NULL; diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index 13d8fc940..afbde5a60 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -725,7 +725,11 @@ Word16 computeMixingMatrices_fx( Word32 G_hat_fx[MAX_OUTPUT_CHANNELS]; Word16 G_hat_buff_e[MAX_OUTPUT_CHANNELS]; +#ifdef OPT_BASOP_ADD_v1 + Word16 mat_mult_buffer2_e, mat_mult_buffer3_e; +#else /* OPT_BASOP_ADD_v1 */ Word16 mat_mult_buffer1_e, mat_mult_buffer2_e, mat_mult_buffer3_e; +#endif /* OPT_BASOP_ADD_v1 */ Word32 mat_mult_buffer3_fx[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; @@ -775,7 +779,9 @@ Word16 computeMixingMatrices_fx( mat2svdMat_fx( Cy_fx, svd_in_buffer_fx, lengthCy, lengthCy, 0 ); svd_fx( svd_in_buffer_fx, Cy_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCy, lengthCy ); - +#ifdef OPT_BASOP_ADD_v1 + Word16 max_e = -32; +#endif /* OPT_BASOP_ADD_v1 */ /* Computing Ky */ FOR( i = 0; i < lengthCy; ++i ) { @@ -788,8 +794,20 @@ Word16 computeMixingMatrices_fx( move32(); Ky_fx_e[i + ( j * lengthCy )] = tmp_e; move16(); +#ifdef OPT_BASOP_ADD_v1 + max_e = s_max( max_e, tmp_e ); +#endif /* OPT_BASOP_ADD_v1 */ } } +#ifdef OPT_BASOP_ADD_v1 + FOR( i = 0; i < lengthCy * lengthCy; ++i ) + { + Ky_fx[i] = L_shr( Ky_fx[i], sub( max_e, Ky_fx_e[i] ) ); + move32(); + Ky_fx_e[i] = max_e; + move16(); + } +#endif /* OPT_BASOP_ADD_v1 */ /*-----------------------------------------------------------------* * Decomposition of Cx @@ -800,7 +818,9 @@ Word16 computeMixingMatrices_fx( mat2svdMat_fx( Cx_fx, svd_in_buffer_fx, lengthCx, lengthCx, 0 ); svd_fx( svd_in_buffer_fx, Cx_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCx, lengthCx ); - +#ifdef OPT_BASOP_ADD_v1 + max_e = -32; +#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCx; ++i ) { FOR( j = 0; j < lengthCx; ++j ) @@ -812,9 +832,20 @@ Word16 computeMixingMatrices_fx( move32(); Kx_fx_e[( i + ( j * lengthCx ) )] = tmp_e; move16(); +#ifdef OPT_BASOP_ADD_v1 + max_e = s_max( max_e, tmp_e ); +#endif /* OPT_BASOP_ADD_v1 */ } } - +#ifdef OPT_BASOP_ADD_v1 + FOR( i = 0; i < lengthCx * lengthCx; ++i ) + { + Kx_fx[i] = L_shr( Kx_fx[i], sub( max_e, Kx_fx_e[i] ) ); + move32(); + Kx_fx_e[i] = max_e; + move16(); + } +#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCx; ++i ) { @@ -938,14 +969,25 @@ Word16 computeMixingMatrices_fx( /* Computing the input matrix Kx'*Q'*G_hat'*Ky */ +#ifdef OPT_BASOP_ADD_v1 + Word16 mat_mult_buffer1_fx_e; +#else /* OPT_BASOP_ADD_v1 */ Word16 mat_mult_buffer1_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; Word16 Q_e_arr[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; set16_fx( Q_e_arr, Q_e, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS ); matrix_product_mant_exp( Kx_fx, Kx_fx_e, lengthCx, lengthCx, 1, Q_fx, Q_e_arr, lengthCy, lengthCx, 1, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); +#endif /* OPT_BASOP_ADD_v1 */ Word16 mat_mult_buffer2_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; +#ifdef OPT_BASOP_ADD_v1 + matrix_product_mant_exp_fx( Kx_fx, Kx_fx_e[0], lengthCx, lengthCx, 1, Q_fx, Q_e, lengthCy, lengthCx, 1, mat_mult_buffer1_fx, &mat_mult_buffer1_fx_e ); + + matrix_diag_product_fx_2( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCx, lengthCy, 0, G_hat_fx, G_hat_buff_e, lengthCy, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); + + matrix_product_mant_exp_fx( mat_mult_buffer2_fx, mat_mult_buffer2_fx_e[0], lengthCx, lengthCy, 0, Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_fx_e ); +#else /* OPT_BASOP_ADD_v1 */ matrix_diag_product_fx_1( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCx, lengthCy, 0, G_hat_fx, G_hat_buff_e, lengthCy, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); matrix_product_mant_exp( mat_mult_buffer2_fx, mat_mult_buffer2_fx_e, lengthCx, lengthCy, 0, Ky_fx, Ky_fx_e, lengthCy, lengthCy, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); @@ -969,6 +1011,7 @@ Word16 computeMixingMatrices_fx( mat_mult_buffer1_e = exp; move16(); +#endif /* OPT_BASOP_ADD_v1 */ IF( LT_16( lengthCx, lengthCy ) ) { @@ -977,7 +1020,11 @@ Word16 computeMixingMatrices_fx( move16(); nC = lengthCx; move16(); +#ifdef OPT_BASOP_ADD_v1 + svd_fx( svd_in_buffer_fx, mat_mult_buffer1_fx_e, svd_v_buffer_fx, svd_s_buffer_fx, svd_u_buffer_fx, svd_s_buffer_e, nL, nC ); +#else /* OPT_BASOP_ADD_v1 */ svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_v_buffer_fx, svd_s_buffer_fx, svd_u_buffer_fx, svd_s_buffer_e, nL, nC ); +#endif /* OPT_BASOP_ADD_v1 */ } ELSE { @@ -986,7 +1033,11 @@ Word16 computeMixingMatrices_fx( move16(); nC = lengthCy; move16(); +#ifdef OPT_BASOP_ADD_v1 + svd_fx( svd_in_buffer_fx, mat_mult_buffer1_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, nL, nC ); +#else /* OPT_BASOP_ADD_v1 */ svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, nL, nC ); +#endif /* OPT_BASOP_ADD_v1 */ } /* Actually Processing P */ @@ -997,25 +1048,46 @@ Word16 computeMixingMatrices_fx( svdMat2mat_fx( svd_v_buffer_fx, mat_mult_buffer1_fx, lengthCy, lengthCx ); svdMat2mat_fx( svd_u_buffer_fx, mat_mult_buffer2_fx, lengthCx, lengthCx ); +#ifdef OPT_BASOP_ADD_v1 + mat_mult_buffer1_fx_e = 0; +#else /* OPT_BASOP_ADD_v1 */ mat_mult_buffer1_e = 0; +#endif /* OPT_BASOP_ADD_v1 */ move16(); mat_mult_buffer2_e = 0; move16(); +#ifdef OPT_BASOP_ADD_v1 + matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCy, lengthCx, 0, + mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCx, 1, + mat_mult_buffer3_fx, &mat_mult_buffer3_e ); +#else /* OPT_BASOP_ADD_v1 */ matrix_product_mant_exp_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, lengthCy, lengthCx, 0, mat_mult_buffer2_fx, mat_mult_buffer2_e, lengthCx, lengthCx, 1, mat_mult_buffer3_fx, &mat_mult_buffer3_e ); +#endif /* OPT_BASOP_ADD_v1 */ /************************ Formulate M **********************/ +#ifdef OPT_BASOP_ADD_v1 + matrix_product_mant_exp_fx( Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, &mat_mult_buffer1_fx_e ); +#else /* OPT_BASOP_ADD_v1 */ Word16 mat_mult_buffer3_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; set16_fx( mat_mult_buffer3_fx_e, mat_mult_buffer3_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); matrix_product_mant_exp( Ky_fx, Ky_fx_e, lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_fx_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); +#endif /* OPT_BASOP_ADD_v1 */ Word16 mixing_matrix_fx_e[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; +#ifdef OPT_BASOP_ADD_v1 + Word16 mat_mult_buffer1_fx_e1[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; + set16_fx( mat_mult_buffer1_fx_e1, mat_mult_buffer1_fx_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); + + matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e1, lengthCy, lengthCx, 0, Kx_reg_inv_fx, Kx_reg_inv_e, lengthCx, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e ); +#else /* OPT_BASOP_ADD_v1 */ matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCy, lengthCx, 0, Kx_reg_inv_fx, Kx_reg_inv_e, lengthCx, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e ); +#endif /* OPT_BASOP_ADD_v1 */ /*-----------------------------------------------------------------* * Formulate Cr @@ -1026,9 +1098,15 @@ Word16 computeMixingMatrices_fx( Word16 Cx_e_arr[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; set16_fx( Cx_e_arr, Cx_fx_e, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); +#ifdef OPT_BASOP_ADD_v1 + matrix_product_mant_exp( mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 0, Cx_fx, Cx_e_arr, lengthCx, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e1 ); + + matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e1, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 1, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); +#else /* OPT_BASOP_ADD_v1 */ matrix_product_mant_exp( mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 0, Cx_fx, Cx_e_arr, lengthCx, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_fx_e ); matrix_product_mant_exp( mat_mult_buffer1_fx, mat_mult_buffer1_fx_e, lengthCy, lengthCx, 0, mixing_matrix_fx, mixing_matrix_fx_e, lengthCy, lengthCx, 1, mat_mult_buffer2_fx, mat_mult_buffer2_fx_e ); +#endif /* OPT_BASOP_ADD_v1 */ exp = mixing_matrix_fx_e[0]; move16(); @@ -1067,7 +1145,11 @@ Word16 computeMixingMatrices_fx( } /* Avoid Meaningless negative main diagonal elements */ +#ifdef OPT_BASOP_ADD_v1 + IF( Cr_fx[i + ( i * lengthCy )] < 0 ) +#else /* OPT_BASOP_ADD_v1 */ IF( BASOP_Util_Cmp_Mant32Exp( Cr_fx[i + ( i * lengthCy )], exp, 0, 0 ) < 0 ) +#endif /* OPT_BASOP_ADD_v1 */ { Cr_fx[i + ( i * lengthCy )] = 0; move32(); @@ -1129,7 +1211,11 @@ Word16 computeMixingMatrices_fx( { /* Avoid correction for very small energies, main diagonal elements of Cy_tilde_p may be negative */ +#ifdef OPT_BASOP_ADD_v1 + IF( Cy_tilde_p_fx[i + ( i * lengthCy )] < 0 ) +#else /* OPT_BASOP_ADD_v1 */ IF( BASOP_Util_Cmp_Mant32Exp( Cy_tilde_p_fx[i + ( i * lengthCy )], mat_mult_buffer2_e, 0, 0 ) < 0 ) +#endif /* OPT_BASOP_ADD_v1 */ { adj_fx_p[i] = 1073741824; // 1.0f in Q30 move32(); @@ -1148,7 +1234,12 @@ Word16 computeMixingMatrices_fx( move16(); } +#ifdef OPT_BASOP_ADD_v1 + Word32 temp = W_shl_sat_l( W_deposit32_l( 4 ), sub( 31, adj_e[i] ) ); + IF( GT_32( adj_fx_p[i], temp ) ) +#else /* OPT_BASOP_ADD_v1 */ IF( BASOP_Util_Cmp_Mant32Exp( adj_fx_p[i], adj_e[i], 1073741824, 3 ) > 0 ) +#endif /* OPT_BASOP_ADD_v1 */ { adj_fx_p[i] = 1073741824; // 1.0f in Q30 move32(); @@ -1281,6 +1372,9 @@ Word16 computeMixingMatricesResidual_fx( svd_fx( svd_in_buffer_fx, Cy_fx_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, svd_s_buffer_e, lengthCy, lengthCy ); /* Computing Ky */ +#ifdef OPT_BASOP_ADD_v1 + Word16 max_e = -32; +#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCy; ++i ) { FOR( j = 0; j < lengthCy; ++j ) @@ -1292,9 +1386,22 @@ Word16 computeMixingMatricesResidual_fx( move32(); Ky_fx_e[i + j * lengthCy] = tmp_e; move16(); +#ifdef OPT_BASOP_ADD_v1 + max_e = s_max( max_e, tmp_e ); +#endif /* OPT_BASOP_ADD_v1 */ } } +#ifdef OPT_BASOP_ADD_v1 + FOR( i = 0; i < lengthCy * lengthCy; ++i ) + { + Ky_fx[i] = L_shr( Ky_fx[i], sub( max_e, Ky_fx_e[i] ) ); + move32(); + Ky_fx_e[i] = max_e; + move16(); + } +#endif /* OPT_BASOP_ADD_v1 */ + /*-----------------------------------------------------------------* * Decomposition of Cx *-----------------------------------------------------------------*/ @@ -1305,7 +1412,9 @@ Word16 computeMixingMatricesResidual_fx( * square root of the diagonal of Cx */ /* Computing Kx */ - +#ifdef OPT_BASOP_ADD_v1 + max_e = -32; +#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCx; ++i ) { exp = Cx_e; @@ -1314,7 +1423,20 @@ Word16 computeMixingMatricesResidual_fx( move32(); Kx_fx_e[i] = exp; move16(); +#ifdef OPT_BASOP_ADD_v1 + max_e = s_max( max_e, exp ); +#endif /* OPT_BASOP_ADD_v1 */ + } + +#ifdef OPT_BASOP_ADD_v1 + FOR( i = 0; i < lengthCx; ++i ) + { + Kx_fx[i] = L_shr( Kx_fx[i], sub( max_e, Kx_fx_e[i] ) ); + move32(); + Kx_fx_e[i] = max_e; + move16(); } +#endif /* OPT_BASOP_ADD_v1 */ /*-----------------------------------------------------------------* * Regularization of Sx @@ -1322,16 +1444,25 @@ Word16 computeMixingMatricesResidual_fx( limit_fx = Kx_fx[0]; move32(); +#ifndef OPT_BASOP_ADD_v1 limit_e = Kx_fx_e[0]; move16(); +#endif /* OPT_BASOP_ADD_v1 */ + FOR( i = 1; i < lengthCx; i++ ) { +#ifdef OPT_BASOP_ADD_v1 + IF( GT_32( Kx_fx[i], limit_fx ) ) +#else /* OPT_BASOP_ADD_v1 */ IF( BASOP_Util_Cmp_Mant32Exp( Kx_fx[i], Kx_fx_e[i], limit_fx, limit_e ) > 0 ) +#endif /* OPT_BASOP_ADD_v1 */ { limit_fx = Kx_fx[i]; move32(); +#ifndef OPT_BASOP_ADD_v1 limit_e = Kx_fx_e[i]; move16(); +#endif /* OPT_BASOP_ADD_v1 */ } } @@ -1339,7 +1470,11 @@ Word16 computeMixingMatricesResidual_fx( L_tmp = L_add( L_tmp, EPSILLON_FX ); limit_fx = L_tmp; move16(); +#ifdef OPT_BASOP_ADD_v1 + limit_e = add( Kx_fx_e[0], reg_Sx_e ); +#else /* OPT_BASOP_ADD_v1 */ limit_e = add( limit_e, reg_Sx_e ); +#endif /* OPT_BASOP_ADD_v1 */ FOR( i = 0; i < lengthCx; ++i ) { @@ -1488,10 +1623,16 @@ Word16 computeMixingMatricesResidual_fx( * Formulate M *-----------------------------------------------------------------*/ + +#ifdef OPT_BASOP_ADD_v1 + matrix_product_mant_exp_fx( Ky_fx, Ky_fx_e[0], lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_buff_e ); + set16_fx( mat_mult_buffer1_buff_e, mat_mult_buffer1_buff_e[0], MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); +#else /* OPT_BASOP_ADD_v1 */ Word16 mat_mult_buffer3_fx_e[MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS]; set16_fx( mat_mult_buffer3_fx_e, mat_mult_buffer3_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); matrix_product_mant_exp( Ky_fx, Ky_fx_e, lengthCy, lengthCy, 0, mat_mult_buffer3_fx, mat_mult_buffer3_fx_e, lengthCy, lengthCx, 0, mat_mult_buffer1_fx, mat_mult_buffer1_buff_e ); +#endif /* OPT_BASOP_ADD_v1 */ Word16 mixing_matrix_fx_e[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; @@ -1576,7 +1717,12 @@ Word16 computeMixingMatricesResidual_fx( move32(); adj_buff_e[i] = scale; move16(); +#ifdef OPT_BASOP_ADD_v1 + Word32 temp = W_shl_sat_l( W_deposit32_l( 4 ), sub( 31, scale ) ); + IF( GT_32( adj_fx_p[i], temp ) ) // 1073741824 -> 1.0f in Q30 +#else /* OPT_BASOP_ADD_v1 */ IF( BASOP_Util_Cmp_Mant32Exp( adj_fx_p[i], scale, 1073741824, 3 ) > 0 ) // 1073741824 -> 1.0f in Q30 +#endif /* OPT_BASOP_ADD_v1 */ { adj_fx_p[i] = 1073741824; // 1.0f in Q30 move32(); @@ -1971,7 +2117,12 @@ Word16 computeMixingMatricesISM_fx( } } +#ifdef OPT_BASOP_ADD_v1 + Word32 temp = W_shl_sat_l( W_deposit32_l( 4 ), sub( 31, temp_e[i] ) ); + IF( GT_32( adj_fx[i], temp ) ) +#else /* OPT_BASOP_ADD_v1 */ IF( BASOP_Util_Cmp_Mant32Exp( adj_fx[i], temp_e[i], MAX_32, 2 ) > 0 ) +#endif /* OPT_BASOP_ADD_v1 */ { adj_fx[i] = MAX_32; move32(); diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 5a948bdfa..4c1d5d190 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -2931,7 +2931,11 @@ static void ivas_param_mc_get_mixing_matrices_fx( FOR( ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++ ) { +#ifdef OPT_BASOP_ADD_v1 + if ( Cproto_diag_fx[ch_idx1] < 0 ) +#else /* OPT_BASOP_ADD_v1 */ if ( BASOP_Util_Cmp_Mant32Exp( Cproto_diag_fx[ch_idx1], Cproto_diag_e, 0, 0 ) < 0 ) +#endif /* OPT_BASOP_ADD_v1 */ { Cproto_diag_fx[ch_idx1] = 0; move16(); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 44207c79a..386644ab1 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -666,7 +666,11 @@ typedef struct ivas_binaural_rendering_conv_module_struct_fx Word32 ***filterStatesLeftReal_fx; Word32 ***filterStatesLeftImag_fx; +#ifdef OPT_BASOP_ADD_v1 + Word16 Q_filterStatesLeft; +#else /* OPT_BASOP_ADD_v1 */ Word16 ***Q_filterStatesLeft; +#endif /* OPT_BASOP_ADD_v1 */ Word16 numTapsArray[BINAURAL_CONVBANDS]; Word16 numTaps; -- GitLab From c08fe4f43533a7ec9383b28fa30525126abb57b4 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 5 Mar 2025 17:36:30 +0100 Subject: [PATCH 38/97] Add check for variable PYTEST_MLD_SHORT in .rules-pytest-to-ref-short to enable scheduled trigger --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fc4c023dc..ac52a99a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -274,12 +274,11 @@ stages: .rules-pytest-to-ref-short: rules: + - if: $PYTEST_MLD_SHORT # Set by scheduled pipeline - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare" - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == 'push' when: never - - if: $CI_PIPELINE_SOURCE == 'schedule' - when: never .rules-pytest-to-input-short: rules: -- GitLab From 9070166f865c137b9d17c3786f678521908d5fa8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 5 Mar 2025 21:49:33 +0530 Subject: [PATCH 39/97] Fix for 3GPP issue 1334: possible Overflow in stereo leading to a click/pop Link #1334 --- lib_com/ivas_prot_fx.h | 2 +- lib_enc/ivas_cpe_enc_fx.c | 2 +- lib_enc/ivas_stereo_dft_enc_fx.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 3c01bebfd..4a72b194a 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2922,7 +2922,7 @@ void stereo_dft_enc_write_BS_fx( void stereo_dft_enc_res_fx( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ - const Word32 *input_8k, /* i : input buffer sampled at 8kHz Q16 */ + const Word32 *input_8k, /* i : input buffer sampled at 8kHz Q15 */ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ Word16 *nb_bits, /* o : number of bits written */ const Word16 max_bits ); diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 8f9a0edf6..3fd9c2d7a 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -1207,7 +1207,7 @@ ivas_error ivas_cpe_enc_fx( FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) { - Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 + Q1 ); + Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 ); // Q(-1) -> Q15 } stereo_dft_enc_res_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM - STEREO_DFT_OVL_8k, hCPE->hMetaData, &nb_bits, max_bits ); } diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index cf246368f..8578a46ae 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -2700,7 +2700,7 @@ static void stereo_dft_enc_get_res_cod_mode_flag_fx( void stereo_dft_enc_res_fx( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ - const Word32 *input_8k, /* i : input buffer sampled at 8kHz Q16 */ + const Word32 *input_8k, /* i : input buffer sampled at 8kHz Q15 */ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ Word16 *nb_bits, /* o : number of bits written */ const Word16 max_bits ) @@ -2745,7 +2745,7 @@ void stereo_dft_enc_res_fx( /* MDCT analysis */ // TCX_MDCT_flt( win, MDCT_RES, STEREO_DFT_OVL_8k, L_FRAME8k - STEREO_DFT_OVL_8k, STEREO_DFT_OVL_8k, IVAS_CPE_DFT ); - MDCT_RES_e = 16; + MDCT_RES_e = 17; move16(); TCX_MDCT( win, MDCT_RES, &MDCT_RES_e, STEREO_DFT_OVL_8k, L_FRAME8k - STEREO_DFT_OVL_8k, STEREO_DFT_OVL_8k, IVAS_CPE_DFT ); -- GitLab From e0bea5dc61bd03613b0c783ebf1acb6789fd143c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 5 Mar 2025 21:52:29 +0100 Subject: [PATCH 40/97] fix compiler warnings --- lib_enc/speech_music_classif_fx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 0188ba45c..415bbaafd 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2286,8 +2286,8 @@ Word16 ivas_smc_gmm_fx( lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 #else - wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 - ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_speech_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + ps_fx[m] = L_sub( L_sub( L_add( log_weights_speech_compute[m], log_det_chol_speech_fx[m] ), W_extract_l( W_shr( wprob_fx, Q10 ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 #endif move32(); v_sub32_fx( FV_fx, &means_music_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); @@ -2297,8 +2297,8 @@ Word16 ivas_smc_gmm_fx( lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 #else - wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 - pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_music_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + pm_fx[m] = L_sub( L_sub( L_add( log_weights_music_compute[m], log_det_chol_music_fx[m] ), W_extract_l( W_shr( wprob_fx, Q10 ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 #endif move32(); v_sub32_fx( FV_fx, &means_noise_fx[m * N_PCA_COEF], fvm_fx, N_PCA_COEF ); @@ -2308,8 +2308,8 @@ Word16 ivas_smc_gmm_fx( lprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF, fvm_exp, 31 - 28, &lprob_exp ); pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), L_shl( lprob_fx, sub( Q18 - 1, sub( Q31, lprob_exp ) ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 #else - wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 - pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_shr( wprob_fx, Q10 ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 + wprob_fx = dot_product_cholesky_fixed( fvm_fx, &prec_chol_noise_fx[m * ( N_PCA_COEF * N_PCA_COEF + N_PCA_COEF ) / 2], N_PCA_COEF ); // Q10 + pn_fx[m] = L_sub( L_sub( L_add( log_weights_noise_compute[m], log_det_chol_noise_fx[m] ), W_extract_l( W_shr( wprob_fx, Q10 ) ) ), HALF_N_PCA_COEF_LOG_P12_Q18 ); // Q18 #endif move32(); } @@ -2332,7 +2332,7 @@ Word16 ivas_smc_gmm_fx( hSpMusClas->lpn_fx = extract_l( L_shr( lpn_fx, 11 ) ); // Q7 move16(); #else - hSpMusClas->lpm_fx = extract_h( L_shl_sat( lpm_fx, 16 - 11 ) ); // Q7 + hSpMusClas->lpm_fx = extract_h( L_shl_sat( lpm_fx, 16 - 11 ) ); // Q7 move16(); hSpMusClas->lps_fx = extract_h( L_shl_sat( lps_fx, 16 - 11 ) ); // Q7 move16(); -- GitLab From 75ccfd47463bd199135478c6a52e050d66571113 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 6 Mar 2025 18:34:18 +0530 Subject: [PATCH 41/97] Bug fix related to 3GPP issue 1316 --- lib_enc/ivas_mdct_core_enc_fx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 6f1d4117d..edfc607ed 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -1168,6 +1168,7 @@ void ivas_mdct_core_whitening_enc_fx( Word32 scf_fx[CPE_CHANNELS][NB_DIV][M]; Word32 scf_q_fx[CPE_CHANNELS][NB_DIV][M]; Word64 chE_fx[2], chE_tot_fx; + Word16 chE_q[2]; Word8 sns_low_br_mode; Word16 nbits_start_sns; Word16 num_sns; @@ -1905,6 +1906,7 @@ void ivas_mdct_core_whitening_enc_fx( IF( mct_on ) { set64_fx( chE_fx, 0, NB_DIV ); + set16_fx( chE_q, 0, NB_DIV ); } init_tcx_enc_info_fx( st, &L_subframe, &L_subframeTCX, &tcx_subframe_coded_lines ); @@ -1973,6 +1975,8 @@ void ivas_mdct_core_whitening_enc_fx( chE_fx[n] = W_add( W_deposit32_l( powerSpec_fx[i] ), chE_fx[n] ); move64(); } + chE_q[n] = sub( add( q_pow_tmp, q_pow ), 32 ); + move16(); } sns_compute_scf_fx( powerSpec_fx, st->hTcxCfg->psychParamsCurrent, st->L_frame, scf_fx[ch][n], sub( add( q_pow_tmp, q_pow ), 32 ) ); } @@ -1980,14 +1984,14 @@ void ivas_mdct_core_whitening_enc_fx( /* MCT: detect whether there are silent channels and set mct_chan_mode accordingly */ IF( mct_on ) { - Word16 q = sub( add( q_pow_tmp, q_pow ), 32 ); + Word16 q = s_min( chE_q[0], chE_q[1] ); Word64 silent_thr = SILENT_CHANNEL_THRES_FX; move64(); chE_tot_fx = 0; move64(); FOR( i = 0; i < NB_DIV; i++ ) { - chE_tot_fx = W_add( chE_fx[i], chE_tot_fx ); + chE_tot_fx = W_add( W_shr( chE_fx[i], sub( chE_q[i], q ) ), chE_tot_fx ); } IF( GT_16( q, Q24 ) ) { -- GitLab From caec0b360e69aa746d27ca4166994e5e810e43ce Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 6 Mar 2025 18:40:51 +0530 Subject: [PATCH 42/97] Fix for 3GPP issue 1344: Decoder segfault for Stereo at 24.4kbps in ivas_fec_noise_filling_fx() Link #1344 --- lib_dec/FEC_HQ_phase_ecu_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index dd63b6508..34d01d7fe 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -4595,11 +4595,11 @@ static void ivas_fec_noise_filling_fx( { L_tmp = L_mult( *sinq_tab, *sinq_tab ); /*Q30 */ sinq_tab++; - q2 = round_fx( L_sub( 2147483647, L_tmp ) ); /*Q15 */ - q1 = round_fx( L_tmp ); /*Q15 */ - L_tmp = L_mult( ( *pt1 ), q1 ); /*Qsynth+16 */ - L_tmp = L_mac( L_tmp, shr( *pt6++, Q_old_out ), q2 ); /*Qsynth+16 */ - ( *pt1++ ) = round_fx( L_tmp ); /*Qsynth */ + q2 = round_fx( L_sub( 2147483647, L_tmp ) ); /*Q15 */ + q1 = round_fx( L_tmp ); /*Q15 */ + L_tmp = L_mult( ( *pt1 ), q1 ); /*Qsynth+16 */ + L_tmp = L_add( L_tmp, L_shr( Mpy_32_16_1( L_deposit_h( *pt6++ ), q2 ), Q_old_out ) ); /*Qsynth+16 */ + ( *pt1++ ) = round_fx( L_tmp ); /*Qsynth */ move16(); } -- GitLab From 9a549b097a08fad2217ee3414acccfc0d24ded1d Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 6 Mar 2025 16:00:04 +0100 Subject: [PATCH 43/97] update .gitlab-ci.yaml - remove -p BASOP from instrumentation job and getWmops.sh --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac52a99a7..58547f2ab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -977,7 +977,7 @@ build-codec-linux-instrumented-make: script: - *print-common-info - *update-scripts-repo - - bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP + - bash scripts/prepare_instrumentation.sh -m MEM_ONLY - make -j -C $INSTR_DIR build-codec-linux-debugging-make: @@ -1730,7 +1730,7 @@ voip-be-on-merge-request: stage: test variables: ret_val: 0 - GET_WMOPS_ARGS: "mem_only basop" + GET_WMOPS_ARGS: "mem_only" timeout: 3 hours 30 minutes before_script: - *print-common-info -- GitLab From 693ea5ac46f50e64ab13133926f168db57548a29 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 6 Mar 2025 18:36:41 +0530 Subject: [PATCH 44/97] Fix for 3GPP issue 1346: Decoder crash for Stereo at 24.4kbps JBM decoding in ivas_hq_core_dec_fx() Link #1346 --- lib_com/lerp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/lerp.c b/lib_com/lerp.c index bb33d9922..28719205a 100644 --- a/lib_com/lerp.c +++ b/lib_com/lerp.c @@ -430,7 +430,7 @@ static void lerp_proc32( Word32 *f /*Qx*/, Word32 *f_out /*Qx*/, Word16 bufferNe { diff = sub( 16384 /*0.5f Q15*/, diff ); /*Q15*/ } - *ptr++ = L_add_sat( f[idx], Mpy_32_16_1( L_sub( f[idx + 1], f[idx] ), diff ) ); /*Qx*/ + *ptr++ = L_add_sat( f[idx], L_sub( Mpy_32_16_1( f[idx + 1], diff ), Mpy_32_16_1( f[idx], diff ) ) ); /*Qx*/ move32(); pos = L_add( pos, shift ); /*Q16*/ idx = extract_h( pos ); -- GitLab From 842e5d97b7e8917b33ceddcf5de3006d0cdf55c5 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 6 Mar 2025 18:44:47 +0530 Subject: [PATCH 45/97] Fix for 3GPP issue 1307: Missing signal in BASOP enc-dec path compared to float enc-dec path using selection test MASA at 24.4 kbps with DTX enabled Link #1307 --- lib_enc/nois_est_fx.c | 37 ++++++++++++++++++++----------------- lib_enc/stat_enc.h | 3 +++ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 68eed3d65..0851e4c17 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -326,6 +326,10 @@ void noise_est_init_ivas_fx( hNoiseEst->Etot_sq_st_est_fx = 1600; /* 400 in Q2 */ move16(); move16(); + hNoiseEst->L_Etot_st_est_fx = 167772160; /* 20.0f in Q23 */ + hNoiseEst->L_Etot_sq_st_est_fx = 26214400; /* 400 in Q16 */ + move32(); + move32(); hNoiseEst->epsP_0_2_lp_fx = 4096; /*1.0 Q12*/ move16(); hNoiseEst->epsP_0_2_ad_lp_fx = 0; @@ -2195,9 +2199,9 @@ void noise_est_ivas_fx( Word16 vad_bwidth_fx; /* vad ns control variabel for input bwidth from teh BWD */ /* for DTX operation */ - Word16 lim_Etot_fx; /* Q8 */ - Word16 lim_Etot_sq_fx; /* Q2 */ - Word16 st_E_var_est_fx; /* Q2 */ + Word16 lim_Etot_fx; /* Q8 */ + Word32 lim_Etot_sq_fx; /* Q16 */ + Word32 st_E_var_est_fx; NOISE_EST_HANDLE hNoiseEst; SP_MUS_CLAS_HANDLE hSpMusClas; Word32 Le_min_scaled; @@ -2720,32 +2724,31 @@ void noise_est_ivas_fx( Lnon_sta2 = L_deposit_l( 1024 ); /* 1.0 in Q10 */ } - lim_Etot_fx = s_max( 5120, Etot ); /* 20.0f Q8 */ - lim_Etot_sq_fx = extract_h( L_shl_r( L_mult( lim_Etot_fx, lim_Etot_fx ), 1 ) ); /* Q2 */ + lim_Etot_fx = s_max( 5120, Etot ); /* 20.0f Q8 */ + lim_Etot_sq_fx = L_mult0( lim_Etot_fx, lim_Etot_fx ); /* Q16 */ IF( LT_16( ini_frame, 150 ) ) { /* Allow use of quicker filter during init - if needed */ /* st->Etot_st_est = 0.25f * lim_Etot + (1.0f-0.25F) * st->Etot_st_est; */ - hNoiseEst->Etot_st_est_fx = mac_r( L_mult( 8192, lim_Etot_fx ), 24576, hNoiseEst->Etot_st_est_fx ); // Q8 - move16(); + hNoiseEst->L_Etot_st_est_fx = Madd_32_16_r( L_mult0( 8192, lim_Etot_fx ), hNoiseEst->L_Etot_st_est_fx, 24576 ); // Q23 + move32(); /* st->Etot_sq_st_est = 0.25f * lim_Etot * lim_Etot + (1.0f-0.25f) * st->Etot_sq_st_est; */ - hNoiseEst->Etot_sq_st_est_fx = mac_r( L_mult( 8192, lim_Etot_sq_fx ), 24576, hNoiseEst->Etot_sq_st_est_fx ); // Q2 - move16(); + hNoiseEst->L_Etot_sq_st_est_fx = Madd_32_16_r( Mult_32_16( lim_Etot_sq_fx, 8192 ), hNoiseEst->L_Etot_sq_st_est_fx, 24576 ); // Q16 + move32(); } ELSE { /* st->Etot_st_est = 0.25f * lim_Etot + (1.0f-0.25F) * st->Etot_st_est; */ - hNoiseEst->Etot_st_est_fx = mac_r( L_mult( 8192, lim_Etot_fx ), 24576, hNoiseEst->Etot_st_est_fx ); // Q8 - move16(); + hNoiseEst->L_Etot_st_est_fx = Madd_32_16_r( L_mult0( 8192, lim_Etot_fx ), hNoiseEst->L_Etot_st_est_fx, 24576 ); // Q23 + move32(); /* st->Etot_sq_st_est = 0.25f * lim_Etot * lim_Etot + (1.0f-0.25f) * st->Etot_sq_st_est; */ - hNoiseEst->Etot_sq_st_est_fx = mac_r( L_mult( 8192, lim_Etot_sq_fx ), 24576, hNoiseEst->Etot_sq_st_est_fx ); // Q2 - move16(); + hNoiseEst->L_Etot_sq_st_est_fx = Madd_32_16_r( Mult_32_16( lim_Etot_sq_fx, 8192 ), hNoiseEst->L_Etot_sq_st_est_fx, 24576 ); // Q16 + move32(); } - st_E_var_est_fx = sub( hNoiseEst->Etot_sq_st_est_fx, extract_h( L_shl_r( L_mult( hNoiseEst->Etot_st_est_fx, hNoiseEst->Etot_st_est_fx ), 1 ) ) ); // Q2 - - + Word16 exp_tmp; + st_E_var_est_fx = BASOP_Util_Add_Mant32Exp( hNoiseEst->L_Etot_sq_st_est_fx, Q15, L_negate( Mpy_32_32( hNoiseEst->L_Etot_st_est_fx, hNoiseEst->L_Etot_st_est_fx ) ), Q16, &exp_tmp ); // exp(exp_tmp) /*-----------------------------------------------------------------* * Count frames since last correlation or harmonic event *-----------------------------------------------------------------*/ @@ -2775,7 +2778,7 @@ void noise_est_ivas_fx( } test(); test(); - IF( GT_16( *st_harm_cor_cnt, 1 ) && GT_16( Etot, 7680 /* 30.0f in Q8 */ ) && GT_16( st_E_var_est_fx, 32 /* 8.0f in Q2 */ ) ) + IF( GT_16( *st_harm_cor_cnt, 1 ) && GT_16( Etot, 7680 /* 30.0f in Q8 */ ) && EQ_16( BASOP_Util_Cmp_Mant32Exp( st_E_var_est_fx, exp_tmp, 524288 /* 8.0f in Q16 */, Q15 ), 1 ) ) { /* st->harm_cor_cnt = max(1, (short) round_f( (float) st->harm_cor_cnt / 4.0f )) ; */ *st_harm_cor_cnt = s_max( 1, shr( add( *st_harm_cor_cnt, 2 ), 2 ) ); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 6fd9ce6f3..ad572d2ba 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -566,6 +566,9 @@ typedef struct noise_estimation_structure Word16 Etot_st_est_fx; /* Q8 Noise estimation - short term estimate of E{ Etot } */ Word16 Etot_sq_st_est_fx; /* Q2 Noise estimation - short term estimate of E{ Etot^2 } */ + Word32 L_Etot_st_est_fx; /* Q23 Noise estimation - short term estimate of E{ Etot } */ + Word32 L_Etot_sq_st_est_fx; /* Q16 Noise estimation - short term estimate of E{ Etot^2 } */ + Word16 aEn_inac_cnt; } NOISE_EST_DATA, *NOISE_EST_HANDLE; -- GitLab From 3116ef12792222dc5086b9edb5a9b52469994161 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 7 Mar 2025 07:28:01 +0530 Subject: [PATCH 46/97] Clean up of prot.h file --- Workspace_msvc/lib_com.vcxproj | 3 - Workspace_msvc/lib_com.vcxproj.filters | 9 - lib_com/ari_hm_fx.c | 1 - lib_com/arith_coder_fx.c | 1 - lib_com/basop_tcx_utils.c | 2 +- lib_com/bitalloc_fx.c | 1 - lib_com/bitstream.c | 3 +- lib_com/cldfb.c | 1 - lib_com/cng_exc.c | 57 - lib_com/codec_tcx_common.c | 1 - lib_com/core_com_config.c | 60 +- lib_com/deemph.c | 3 +- lib_com/delay_comp.c | 3 +- lib_com/disclaimer.c | 2 +- lib_com/enr_1_az.c | 3 +- lib_com/env_adj.c | 3 +- lib_com/env_stab.c | 3 +- lib_com/env_stab_trans.c | 3 +- lib_com/fd_cng_com_fx.c | 1 - lib_com/fft.c | 2 +- lib_com/fft_fx.c | 2 +- lib_com/fft_rel.c | 3 +- lib_com/fill_spectrum.c | 3 +- lib_com/findpulse.c | 3 +- lib_com/float_to_fix_ops.c | 1 - lib_com/frame_ener_fx.c | 3 +- lib_com/get_gain_fx.c | 3 +- lib_com/gs_bitallocation_ivas_fx.c | 1 - lib_com/gs_gains.c | 1 - lib_com/gs_preech_fx.c | 3 +- lib_com/hp50_fx.c | 3 +- lib_com/hq2_core_com.c | 2 +- lib_com/hq_conf.c | 3 +- lib_com/hq_tools_fx.c | 1 - lib_com/ifft_rel.c | 3 +- lib_com/int_lsp.c | 3 +- lib_com/interleave_spectrum.c | 3 +- lib_com/interpol.c | 3 +- lib_com/ivas_agc_com_fx.c | 2 +- lib_com/ivas_arith_fx.c | 3 +- lib_com/ivas_avq_pos_reorder_com_fx.c | 2 +- lib_com/ivas_cov_smooth_fx.c | 1 - lib_com/ivas_dirac_com_fx.c | 3 +- lib_com/ivas_entropy_coder_common_fx.c | 2 +- lib_com/ivas_fb_mixer_fx.c | 3 +- lib_com/ivas_ism_com_fx.c | 3 +- lib_com/ivas_lfe_com_fx.c | 2 +- lib_com/ivas_masa_com_fx.c | 3 +- lib_com/ivas_mc_com_fx.c | 2 +- lib_com/ivas_mc_param_com_fx.c | 1 - lib_com/ivas_mct_com_fx.c | 2 +- lib_com/ivas_mdct_core_com_fx.c | 3 +- lib_com/ivas_mdft_imdft_fx.c | 3 +- lib_com/ivas_omasa_com_fx.c | 3 +- lib_com/ivas_pca_tools_fx.c | 1 - lib_com/ivas_qmetadata_com_fx.c | 3 +- lib_com/ivas_qspherical_com_fx.c | 4 +- lib_com/ivas_sba_config_fx.c | 2 +- lib_com/ivas_sns_com_fx.c | 1 - lib_com/ivas_spar_com_fx.c | 1 - lib_com/ivas_spar_com_quant_util_fx.c | 1 - lib_com/ivas_stereo_dft_com_fx.c | 2 +- lib_com/ivas_stereo_eclvq_com_fx.c | 2 +- lib_com/ivas_stereo_ica_com_fx.c | 1 - lib_com/ivas_stereo_mdct_bands_com_fx.c | 3 +- lib_com/ivas_stereo_psychlpc_com_fx.c | 2 +- lib_com/ivas_stereo_td_bit_alloc_fx.c | 3 +- lib_com/ivas_tools_fx.c | 3 +- lib_com/ivas_transient_det_fx.c | 3 +- lib_com/lag_wind.c | 1 - lib_com/lerp.c | 129 - lib_com/limit_t0.c | 231 - lib_com/longarith.c | 3 +- lib_com/lsp_conv_poly_fx.c | 3 +- lib_com/modif_fs.c | 3 +- lib_com/mslvq_com.c | 3 +- lib_com/mslvq_com_fx.c | 1 - lib_com/preemph.c | 2 +- lib_com/prot.h | 8340 ----------------- lib_com/prot_fx.h | 793 +- lib_com/pvq_com_fx.c | 1 - lib_com/residu_fx.c | 1 - lib_com/rom_com.c | 3 +- lib_com/rom_com_fx.c | 2 +- lib_com/swb_tbe_com.c | 1 - lib_com/swb_tbe_com_fx.c | 1 - lib_com/tcx_mdct_window.c | 1 - lib_com/tcx_utils_fx.c | 1 - lib_com/tns_base.c | 1 - lib_com/tools.c | 1199 +-- lib_com/tools_fx.c | 1 - lib_com/wtda.c | 3 +- lib_dec/acelp_core_dec_ivas_fx.c | 1 - lib_dec/acelp_core_switch_dec_fx.c | 1 - lib_dec/ari_hm_dec.c | 3 +- lib_dec/arith_coder_dec_fx.c | 1 - lib_dec/avq_dec_fx.c | 1 - lib_dec/cng_dec_fx.c | 1 - lib_dec/core_dec_init_fx.c | 1 - lib_dec/core_dec_switch_fx.c | 1 - lib_dec/dec_tcx_fx.c | 1 - lib_dec/gs_dec_fx.c | 1 - lib_dec/hf_synth_fx.c | 1 - lib_dec/hq_core_dec_fx.c | 1 - lib_dec/igf_dec_fx.c | 3 +- lib_dec/init_dec_fx.c | 1 - lib_dec/ivas_agc_dec_fx.c | 1 - lib_dec/ivas_binRenderer_internal_fx.c | 3 +- lib_dec/ivas_core_dec_fx.c | 3 +- lib_dec/ivas_corecoder_dec_reconfig_fx.c | 1 - lib_dec/ivas_cpe_dec_fx.c | 3 +- lib_dec/ivas_decision_matrix_dec_fx.c | 3 +- lib_dec/ivas_dirac_dec_fx.c | 3 +- lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 3 +- lib_dec/ivas_entropy_decoder_fx.c | 3 +- lib_dec/ivas_init_dec.c | 3 +- lib_dec/ivas_ism_dec_fx.c | 3 +- lib_dec/ivas_ism_dtx_dec_fx.c | 3 +- lib_dec/ivas_ism_metadata_dec_fx.c | 1 - lib_dec/ivas_ism_param_dec_fx.c | 3 +- lib_dec/ivas_ism_renderer_fx.c | 1 - lib_dec/ivas_jbm_dec_fx.c | 3 +- lib_dec/ivas_lfe_dec_fx.c | 1 - lib_dec/ivas_lfe_plc_fx.c | 1 - lib_dec/ivas_ls_custom_dec_fx.c | 3 +- lib_dec/ivas_masa_dec_fx.c | 1 - lib_dec/ivas_mc_param_dec_fx.c | 3 +- lib_dec/ivas_mc_paramupmix_dec_fx.c | 1 - lib_dec/ivas_mcmasa_dec_fx.c | 2 +- lib_dec/ivas_mct_core_dec_fx.c | 3 +- lib_dec/ivas_mct_dec_fx.c | 1 - lib_dec/ivas_mct_dec_mct_fx_fx.c | 3 +- lib_dec/ivas_mdct_core_dec_fx.c | 3 +- lib_dec/ivas_mono_dmx_renderer_fx.c | 1 - lib_dec/ivas_objectRenderer_internal_fx.c | 3 +- lib_dec/ivas_omasa_dec_fx.c | 3 +- lib_dec/ivas_osba_dec_fx.c | 3 +- lib_dec/ivas_out_setup_conversion_fx.c | 3 +- lib_dec/ivas_pca_dec_fx.c | 3 +- lib_dec/ivas_post_proc_fx.c | 1 - lib_dec/ivas_qmetadata_dec_fx.c | 3 +- lib_dec/ivas_qspherical_dec_fx.c | 2 +- lib_dec/ivas_range_uni_dec_fx.c | 3 +- lib_dec/ivas_sba_dec_fx.c | 3 +- lib_dec/ivas_sba_rendering_internal_fx.c | 3 +- lib_dec/ivas_sce_dec_fx.c | 1 - lib_dec/ivas_sns_dec_fx.c | 3 +- lib_dec/ivas_spar_decoder_fx.c | 3 +- lib_dec/ivas_spar_md_dec_fx.c | 3 +- lib_dec/ivas_stereo_adapt_GR_dec_fx.c | 3 +- lib_dec/ivas_stereo_cng_dec.c | 3 +- lib_dec/ivas_stereo_dft_dec.c | 1 - lib_dec/ivas_stereo_dft_dec_dmx_fx.c | 3 +- lib_dec/ivas_stereo_dft_dec_fx.c | 1 - lib_dec/ivas_stereo_dft_plc_fx.c | 1 - lib_dec/ivas_stereo_eclvq_dec_fx.c | 2 +- lib_dec/ivas_stereo_ica_dec_fx.c | 3 +- lib_dec/ivas_stereo_icbwe_dec_fx.c | 1 - lib_dec/ivas_stereo_mdct_core_dec_fx.c | 3 +- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 3 +- lib_dec/ivas_stereo_switching_dec_fx.c | 3 +- lib_dec/ivas_stereo_td_dec_fx.c | 1 - lib_dec/ivas_svd_dec_fx.c | 3 +- lib_dec/ivas_tcx_core_dec_fx.c | 3 +- lib_dec/ivas_td_low_rate_dec_fx.c | 1 - lib_dec/jbm_jb4_circularbuffer.c | 2 +- lib_dec/jbm_jb4_circularbuffer.h | 2 +- lib_dec/jbm_jb4_inputbuffer.c | 2 +- lib_dec/jbm_jb4_jmf.c | 2 +- lib_dec/jbm_jb4sb.c | 1 - lib_dec/jbm_pcmdsp_apa.c | 3 +- lib_dec/lib_dec_fx.c | 5 +- lib_dec/swb_tbe_dec_fx.c | 1 - lib_dec/tonalMDCTconcealment_fx.c | 1 - lib_enc/ACcontextMapping_enc_fx.c | 1 - lib_enc/FEC_enc_fx.c | 1 - lib_enc/SNR_calc_fx.c | 1 - lib_enc/acelp_core_enc_fx.c | 1 - lib_enc/acelp_core_switch_enc_fx.c | 1 - lib_enc/ari_hm_enc_fx.c | 4 +- lib_enc/avq_cod_fx.c | 4 +- lib_enc/cng_enc_fx.c | 10 +- lib_enc/cod2t32_fx.c | 1 - lib_enc/cod4t64_fast.c | 1 - lib_enc/cod4t64_fx.c | 3 +- lib_enc/cod_tcx_fx.c | 2 - lib_enc/core_enc_init_fx.c | 1 - lib_enc/core_enc_switch_fx.c | 5 +- lib_enc/dtx_fx.c | 1 - lib_enc/enc_gen_voic_fx.c | 3 +- lib_enc/enc_higher_acelp_fx.c | 3 +- lib_enc/enc_pit_exc_fx.c | 1 - lib_enc/enc_prm_fx.c | 3 +- lib_enc/enc_tran_fx.c | 1 - lib_enc/enc_uv_fx.c | 3 +- lib_enc/eval_pit_contr_fx.c | 1 - lib_enc/evs_enc_fx.c | 3 +- lib_enc/fd_cng_enc_fx.c | 1 - lib_enc/find_wsp_fx.c | 3 +- lib_enc/gain_enc_fx.c | 1 - lib_enc/gaus_enc_fx.c | 1 - lib_enc/gs_enc_fx.c | 2 - lib_enc/hq_classifier_enc_fx.c | 1 - lib_enc/hq_core_enc_fx.c | 10 +- lib_enc/hq_env_enc_fx.c | 1 - lib_enc/hq_hr_enc_fx.c | 1 - lib_enc/hq_lr_enc_fx.c | 1 - lib_enc/hvq_enc_fx.c | 1 - lib_enc/igf_enc.c | 38 +- lib_enc/igf_enc_fx.c | 3 +- lib_enc/igf_scf_enc.c | 3 +- lib_enc/init_enc_fx.c | 1 - lib_enc/inov_enc_fx.c | 1 - lib_enc/ivas_agc_enc_fx.c | 3 +- lib_enc/ivas_core_enc_fx.c | 3 +- lib_enc/ivas_core_pre_proc_front_fx.c | 2 - lib_enc/ivas_core_pre_proc_fx.c | 3 +- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 1 - lib_enc/ivas_cpe_enc_fx.c | 3 +- lib_enc/ivas_decision_matrix_enc_fx.c | 3 +- lib_enc/ivas_dirac_enc_fx.c | 1 - lib_enc/ivas_enc_cov_handler_fx.c | 3 +- lib_enc/ivas_enc_fx.c | 3 +- lib_enc/ivas_entropy_coder_fx.c | 1 - lib_enc/ivas_front_vad_fx.c | 3 +- lib_enc/ivas_init_enc_fx.c | 3 +- lib_enc/ivas_ism_dtx_enc_fx.c | 3 +- lib_enc/ivas_ism_enc_fx.c | 3 +- lib_enc/ivas_ism_metadata_enc_fx.c | 3 +- lib_enc/ivas_ism_param_enc_fx.c | 1 - lib_enc/ivas_lfe_enc_fx.c | 3 +- lib_enc/ivas_masa_enc_fx.c | 1 - lib_enc/ivas_mc_param_enc_fx.c | 2 - lib_enc/ivas_mc_paramupmix_enc_fx.c | 3 +- lib_enc/ivas_mcmasa_enc_fx.c | 1 - lib_enc/ivas_mct_core_enc_fx.c | 4 +- lib_enc/ivas_mct_enc_fx.c | 3 +- lib_enc/ivas_mct_enc_mct_fx.c | 1 - lib_enc/ivas_mdct_core_enc_fx.c | 3 +- lib_enc/ivas_omasa_enc_fx.c | 1 - lib_enc/ivas_osba_enc_fx.c | 3 +- lib_enc/ivas_pca_enc_fx.c | 3 +- lib_enc/ivas_qmetadata_enc_fx.c | 4 +- lib_enc/ivas_qspherical_enc_fx.c | 1 - lib_enc/ivas_range_uni_enc_fx.c | 2 +- lib_enc/ivas_sba_enc_fx.c | 3 +- lib_enc/ivas_sce_enc_fx.c | 1 - lib_enc/ivas_sns_enc_fx.c | 3 +- lib_enc/ivas_spar_encoder_fx.c | 1 - lib_enc/ivas_spar_md_enc_fx.c | 2 - lib_enc/ivas_stereo_adapt_GR_enc_fx.c | 2 +- lib_enc/ivas_stereo_classifier_fx.c | 3 +- lib_enc/ivas_stereo_cng_enc_fx.c | 3 +- lib_enc/ivas_stereo_dft_enc_fx.c | 3 +- lib_enc/ivas_stereo_dft_enc_itd_fx.c | 1 - lib_enc/ivas_stereo_dft_td_itd_fx.c | 3 +- lib_enc/ivas_stereo_dmx_evs_fx.c | 2 - lib_enc/ivas_stereo_eclvq_enc_fx.c | 1 - lib_enc/ivas_stereo_ica_enc_fx.c | 3 +- lib_enc/ivas_stereo_icbwe_enc_fx.c | 3 +- lib_enc/ivas_stereo_mdct_core_enc_fx.c | 1 - lib_enc/ivas_stereo_mdct_igf_enc_fx.c | 1 - lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 1 - lib_enc/ivas_stereo_switching_enc_fx.c | 3 +- lib_enc/ivas_stereo_td_analysis_fx.c | 3 +- lib_enc/ivas_stereo_td_enc_fx.c | 3 +- lib_enc/ivas_tcx_core_enc_fx.c | 3 +- lib_enc/ivas_td_low_rate_enc_fx.c | 1 - lib_enc/lib_enc.c | 1 - lib_enc/lsf_enc_fx.c | 1 - lib_enc/lsf_msvq_ma_enc.c | 1 - lib_enc/mdct_classifier_fx.c | 1 - lib_enc/mslvq_enc_fx.c | 3 +- lib_enc/nelp_enc_fx.c | 1 - lib_enc/peak_vq_enc_fx.c | 1 - lib_enc/pit_enc_fx.c | 1 - lib_enc/range_enc_fx.c | 1 - lib_enc/speech_music_classif_fx.c | 1 - lib_enc/stat_noise_uv_enc_fx.c | 1 - lib_enc/swb_bwe_enc_fx.c | 3 +- lib_enc/swb_bwe_enc_lr_fx.c | 1 - lib_enc/swb_tbe_enc.c | 46 - lib_enc/swb_tbe_enc_fx.c | 1 - lib_enc/tcq_core_enc_fx.c | 1 - lib_enc/tns_base_enc_fx.c | 1 - lib_enc/transition_enc_fx.c | 1 - lib_rend/ivas_allrad_dec_fx.c | 2 +- lib_rend/ivas_crend_fx.c | 3 +- lib_rend/ivas_dirac_ana_fx.c | 3 +- .../ivas_dirac_dec_binaural_functions_fx.c | 1 - lib_rend/ivas_dirac_decorr_dec_fx.c | 3 +- lib_rend/ivas_dirac_onsets_dec_fx.c | 3 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 3 +- lib_rend/ivas_dirac_rend_fx.c | 3 +- lib_rend/ivas_efap_fx.c | 1 - lib_rend/ivas_hrtf_fx.c | 2 +- lib_rend/ivas_limiter_fx.c | 2 +- lib_rend/ivas_masa_merge_fx.c | 3 +- lib_rend/ivas_mcmasa_ana_fx.c | 3 +- lib_rend/ivas_objectRenderer_fx.c | 3 +- lib_rend/ivas_objectRenderer_hrFilt_fx.c | 3 +- lib_rend/ivas_objectRenderer_mix_fx.c | 3 +- lib_rend/ivas_objectRenderer_sfx_fx.c | 3 +- lib_rend/ivas_objectRenderer_sources_fx.c | 3 +- lib_rend/ivas_objectRenderer_vec_fx.c | 3 +- lib_rend/ivas_omasa_ana_fx.c | 3 +- lib_rend/ivas_output_init.c | 2 +- lib_rend/ivas_reflections_fx.c | 3 +- lib_rend/ivas_render_config_fx.c | 3 +- lib_rend/ivas_reverb_delay_line_fx.c | 3 +- lib_rend/ivas_reverb_fft_filter_fx.c | 3 +- lib_rend/ivas_reverb_filter_design_fx.c | 1 - lib_rend/ivas_reverb_fx.c | 3 +- lib_rend/ivas_reverb_iir_filter_fx.c | 3 +- lib_rend/ivas_reverb_utils_fx.c | 3 +- lib_rend/ivas_rotation_fx.c | 3 +- lib_rend/ivas_sba_rendering_fx.c | 1 - lib_rend/ivas_shoebox_fx.c | 1 - lib_rend/ivas_td_decorr_fx.c | 1 - lib_rend/ivas_vbap_fx.c | 3 +- lib_rend/lib_rend.c | 1 - lib_util/hrtf_file_reader.c | 3 +- lib_util/ls_custom_file_reader.c | 2 +- lib_util/mime_io.c | 2 +- lib_util/render_config_reader.c | 2 +- lib_util/rotation_file_reader.c | 1 - lib_util/vector3_pair_file_reader.c | 1 - 327 files changed, 990 insertions(+), 10601 deletions(-) delete mode 100644 lib_com/cng_exc.c delete mode 100644 lib_com/limit_t0.c delete mode 100644 lib_com/prot.h delete mode 100644 lib_enc/swb_tbe_enc.c diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 8c42f19ca..5b26a2911 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -138,7 +138,6 @@ - @@ -238,7 +237,6 @@ - @@ -324,7 +322,6 @@ - diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index 8f2be8853..b9769e3ec 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -304,9 +304,6 @@ common_all_c - - common_all_c - common_all_c @@ -412,9 +409,6 @@ common_all_c - - common_all_c - common_all_c @@ -588,9 +582,6 @@ common_h - - common_h - common_h diff --git a/lib_com/ari_hm_fx.c b/lib_com/ari_hm_fx.c index 076bc8d92..46f8ecea1 100644 --- a/lib_com/ari_hm_fx.c +++ b/lib_com/ari_hm_fx.c @@ -10,7 +10,6 @@ #include "basop_util.h" #include "rom_com.h" #include "prot_fx.h" -#include "prot.h" #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) void UnmapIndex( diff --git a/lib_com/arith_coder_fx.c b/lib_com/arith_coder_fx.c index de22a7cf3..846b4dcea 100644 --- a/lib_com/arith_coder_fx.c +++ b/lib_com/arith_coder_fx.c @@ -6,7 +6,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "prot.h" #include "basop_util.h" #include "basop_proto_func.h" #include "cnst.h" diff --git a/lib_com/basop_tcx_utils.c b/lib_com/basop_tcx_utils.c index 378faae0f..8038c4f91 100644 --- a/lib_com/basop_tcx_utils.c +++ b/lib_com/basop_tcx_utils.c @@ -40,7 +40,7 @@ #include "cnst.h" #include "basop_proto_func.h" #include "stl.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #define WMC_TOOL_SKIP diff --git a/lib_com/bitalloc_fx.c b/lib_com/bitalloc_fx.c index 92a8e3928..30ae2d47b 100644 --- a/lib_com/bitalloc_fx.c +++ b/lib_com/bitalloc_fx.c @@ -7,7 +7,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ void bitalloc_fx( Word16 *y, /* i : reordered norm of sub-vectors Q0 */ diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index e5754fa35..9c0a53f8f 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -38,7 +38,6 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "stat_enc.h" #include "stat_dec.h" @@ -1884,7 +1883,7 @@ static void decision_matrix_core_dec( * Set up MDCT core switching if indicated in the bitstream *-------------------------------------------------------------------*/ -void mdct_switching_dec( +void mdct_switching_dec_ivas_fx( Decoder_State *st /* i/o: decoder state structure */ ) { diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 1907ef327..38195b65d 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -39,7 +39,6 @@ #include "options.h" #include #include "stat_dec.h" -#include "prot.h" #include "prot_fx.h" #include "rom_com.h" #include "rom_com_fx.h" diff --git a/lib_com/cng_exc.c b/lib_com/cng_exc.c deleted file mode 100644 index 494305e6f..000000000 --- a/lib_com/cng_exc.c +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "rom_com.h" -#include "wmc_auto.h" - -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - -#define A2 0.2f -#define GAIN_VAR 0.000011f - - -/*-------------------------------------------------------* - * cng_params_upd() - * - * update CNG parameters - *-------------------------------------------------------*/ diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c index f6da34b55..1ebc2829c 100644 --- a/lib_com/codec_tcx_common.c +++ b/lib_com/codec_tcx_common.c @@ -6,7 +6,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "basop_util.h" #include "rom_basop_util.h" diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index fdf935461..ed72605de 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -38,10 +38,9 @@ #include #include "options.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #define FSCALE_DENOM_BY_12800_Q15 1311 @@ -551,63 +550,6 @@ int16_t sr2fscale( return (int16_t) ( ( FSCALE_DENOM * sr_core ) / 12800 ); } -/*-------------------------------------------------------------------* - * getCoreSamplerateMode2_flt() - * - * - *-------------------------------------------------------------------*/ - -int32_t getCoreSamplerateMode2_flt( - const int16_t element_mode, /* i : IVAS element mode */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */ - const int16_t rf_mode, /* i : flag to signal the RF mode */ - const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ -) -{ - int32_t sr_core = 0; - - if ( bwidth == NB ) - { - sr_core = INT_FS_12k8; - } - else if ( element_mode == EVS_MONO && ( ( bwidth == WB && total_brate < ACELP_13k20 ) || ( bwidth == SWB && total_brate <= ACELP_13k20 ) || ( rf_mode == 1 ) ) ) - { - sr_core = INT_FS_12k8; - } - else if ( element_mode > EVS_MONO && flag_ACELP16k == 0 ) - { - sr_core = INT_FS_12k8; - } - else if ( bwidth == WB || ( bwidth == SWB && total_brate <= ACELP_32k ) || ( bwidth == FB && total_brate <= ACELP_32k ) ) - { - sr_core = INT_FS_16k; - } - else if ( ( bwidth == SWB || bwidth == FB ) && total_brate <= MAX_ACELP_BRATE && element_mode == IVAS_SCE && !is_ism_format ) - { - sr_core = INT_FS_16k; - } - else if ( ( bwidth == SWB || bwidth == FB ) && total_brate <= MAX_ACELP_BRATE_ISM && element_mode == IVAS_SCE && is_ism_format ) - { - sr_core = INT_FS_16k; - } - else if ( ( bwidth == SWB || bwidth == FB ) && total_brate <= MAX_ACELP_BRATE && element_mode == IVAS_SCE && is_ism_format ) - { - sr_core = 25600; - } - else if ( ( ( bwidth == SWB || bwidth == FB ) && element_mode == EVS_MONO && total_brate <= HQ_64k ) || ( element_mode > IVAS_SCE && ( ( bwidth == SWB && total_brate <= IVAS_96k ) || ( bwidth == FB && total_brate <= IVAS_96k ) ) ) ) - { - sr_core = 25600; - } - else if ( bwidth == SWB || bwidth == FB ) - { - sr_core = 32000; - } - - return sr_core; -} - Word32 getCoreSamplerateMode2( const Word16 element_mode, /* i : IVAS element mode Q0*/ const Word32 total_brate, /* i : total bitrate Q0*/ diff --git a/lib_com/deemph.c b/lib_com/deemph.c index b2b43cf72..c03a050bc 100644 --- a/lib_com/deemph.c +++ b/lib_com/deemph.c @@ -36,9 +36,8 @@ #include #include "options.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" void deemph_fx_32( diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 9e6c450cd..edccca074 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -36,10 +36,9 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" /*-------------------------------------------------------------------------- * get_delay() diff --git a/lib_com/disclaimer.c b/lib_com/disclaimer.c index ba0973f97..1a01c2c32 100644 --- a/lib_com/disclaimer.c +++ b/lib_com/disclaimer.c @@ -36,7 +36,7 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #define WMC_TOOL_SKIP diff --git a/lib_com/enr_1_az.c b/lib_com/enr_1_az.c index 81fb78262..5c99cdfa5 100644 --- a/lib_com/enr_1_az.c +++ b/lib_com/enr_1_az.c @@ -37,9 +37,8 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" Word16 Enr_1_Az_fx_o( /* o : impulse response energy Q3 */ diff --git a/lib_com/env_adj.c b/lib_com/env_adj.c index 18520e188..5a83dbe5f 100644 --- a/lib_com/env_adj.c +++ b/lib_com/env_adj.c @@ -38,9 +38,8 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" /*--------------------------------------------------------------------------* * env_adj() diff --git a/lib_com/env_stab.c b/lib_com/env_stab.c index b80fd0a8b..a3140b4e4 100644 --- a/lib_com/env_stab.c +++ b/lib_com/env_stab.c @@ -39,11 +39,10 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" #include "stl.h" -#include "prot_fx.h" /*--------------------------------------------------------------------------* * Local constants *--------------------------------------------------------------------------*/ diff --git a/lib_com/env_stab_trans.c b/lib_com/env_stab_trans.c index 8c6ec265f..829bef5f4 100644 --- a/lib_com/env_stab_trans.c +++ b/lib_com/env_stab_trans.c @@ -38,10 +38,9 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" /*--------------------------------------------------------------------------* * env_stab_transient_detect() * diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index e04a13fdf..78809ed2c 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -12,7 +12,6 @@ #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" -#include "prot.h" #define FFT_SCALING_512 1073741824 // Q22 #define FFT_SCALING_640 1342177280 // Q22 diff --git a/lib_com/fft.c b/lib_com/fft.c index 352a24be9..e262f3909 100644 --- a/lib_com/fft.c +++ b/lib_com/fft.c @@ -39,7 +39,7 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index acadbb06b..73ff582df 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -44,7 +44,7 @@ #include "options.h" #include #include "cnst.h" -// #include "prot.h" +// #include "prot_fx.h" #include "prot_fx.h" //#include "cnst_fx.h" #include "rom_com.h" diff --git a/lib_com/fft_rel.c b/lib_com/fft_rel.c index 839b2faaf..1d020cabd 100644 --- a/lib_com/fft_rel.c +++ b/lib_com/fft_rel.c @@ -36,10 +36,9 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" /*---------------------------------------------------------------------* * Local constants diff --git a/lib_com/fill_spectrum.c b/lib_com/fill_spectrum.c index 12ed75f0a..bd9080a7b 100644 --- a/lib_com/fill_spectrum.c +++ b/lib_com/fill_spectrum.c @@ -38,9 +38,8 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/findpulse.c b/lib_com/findpulse.c index f2347d5b3..68853e061 100644 --- a/lib_com/findpulse.c +++ b/lib_com/findpulse.c @@ -37,10 +37,9 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" /*----------------------------------------------------------------------------------* * findpulse() diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 41d90359f..1f7c28fd8 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -3,7 +3,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #define WMC_TOOL_SKIP diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index 4428c0796..68fdf33c3 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -38,9 +38,8 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" /*----------------------------------------------------------------------------------* * fer_energy() * diff --git a/lib_com/get_gain_fx.c b/lib_com/get_gain_fx.c index d4c2413c3..8ec4f5a40 100644 --- a/lib_com/get_gain_fx.c +++ b/lib_com/get_gain_fx.c @@ -36,9 +36,8 @@ #include #include "options.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" /*----------------------------------------------------------------------------------* * get_gain() diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c index eef3d50c6..0921dc88c 100644 --- a/lib_com/gs_bitallocation_ivas_fx.c +++ b/lib_com/gs_bitallocation_ivas_fx.c @@ -5,7 +5,6 @@ #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "ivas_prot.h" /* Function prototypes */ #include "assert.h" /* Debug prototypes */ diff --git a/lib_com/gs_gains.c b/lib_com/gs_gains.c index 9adb448a4..8fa769475 100644 --- a/lib_com/gs_gains.c +++ b/lib_com/gs_gains.c @@ -39,7 +39,6 @@ #include #include "cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index 2e9e5eb96..3b3eaa777 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -39,9 +39,8 @@ #include #include "cnst.h" #include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" /*-------------------------------------------------------------------* * Local constants diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index 9820eb3c8..f5e7105cf 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -37,9 +37,8 @@ #include #include #include "options.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #define HP20_COEFF_SCALE ( 2 ) diff --git a/lib_com/hq2_core_com.c b/lib_com/hq2_core_com.c index bc4edb869..121dae06a 100644 --- a/lib_com/hq2_core_com.c +++ b/lib_com/hq2_core_com.c @@ -39,7 +39,7 @@ #include #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "basop_util.h" #include "basop_proto_func.h" #include "wmc_auto.h" diff --git a/lib_com/hq_conf.c b/lib_com/hq_conf.c index c139a493c..90a256cea 100644 --- a/lib_com/hq_conf.c +++ b/lib_com/hq_conf.c @@ -38,9 +38,8 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" void hq_configure_fx( diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index 4426f85d9..cf3ce202e 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -39,7 +39,6 @@ #include "rom_com.h" /* Static table prototypes FIP version */ #include "stl.h" /* required for wmc_tool */ #include "prot_fx.h" -#include "prot.h" #include "ivas_prot_fx.h" /*--------------------------------------------------------------------------* diff --git a/lib_com/ifft_rel.c b/lib_com/ifft_rel.c index 423eea46d..9e64a4e25 100644 --- a/lib_com/ifft_rel.c +++ b/lib_com/ifft_rel.c @@ -36,10 +36,9 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" /*-----------------------------------------------------------------* * Local constants *-----------------------------------------------------------------*/ diff --git a/lib_com/int_lsp.c b/lib_com/int_lsp.c index 0f673b8fd..570e9ebd9 100644 --- a/lib_com/int_lsp.c +++ b/lib_com/int_lsp.c @@ -37,10 +37,9 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" void int_lsp_fx( diff --git a/lib_com/interleave_spectrum.c b/lib_com/interleave_spectrum.c index 745ee6ac3..5c4c98e29 100644 --- a/lib_com/interleave_spectrum.c +++ b/lib_com/interleave_spectrum.c @@ -37,10 +37,9 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/interpol.c b/lib_com/interpol.c index 45021f1c2..a490a7552 100644 --- a/lib_com/interpol.c +++ b/lib_com/interpol.c @@ -36,10 +36,9 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "rom_com.h" -#include "prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_com/ivas_agc_com_fx.c b/lib_com/ivas_agc_com_fx.c index b2c09fa07..94e6b222f 100644 --- a/lib_com/ivas_agc_com_fx.c +++ b/lib_com/ivas_agc_com_fx.c @@ -38,7 +38,7 @@ #include "ivas_prot_fx.h" #include #include "wmc_auto.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" /*------------------------------------------------------------------------------------------* * Local constants diff --git a/lib_com/ivas_arith_fx.c b/lib_com/ivas_arith_fx.c index 2f729bbd4..006a31177 100644 --- a/lib_com/ivas_arith_fx.c +++ b/lib_com/ivas_arith_fx.c @@ -33,9 +33,8 @@ #include #include "options.h" #include "wmc_auto.h" -#include "prot.h" -#include "ivas_prot.h" #include "prot_fx.h" +#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "stat_dec.h" diff --git a/lib_com/ivas_avq_pos_reorder_com_fx.c b/lib_com/ivas_avq_pos_reorder_com_fx.c index ac539b787..25f8be3ad 100644 --- a/lib_com/ivas_avq_pos_reorder_com_fx.c +++ b/lib_com/ivas_avq_pos_reorder_com_fx.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" /*-----------------------------------------------------------------* diff --git a/lib_com/ivas_cov_smooth_fx.c b/lib_com/ivas_cov_smooth_fx.c index 445ea8c78..acc0df821 100644 --- a/lib_com/ivas_cov_smooth_fx.c +++ b/lib_com/ivas_cov_smooth_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "ivas_prot.h" #include "wmc_auto.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 557db9696..9b60b2c5c 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -37,10 +37,9 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_com/ivas_entropy_coder_common_fx.c b/lib_com/ivas_entropy_coder_common_fx.c index d28828d6f..99381d19a 100644 --- a/lib_com/ivas_entropy_coder_common_fx.c +++ b/lib_com/ivas_entropy_coder_common_fx.c @@ -35,7 +35,7 @@ #include "ivas_prot.h" #include "ivas_rom_com.h" #include "math.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c index 43f468fb0..883861024 100644 --- a/lib_com/ivas_fb_mixer_fx.c +++ b/lib_com/ivas_fb_mixer_fx.c @@ -34,13 +34,12 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index d3f18a795..f1201b06c 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -35,13 +35,12 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_com/ivas_lfe_com_fx.c b/lib_com/ivas_lfe_com_fx.c index 4d993d64f..7464c41c2 100644 --- a/lib_com/ivas_lfe_com_fx.c +++ b/lib_com/ivas_lfe_com_fx.c @@ -34,7 +34,7 @@ #include "math.h" #include "options.h" #include "ivas_stat_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index 35db926d0..fbe752aad 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -34,14 +34,13 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_rom_com_fx.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_mc_com_fx.c b/lib_com/ivas_mc_com_fx.c index 88d6c1b5e..62d623b83 100644 --- a/lib_com/ivas_mc_com_fx.c +++ b/lib_com/ivas_mc_com_fx.c @@ -34,7 +34,7 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_mc_param_com_fx.c b/lib_com/ivas_mc_param_com_fx.c index d69da849a..a54abe7ab 100644 --- a/lib_com/ivas_mc_param_com_fx.c +++ b/lib_com/ivas_mc_param_com_fx.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_stat_com.h" diff --git a/lib_com/ivas_mct_com_fx.c b/lib_com/ivas_mct_com_fx.c index b220d69a7..1f3c58153 100644 --- a/lib_com/ivas_mct_com_fx.c +++ b/lib_com/ivas_mct_com_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include diff --git a/lib_com/ivas_mdct_core_com_fx.c b/lib_com/ivas_mdct_core_com_fx.c index a5cfb8673..000f3992f 100644 --- a/lib_com/ivas_mdct_core_com_fx.c +++ b/lib_com/ivas_mdct_core_com_fx.c @@ -34,9 +34,8 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" /*--------------------------------------------------------------------------* diff --git a/lib_com/ivas_mdft_imdft_fx.c b/lib_com/ivas_mdft_imdft_fx.c index 0f24fba81..b10444307 100644 --- a/lib_com/ivas_mdft_imdft_fx.c +++ b/lib_com/ivas_mdft_imdft_fx.c @@ -33,14 +33,13 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" #include #include -#include "prot_fx.h" #include "debug.h" #include "ivas_rom_com_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_omasa_com_fx.c b/lib_com/ivas_omasa_com_fx.c index eb230b224..ef6350285 100644 --- a/lib_com/ivas_omasa_com_fx.c +++ b/lib_com/ivas_omasa_com_fx.c @@ -35,11 +35,10 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_rom_com.h" #include "rom_com.h" #include -#include "prot_fx.h" /*--------------------------------------------------------------- * Local constants diff --git a/lib_com/ivas_pca_tools_fx.c b/lib_com/ivas_pca_tools_fx.c index 5689e81c0..1e36c5e8e 100644 --- a/lib_com/ivas_pca_tools_fx.c +++ b/lib_com/ivas_pca_tools_fx.c @@ -38,7 +38,6 @@ #include #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_qmetadata_com_fx.c b/lib_com/ivas_qmetadata_com_fx.c index cbc67de00..79a585e8b 100644 --- a/lib_com/ivas_qmetadata_com_fx.c +++ b/lib_com/ivas_qmetadata_com_fx.c @@ -37,10 +37,9 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_com/ivas_qspherical_com_fx.c b/lib_com/ivas_qspherical_com_fx.c index 8ef48be2e..5caa850cb 100644 --- a/lib_com/ivas_qspherical_com_fx.c +++ b/lib_com/ivas_qspherical_com_fx.c @@ -37,12 +37,10 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_com/ivas_sba_config_fx.c b/lib_com/ivas_sba_config_fx.c index 94ceb8e3c..38785956c 100644 --- a/lib_com/ivas_sba_config_fx.c +++ b/lib_com/ivas_sba_config_fx.c @@ -37,7 +37,7 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index 788fb3c56..f35de8eb0 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 0ebae0de6..fc6e60310 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "basop_util.h" #include "ivas_stat_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" diff --git a/lib_com/ivas_spar_com_quant_util_fx.c b/lib_com/ivas_spar_com_quant_util_fx.c index 0f0e003dd..8292de5c1 100644 --- a/lib_com/ivas_spar_com_quant_util_fx.c +++ b/lib_com/ivas_spar_com_quant_util_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "math.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_stereo_dft_com_fx.c b/lib_com/ivas_stereo_dft_com_fx.c index 1157fffcf..80e64c0cc 100644 --- a/lib_com/ivas_stereo_dft_com_fx.c +++ b/lib_com/ivas_stereo_dft_com_fx.c @@ -36,7 +36,7 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_stereo_eclvq_com_fx.c b/lib_com/ivas_stereo_eclvq_com_fx.c index b4fb66429..d0ffff39c 100644 --- a/lib_com/ivas_stereo_eclvq_com_fx.c +++ b/lib_com/ivas_stereo_eclvq_com_fx.c @@ -37,7 +37,7 @@ #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" /*--------------------------------------------------------------- diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c index 78a3c90ca..9aa880842 100644 --- a/lib_com/ivas_stereo_ica_com_fx.c +++ b/lib_com/ivas_stereo_ica_com_fx.c @@ -36,7 +36,6 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_stereo_mdct_bands_com_fx.c b/lib_com/ivas_stereo_mdct_bands_com_fx.c index b1750fd16..c21abcf8c 100644 --- a/lib_com/ivas_stereo_mdct_bands_com_fx.c +++ b/lib_com/ivas_stereo_mdct_bands_com_fx.c @@ -37,9 +37,8 @@ #include "ivas_rom_com.h" #include "ivas_prot.h" #include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_com/ivas_stereo_psychlpc_com_fx.c b/lib_com/ivas_stereo_psychlpc_com_fx.c index 996b262db..cb3c39df2 100644 --- a/lib_com/ivas_stereo_psychlpc_com_fx.c +++ b/lib_com/ivas_stereo_psychlpc_com_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include "ivas_rom_com.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" #include diff --git a/lib_com/ivas_stereo_td_bit_alloc_fx.c b/lib_com/ivas_stereo_td_bit_alloc_fx.c index 14ab8131e..9074473d7 100644 --- a/lib_com/ivas_stereo_td_bit_alloc_fx.c +++ b/lib_com/ivas_stereo_td_bit_alloc_fx.c @@ -38,9 +38,8 @@ #include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 9cd1a063e..e460637f7 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -34,11 +34,10 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_rom_com.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #define ANGLE_90_DEG_Q22 377487360 diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index b5ea507eb..97025b46f 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -34,11 +34,10 @@ #include "options.h" #include "math.h" #include "wmc_auto.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_stat_com.h" /*------------------------------------------------------------------------------------------* diff --git a/lib_com/lag_wind.c b/lib_com/lag_wind.c index e0871fa70..9fb287271 100644 --- a/lib_com/lag_wind.c +++ b/lib_com/lag_wind.c @@ -37,7 +37,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "cnst.h" #include "rom_com.h" diff --git a/lib_com/lerp.c b/lib_com/lerp.c index 28719205a..4e306b936 100644 --- a/lib_com/lerp.c +++ b/lib_com/lerp.c @@ -36,154 +36,25 @@ #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "wmc_auto.h" - /*-------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------*/ -static void lerp_proc_flt( const float *f, float *f_out, const int16_t bufferNewSize, const int16_t bufferOldSize ); - - /*-------------------------------------------------------------* * procedure lerp_flt() * * * * * *-------------------------------------------------------------*/ -void lerp_flt( - const float *f, - float *f_out, - const int16_t bufferNewSize, - const int16_t bufferOldSize_inp ) -{ - float maxFac; - int16_t bufferOldSize, tmpNewSize; - - maxFac = 507.0 / 128.0; - bufferOldSize = bufferOldSize_inp; - - if ( (float) bufferNewSize / bufferOldSize > maxFac ) - { - tmpNewSize = bufferOldSize * 2; - while ( bufferNewSize > bufferOldSize ) - { - if ( (float) bufferNewSize / bufferOldSize <= maxFac ) - { - tmpNewSize = bufferNewSize; - } - - lerp_proc_flt( f, f_out, tmpNewSize, bufferOldSize ); - - f = f_out; - bufferOldSize = tmpNewSize; - tmpNewSize *= 2; - } - } - else if ( (float) bufferOldSize / bufferNewSize > maxFac ) - { - tmpNewSize = bufferOldSize / 2; - while ( bufferNewSize < bufferOldSize ) - { - if ( (float) bufferOldSize / bufferNewSize <= maxFac ) - { - tmpNewSize = bufferNewSize; - } - - lerp_proc_flt( f, f_out, tmpNewSize, bufferOldSize ); - - f = f_out; - bufferOldSize = tmpNewSize; - tmpNewSize /= 2; - } - } - else - { - lerp_proc_flt( f, f_out, bufferNewSize, bufferOldSize ); - } - - return; -} - /*-------------------------------------------------------------* * procedure lerp_proc_flt() * * * * * *-------------------------------------------------------------*/ -static void lerp_proc_flt( - const float *f, - float *f_out, - const int16_t bufferNewSize, - const int16_t bufferOldSize ) -{ - int16_t i, idx; - float pos, shift, diff; - float buf[2 * L_FRAME_MAX]; - Word16 tmp; - - if ( bufferNewSize == bufferOldSize ) - { - mvr2r( f, buf, bufferNewSize ); - mvr2r( buf, f_out, bufferNewSize ); - return; - } - - /* Using the basop code to avoid reading beyond end of input for bufferOldSize=320, bufferNewSize=640 */ - tmp = div_s( bufferOldSize, shl( bufferNewSize, 4 ) ); - shift = (float) ( L_shl( L_deposit_l( tmp ), 4 - 15 + 16 ) ) / 65536.0f; - pos = 0.5f * shift - 0.5f; - - if ( shift < 0.3f ) - { - pos = pos - 0.13f; - } - - /* first point of interpolation */ - if ( pos < 0 ) - { - buf[0] = f[0] + pos * ( f[1] - f[0] ); - } - else - { - idx = (int16_t) pos; - diff = pos - idx; - buf[0] = f[idx] + diff * ( f[idx + 1] - f[idx] ); - } - - pos += shift; - - for ( i = 1; i < bufferNewSize - 1; i++ ) - { - idx = (int16_t) pos; - diff = pos - idx; - - buf[i] = f[idx] + diff * ( f[idx + 1] - f[idx] ); - pos += shift; - } - - - /* last point */ - idx = (int16_t) pos; - - if ( pos > bufferOldSize - 1 ) - { - idx = bufferOldSize - 2; - } - - diff = pos - idx; - - buf[bufferNewSize - 1] = f[idx] + diff * ( f[idx + 1] - f[idx] ); - - mvr2r( buf, f_out, bufferNewSize ); - - return; -} - - /*-------------------------------------------------------------* * Local constants *-------------------------------------------------------------*/ diff --git a/lib_com/limit_t0.c b/lib_com/limit_t0.c deleted file mode 100644 index d49cad283..000000000 --- a/lib_com/limit_t0.c +++ /dev/null @@ -1,231 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include "cnst.h" -#include "prot.h" -#include "wmc_auto.h" - -/*-------------------------------------------------* - * Local constants - *-------------------------------------------------*/ - -#define LIMIT_PIT_REL_LOWER 2 /* delta interval to extend pitch coding in relative Q */ -#define LIMIT_PIT_REL_UPPER 0 - -/*-------------------------------------------------* - * limit_T0() - * - * Close-loop pitch lag search limitation - *-------------------------------------------------*/ - -void limit_T0( - const int16_t L_frame, /* i : length of the frame */ - const int16_t delta, /* i : Half the close-loop searched interval */ - const int16_t pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ - const int16_t limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */ - const int16_t T0, /* i : rough pitch estimate around which the search is done */ - const int16_t T0_frac, /* i : pitch estimate fractional part */ - int16_t *T0_min, /* o : lower pitch limit */ - int16_t *T0_max /* o : higher pitch limit */ -) -{ - int16_t delta2, T1; - int16_t pit_min, pit_max; - - if ( limit_flag == 0 ) /* restrained Q limits */ - { - /* set limits */ - if ( L_frame == L_FRAME ) - { - pit_max = PIT_MAX; - pit_min = PIT_MIN; - } - else /* L_frame == L_FRAME16k */ - { - pit_max = PIT16k_MAX; - pit_min = PIT16k_MIN; - } - - delta2 = 2 * delta - 1; - - T1 = T0; - if ( T0_frac >= 2 ) - { - T1++; - } - *T0_min = T1 - delta; - - if ( *T0_min < pit_min ) - { - *T0_min = pit_min; - } - *T0_max = *T0_min + delta2; - - if ( *T0_max > pit_max ) - { - *T0_max = pit_max; - *T0_min = *T0_max - delta2; - } - } - else /* extended Q limits */ - { - - /* set limits */ - if ( L_frame == L_FRAME ) - { - pit_max = PIT_MAX; - pit_min = PIT_MIN_EXTEND; - - if ( limit_flag == 2 ) - { - pit_min = PIT_MIN_DOUBLEEXTEND; - } - } - else /* L_frame == L_FRAME16k */ - { - pit_max = PIT16k_MAX; - pit_min = PIT16k_MIN_EXTEND; - } - - delta2 = 2 * delta - 1; - - T1 = T0; - if ( T0_frac >= 2 ) - { - T1++; - } - *T0_min = T1 - delta; - - if ( pit_flag == 0 ) - { - /* subframes with absolute search: keep Q range */ - if ( *T0_min < pit_min ) - { - *T0_min = pit_min; - } - *T0_max = *T0_min + delta2; - - if ( *T0_max > pit_max ) - { - *T0_max = pit_max; - *T0_min = *T0_max - delta2; - } - } - else - { - /* subframes with relative search: extend Q range */ - if ( *T0_min < pit_min - LIMIT_PIT_REL_LOWER ) - { - *T0_min = pit_min - LIMIT_PIT_REL_LOWER; - } - - if ( *T0_min < L_INTERPOL ) - { - *T0_min = L_INTERPOL; - } - *T0_max = *T0_min + delta2; - - if ( *T0_max > pit_max + LIMIT_PIT_REL_UPPER ) - { - *T0_max = pit_max + LIMIT_PIT_REL_UPPER; - *T0_min = *T0_max - delta2; - } - } - } - - return; -} - - -/*-------------------------------------------------* - * Routine limit_T0_voiced_ivas() - * - * Close-loop pitch lag search limitation - *-------------------------------------------------*/ - -void limit_T0_voiced_ivas( - const int16_t nbits, - const int16_t res, - const int16_t T0, /* i : rough pitch estimate around which the search is done */ - const int16_t T0_frac, /* i : pitch estimate fractional part */ - const int16_t T0_res, /* i : pitch resolution */ - int16_t *T0_min, /* o : lower pitch limit */ - int16_t *T0_min_frac, /* o : lower pitch limit */ - int16_t *T0_max, /* o : higher pitch limit */ - int16_t *T0_max_frac, /* o : higher pitch limit */ - const int16_t pit_min, /* i : Minimum pitch lag */ - const int16_t pit_max /* i : Maximum pitch lag */ -) -{ - int16_t T1, temp1, temp2; - - /* Mid-point */ - T1 = T0; - if ( ( T0_res > 1 ) && ( T0_frac >= ( T0_res >> 1 ) ) ) - { - T1++; - } - - /* Lower-bound */ - temp1 = ( T1 * res ) - ( 1 << ( nbits - 1 ) ); - temp2 = temp1 / res; - *T0_min = temp2; - *T0_min_frac = temp1 - temp2 * res; - if ( *T0_min < pit_min ) - { - *T0_min = pit_min; - *T0_min_frac = 0; - } - - /* Higher-bound */ - temp1 = ( *T0_min * res ) + *T0_min_frac + ( 1 << nbits ) - 1; - temp2 = temp1 / res; - *T0_max = temp2; - *T0_max_frac = temp1 - temp2 * res; - if ( *T0_max > pit_max ) - { - *T0_max = pit_max; - *T0_max_frac = res - 1; - temp1 = ( *T0_max * res ) + *T0_max_frac - ( 1 << nbits ) + 1; - temp2 = temp1 / res; - *T0_min = temp2; - *T0_min_frac = temp1 - temp2 * res; - } - - return; -} diff --git a/lib_com/longarith.c b/lib_com/longarith.c index 66c5dd15e..8946e41aa 100644 --- a/lib_com/longarith.c +++ b/lib_com/longarith.c @@ -37,10 +37,9 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_com/lsp_conv_poly_fx.c b/lib_com/lsp_conv_poly_fx.c index 61ead2bf2..4f493cacd 100644 --- a/lib_com/lsp_conv_poly_fx.c +++ b/lib_com/lsp_conv_poly_fx.c @@ -6,10 +6,9 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* * Local constants diff --git a/lib_com/modif_fs.c b/lib_com/modif_fs.c index 1b2836252..7ed3cb59b 100644 --- a/lib_com/modif_fs.c +++ b/lib_com/modif_fs.c @@ -38,10 +38,9 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" void Interpolate_allpass_steep_32( diff --git a/lib_com/mslvq_com.c b/lib_com/mslvq_com.c index 34e2083b9..a15b11611 100644 --- a/lib_com/mslvq_com.c +++ b/lib_com/mslvq_com.c @@ -38,10 +38,9 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------* diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c index d97830a5f..10e560433 100644 --- a/lib_com/mslvq_com_fx.c +++ b/lib_com/mslvq_com_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "stl.h" diff --git a/lib_com/preemph.c b/lib_com/preemph.c index 490a18aef..9ebc0f72a 100644 --- a/lib_com/preemph.c +++ b/lib_com/preemph.c @@ -36,7 +36,7 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" /*-------------------------------------------------------------* diff --git a/lib_com/prot.h b/lib_com/prot.h deleted file mode 100644 index f5d69075e..000000000 --- a/lib_com/prot.h +++ /dev/null @@ -1,8340 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#ifndef PROT_H -#define PROT_H - -#include -#include -#include -#include "options.h" -#include "typedef.h" -#include "stat_enc.h" -#include "stat_dec.h" -#include "stat_com.h" -#include "ivas_stat_com.h" -#include "ivas_stat_enc.h" -#include "ivas_stat_dec.h" -#include "cnst.h" -#include "stl.h" -#include "ivas_error_utils.h" - - -/*----------------------------------------------------------------------------------* - * Prototypes of global macros - *----------------------------------------------------------------------------------*/ - -#ifndef min -#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef max -#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef TRUNC -#define TRUNC( x ) ( (int16_t) ( ( ( x ) >= 32767. ? 32767 : ( ( x ) <= -32768. ? -32768 : ( x ) ) ) + 0.5 ) ) -#endif - -#define log_base_2( x ) ( (double) log( (double) ( x ) ) * 1.4426950408889634074f ) -#define round_f( x ) ( ( ( x ) > 0 ) ? (int32_t) ( ( x ) + 0.5f ) : ( -(int32_t) ( ( -x ) + 0.5f ) ) ) - -#ifndef ABSVAL -#define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) ) -#endif - -#ifndef SQR -#define SQR( a ) ( ( a ) * ( a ) ) -#endif - -#ifndef SWAP -#define SWAP( a, b ) \ - { \ - tempr = ( a ); \ - ( a ) = ( b ); \ - ( b ) = tempr; \ - } -#endif - -#ifndef swap -#define swap( x, y, type ) \ - { \ - type u__p; \ - u__p = x; \ - x = y; \ - y = u__p; \ - } -#endif - -#define set_max( a, b ) \ - { \ - if ( ( b ) > *a ) \ - { \ - *a = ( b ); \ - } \ - } /* If the first argument is already the highes or lowest, nothing is done. */ -#define set_min( a, b ) \ - { \ - if ( ( b ) < *a ) \ - { \ - *a = ( b ); \ - } \ - } /* Otherwise, the 2nd arg is stored at the address of the first arg. */ - - -/*----------------------------------------------------------------------------------* - * MODE1 prototypes - *----------------------------------------------------------------------------------*/ - -/*! r: inverse square root of input value */ -float inv_sqrt( - const float x /* i : input value */ -); - -/*! r: output random value */ -int16_t own_random( - int16_t *seed /* i/o: random seed */ -); - -/*! r: sign of x (+1/-1) */ -float sign( - const float x /* i : input value of x */ -); - -/*! r: logarithm2 of x */ -float log2_f( - const float x /* i : input value of x */ -); - -int16_t norm_ul_float( - uint32_t UL_var1 ); - -/*! r: sum of all vector elements */ -int16_t sum_s( - const int16_t *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -); - -/*! r: sum of all vector elements */ -int32_t sum_l( - const int32_t *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -); - -/*! r: sum of all vector elements */ -float sum_f( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -); - -/*! r: sum of all squared vector elements */ -float sum2_f( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -); - -void set_c( - int8_t y[], /* i/o: Vector to set */ - const int8_t a, /* i : Value to set the vector to */ - const int32_t N /* i : Length of the vector */ -); - -void set_s( - int16_t y[], /* i/o: Vector to set */ - const int16_t a, /* i : Value to set the vector to */ - const int16_t N /* i : Lenght of the vector */ -); - -void set_l( - int32_t y[], /* i/o: Vector to set */ - const int32_t a, /* i : Value to set the vector to */ - const int16_t N /* i : Length of the vector */ -); - -void set_f( - float y[], /* i/o: Vector to set */ - const float a, /* i : Value to set the vector to */ - const int16_t N /* i : Lenght of the vector */ -); - -void set_zero_fx( - Word32 *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ -); -void set_zero2_fx( - Word32 *vec, /* o : input vector */ - const Word32 lvec /* i : length of the vector */ -); -void set16_zero_fx( - Word16 *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ -); - -void set_zero( - float *vec, /* o : input vector */ - const int16_t lvec /* i : length of the vector */ -); - -void mvr2r( - const float x[], /* i : input vector */ - float y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -void mvs2s( - const int16_t x[], /* i : input vector */ - int16_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -uint32_t mvr2s( - const float x[], /* i : input vector */ - int16_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -void mvs2r( - const int16_t x[], /* i : input vector */ - float y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -void mvl2l( - const int32_t x[], /* i : input vector */ - int32_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - - -/*! r: index of the maximum value in the input vector */ -int16_t maximum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *max_val /* o : maximum value in the input vector */ -); -/*! r: index of the maximum value in the input vector */ -int16_t maximumAbs( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *max_val /* o : maximum value in the input vector */ -); - -Word16 maximumAbs_l( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ -); - -/*! r: index of the minimum value in the input vector */ -int16_t minimum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *min_val /* o : minimum value in the input vector */ -); - -/*! r: index of the minimum value in the input vector */ -int16_t minimum_s( - const int16_t *vec, /* i : Input vector */ - const int16_t lvec, /* i : Vector length */ - int16_t *min_val /* o : minimum value in the input vector */ -); - -/*! r: return index with max energy value in vector */ -int16_t emaximum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *ener_max /* o : maximum energy value */ -); - -/*! r: vector mean */ -float mean( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -); - -/*! r: dot product of x[] and y[] */ -float dotp( - const float x[], /* i : vector x[] */ - const float y[], /* i : vector y[] */ - const int16_t n /* i : vector length */ -); - -void conv( - const float x[], /* i : input vector */ - const float h[], /* i : impulse response (or second input vector) */ - float y[], /* o : output vetor (result of convolution) */ - const int16_t L /* i : vector size */ -); - -void fir( - const float x[], /* i : input vector */ - const float h[], /* i : impulse response of the FIR filter */ - float y[], /* o : output vector (result of filtering) */ - float mem[], /* i/o: memory of the input signal (M samples) */ - const int16_t L, /* i : input vector size */ - const int16_t K, /* i : order of the FIR filter (M+1 coefs.) */ - const int16_t upd /* i : 1 = update the memory, 0 = not */ -); - -void v_add( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 + vector 2 */ - const int16_t N /* i : Vector length */ -); - -void v_sub( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 - vector 2 */ - const int16_t N /* i : Vector length */ -); - -void v_mult( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 .* vector 2*/ - const int16_t N /* i : Vector length */ -); - -void v_multc( - const float x[], /* i : Input vector */ - const float c, /* i : Constant */ - float y[], /* o : Output vector that contains c*x */ - const int16_t N /* i : Vector length */ -); - -/*! r: index of the winning codeword */ -int16_t squant( - const float x, /* i : scalar value to quantize */ - float *xq, /* o : quantized value */ - const float cb[], /* i : codebook */ - const int16_t cbsize /* i : codebook size */ -); - -int16_t squant_int( - uint8_t x, /* i : scalar value to quantize */ - uint8_t *xq, /* o : quantized value */ - const uint8_t *cb, /* i : codebook */ - const int16_t cbsize /* i : codebook size */ -); - -/*! r: index of the winning codevector */ -int16_t vquant( - float x[], /* i : vector to quantize */ - const float x_mean[], /* i : vector mean to subtract (0 if none) */ - float xq[], /* o : quantized vector */ - const float cb[], /* i : codebook */ - const int16_t dim, /* i : dimension of codebook vectors */ - const int16_t cbsize /* i : codebook size */ -); - -/*! r: index of the winning codevector */ -int16_t w_vquant( - float x[], /* i : vector to quantize */ - const float x_mean[], /* i : vector mean to subtract (0 if none) */ - const int16_t weights[], /* i : error weights */ - float xq[], /* o : quantized vector */ - const float cb[], /* i : codebook */ - const int16_t dim, /* i : dimension of codebook vectors */ - const int16_t cbsize, /* i : codebook size */ - const int16_t reverse /* i : reverse codebook vectors */ -); - -/*! r: index of the winning codeword */ -int16_t usquant( - const float x, /* i : scalar value to quantize */ - float *xq, /* o : quantized value */ - const float qlow, /* i : lowest codebook entry (index 0) */ - const float delta, /* i : quantization step */ - const int16_t cbsize /* i : codebook size */ -); - -/*! r: dequanzited gain */ -float usdequant( - const int16_t idx, /* i : quantizer index */ - const float qlow, /* i : lowest codebook entry (index 0) */ - const float delta /* i : quantization step */ -); - -void v_sort_float( - float *r, /* i/o: Vector to be sorted in place */ - const int16_t lo, /* i : Low limit of sorting range */ - const int16_t up /* i : High limit of sorting range */ -); - -void sort( - uint16_t *x, /* i/o: Vector to be sorted */ - uint16_t len /* i/o: vector length */ -); - -void sort_l( - Word32 *x, /* i/o: Vector to be sorted */ - Word16 len /* i/o: vector length */ -); - -/*! r: variance of vector */ -float var( - const float *x, /* i : input vector */ - const int16_t len /* i : length of inputvector */ -); - -/*! r: standard deviation */ -float std_dev( - const float *x, /* i : input vector */ - const int16_t len /* i : length of the input vector */ -); - -/*! r: the dot product x'*A*x */ -float dot_product_mat( - const float *x, /* i : vector x */ - const float *A, /* i : matrix A */ - const int16_t m /* i : vector length */ -); - -float root_a( - float a ); - -float root_a_over_b( - float a, - float b ); - -void polezero_filter( - const float *in, /* i : input vector */ - float *out, /* o : output vector */ - const int16_t N, /* i : input vector size */ - const float *b, /* i : numerator coefficients */ - const float *a, /* i : denominator coefficients */ - const int16_t order, /* i : filter order */ - float *mem /* i/o: filter memory */ -); - -double rint_new( - double x /* i/o: Round to the nearest integer with mid point exception */ -); - -double anint( - double x /* i/o: Round to the nearest integer */ -); - -/*! r: Output either 1 if Numeric, 0 if NaN or Inf */ -int16_t is_numeric_float( - float x /* i : Input value which is checked if numeric or not */ -); - -void delay_signal_float( - float x[], /* i/o: signal to be delayed */ - const int16_t len, /* i : length of the input signal */ - float mem[], /* i/o: synchronization memory */ - const int16_t delay /* i : delay in samples */ -); - -ivas_error push_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - int16_t id, /* i : ID of the indice */ - uint16_t value, /* i : value of the quantized indice */ - int16_t nb_bits /* i : number of bits used to quantize the indice */ -); - -ivas_error push_next_indice( - BSTR_ENC_HANDLE hBstr, - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ -); - -ivas_error push_next_bits( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ - const Word16 nb_bits /* i : number of bits to pack */ -); - -/*! r: maximum number of indices */ -Word16 get_ivas_max_num_indices_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); - -/*! r: maximum number of indices */ -int16_t get_BWE_max_num_indices( - const int32_t extl_brate /* i : extensiona layer bitrate */ -); - -/*! r: maximum number of indices */ -Word16 get_ivas_max_num_indices_metadata_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); -ivas_error ind_list_realloc( - INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ - const int16_t max_num_indices, /* i : new maximum number of allowed indices in the list */ - Encoder_Struct *st_ivas /* i : IVAS encoder structure */ -); - -ivas_error check_ind_list_limits( - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -); - -void move_indices( - INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ - INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ - const int16_t nb_indices /* i : number of moved indices */ -); - -/*! r: index of the indice in the list, -1 if not found */ -int16_t find_indice( - BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ - const int16_t id, /* i : ID of the indice */ - uint16_t *value, /* o : value of the quantized indice */ - int16_t *nb_bits /* o : number of bits used to quantize the indice */ -); - -/*! r: number of deleted indices */ -uint16_t delete_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t id /* i : ID of the indice */ -); - -/*! r: value of the indice */ -uint16_t get_next_indice( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t nb_bits /* i : number of bits that were used to quantize the indice */ -); - -/*! r: value of the indice */ -uint16_t get_next_indice_1( - Decoder_State *st /* i/o: decoder state structure */ -); - -void get_next_indice_tmp( - Decoder_State *st, /* o : decoder state structure */ - int16_t nb_bits /* i : number of bits that were used to quantize the indice */ -); - -/*! r: value of the indice */ -uint16_t get_indice( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t pos, /* i : absolute position in the bitstream */ - int16_t nb_bits /* i : number of bits that were used to quantize the indice */ -); - -/*! r: value of the indice */ -uint16_t get_indice_1( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t pos /* i : absolute position in the bitstream */ -); - -void reset_indices_enc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t max_num_indices /* i : max number of indices */ -); - -void reset_indices_dec( - Decoder_State *st /* i/o: decoder state structure */ -); - -ivas_error write_indices_ivas( - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - uint16_t *bit_stream, /* i/o: output bitstream */ - uint16_t *num_bits /* i/o: number of bits written to output */ -); - -Word16 rate2EVSmode_float( - const Word32 brate, /* i : bitrate */ - int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ -); - - -/*! r: 1 = OK, 0 = something wrong */ -ivas_error read_indices( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t bit_stream[], /* i : bitstream buffer */ - UWord16 num_bits, /* i : number of bits in bitstream */ - int16_t *prev_ft_speech, - int16_t *CNG, - int16_t bfi /* i : bad frame indicator */ -); - - -void ivas_set_bitstream_pointers( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -Decoder_State **reset_elements( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - -void convertSerialToBytestream( - const uint16_t *const serial, /* i : input serial bitstream with values 0 and 1 */ - const uint16_t num_bits, /* i : number of bits in the input bitstream */ - uint8_t *const bytestream /* o : output compact bitstream (bytestream) */ -); - -void convertBytestreamToSerial( - const uint8_t *const bytestream, /* i : input compact bitstream (bytestream) */ - const uint16_t num_bits, /* i : number of bits in the input bitstream */ - uint16_t *const serial /* o : output serial bitstream with values 0 and 1 */ -); - -void mdct_switching_dec( - Decoder_State *st /* i/o: decoder state structure */ -); - -void evs_dec_previewFrame_float( - uint8_t *bitstream, /* i : bitstream pointer */ - int16_t bitstreamSize, /* i : bitstream size */ - int16_t *partialCopyFrameType, /* o : frame type of the partial copy */ - int16_t *partialCopyOffset /* o : offset of the partial copy relative to the primary copy */ -); - - -void getPartialCopyInfo_float( - Decoder_State *st, /* i : decoder state structure */ - int16_t *sharpFlag ); - -void get_NextCoderType( - uint8_t *bitstream, /* i : bitstream */ - int16_t *next_coder_type /* o : next coder type */ -); - -int16_t print_disclaimer( - FILE *fPtr ); - - -/*! r: delay value in ns */ -int32_t get_delay( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t io_fs, /* i : input/output sampling frequency */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ -); - -void decision_matrix_enc( - Encoder_State *st, /* i/o: encoder state structure */ - int16_t *hq_core_type /* o : HQ core type */ -); - -void signaling_enc( - Encoder_State *st /* i : encoder state structure */ -); - -int16_t signaling_mode1_tcx20_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t push /* i : flag to push indice */ -); - -void decision_matrix_dec( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *sharpFlag, /* o : formant sharpening flag */ - int16_t *hq_core_type, /* o : HQ core type */ - int16_t *core_switching_flag /* o : ACELP->HQ switching frame flag */ -); - - -void amr_wb_dec_init( - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ -); - -void hf_synth_amr_wb_init( - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ -); - -void hf_synth_amr_wb_reset( - AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ -); - -void hf_synth_amr_wb( - AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t output_frame, /* i : output frame length */ - const float *Aq, /* i : quantized Az */ - const float *exc, /* i : excitation at 12.8 kHz */ - float *synth, /* i/o: synthesis signal at 12.8 kHz */ - int16_t *amr_io_class, /* i : signal class (determined by FEC algorithm) */ - float *synth_out, /* i/o: synthesis signal at output Fs */ - float fmerit, /* i : classify parameter from FEC */ - const int16_t *hf_gain, /* i : decoded HF gain */ - const float *voice_factors, /* i : voicing factors */ - const float pitch_buf[], /* i : pitch buffer */ - const float ng_ener_ST, /* i : Noise gate - short-term energy */ - const float *lsf_new /* i : ISF vector */ -); - -void hf_cod_init( - float *mem_hp400_enc, /* o : memory of hp 400 Hz filter */ - float *mem_hf1_enc, /* o : HF band-pass filter memory */ - float *mem_syn_hf_enc, /* o : HF synthesis memory */ - float *mem_hf2_enc, /* o : HF band-pass filter memory */ - float *gain_alpha /* o : smoothing gain for transitions between active and inactive frames */ -); - -void hf_cod( - const int32_t core_brate, /* i : core bitrate */ - const float *speech16k, /* i : original speech at 16 kHz */ - const float Aq[], /* i : quantized Aq */ - const float exc[], /* i : excitation at 12.8 kHz */ - float synth[], /* i : 12.8kHz synthesis signal */ - int16_t *seed2_enc, /* i/o: random seed for HF noise gen */ - float *mem_hp400_enc, /* i/o: memory of hp 400 Hz filter */ - float *mem_syn_hf_enc, /* i/o: HF synthesis memory */ - float *mem_hf1_enc, /* i/o: HF band-pass filter memory */ - float *mem_hf2_enc, /* i/o: HF band-pass filter memory */ - const int16_t *dtxHangoverCount, - float *gain_alpha, /* i/o: smoothing gain for transitions between active and inactive frames */ - int16_t *hf_gain /* o : HF gain to be transmitted to decoder */ -); - -void hf_synth_init( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ -); - -void hf_synth_reset( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ -); - -void hf_synth( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t output_frame, /* i : output frame length */ - const float *Aq, /* i : quantized Az */ - const float *exc, /* i : excitation at 12.8 kHz */ - float *synth, /* i/o: 12.8kHz synthesis signal */ - float *synth16k /* i/o: 16kHz synthesis signal */ -); - -void fft_rel( - float x[], /* i/o: input/output vector */ - const int16_t n, /* i : vector length */ - const int16_t m /* i : log2 of vector length */ -); - -void ifft_rel( - float io[], /* i/o: input/output vector */ - const int16_t n, /* i : vector length */ - const int16_t m /* i : log2 of vector length */ -); - -void preemph( - float *signal, /* i/o: signal */ - const float mu, /* i : preemphasis factor */ - const int16_t L, /* i : vector size */ - float *mem /* i/o: memory (x[-1]) */ -); -void preemph_ivas_fx( - Word32 *signal, /* i/o: signal Qx*/ - const Word16 mu, /* i : preemphasis factor Q15*/ - const Word16 L, /* i : vector size Q0*/ - Word32 *mem /* i/o: memory (x[-1]) Qx*/ -); - -void cb_shape( - const int16_t preemphFlag, /* i : flag for pre-emphasis */ - const int16_t pitchFlag, /* i : flag for pitch sharpening */ - const int16_t scramblingFlag, /* i : flag for phase scrambling */ - const int16_t formantFlag, /* i : flag for formant sharpening */ - const int16_t formantTiltFlag, /* i : flag for formant tilt */ - const float g1, /* i : formant sharpening numerator weighting */ - const float g2, /* i : formant sharpening denominator weighting */ - const float *p_Aq, /* i : LP filter coefficients */ - float *code, /* i/o: signal to shape */ - const float tilt_code, /* i : tilt of code */ - const float pt_pitch, /* i : pointer to current subframe fractional pitch*/ - const int16_t L_subfr /* i : subfframe length */ -); - -void CNG_exc( - const int32_t core_brate, /* i : core bitrate */ - const int16_t L_frame, /* i : length of the frame */ - float *Enew, /* i/o: decoded SID energy */ - int16_t *seed, /* i/o: random generator seed */ - float exc[], /* o : current non-enhanced excitation */ - float exc2[], /* o : current enhanced excitation */ - float *lp_ener, /* i/o: LP filtered E */ - const int32_t last_core_brate, /* i : previous frame core bitrate */ - int16_t *first_CNG, /* i/o: first CNG frame flag for energy init. */ - int16_t *cng_ener_seed, /* i/o: random generator seed for CNG energy */ - float bwe_exc[], /* o : excitation for SWB TBE */ - const int16_t allow_cn_step, /* i : allow CN step */ - int16_t *last_allow_cn_step, /* i/o: last CN_step */ - const int16_t num_ho, /* i : number of selected hangover frames */ - float q_env[], - float *lp_env, - float *old_env, - float *exc_mem, - float *exc_mem1, - int16_t *sid_bw, - int16_t *cng_ener_seed1, - float exc3[], - const int16_t Opt_AMR_WB, /* i : AMR-WB interop flag */ - const int16_t element_mode /* i : IVAS Element mode */ -); - - -void cng_params_postupd( - const int16_t ho_circ_ptr, /* i : pointer for CNG averaging buffers */ - int16_t *cng_buf_cnt, /* i/o: counter for CNG store buffers */ - const float *cng_exc2_buf, /* i : Excitation buffer */ - const int32_t *cng_brate_buf, /* i : bitrate buffer */ - float ho_env_circ[], /* i/o: Envelope buffer */ - const int16_t element_mode, /* i : Element mode */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void calculate_hangover_attenuation_gain( - Encoder_State *st, /* i : encoder state structure */ - float *att, /* o : attenuation factor */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -int16_t get_cng_mode_ivas( - const int32_t last_active_brate /* i : last active bitrate */ -); - -void disf_ns_28b( - int16_t *indice, /* i : quantized indices, use indice[0] = -1 in the decoder*/ - float *isf_q /* o : ISF in the frequency domain (0..6400) */ -); - -void limit_T0( - const int16_t L_frame, /* i : length of the frame */ - const int16_t delta, /* i : Half the close-loop searched interval */ - const int16_t pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ - const int16_t limit_flag, /* i : flag for limits (0=restrained, 1=extended) */ - const int16_t T0, /* i : rough pitch estimate around which the search is done */ - const int16_t T0_frac, /* i : pitch estimate fractional part */ - int16_t *T0_min, /* o : lower pitch limit */ - int16_t *T0_max /* o : higher pitch limit */ -); - -/*! r: interpolated value */ -float interpolation( - const float *x, /* i : input vector */ - const float *win, /* i : interpolation window */ - const int16_t frac, /* i : fraction */ - const int16_t up_samp, /* i : upsampling factor */ - const int16_t nb_coef /* i : nb of filter coef */ -); - -void deemph( - float *signal, /* i/o: signal */ - const float mu, /* i : deemphasis factor */ - const int16_t L, /* i : vector size */ - float *mem /* i/o: memory (y[-1]) */ -); - -void weight_a( - const float *a, /* i : LP filter coefficients */ - float *ap, /* o : weighted LP filter coefficients */ - const float gamma, /* i : weighting factor */ - const int16_t m /* i : order of LP filter */ -); - -void weight_a_subfr( - const int16_t nb_subfr, /* i : number of subframes */ - const float *a, /* i : LP filter coefficients */ - float *ap, /* o : weighted LP filter coefficients */ - const float gamma, /* i : weighting factor */ - const int16_t m /* i : order of LP filter */ -); - -void syn_12k8( - const int16_t L_frame, /* i : length of the frame */ - const float *Aq, /* i : LP filter coefficients */ - const float *exc, /* i : input signal */ - float *synth, /* o : output signal */ - float *mem, /* i/o: initial filter states */ - const int16_t update_m /* i : update memory flag: 0 --> no memory update */ -); /* 1 --> update of memory */ - -void syn_filt( - const float a[], /* i : LP filter coefficients */ - const int16_t m, /* i : order of LP filter */ - const float x[], /* i : input signal */ - float y[], /* o : output signal */ - const int16_t l, /* i : size of filtering */ - float mem[], /* i/o: initial filter states */ - const int16_t update_m /* i : update memory flag: 0 --> no memory update */ -); /* 1 --> update of memory */ - -void synth_mem_updt2_flt( - const int16_t L_frame, /* i : frame length */ - const int16_t last_L_frame, /* i : frame length */ - float old_exc[], /* i/o: excitation buffer */ - float mem_syn_r[], /* i/o: synthesis filter memory */ - float mem_syn2[], /* o : synthesis filter memory for find_target */ - float mem_syn[], /* o : synthesis filter memory for find_target */ - const int16_t dec /* i : flag for decoder indication */ -); - -void int_lsp( - const int16_t L_frame, /* i : length of the frame */ - const float lsp_old[], /* i : LSPs from past frame */ - const float lsp_new[], /* i : LSPs from present frame */ - float *Aq, /* o : LP coefficients in both subframes */ - const int16_t m, /* i : order of LP filter */ - const float *int_coeffs, /* i : interpolation coefficients */ - const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ -); - -void int_lsp4( - const int16_t L_frame, /* i : length of the frame */ - const float lsp_old[], /* i : previous end-frame LSPs */ - const float lsp_mid[], /* i : current mid-frame LSPs */ - const float lsp_new[], /* i : current end-frame LSPs */ - float *Aq, /* o : LP coefficients in both subframes */ - const int16_t m, /* i : order of LP filter */ - int16_t relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */ -); - -/*! r: length of output */ -int16_t modify_Fs( - const float sigIn[], /* i : signal to decimate */ - const int16_t lg, /* i : length of input */ - const int32_t fin, /* i : frequency of input */ - float sigOut[], /* o : decimated signal */ - const int32_t fout, /* i : frequency of output */ - float mem[], /* i/o: filter memory */ - const int16_t nblp /* i : flag indicating if NB low-pass is applied */ -); - -void pred_lt4_flt( - const float excI[], /* i : input excitation buffer */ - float excO[], /* o : output excitation buffer */ - const int16_t T0, /* i : integer pitch lag */ - int16_t frac, /* i : fraction of lag */ - const int16_t L_subfr, /* i : subframe size */ - const float *win, /* i : interpolation window */ - const int16_t nb_coef, /* i : nb of filter coef */ - const int16_t up_sample /* i : up_sample */ -); - -void pred_lt4_tc_flt( - float exc[], /* i : excitation buffer */ - const int16_t T0, /* i : integer pitch lag */ - int16_t frac, /* i : fraction of lag */ - const float *win, /* i : interpolation window */ - const int16_t imp_pos, /* i : glottal impulse position */ - const int16_t i_subfr /* i : subframe index */ -); - -void residu( - const float *a, /* i : LP filter coefficients */ - const int16_t m, /* i : order of LP filter */ - const float *x, /* i : input signal (usually speech) */ - float *y, /* o : output signal (usually residual) */ - const int16_t l /* i : size of filtering */ -); - -void calc_residu( - const float *speech, /* i : weighted speech signal */ - float *res, /* o : residual signal */ - const float *p_Aq, /* i : quantized LP filter coefficients */ - const int16_t L_frame /* i : size of frame */ -); - -/*! r: impulse response energy */ -float enr_1_Az( - const float Aq[], /* i : LP filter coefs */ - const int16_t len /* i : impulse response length */ -); - -void Es_pred_enc( - float *Es_pred, /* o : predicited scaled innovation energy */ - int16_t *Es_pred_indice, /* o : indice corresponding to above parameter */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t L_subfr, /* i : length of the subframe */ - const float *res, /* i : residual signal */ - const float *voicing, /* i : normal. correlattion in three 1/2frames */ - const int16_t nb_bits, /* i : allocated number of bits */ - const int16_t no_ltp /* i : no_ltp flag */ -); - -void create_offset( - UWord32 *offset_scale1, - UWord32 *offset_scale2, - const int16_t mode, - const int16_t prediction_flag ); - -float mslvq( - float *pTmp, /* i : M-dimensional input vector */ - float *quant, /* o : quantized vector */ - float *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ - int16_t *idx_lead, /* o : leader index for each 8-dim subvector */ - int16_t *idx_scale, /* o : scale index for each subvector */ - const float *w, /* i : weights for LSF quantization */ - const int16_t mode, /* i : number indicating the coding mode */ - const int16_t mode_glb, /* i : LVQ coding mode */ - const int16_t pred_flag /* i : prediction flag (0: safety net, 1 - predictive )*/ -); - -void permute( - float *pTmp1, /* i/o: vector whose components are to be permuted */ - const int16_t *perm /* i : permutation info (indexes that should be interchanged), max two perms */ -); - -void sort_desc_ind( - float *s, - const int16_t len, - int16_t *ind ); - -float mslvq_cng( - int16_t idx_cv, /* i : index of cv from previous stage */ - float *pTmp, /* i : 16 dimensional input vector */ - float *quant, /* o : quantized vector */ - float *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ - int16_t *idx_lead, /* o : leader index for each 8-dim subvector */ - int16_t *idx_scale, /* o : scale index for each subvector */ - const float *w /* i : weights for LSF quantization */ -); - -int16_t deindex_lvq_cng( - int16_t *index, /* i : index to be decoded, as an array of 3 short */ - float *x_lvq, /* o : decoded codevector */ - const int16_t idx_cv, /* i : relative mode_lvq, wrt START_CNG */ - const int16_t no_bits /* i : number of bits for lattice */ -); - -void multiply32_32_64( - UWord32 x, /* i : operand 1 */ - UWord32 y, /* i : operand 2 */ - UWord32 *res /* o : result as array of two uint32 */ -); - -int16_t deindex_lvq( - int16_t *index, /* i : index to be decoded, as an array of 3 short */ - float *x_lvq, /* o : decoded codevector */ - const int16_t mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */ - const int16_t sf_flag, /* i : safety net flag */ - const int16_t no_bits /* i : number of bits for lattice */ -); - -void index_lvq( - float *quant, /* i : codevector to be indexed (2 8-dim subvectors) */ - int16_t *idx_lead, /* i : leader class index for each subvector */ - int16_t *idx_scale, /* i : scale index for each subvector */ - const int16_t mode, /* i : integer signaling the quantizer structure for the current bitrate */ - int16_t *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ - const int16_t prediction_flag /* i : predictive mode or not */ -); - -int16_t qlsf_ARSN_tcvq_Dec_16k( - float *y, /* o : Quantized LSF vector */ - int16_t *indice, /* i : Indices */ - const int16_t nBits /* i : number of bits */ -); - - -int16_t lsf_bctcvq_decprm_ivas( - Decoder_State *st, - int16_t *param_lpc ); - - -void disf_2s_36b( - int16_t *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */ - float *isf_q, /* o : quantized ISFs in the cosine domain */ - float *mem_AR, /* i/o: quantizer memory for AR model */ - float *mem_MA /* i/o: quantizer memory for MA model */ -); - -void disf_2s_46b( - int16_t *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */ - float *isf_q, /* o : quantized ISFs in the cosine domain */ - float *mem_AR, /* o : quantizer memory for AR model */ - float *mem_MA /* i/o: quantizer memory for MA model */ -); - -void re8_k2y( - const int16_t *k, /* i : Voronoi index k[0..7] */ - const int16_t m, /* i : Voronoi modulo (m = 2^r = 1<=2) */ - int16_t *y /* o : 8-dimensional point y[0..7] in RE8 */ -); - -void re8_PPV( - const float x[], /* i : point in R^8 */ - int16_t y[] /* o : point in RE8 (8-dimensional integer vector) */ -); - -void enhancer( - const int16_t codec_mode, /* i : flag indicating Codec Mode */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t cbk_index, /* i : */ - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const int16_t coder_type, /* i : coding type */ - const int16_t L_frame, /* i : frame size */ - const float voice_fac, /* i : subframe voicing estimation */ - const float stab_fac, /* i : LP filter stablility measure */ - const float norm_gain_code, /* i : normalized innovative cb. gain */ - const float gain_inov, /* i : gain of the unscaled innovation */ - float *gc_threshold, /* i/o: code threshold */ - float *code, /* i/o: innovation */ - float *exc2, /* i/o: adapt. excitation/total exc. */ - const float gain_pit, /* i : Quantized pitch gain */ - float *dispMem /* i/o: Phase dispersion algorithm memory */ -); - -void phase_dispersion_flt( - const float gain_code, /* i : gain of code */ - const float gain_pit, /* i : gain of pitch */ - float code[], /* i/o: code vector */ - const int16_t mode, /* i : level, 0=hi, 1=lo, 2=off */ - float disp_mem[] /* i/o: static memory (size = 8) */ -); - -void re8_vor( - int16_t y[], /* i : point in RE8 (8-dimensional integer vector) */ - int16_t *n, /* o : codebook number n=0,2,3,4,... (scalar integer) */ - int16_t k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 */ - int16_t c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c */ - int16_t *ka /* o : identifier of absolute leader (needed to index c)*/ -); - -void DoRTFT480( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT320( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT160( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT128( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT120( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT80( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT20( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT40( - float *x, /* i/o: real part of input and output data */ - float *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFTn( - float *x, /* i/o: real part of input and output data */ - float *y, /* i/o: imaginary part of input and output data */ - const int16_t n /* i : size of the FFT n=(2^k) up to 1024 */ -); - -void BASOP_cfft_ivas( - Word32 *re, /* i/o: real part */ - Word32 *im, /* i/o: imag part */ - Word16 s, /* i : stride real and imag part */ - Word16 *scale /* i : scalefactor */ -); - -void fft( - float *re, /* i/o: real part */ - float *im, /* i/o: imag part */ - const int16_t length, /* i : length of fft */ - const int16_t s /* i : sign */ -); - -void rfft( - float *x, /* i/o: values */ - const float *w, /* i : window */ - const int16_t length, /* i : length of fft */ - const int16_t isign /* i : sign */ -); - -void sinq( - const float tmp, /* i : sinus factor cos(tmp*i+phi) */ - const float phi, /* i : sinus phase cos(tmp*i+phi) */ - const int16_t N, /* i : size of output */ - float x[] /* o : output vector */ -); - -void edct2( - const int16_t n, - const int16_t isgn, - float *in, - float *a, - const int16_t *ip, - const float *w ); - -void stat_noise_uv_mod( - const int16_t coder_type, /* i : coder type */ - float noisiness, /* i : noisiness parameter */ - const float *const lsp_old, /* i : old LSP vector at 4th sfr */ - const float *const lsp_new, /* i : LSP vector at 4th sfr */ - const float *const lsp_mid, /* i : LSP vector at 2nd sfr */ - float *Aq, /* o : A(z) quantized for the 4 subframes */ - float *exc2, /* o : excitation buffer */ - const int16_t bfi, /* i : bad frame indicator */ - float *ge_sm, /* i/o: smoothed excitation gain */ - int16_t *uv_count, /* i/o: unvoiced counter */ - int16_t *act_count, /* i/o: activation counter */ - float lspold_s[], /* i/o: old LSP */ - int16_t *noimix_seed, /* i/o: mixture seed */ - float *st_min_alpha, /* i/o: minimum alpha */ - float *exc_pe, /* i/o: memory of the preemphasis filter */ - const int32_t bitrate, /* i : core bitrate */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void limit_band_noise_level_calc( - const int16_t *wnorm, /* i : reordered norm of sub-vectors */ - int16_t *limit, /* o : highest band of bit allocation */ - const int32_t core_brate, /* i : core bitrate */ - float *noise_level /* o : noise level */ -); - -/*! r: hqswb_clas */ -int16_t peak_avrg_ratio( - const int32_t total_brate, /* i : total bitrate */ - const float *input_hi, /* i : input signal */ - const int16_t N, /* i : number of coefficients */ - int16_t *mode_count, /* i/o: HQ_HARMONIC mode count */ - int16_t *mode_count1 /* i/o: HQ_NORMAL mode count */ -); - -/*! r: Number of coefficients in nf codebook */ -int16_t build_nf_codebook( - const int16_t flag_32K_env_ho, /* i : Envelope attenuation hangover flag */ - const float *coeff, /* i : Coded spectral coefficients */ - const int16_t *sfm_start, /* i : Subband start indices */ - const int16_t *sfmsize, /* i : Subband widths */ - const int16_t *sfm_end, /* i : Subband end indices */ - const int16_t nb_sfm, /* i : Last coded band */ - const int16_t *R, /* i : Per-band bit allocation */ - float *CodeBook, /* o : Noise-fill codebook */ - float *CodeBook_mod /* o : Densified noise-fill codebook */ -); - -void apply_noisefill_HQ( - const int16_t *R, /* i : bit allocation */ - const int16_t length, /* i : input frame length */ - const int16_t flag_32K_env_ho, /* i : envelope stability hangover flag */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t last_sfm, /* i : last coded subband */ - const float *CodeBook, /* i : Noise-fill codebook */ - const float *CodeBook_mod, /* i : Densified noise-fill codebook */ - const int16_t cb_size, /* i : Codebook length */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t *sfmsize, /* i : Subband band width */ - float *coeff /* i/o: coded/noisefilled spectrum */ -); - -void harm_bwe_fine( - const int16_t *R, /* i : bit allocation */ - const int16_t last_sfm, /* i : last coded subband */ - const int16_t high_sfm, /* i : higher transition band to BWE */ - const int16_t num_sfm, /* i : total number of bands */ - const int16_t *norm, /* i : quantization indices for norms */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - int16_t *prev_L_swb_norm, /* i/o: last normalize length */ - float *coeff, /* i/o: coded/noisefilled normalized spectrum */ - float *coeff_out, /* o : coded/noisefilled spectrum */ - float *coeff_fine /* o : BWE fine structure */ -); - -void hvq_bwe_fine( - const int16_t last_sfm, /* i : last coded subband */ - const int16_t num_sfm, /* i : total number of bands */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t *peak_idx, /* i : Peak index */ - const int16_t Npeaks, /* i : Number of peaks */ - int16_t *peak_pos, /* i/o: Peak positions */ - int16_t *prev_L_swb_norm, /* i/o: last normalize length */ - float *coeff, /* i/o: coded/noisefilled normalized spectrum */ - int16_t *bwe_peaks, /* o : Positions of peaks in BWE */ - float *coeff_fine /* o : HVQ BWE fine structure */ -); - -void hq_fold_bwe( - const int16_t last_sfm, /* i : last coded subband */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t num_sfm, /* i : Number of subbands */ - float *coeff /* i/o: coded/noisefilled normalized spectrum */ -); - -void apply_nf_gain( - const int16_t nf_idx, /* i : noise fill gain index */ - const int16_t last_sfm, /* i : last coded subband */ - const int16_t *R, /* i : bit allocation */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - float *coeff /* i/o: coded/noisefilled normalized spectrum */ - -); - -void hq_generic_fine( - float *coeff, /* i : coded/noisefilled normalized spectrum */ - const int16_t last_sfm, /* i : Last coded band */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - int16_t *bwe_seed, /* i/o: random seed for generating BWE input */ - float *coeff_out1 /* o : HQ GENERIC input */ -); - -void harm_bwe( - const float *coeff_fine, /* i : fine structure for BWE */ - const float *coeff, /* i : coded/noisefilled normalized spectrum */ - const int16_t num_sfm, /* i : Number of subbands */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t last_sfm, /* i : last coded subband */ - const int16_t high_sfm, /* i : higher transition band to BWE */ - const int16_t *R, /* i : bit allocation */ - const int16_t prev_hq_mode, /* i : previous hq mode */ - int16_t *norm, /* i/o: quantization indices for norms */ - float *noise_level, /* i/o: noise levels for harmonic modes */ - float *prev_noise_level, /* i/o: noise factor in previous frame */ - int16_t *bwe_seed, /* i/o: random seed for generating BWE input */ - float *coeff_out, /* o : coded/noisefilled spectrum */ - const int16_t element_mode /* i : element mode */ -); - -void hvq_bwe( - const float *coeff, /* i : coded/noisefilled spectrum */ - const float *coeff_fine, /* i : BWE fine structure */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t *sfm_len, /* i : Subband length */ - const int16_t last_sfm, /* i : last coded subband */ - const int16_t prev_hq_mode, /* i : previous hq mode */ - const int16_t *bwe_peaks, /* i : HVQ bwe peaks */ - const int16_t bin_th, /* i : HVQ transition bin */ - const int16_t num_sfm, /* i : Number of bands */ - const int32_t core_brate, /* i : Core bitrate */ - const int16_t *R, /* i : Bit allocation */ - int16_t *norm, /* i/o: quantization indices for norms */ - float *noise_level, /* i/o: noise levels for harmonic modes */ - float *prev_noise_level, /* i/o: noise factor in previous frame */ - int16_t *bwe_seed, /* i/o: random seed for generating BWE input */ - float *coeff_out /* o : coded/noisefilled spectrum */ -); - -void hvq_concat_bands( - const int16_t pvq_bands, /* i : Number of bands in concatenated PVQ target */ - const int16_t *sel_bnds, /* i : Array of selected high bands */ - const int16_t n_sel_bnds, /* i : Number of selected high bands */ - int16_t *hvq_band_start, /* o : Band start indices */ - int16_t *hvq_band_width, /* o : Band widths */ - int16_t *hvq_band_end /* o : Band end indices */ -); - -void hq_generic_bwe( - const int16_t HQ_mode, /* i : HQ mode */ - float *coeff_out1, /* i/o: BWE input & temporary buffer */ - const float *hq_generic_fenv, /* i : SWB frequency envelopes */ - float *coeff_out, /* o : SWB signal in MDCT domain */ - const int16_t hq_generic_offset, /* i : frequency offset for representing hq generic*/ - int16_t *prev_L_swb_norm, /* i/o: last normalize length */ - const int16_t hq_generic_exc_clas, /* i : hq generic hf excitation class */ - const int16_t *sfm_end, /* i : End of bands */ - const int16_t num_sfm, /* i : Number of bands */ - const int16_t num_env_bands, /* i : Number of coded envelope bands */ - const int16_t *R /* i : Bit allocation */ -); - -void map_hq_generic_fenv_norm( - const int16_t hqswb_clas, /* i : signal classification flag */ - const float *hq_generic_fenv, /* i : HQ GENERIC envelope */ - int16_t *ynrm, /* o : high band norm indices */ - int16_t *normqlg2, /* o : high band norm values */ - const int16_t num_env_bands, /* i : Number coded envelope bands */ - const int16_t nb_sfm, /* i : Number of envelope bands */ - const int16_t hq_generic_offset /* i : Freq offset for HQ GENERIC */ -); - -/*! r: Number of bits consumed for the delta coding */ -int16_t calc_nor_delta_hf( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const float *t_audio, /* i : transform-domain coefficients */ - int16_t *ynrm, /* i/o: norm indices */ - int16_t *Rsubband, /* i/o: sub-band bit allocation */ - const int16_t num_env_bands, /* i : Number coded envelope bands */ - const int16_t nb_sfm, /* i : Number of envelope bands */ - const int16_t *sfmsize, /* i : band length */ - const int16_t *sfm_start, /* i : Start index of bands */ - const int16_t core_sfm /* i : index of the end band for core */ -); - -/*! r: Number of bits consumed for the delta coding */ -int16_t get_nor_delta_hf( - Decoder_State *st, /* i/o: Decoder state */ - int16_t *ynrm, /* i/o: norm indices */ - int16_t *Rsubband, /* i/o: sub-band bit allocation */ - const int16_t num_env_bands, /* i : Number coded envelope bands */ - const int16_t nb_sfm, /* i : Number of envelope bands */ - const int16_t core_sfm ); /* i : index of the end band for core */ - -void hq_wb_nf_bwe( - const float *coeff, /* i : coded/noisefilled normal. spectrum */ - const int16_t is_transient, /* i : is transient flag */ - const int16_t prev_bfi, /* i : previous bad frame indicator */ - const float *normq_v, /* i : norms */ - const int16_t num_sfm, /* i : Number of subbands */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t *sfmsize, /* i : Subband band width */ - const int16_t last_sfm, /* i : last coded subband */ - const int16_t *R, /* i : bit allocation */ - const int16_t prev_is_transient, /* i : previous transient flag */ - float *prev_normq, /* i/o: previous norms */ - float *prev_env, /* i/o: previous noise envelopes */ - int16_t *bwe_seed, /* i/o: random seed for generating BWE input */ - float *prev_coeff_out, /* i/o: decoded spectrum in previous frame */ - int16_t *prev_R, /* i/o: previous frame bit allocation info. */ - float *coeff_out /* o : coded/noisefilled spectrum */ -); - -/*! r: Number of bits */ -int16_t encode_envelope_indices( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t num_sfm, /* i : Number of subbands */ - const int16_t numnrmibits, /* i : Bitrate of fall-back coding mode */ - int16_t *difidx, /* i/o: Diff indices/encoded diff indices */ - int16_t *LCmode, /* o : Coding mode */ - const int16_t flag_pack, /* i : indicator of packing or estimating bits */ - const int16_t flag_HQ2, /* i : indicator of HQ2 core */ - const int16_t is_transient /* i : transient flag */ -); - -void diff_envelope_coding( - const int16_t is_transient, /* i : transient indicator */ - const int16_t num_env_bands, /* i : number of envelope bands to code */ - const int16_t start_norm, /* i : start of envelope coding */ - int16_t *ynrm, /* i/o: quantization indices for norms */ - int16_t *normqlg2, /* i/o: quantized norms */ - int16_t *difidx /* o : differential code */ -); - -/*! r: Number of bits */ -int16_t decode_envelope_indices( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t start_norm, /* i : First SDE encoded norm */ - const int16_t num_sfm, /* i : Number of norms */ - const int16_t numnrmibits, /* i : Bitrate of fall-back coding mode */ - int16_t *ynrm, /* o : Decoded norm indices */ - const int16_t flag_HQ2, /* i : indicator of HQ2 core */ - const int16_t is_transient /* i : transient flag */ -); - -/*! r: Number of bits */ -void dequantize_norms( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t start_norm, /* i : First SDE encoded norm */ - const int16_t num_sfm, /* i : Number of norms */ - const int16_t is_transient, /* i : Transient flag */ - int16_t *ynrm, /* o : Decoded norm indices */ - int16_t *normqlg2 /* o : Log2 of decoded norms */ -); - -void hq_configure( - const int16_t length, /* i : Frame length */ - const int16_t hqswb_clas, /* i : HQ SWB class */ - const int32_t core_brate, /* i : core bitrate */ - int16_t *num_sfm, /* o : Total number of subbands */ - int16_t *nb_sfm, /* o : Total number of coded bands */ - int16_t *start_norm, /* o : First norm to be SDE encoded */ - int16_t *num_sde_norm, /* o : Number of norms for SDE encoding */ - int16_t *numnrmibits, /* o : Number of bits in fall-back norm encoding */ - int16_t *hq_generic_offset, /* o : Freq offset for HQ GENERIC */ - int16_t *sfmsize, /* o : Subband bandwidths */ - int16_t *sfm_start, /* o : Subband start coefficients */ - int16_t *sfm_end /* o : Subband end coefficients */ -); - -/*! r: Consumed bits */ -int16_t hvq_enc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t bwidth, /* i : audio bandwidth */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t hvq_bits, /* i : HVQ bit budget */ - const int16_t Npeaks, /* i : Number of peaks */ - const int16_t *ynrm, /* i : Envelope coefficients */ - int16_t *R, /* i/o: Bit allocation/updated bit allocation */ - int16_t *peaks, /* i/o: Peak pos. / Encoded peak pos. */ - float *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */ - float *noise_level, /* o : Quantized noise level */ - const float *pe_gains, /* i : Peak gains */ - const float *coefs, /* i : spectrum coefficients */ - float *coefs_out /* o : encoded spectrum coefficients */ -); -/*! r: Consumed bits */ -int16_t hq_classifier_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t core_brate, /* i : Core bitrate */ - const int16_t length, /* i : Frame length */ - int16_t *is_transient, /* o : Transient flag */ - int16_t *hqswb_clas /* o : HQ class */ -); - -void hq_bit_allocation( - const int32_t core_brate, /* i : Core bitrate */ - const int16_t length, /* i : Frame length */ - const int16_t hqswb_clas, /* i : HQ class */ - int16_t *num_bits, /* i/o: Remaining bit budget */ - const int16_t *normqlg2, /* i : Quantized norms */ - const int16_t nb_sfm, /* i : Number sub bands to be encoded */ - const int16_t *sfmsize, /* i : Sub band bandwidths */ - float *noise_level, /* o : HVQ noise level */ - int16_t *R, /* o : Bit allocation per sub band */ - int16_t *Rsubband, /* o : Fractional bit allocation (Q3) */ - int16_t *sum, /* o : Sum of allocated shape bits */ - int16_t *core_sfm, /* o : Last coded band in core */ - const int16_t num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */ -); - -void enforce_zero_for_min_envelope( - const int16_t hqswb_clas, /* i : HQ coding class */ - const int16_t *ynrm, /* i : Envelope indices */ - float *coefsq, /* i/o: Quantized spectrum/zeroed spectrum */ - int16_t nb_sfm, /* i : Number of coded sub bands */ - const int16_t *sfm_start, /* i : Sub band start indices */ - const int16_t *sfm_end /* i : Sub band end indices */ -); - -void apply_envelope( - const float *coeff, /* i/o: Coded/noisefilled normalized spectrum */ - const int16_t *norm, /* i : Envelope */ - const float *norm_adj, /* i : Envelope adjustment */ - const int16_t num_sfm, /* i : Total number of bands */ - const int16_t last_sfm, /* i : Last coded band */ - const int16_t HQ_mode, /* i : HQ mode */ - const int16_t length, /* i : Frame length */ - const int16_t *sfm_start, /* i : Sub band start indices */ - const int16_t *sfm_end, /* i : Sub band end indices */ - float *normq_v, /* o : Envelope with adjustment */ - float *coeff_out, /* o : coded/noisefilled spectrum */ - float *coeff_out1 /* o : noisefilled spectrum for HQ SWB BWE */ -); - -void apply_envelope_enc( - float *coeff, /* i/o: Normalized/scaled normalized spectrum */ - const int16_t *norm, /* i : Envelope */ - const int16_t num_sfm, /* i : Total number of bands */ - const int16_t *sfm_start, /* i : Sub band start indices */ - const int16_t *sfm_end /* i : Sub band end indices */ -); - -/*! r: Leading_sign_index, index, size, k_val */ -PvqEntry mpvq_encode_vec( - const int16_t *vec_in, /* i : Signed pulse train */ - const int16_t dim_in, /* i : Dimension */ - int16_t k_val_local /* i/o: Num unit pulses */ -); - -/*! r: Size, dim, k_val */ -PvqEntry get_size_mpvq_calc_offset( - const int16_t dim_in, /* i : Dimension */ - const int16_t k_val_in, /* i : Num unit pulses */ - uint32_t *h_mem /* o : Offsets */ -); - -void mpvq_decode_vec( - const PvqEntry *entry, /* i : Sign_ind, index, dim, k_val */ - uint32_t *h_mem, /* i : A/U offsets */ - int16_t *vec_out /* o : Pulse train */ -); - -/*! r: Multiplication result */ -uint32_t UMult_32_32( - const uint32_t UL_var1, /* i : factor 1 */ - const uint32_t UL_var2 /* i : factor 2 */ -); - -/*! r: inverse */ -uint32_t UL_inverse_float( - const uint32_t UL_val, /* i : input value Q_exp */ - int16_t *exp /* i/o: input exp / result exp */ -); - -/*! r: ratio */ -Word16 ratio_float( - const Word32 numer, /* i : numerator */ - const Word32 denom, /* i : denominator */ - Word16 *expo /* i/o: input exp / result exp */ -); - -/*! r: Angle between 0 and EVS_PI/2 radian (Q14) */ -Word16 atan2_fx_flt( - const Word32 y, /* i : near side (Argument must be positive) (Q15) */ - const Word32 x /* i : opposite side (Q15) */ -); - -void pvq_encode_frame( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const float *coefs_norm, /* i : normalized coefficients to encode */ - float *coefs_quant, /* o : quantized coefficients */ - float *gopt, /* o : optimal shape gains */ - int16_t *npulses, /* o : number of pulses per band */ - int16_t *pulse_vector, /* o : non-normalized pulse shapes */ - const int16_t *sfm_start, /* i : indices of first coefficients in the bands */ - const int16_t *sfm_end, /* i : indices of last coefficients in the bands */ - const int16_t *sfmsize, /* i : band sizes */ - const int16_t nb_sfm, /* i : total number of bands */ - const int16_t *R, /* i : bitallocation per band (Q3) */ - const int16_t pvq_bits, /* i : number of bits avaiable */ - const int16_t core /* i : core */ -); - -void pvq_decode_frame( - Decoder_State *st, /* i/o: Decoder state */ - float *coefs_quant, /* o : quantized coefficients */ - int16_t *npulses, /* o : number of pulses per band */ - int16_t *pulse_vector, /* o : non-normalized pulse shapes */ - const int16_t *sfm_start, /* i : indices of first coeffs in the bands */ - const int16_t *sfm_end, /* i : indices of last coeffs in the bands */ - const int16_t *sfmsize, /* i : band sizes */ - const int16_t nb_sfm, /* i : total number of bands */ - const int16_t *R, /* i : bitallocation per band (Q3) */ - const int16_t pvq_bits, /* i : number of bits avaiable */ - const int16_t core /* i : core */ -); - -void srt_vec_ind( - const int16_t *linear, /* linear input */ - int16_t *srt, /* sorted output */ - int16_t *I, /* index for sorted output */ - const int16_t length ); - -void srt_vec_ind_f( - const float *linear, /* linear input */ - float *srt, /* sorted output */ - int16_t *I, /* index for sorted output */ - const int16_t length /* length of vector */ -); - -/*! r: floor(sqrt(input)) */ -uint32_t floor_sqrt_exact( - const uint32_t input /* i : unsigned input [0.. UINT_MAX/4] */ -); - -void fine_gain_quant( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t *ord, /* i : Indices for energy order */ - const int16_t num_sfm, /* i : Number of bands */ - const int16_t *gain_bits, /* i : Gain adjustment bits per sub band */ - float *fg_pred, /* i/o: Predicted gains / Corrected gains */ - const float *gopt /* i : Optimal gains */ -); - -void apply_gain( - const int16_t *ord, /* i : Indices for energy order */ - const int16_t *band_start, /* i : Sub band start indices */ - const int16_t *band_end, /* i : Sub band end indices */ - const int16_t num_sfm, /* i : Number of bands */ - const float *gains, /* i : Band gain vector */ - float *xq /* i/o: float synthesis / gain adjusted synth */ -); - -void fine_gain_pred( - const int16_t *sfm_start, /* i : Sub band start indices */ - const int16_t *sfm_end, /* i : Sub band end indices */ - const int16_t *sfm_size, /* i : Sub band bandwidths */ - const int16_t *i_sort, /* i : Energy sorting indices */ - const int16_t *K, /* i : Number of pulses per band */ - const int16_t *maxpulse, /* i : Maximum pulse per band */ - const int16_t *R, /* i : Bits per sub band (Q3) */ - const int16_t num_sfm, /* i : Number of sub bands */ - float *xq, /* i/o: Quantized vector /quantized vector with finegain adj */ - int16_t *y, /* i/o: Quantized vector */ - float *fg_pred, /* o : Predicted fine gains */ - const int16_t core /* i : Core */ -); - -void fine_gain_dec( - Decoder_State *st, /* i/o: Decoder state struct */ - const int16_t *ord, /* i : Indices for energy order */ - const int16_t num_sfm, /* i : Number of bands */ - const int16_t *gain_bits, /* i : Gain adjustment bits per sub band */ - float *fg_pred /* i/o: Predicted gains / Corrected gains */ -); - -void get_max_pulses( - const int16_t *band_start, /* i : Sub band start indices */ - const int16_t *band_end, /* i : Sub band end indices */ - const int16_t *k_sort, /* i : Indices for sorting by energy */ - const int16_t *npulses, /* i : Pulses per sub band */ - const int16_t BANDS, /* i : Number of bands */ - int16_t *inp_vector, /* i/o: Encoded shape vectors */ - int16_t *maxpulse /* o : Maximum pulse height per band */ -); - -Word32 ar_div_ivas( - Word32 num, - Word32 denum ); - -void ar_encoder_start( - PARCODEC arInst, - TCQ_PBITSTREAM bsInst, - int16_t max_bits ); - -void ar_decoder_start( - PARCODEC arInst, - TCQ_PBITSTREAM bsInst ); - -void ar_encoder_done( - PARCODEC arInst ); - -void ar_decoder_done( - PARCODEC arInst ); - - -Word32 Mult_32_16( - Word32 a, - Word16 b ); - -Word32 Mult_32_32( - Word32 a, - Word32 b ); - - -void decode_mangitude_tcq_fx_ivas( - ARCODEC *pardec, - Word16 size, - Word16 npulses, - Word16 nzpos, - Word32 *positions, - Word32 *out, - Word32 *surplus_fx ); - -void decode_signs_fx_ivas( - ARCODEC *pardec, - Word16 size, - Word32 *out ); - -void srt_vec_ind_fx_ivas( - const Word32 *linear, - Word32 *srt, - Word16 *I, - Word16 length ); - - -void bit_allocation_second_fx2( - Word32 *Rk, - Word32 *Rk_sort, - Word16 BANDS, - const Word16 *band_width, - Word16 *k_sort, - Word16 *k_num, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame ); - - -Word32 encode_magnitude_tcq_fx_ivas( - ARCODEC *parenc, - float *magn_fx, - Word16 size, - Word16 npulses, - Word16 nzpos, - Word32 *savedstates, - Word32 *est_frame_bits_fx ); - -Word32 encode_signs_fx_ivas( - ARCODEC *parenc, - float *magn, - Word16 size, - Word16 npos, - Word32 *est_frame_bits_fx ); - -Word32 encode_magnitude_usq_fx_ivas( - ARCODEC *parenc, - float *magn_fx, - Word16 size, - Word16 npulses, - Word16 nzpos, - Word32 *est_frame_bits_fx ); - -ivas_error tcq_core_LR_enc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - int32_t inp_vector[], - const float coefs_norm[], - float coefs_quant[], - const int16_t bit_budget, /* number of bits */ - const int16_t nb_sfm, - const int16_t *sfm_start, - const int16_t *sfm_end, - const int16_t *sfmsize, - Word32 *Rk_fx, - int16_t *npulses, - int16_t *k_sort, - const int16_t *p2a_flags, - const int16_t p2a_bands, - const int16_t *last_bitalloc, - const int16_t input_frame, - const int16_t adjustFlag, - const int16_t is_transient ); - -void tcq_core_LR_dec( - Decoder_State *st, - int32_t *inp_vector, - const int16_t bit_budget, - const int16_t bands, - const int16_t *band_start, - const int16_t *band_width, - Word32 *Rk_fx, - int16_t npulses[], - int16_t *k_sort, - const int16_t *p2a_flags, - const int16_t p2a_bands, - const int16_t *last_bitalloc, - const int16_t input_frame, - const int16_t adjustFlag, - const int16_t *is_transient ); - - -void TCQLSB( - int16_t bcount, - float *abuffer, - float *mbuffer, - float *sbuffer, - int16_t *dpath ); - -void RestoreTCQ( - float *magn, - int16_t size, - int16_t *bcount, - float *mbuffer ); - -void SaveTCQdata( - PARCODEC arInst, - int16_t *dpath, - int16_t bcount ); - -void LoadTCQdata( - PARCODEC arInst, - int16_t *dpath, - int16_t bcount ); - -void RestoreTCQdec( - int32_t *magn, - int16_t size, - int16_t *bcount, - float *mbuffer ); - -void TCQLSBdec( - int16_t *dpath, - float *mbuffer, - int16_t bcount ); - -void bit_allocation_second_fx2( - Word32 *Rk, - Word32 *Rk_sort, - Word16 BANDS, - const Word16 *band_width, - Word16 *k_sort, - Word16 *k_num, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame ); - -void io_ini_enc( - const int32_t argc, /* i : command line arguments number */ - char *argv[], /* i : command line arguments */ - FILE **f_input, /* o : input signal file */ - FILE **f_stream, /* o : output bitstream file */ - FILE **f_rate, /* o : bitrate switching profile (0 if N/A) */ - FILE **f_bwidth, /* o : bandwidth switching profile (0 if N/A) */ - FILE **f_metadata, /* o : metadata files (NULL if N/A) */ -#ifdef DEBUGGING - FILE **f_force, /* o : force switching profile (0 if N/A) */ -#endif - FILE **f_rf, /* o : channel aware configuration file */ - int16_t *quietMode, /* o : limit printouts */ - int16_t *noDelayCmp, /* o : turn off delay compensation */ - Encoder_Struct *st /* o : IVAS encoder structure */ -); - -void read_next_rfparam( - int16_t *rf_fec_offset, /* o : RF offset */ - int16_t *rf_fec_indicator, /* o : RF FEC indicator */ - FILE *f_rf /* i : file pointer to read parameters */ -); - -void read_next_brate( - int32_t *total_brate, /* i/o: total bitrate */ - const int32_t last_total_brate, /* i : last total bitrate */ - FILE *f_rate, /* i : bitrate switching profile (0 if N/A) */ - const int16_t element_mode, /* i : IVAS element mode */ - int32_t input_Fs, /* i : input sampling frequency */ - int16_t *Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - int16_t *Opt_SC_VBR, /* i/o: SC-VBR flag */ - int16_t *codec_mode /* i/o: Mode 1 or 2 */ -); - -void read_next_bwidth( - int16_t *max_bwidth, /* i/o: maximum encoded bandwidth */ - FILE *f_bwidth, /* i : bandwidth switching profile (0 if N/A) */ - int32_t *bwidth_profile_cnt, /* i/o: counter of frames for bandwidth switching profile file */ - int32_t input_Fs /* i : input sampling rate */ -); - -#ifdef DEBUGGING -void read_next_force( - int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/ - FILE *f_force, /* i : force switching profile (0 if N/A) */ - int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */ -); -#endif - -ivas_error init_encoder_ivas_fx( - Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - const Word16 idchan, /* i : channel ID */ - const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ - const Word16 interval_SID, /* i : interval for SID update */ - const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const Word32 element_brate /* i : element bitrate */ -); - -void LPDmem_enc_init( - LPD_state_HANDLE hLPDmem /* i/o: LP memories */ -); - -ivas_error evs_enc( - Encoder_State *st, /* i/o: state structure */ - const int16_t *data, /* i : input signal */ - float *mem_hp20_in, /* i/o: hp20 filter memory */ - const int16_t n_samples /* i : number of input samples */ -); -void amr_wb_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t *data, /* i : input signal */ - float *mem_hp20_in, /* i/o: hp20 filter memory */ - const int16_t n_samples /* i : number of input samples */ -); - -void sc_vbr_enc_init( - SC_VBR_ENC_HANDLE hSC_VBR /* i/o: SC-VBR encoder handle */ -); - -void amr_wb_enc_init( - AMRWB_IO_ENC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO encoder handle */ -); - -void pre_proc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t input_frame, /* i : frame length */ - float old_inp_12k8[], /* i/o: buffer of old input signal */ - float old_inp_16k[], /* i/o: buffer of old input signal @ 16kHz */ - float **inp, /* o : ptr. to inp. signal in the current frame*/ - float fr_bands[2 * NB_BANDS], /* i : energy in frequency bands */ - float *ener, /* o : residual energy from Levinson-Durbin */ - int16_t pitch_orig[3], /* o : open-loop pitch values for quantization */ - float A[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */ - float Aw[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */ - float epsP[M + 1], /* i/o: LP prediction errors */ - float lsp_new[M], /* i/o: LSPs at the end of the frame */ - float lsp_mid[M], /* i/o: LSPs in the middle of the frame */ - int16_t *vad_hover_flag, /* i : VAD hangover flag */ - int16_t *attack_flag, /* o : attack flag */ - float *new_inp_resamp16k, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ - int16_t *Voicing_flag, /* o : voicing flag for HQ FEC */ - float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */ - float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */ - int16_t *hq_core_type /* o : HQ core type */ -); - - -/*! r: HQ_CORE/TCX_20_CORE decision */ -int16_t mdct_classifier( - Encoder_State *st, /* i/o: Encoder state variable */ - const float *fft_buff, /* i : FFT spectrum from fft_rel */ - const float enerBuffer[], /* i : energy buffer */ - const int32_t brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ -); - -void MDCT_selector( - Encoder_State *st, /* i/o: Encoder State */ - const float sp_floor, /* i : Noise floor estimate */ - const float Etot, /* i : Total energy */ - const float cor_map_sum, /* i : sum of correlation map */ - const float enerBuffer[] /* i : energy buffer */ -); - -ivas_error acelp_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 inp[], /* i : input signal of the current frame Q_new*/ - Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ - Word16 *q_old_syn_12k8_16, - Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ - Word16 *unbits, /* o : number of unused bits Q0*/ - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ - Word16 Q_new ); - -ivas_error acelp_core_switch_dec_bfi( - Decoder_State *st /* i/o: decoder state structure */ -); - -void acelp_core_switch_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const float inp12k8[], /* i : input signal @12.8 kHz */ - const float inp16k[], /* i : input signal @16 kHz */ - const float A[NB_SUBFR16k * ( M + 1 )] /* i : A(z) unquantized for the 4 subframes */ -); - -/*! r: length of output */ -int16_t modify_Fs_intcub3m_sup( - const float sigIn[], /* i : signal to decimate with memory of 2 samples (indexes -2 & -1) */ - const int16_t lg, /* i : length of input */ - const int32_t fin, /* i : frequency of input */ - float sigOut[], /* o : decimated signal */ - const int32_t fout, /* i : frequency of output */ - int16_t *delayout /* o : delay of output */ -); - -void core_switching_OLA( - const float *mem_over_hp, /* i : upsampling filter memory */ - const int16_t last_L_frame, /* i : last L_frame lengthture */ - const int32_t output_Fs, /* i : output sampling rate */ - float *synth, /* i/o: synthesized signal from HQ core */ - const float *synth_subfr_out, /* i : synthesized signal from ACELP core */ - float *synth_subfr_bwe, /* i : synthesized BWE from ACELP core */ - const int16_t output_frame, /* i : output frame length */ - const int16_t bwidth /* i : output bandwidth */ -); - -void retro_interp4_5( - const float *syn, - float *pst_old_syn ); - -void retro_interp5_4( - float *pst_old_syn ); -void core_switching_hq_prepare_dec( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *num_bits, /* i/o: bit budget update */ - const int16_t input_frame /* i : input frame length */ -); - -ivas_error acelp_core_switch_dec( - Decoder_State *st, /* i/o: decoder structure */ - float *synth_subfr_out, /* o : synthesized ACELP subframe */ - float *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE */ - const int16_t output_frame, /* i : input frame length */ - const int16_t core_switching_flag, /* i : core switching flag */ - float *mem_synth, /* o : synthesis to overlap */ - const int16_t nchan_out /* i : number of output channels */ -); - -void ResetSHBbuffer_Enc( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ -); - -void ResetSHBbuffer_Dec( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const int16_t extl /* i : BWE extension layer */ -); - -void calc_st_filt( - const float *apond2, /* i : coefficients of numerator */ - const float *apond1, /* i : coefficients of denominator */ - float *parcor0, /* o : 1st parcor calcul. on composed filter */ - float *sig_ltp_ptr, /* i/o: input of 1/A(gamma1) : scaled by 1/g0 */ - float *mem_zero, /* i/o: All zero memory */ - const int16_t L_subfr, /* i : the length of subframe */ - const int16_t extl /* i : extension layer info */ -); - - -void scale_st_ivas( - const float *sig_in, /* i : postfilter input signal */ - float *sig_out, /* i/o: postfilter output signal */ - float *gain_prec, /* i/o: last value of gain for subframe */ - const int16_t L_subfr, /* i : the length of subframe */ - const int16_t extl /* i : extension layer info */ -); - -void filt_mu( - const float *sig_in, /* i : signal (beginning at sample -1) */ - float *sig_out, /* o : output signal */ - const float parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - const int16_t L_subfr, /* i : the length of subframe */ - const int16_t extl /* i : extension layer info */ -); - -void PostShortTerm( - float *sig_in, /* i : input signal (ptr. to current subframe */ - float *lpccoeff, /* i : LPC coefficients for current subframe */ - float *sig_out, /* o : postfiltered output */ - float *mem_stp, /* i/o: postfilter memory */ - float *ptr_mem_stp, /* i/o: pointer to postfilter memory */ - float *ptr_gain_prec, /* i/o: for gain adjustment */ - float *mem_zero, /* i/o: null memory to compute h_st */ - const float formant_fac /* i : Strength of post-filter [0,1] */ -); - -/*! r: Formant filter strength [0,1] */ -float swb_formant_fac( - const float lpc_shb2, /* i : 2nd HB LPC coefficient */ - float *tilt_mem /* i/o: Tilt smoothing memory */ -); - -void GenShapedSHBExcitation( - float *excSHB, /* o : synthesized shaped shb exctiation */ - const float *lpc_shb, /* i : lpc coefficients */ - float *exc16kWhtnd, /* o : whitened synthesized shb excitation */ - float *mem_csfilt, /* i/o: memory */ - float *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - float *state_lpc_syn, /* i/o: memory */ - const int16_t coder_type, /* i : coding type */ - const float *bwe_exc_extended, /* i : bandwidth extended excitation */ - int16_t bwe_seed[], /* i/o: random number generator seed */ - float voice_factors[], /* i : voicing factor */ - const int16_t extl, /* i : extension layer */ - float *tbe_demph, /* i/o: de-emphasis memory */ - float *tbe_premph, /* i/o: pre-emphasis memory */ - float *lpc_shb_sf, /* i : LP coefficients */ - float *shb_ener_sf, /* i : SHB subframe energies */ - float *shb_res_gshape, /* i : SHB LP residual gain shape */ - float *shb_res, /* i : SHB residual used in encoder only */ - int16_t *vf_ind, /* i/o: Mixing factor index */ - const float formant_fac, /* i : Formant sharpening factor [0..1] */ - float fb_state_lpc_syn[], /* i/o: memory */ - float *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - const int32_t total_brate, /* i : overall bitrate */ - const int16_t prev_bfi, /* i : previous frame was lost flag */ - const int16_t element_mode, /* i : element mode */ - const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */ - float *nlExc16k, /* i/o: NL exc for IC-BWE */ - float *mixExc16k, /* i/o: exc spreading for IC-BWE */ - const int32_t extl_brate, /* i : TD BWE bitrate */ - const int16_t MSFlag, /* i : Multi-source flag */ - float EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ - float *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - float *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - float *Env_error, /* o : error in SHB residual envelope modelling*/ - float Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ -); - -void GenSHBSynth( - const float *shb_target_speech, /* i : input synthesized speech */ - float *shb_syn_speech_32k, /* o : output highband component */ - float Hilbert_Mem[], /* i/o: memory */ - float state_lsyn_filt_shb_local[], /* i/o: memory */ - const int16_t L_frame, /* i : ACELP Frame length */ - int16_t *syn_dm_phase ); - -void ScaleShapedSHB( - const int16_t length, /* i : SHB overlap length */ - float *synSHB, /* i/o: synthesized shb signal */ - float *overlap, /* i/o: buffer for overlap-add */ - const float *subgain, /* i : subframe gain */ - const float frame_gain, /* i : frame gain */ - const float *win, /* i : window */ - const float *subwin /* i : subframes window */ -); - -void Interpolate_allpass_steep( - const float *in, /* i : input array of size N */ - float *mem, /* i/o: memory */ - const int16_t N, /* i : number of input samples */ - float *out /* o : output array of size 2*N */ -); - -void Decimate_allpass_steep( - const float *in, /* i : input array of size N */ - float *mem, /* i/o: memory */ - const int16_t N, /* i : number of input samples */ - float *out /* o : output array of size N/2 */ -); - -void interpolate_3_over_2_allpass( - const float *input, /* i : input signal */ - const int16_t len, /* i : number of input samples */ - float *out, /* o : output signal */ - float *mem /* i/o: memory */ -); - -void decimate_2_over_3_allpass( - const float *input, /* i : input signal */ - const int16_t len, /* i : number of input samples */ - float *out, /* o : output signal */ - float *mem, /* i/o: memory */ - float *lp_mem ); - -void interpolate_3_over_1_allpass( - const float *input, /* i : input signal */ - const int16_t len, /* i : number of input samples */ - float *out, /* o : output signal */ - float *mem /* i/o: memory */ -); - -void InitSWBencBuffer( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ -); - -void InitSWBencBufferStates( - TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - float *shb_speech /* o : SHB target signal (6-14kHz) at 16kHz */ -); - -void swb_tbe_enc( - Encoder_State *st, /* i/o: encoder state structure */ - STEREO_ICBWE_ENC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ - const float *new_speech, /* i : original input signal */ - const float *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const float voice_factors[], /* i : voicing factors */ - float *White_exc16k, /* o : shaped white excitation for the FB TBE */ - const float pitch_buf[] /* i : pitch for each subframe */ -); - -void swb_tbe_dec( - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ - const float *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const float voice_factors[], /* i : voicing factors */ - const float old_syn_12k8_16k[], /* i : low band synthesis at 12.8kHz or 16kHz */ - float *White_exc16k, /* o : shaped white excitation for the FB TBE */ - float *synth, /* i/o: ACELP core synthesis/final synthesis */ - float *pitch_buf ); - -void flip_and_downmix_generic( - float input[], /* i : input spectrum */ - float output[], /* o : output spectrum */ - const int16_t length, /* i : length of spectra */ - float mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */ - float mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */ - float mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */ - int16_t *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ -); -void flip_and_downmix_generic_fx_32( - Word32 input[], /* i : input spectrum Qx*/ - Word32 output[], /* o : output spectrum Qx*/ - const Word16 length, /* i : length of spectra */ - Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ - Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ - Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ - Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ -); -void non_linearity( - const float input[], /* i : input signal */ - float output[], /* i : output signal */ - float old_bwe_exc_extended[], /* i/o: memory bugffer */ - const int16_t length, /* i : input length */ - float *prev_scale, /* i/o: memory */ - const int16_t coder_type, /* i : Coder Type */ - const float *voice_factors, /* i : Voice Factors */ - const int16_t L_frame /* i : ACELP frame length */ -); - -void interp_code_5over2( - const float inp_code[], /* i : input vector */ - float interp_code[], /* o : output vector */ - const int16_t inp_length /* i : length of the input vector */ -); - -void interp_code_4over2( - const float inp_code[], /* i : input vector */ - float interp_code[], /* o : output vector */ - const int16_t inp_length /* i : length of the input vector */ -); - -void flip_spectrum_and_decimby4( - const float input[], /* i : input spectrum */ - float output[], /* o : output spectrum */ - const int16_t length, /* i : vector length */ - float mem1[], /* i/o: memory */ - float mem2[], /* i/o: memory */ - const int16_t ramp_flag /* i : flag to trigger slow ramp-up of output */ -); - -void GenShapedWBExcitation( - float *excSHB, /* o : synthesized shaped shb exctiation */ - const float *lpc_shb, /* i : lpc coefficients */ - float *exc4kWhtnd, /* o : whitened synthesized shb excitation */ - float *mem_csfilt, /* i/o: memory */ - float *mem_genSHBexc_filt_down1, /* i/o: memory */ - float *mem_genSHBexc_filt_down2, /* i/o: memory */ - float *mem_genSHBexc_filt_down3, /* i/o: memory */ - float *state_lpc_syn, /* i/o: memory */ - const int16_t coder_type, /* i : coding type */ - const float *bwe_exc_extended, /* i : bandwidth extended exciatation */ - int16_t bwe_seed[], /* i/o: random number generator seed */ - const float voice_factors[], /* i : voicing factor */ - const int16_t uv_flag, /* i : unvoiced flag */ - const int16_t igf_flag ); - -void GenWBSynth( - const float *input_synspeech, /* i : input synthesized speech */ - float *shb_syn_speech_16k, /* o : output highband compnent */ - float *state_lsyn_filt_shb1, /* i/o: memory */ - float *state_lsyn_filt_shb2 /* i/o: memory */ -); - -void wb_tbe_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const float *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz */ - const float *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const float pitch_buf[], /* i : pitch for each subframe */ - const float voicing[] /* o : OL maximum normalized correlation */ -); - -void wb_tbe_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const float *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const float voice_factors[], /* i : voicing factors */ - float *synth /* i/o: ACELP core synthesis/final synthesis */ -); - -void tbe_write_bitstream( - Encoder_State *st /* i/o: encoder state structure */ -); - -void tbe_read_bitstream( - Decoder_State *st /* i/o: decoder state structure */ -); - -void GenTransition( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - float *outputHB, /* o : synthesized HB transitions signal */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t element_mode, /* i : element mode */ - const int16_t L_frame, /* i : ACELP frame length */ - const int16_t rf_flag, /* i : RF flag */ - const int32_t total_brate /* i : total bitrate */ -); - - -void GenTransition_fixed( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs, /* i : output sampling rate : Q0 */ - const Word16 element_mode, /* i : element mode : Q0 */ - const Word16 L_frame, /* i : ACELP frame length : Q0 */ - const Word16 rf_flag, /* i : RF flag : Q0 */ - const Word32 total_brate, /* i : total bitrate : Q0 */ - const Word16 prev_Qx ); - -void GenTransition_WB( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - float *outputHB, /* o : synthesized HB transitions signal */ - const int32_t output_Fs /* i : output sampling rate */ -); - -void GenTransition_WB_fixed( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs /* i : output sampling rate */ -); - -void td_bwe_dec_init( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const int16_t extl, /* i : BWE extension layer */ - const int32_t output_Fs /* i : output sampling rate */ -); - -void TBEreset_enc( - TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const int16_t last_core, /* i : last core */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void TBEreset_dec( - Decoder_State *st /* i/o: decoder state structure */ -); - -/*! r: TBE bit consumption per frame */ -int16_t get_tbe_bits( - const int32_t total_brate, /* i : overall bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t rf_mode /* i : channel aware mode */ -); - -void fb_tbe_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const float new_input[], /* i : input speech at 48 kHz sample rate */ - const float fb_exc[] /* i : FB excitation from the SWB part */ -); - -void fb_tbe_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const float fb_exc[], /* i : FB excitation from the SWB part */ - float *hb_synth, /* i/o: high-band synthesis */ - float *fb_synth_ref, /* o : high-band synthesis 16-20 kHz */ - const int16_t output_frame /* i : output frame length */ -); - -void calc_tilt_bwe( - const float *sp, /* i : input signal */ - float *tilt, /* o : signal tilt */ - const int16_t N /* i : signal length */ -); - -void fd_bwe_enc_init( - FD_BWE_ENC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ -); - -void swb_pre_proc( - Encoder_State *st, /* i/o: encoder state structure */ - float *new_swb_speech, /* o : original input signal at 32kHz */ - float *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz */ - float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer */ - float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer */ - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ -); - -void wb_pre_proc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t last_element_mode, /* i : last element mode */ - const float *new_inp_resamp16k, /* i : original input signal */ - float *hb_speech /* o : HB target signal (6-8kHz) at 16kHz */ -); - -void wb_bwe_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const float *new_wb_speech /* i : original input signal at 16kHz */ -); - -void wb_bwe_dec_flt( - Decoder_State *st, /* i/o: decoder state structure */ - const float output[], /* i : synthesis @internal Fs */ - float *synth, /* i/o: ACELP core synthesis/final synthesis */ - float *hb_synth, /* o : SHB synthesis/final synthesis */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t output_frame, /* i : frame length */ - const float voice_factors[], /* i : voicing factors */ - const float pitch_buf[] /* i : pitch buffer */ -); - -void swb_bwe_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t last_element_mode, /* i : last element mode */ - const float *old_input_12k8, /* i : input signal @12.8kHz for SWB BWE */ - const float *old_input_16k, /* i : input signal @16kHz for SWB BWE */ - const float *old_syn_12k8_16k, /* i : ACELP core synthesis at 12.8kHz or 16kHz*/ - const float *new_swb_speech, /* i : original input signal at 32kHz */ - const float *shb_speech /* i : SHB target signal (6-14kHz) at 16kHz */ -); - -void swb_bwe_enc_hr( - Encoder_State *st, /* i/o: encoder state structure */ - const float *new_input, /* i : input signal */ - const int16_t input_frame, /* i : frame length */ - const int16_t unbits /* i : number of core unused bits */ -); - -void fd_bwe_dec_init_flt( - FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ -); - -void swb_bwe_dec_flt( - Decoder_State *st, /* i/o: decoder state structure */ - const float output[], /* i : synthesis @internal Fs */ - const float *synth, /* i : ACELP core synthesis/final synthesis */ - float *hb_synth, /* o : SHB synthesis/final synthesis */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t output_frame /* i : frame length */ -); - -void hr_bwe_dec_init_flt( - HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */ -); - -void swb_bwe_dec_hr( - Decoder_State *st, /* i/o: decoder state structure */ - const float *syn_12k8_16k, /* i : ACELP core synthesis @16kHz */ - float *hb_synth, /* o : SHB synthesis */ - const int16_t output_frame, /* i : frame length */ - const int16_t unbits, /* i : number of core unused bits */ - const float pitch_buf[] /* i : pitch buffer */ -); - - -void calc_normal_length( - const int16_t core, /* i : core */ - const float *sp, /* i : input signal */ - const int16_t mode, /* i : input mode */ - const int16_t extl, /* i : extension layer */ - int16_t *L_swb_norm, /* o : normalize length */ - int16_t *prev_L_swb_norm /* i/o: last normalize length */ -); - -void calc_norm_envelop( - const float SWB_signal[], /* i : SWB spectrum */ - float *envelope, /* o : normalized envelope */ - const int16_t L_swb_norm, /* i : length of envelope */ - const int16_t SWB_flength, /* i : Length of input/output */ - const int16_t st_offset /* i : offset */ -); - -void time_envelop_shaping( - float werr[], /* i/o: SHB synthesis */ - float SWB_tenv[], /* i/o: frequency envelope */ - const int16_t L /* i : frame length */ -); - -void time_reduce_pre_echo( - const float *synth, /* i : ACELP core synthesis */ - float *error, /* o : SHB BWE synthesis */ - float prev_td_energy, /* o : last td energy */ - const int16_t L /* i : subframe length */ -); - -int16_t WB_BWE_gain_pred( - float *WB_fenv, /* o : WB frequency envelopes */ - const float *core_dec_freq, /* i : Frequency domain core decoded signal */ - const int16_t coder_type, /* i : coding type */ - const int16_t prev_code_type, /* i : coding type of last frame */ - const float prev_WB_fenv, /* i : envelope for last frame */ - const float voice_factors[], /* i : voicing factors */ - const float pitch_buf[], /* i : pitch buffer */ - const int32_t last_core_brate, /* i : previous frame core bitrate */ - const float last_wb_bwe_ener, /* i : previous frame wb bwe signal energy */ - const int16_t last_extl, /* i : extl. layer for last frame */ - const float tilt ); - -void WB_BWE_decoding( - const float *core_dec_freq, /* i : Frequency domain core decoded signal */ - float *WB_fenv, /* i : WB frequency envelopes */ - float *WB_signal, /* o : WB signal in MDCT domain */ - const int16_t WB_flength, /* i : Length of input/output */ - const int16_t mode, /* i : classification for WB signal */ - const int16_t last_extl, /* i : extl. layer for last frame */ - float *prev_Energy, /* i/o: energy for last frame */ - float *prev_WB_fenv, /* i/o: envelope for last frame */ - int16_t *prev_L_wb_norm, /* i/o: length for last frame wb norm */ - const int16_t extl, /* i : extension layer */ - const int16_t coder_type, /* i : coding type */ - const int32_t total_brate, /* i : core layer bitrate */ - int16_t *Seed, /* i/o: random generator seed */ - int16_t *prev_flag, /* i/o: attenu flag of last frame */ - int16_t prev_coder_type /* i : coding type of last frame */ -); - -void SWB_BWE_decoding( - const float *core_dec_freq, /* i : Frequency domain core decoded signal */ - float *SWB_fenv, /* i/o: SWB frequency envelopes */ - float *SWB_signal, /* o : SWB signal in MDCT domain */ - const int16_t SWB_flength, /* i : Length of input/output */ - const int16_t mode, /* i : classification for SWB signal */ - int16_t *frica_flag, /* o : fricative signal flag */ - float *prev_Energy, /* i/o: energy for last frame */ - float *prev_SWB_fenv, /* i/o: envelope for last frame */ - int16_t *prev_L_swb_norm, /* i/o: length for last frame wb norm */ - const float tilt_nb, /* i : tilt of synthesis wb signal */ - int16_t *Seed, /* i/o: random generator seed */ - const int16_t st_offset, /* i : offset value due to different core */ - float *prev_weight, /* i/o: excitation weight value of last frame */ - const int16_t extl, /* i : extension layer */ - const int16_t last_extl /* i : extension layer of last frame */ -); - -void CNG_reset_enc( - Encoder_State *st, /* i/o: encoder state structure */ - float *pitch_buf, /* o : floating pitch for each subframe */ - float *voice_factors, /* o : voicing factors */ - int16_t VBR_cng_reset_flag ); - -/*! r: stability flag */ -uint16_t a2rc( - const float *a, /* i : LPC coefficients */ - float *refl, /* o : Reflection co-efficients */ - const int16_t lpcorder /* i : LPC order */ -); - - -void analy_sp( - const int16_t element_mode, /* i : element mode */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int32_t input_Fs, /* i : input sampling rate */ - float *speech, /* i : speech buffer */ - float *Bin_E, /* o : per bin log energy spectrum */ - float *Bin_E_old, /* o : per bin log energy spectrum for mid-frame */ - float *fr_bands, /* o : per band energy spectrum (2 analyses) */ - float lf_E[], /* o : per bin E for first VOIC_BINS bins (without DC) */ - float *Etot, /* o : total input energy */ - const int16_t min_band, /* i : minimum critical band */ - const int16_t max_band, /* i : maximum critical band */ - float *band_ener, /* o : energy in critical frequency bands without minimum noise floor E_MIN */ - float *PS, /* o : Per bin energy spectrum */ - float *fft_buff /* o : FFT coefficients */ -); - -void CNG_enc( - Encoder_State *st, /* i/o: State structure */ - float Aq[], /* o : LP coefficients */ - const float *speech, /* i : pointer to current frame input speech buffer */ - float enr, /* i : frame energy output from Levinson recursion */ - const float *lsp_mid, /* i : mid frame LSPs */ - float *lsp_new, /* i/o: current frame LSPs */ - float *lsf_new, /* i/o: current frame LSFs */ - int16_t *allow_cn_step, /* o : allow CN step */ - float *q_env, - int16_t *sid_bw ); - -void swb_CNG_enc( - Encoder_State *st, /* i/o: State structure */ - const float *shb_speech, /* i : SHB target signal (6-14kHz) at 16kHz */ - const float *syn_12k8_16k /* i : ACELP core synthesis at 12.8kHz or 16kHz */ -); - -void lsf_enc( - Encoder_State *st, /* i/o: state structure */ - float *lsf_new, /* o : quantized LSF vector */ - float *lsp_new, /* i/o: LSP vector to quantize/quantized */ - float *lsp_mid, /* i : mid-frame LSP vector */ - float *Aq, /* o : quantized A(z) for 4 subframes */ - const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const int16_t GSC_IVAS_mode, /* i : GSC IVAS mode */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -); - -void isf_enc_amr_wb( - Encoder_State *st, /* i/o: state structure */ - float *isf_new, /* o : quantized ISF vector */ - float *isp_new, /* i/o: ISP vector to quantize/quantized */ - float *Aq /* o : quantized A(z) for 4 subframes */ -); - -void find_targets( - const float *speech, /* i : pointer to the speech frame */ - const float *mem_syn, /* i : memory of the synthesis filter */ - const int16_t i_subfr, /* i : subframe index */ - float *mem_w0, /* i/o: weighting filter denominator memory */ - const float *p_Aq, /* i : interpolated quantized A(z) filter */ - const float *res, /* i : residual signal */ - const int16_t L_subfr, /* i : length of vectors for gain quantization */ - const float *Ap, /* i : unquantized A(z) filter with bandwidth expansion */ - const float tilt_fac, /* i : tilt factor */ - float *xn, /* o : Close-loop Pitch search target vector */ - float *cn, /* o : target vector in residual domain */ - float *h1 /* o : impulse response of weighted synthesis filter */ -); - -Word16 quant_2p_2N1_fx( /* o: return (2*N)+1 bits */ - const Word16 pos1, /* i: position of the pulse 1 */ - const Word16 pos2, /* i: position of the pulse 2 */ - const Word16 N /* i: number of bits FOR position */ -); -void find_tilt( - const float fr_bands[], /* i : energy in frequency bands */ - const float bckr[], /* i : per band background noise energy estimate */ - float ee[2], /* o : lf/hf E ration for present frame */ - const int16_t pitch[3], /* i : open loop pitch values for 3 half-frames */ - const float voicing[3], /* i : normalized correlation for 3 half-frames */ - const float *lf_E, /* i : per bin energy for low frequencies */ - const float corr_shift, /* i : normalized correlation correction */ - const int16_t bwidth, /* i : input signal bandwidth */ - const int16_t max_band, /* i : maximum critical band */ - float hp_E[], /* o : energy in HF */ - const int16_t codec_mode, /* i : Mode 1 or 2 */ - float *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise */ - int16_t Opt_vbr_mode ); - -void init_gp_clip( - float mem[] /* o : memory of gain of pitch clipping algorithm */ -); - -int16_t gp_clip( - const int16_t element_mode, /* i : element mode */ - const int32_t core_brate, /* i : core bitrate */ - const float *voicing, /* i : normalized correlations (from OL pitch) */ - const int16_t i_subfr, /* i : subframe index */ - const int16_t coder_type, /* i : coding type */ - const float xn[], /* i : target vector */ - float mem[] /* i/o: memory of gain of pitch clipping algorithm */ -); - -void gp_clip_test_lsf( - const int16_t element_mode, /* i : element mode */ - const int32_t core_brate, /* i : core bitrate */ - const float lsf[], /* i : LSF vector */ - float mem[], /* i/o: memory of gain of pitch clipping algorithm */ - const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ -); - -void gp_clip_test_gain_pit( - const int16_t element_mode, /* i : element mode */ - const int32_t core_brate, /* i : core bitrate */ - const float gain_pit, /* i : gain of quantized pitch */ - float mem[] /* i/o: memory of gain of pitch clipping algorithm */ -); - -void analy_lp( - const float speech[], /* i : pointer to the denoised speech frame */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t L_look, /* i : look-ahead length */ - float *ener, /* o : residual signal energy */ - float A[], /* o : A(z) filter coefficients */ - float epsP[], /* o : LP analysis residual energies for each iteration */ - float lsp_new[], /* o : current frame ISPs */ - float lsp_mid[], /* o : current mid-frame ISPs */ - float lsp_old[], /* i/o: previous frame unquantized ISPs */ - const int16_t Top[2], /* i : open loop pitch lag */ - const float Tnc[2], /* i : open loop pitch gain */ - const int32_t sr_core, /* i : internal sampling rate */ - const int16_t sec_chan_low_rate /* i : TD secondary channel flag */ -); - -void analy_lp_AMR_WB( - const float speech[], /* i : pointer to the speech frame */ - float *ener, /* o : residual energy from Levinson-Durbin */ - float A[], /* o : A(z) filter coefficients */ - float epsP[], /* o : LP analysis residual energies for each iteration */ - float isp_new[], /* o : current frame ISPs */ - float isp_old[], /* i/o: previous frame unquantized ISPs */ - float isf_new[], /* o : current frame ISFs */ - const int16_t Top, /* i : open loop pitch lag */ - const float Tnc /* i : open loop pitch gain */ -); - -void noise_est_init( - NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ -); - -void speech_music_clas_init( - SP_MUS_CLAS_HANDLE hSpMusClas /* i/o: speech/music classifier handle */ -); - -void long_enr( - Encoder_State *st, /* i/o: encoder state structure */ - const float Etot, /* i : total channel energy */ - const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */ - const int16_t high_lpn_flag, /* i : sp/mus LPN flag */ - FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */ - const int16_t n_chan, /* i : number of channels */ - const int16_t localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover LR channels */ - const float Etot_LR[] /* i : total channel energy LR channels */ -); - -void noise_est_pre( - const float Etot, /* i : Energy of current frame */ - const int16_t ini_frame, /* i : Frame number (init) */ - NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation data handle */ - const int16_t idchan, /* i : channel ID */ - const int16_t element_mode, /* i : element mode */ - const int16_t last_element_mode /* i : last element mode */ -); - -void noise_est_down( - const float fr_bands[], /* i : per band input energy (contains 2 vectors) */ - float bckr[], /* i/o: per band background noise energy estimate */ - float tmpN[], /* o : temporary noise update */ - float enr[], /* o : averaged energy over both subframes */ - const int16_t min_band, /* i : minimum critical band */ - const int16_t max_band, /* i : maximum critical band */ - float *totalNoise, /* o : noise estimate over all critical bands */ - const float Etot, /* i : Energy of current frame */ - float *Etot_last, /* i/o: Energy of last frame */ - float *Etot_v_h2 /* i/o: Energy variaions of noise frames */ -); - -void noise_est( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t old_pitch1, /* i : previous frame OL pitch[1] */ - const float tmpN[], /* i : temporary noise update */ - const float *epsP, /* i : LP prediction error energies */ - const float Etot, /* i : total channel E */ - const float relE, /* i : relative frame energy */ - const float corr_shift, /* i : normalized correlation correction */ - const float enr[], /* i : averaged energy over both subframes */ - float fr_bands[], /* i : spectrum per critical bands of the current frame */ - float *cor_map_sum, /* o : sum of correlation map from mult-harm analysis */ - float *ncharX, /* o : noise character for sp/mus classifier */ - float *sp_div, /* o : soectral diversity feature */ - float *non_staX, /* o : non-stationarity for sp/mus classifier */ - int16_t *loc_harm, /* o : multi-harmonicity flag for UV classifier */ - const float *lf_E, /* i : per bin energy for low frequencies */ - int16_t *st_harm_cor_cnt, /* i : 1st harm correlation timer */ - const float Etot_l_lp, /* i : Smoothed low energy */ - float *sp_floor, /* o : noise floor estimate */ - float S_map[], /* o : short-term correlation map */ - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - FRONT_VAD_ENC_HANDLE hFrontVad, /* i/o: front-VAD handle */ - const int16_t ini_frame /* i : Frame number (init) */ -); - -void vad_param_updt( - Encoder_State *st, /* i/o: encoder state structure */ - const float corr_shift, /* i : correlation shift */ - const float corr_shiftR, /* i : correlation shift right channel */ - const float A[], /* i : A(z) unquantized for the 4 subframes */ - const int16_t old_pitch1, /* i : previous frame OL pitch[1] */ - FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */ - const int16_t n_channels /* i : number of channels */ -); - - -void lp_gain_updt( - const int16_t i_subfr, /* i : subframe number */ - const float gain_pit, /* i : Decoded gain pitch */ - const float norm_gain_code, /* i : Normalised gain code */ - float *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) */ - float *lp_gainc, /* i/o: LP-filtered code gain (FEC) */ - const int16_t L_frame /* i : length of the frame */ -); - -void GSC_enc_init( - GSC_ENC_HANDLE hGSCEnc /* i/o: GSC data handle */ -); - - -/*! r: index of the last band where pitch contribution is significant */ -int16_t Pit_exc_contribution_len( - Encoder_State *st, /* i/o: state structure */ - const float *dct_res, /* i : DCT of residual */ - float *dct_pitex, /* i/o: DCT of pitch contribution */ - float *pitch_buf, /* i/o: Pitch per subframe */ - int16_t *hangover /* i : Hangover for the time contribution switching */ -); - -int16_t stab_est( - float etot, /* i : Total energy of the current frame */ - float *lt_diff_etot, /* i/o: Long term total energy variation */ - float *mem_etot, /* i/o: Total energy memory */ - int16_t *nb_thr_3, /* i/o: Number of consecutives frames of level 3 */ - int16_t *nb_thr_1, /* i/o: Number of consecutives frames of level 1 */ - float *thresh, /* i/o: Detection thresold */ - int16_t *last_music_flag, /* i/o: Previous music detection ouptut */ - const int16_t vad_flag /* i : VAD flag */ -); - -float gsc_gainQ( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t element_mode, /* i : element mode */ - const int16_t idchan, /* i : channel ID */ - const float y_gain4[], /* i : gain per band */ - float y_gainQ[], /* o : quantized gain per band */ - const int32_t core_brate, /* i : Core rate */ - const int16_t coder_type, /* i : coding type */ - const int16_t bwidth, /* i : input signal bandwidth */ - const int16_t L_frame, /* i : frame length */ - const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const int32_t core_brate_inp /* i : true core brate */ -); - -void Comp_and_apply_gain( - float exc_diffQ[], /* i/o: gain per band */ - float Ener_per_bd_iQ[], /* o : Quant Ener per band */ - float Ener_per_bd_yQ[], /* o : Ener per band for quantize y */ - int16_t Mbands_gn, /* i : number of bands */ - const int16_t ReUseGain /* i : Reuse the gain in Ener_per_bd_yQ */ -); - -void bands_and_bit_alloc_ivas_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 noise_lev, /* i : dwn scaling factor */ - const Word32 core_brate, /* i : core bit rate */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ - const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ - Word16 *max_ener_band, /* o : Sorted order */ - Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ - Word16 *nb_subbands, /* o : Number of subband allowed */ - const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ - Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */ - Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ -); - -void GSC_dec_init_ivas( - GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ -); - -void decod_audio( - Decoder_State *st, /* i/o: decoder static memory */ - float dct_epit[], /* o : GSC excitation in DCT domain */ - const float *Aq, /* i : LP filter coefficient */ - float *tmp_noise, /* o : long term temporary noise energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc_dct_in, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - float *bwe_exc, /* o : excitation for SWB TBE */ - float *lsf_new, /* i : current frame ISF vector */ - float *gain_buf, /* o : floating pitch gain for each subframe */ - const int16_t tdm_lp_reuse_flag, /* i : LPC reuse flag */ - const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -); - -void gsc_dec( - Decoder_State *st, /* i/o: State structure */ - float exc_dct_in[], /* i/o: dct of pitch-only/total excitation */ - const int16_t pit_band_idx, /* i : pitch band index */ - const int16_t Diff_len, /* i : */ - const int16_t bits_used, /* i : total number of bits used */ - const int16_t nb_subfr, /* i : Number of subframe considered */ - const int16_t coder_type, /* i : coding type */ - int16_t *last_bin, /* i : last bin of bit allocation */ - const float *lsf_new, /* i : ISFs at the end of the frame */ - float *exc_wo_nf, /* o : excitation (in f domain) without noisefill*/ - float *tmp_noise /* o : long-term noise energy */ -); - -void dec_pit_exc( - Decoder_State *st, /* i/o: decoder static memory */ - const int16_t L_frame, /* i : length of the frame */ - const float *Aq, /* i : LP filter coefficient */ - const float Es_pred, /* i : predicted scaled innov. energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *code, /* o : innovation */ - float *exc, /* i/o: adapt. excitation exc */ - const int16_t nb_subfr, /* i : Number of subframe considered */ - float *gain_buf, /* o : floating pitch gain for each subframe */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -); - -void music_postfilt_init_flt( - MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ -); - -void LD_music_post_filter( - MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ - const float dtc_in[], /* i : input synthesis */ - float dtc_out[], /* o : output synthesis */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t coder_type, /* i : Coder type : -1 in case of IO */ - const int16_t Last_coder_type /* i : last Coder type */ -); - -void Post_music_postP( - float dct_buffer_in[], /* i/o: excitation buffer */ - float exc_buffer_out[], /* o : DCT output buffer */ - float *exc2, /* i/o: Current excitation to be overwriten */ - const float *mem_tmp, /* i : previous frame synthesis memory */ - float *st_mem_syn2, /* i/o: current frame synthesis memory */ - const float *Aq, /* i : LPC filter coefficients */ - float *syn /* i/o: 12k8 synthesis */ -); - -void Prep_music_postP( - float exc_buffer_in[], /* i/o: excitation buffer */ - float dct_buffer_out[], /* o : DCT output buffer */ - float filt_lfE[], /* i/o: long term spectrum energy */ - const int16_t last_core, /* i : last core */ - const float *pitch_buf, /* i : current frame pitch information */ - float *LDm_enh_lp_gbin /* o : smoothed suppression gain, per bin FFT */ -); - -void speech_music_classif( - Encoder_State *st, /* i/o: encoder state structure */ - const float *new_inp, /* i : new input signal */ - const float *inp, /* i : input signal to locate attach position */ - const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */ - const float lsp_new[M], /* i : LSPs in current frame */ - const float cor_map_sum, /* i : correlation map sum (from multi-harmonic anal.) */ - const float epsP[M + 1], /* i : LP prediciton error */ - const float PS[], /* i : energy spectrum */ - const float Etot, /* i : total frame energy */ - const float old_cor, /* i : max correlation from previous frame */ - int16_t *attack_flag, /* o : attack flag (GSC or TC) */ - const float non_staX, /* i : unbound non-stationarity for sp/mus classifier */ - const float relE, /* i : relative frame energy */ - int16_t *high_lpn_flag, /* o : sp/mus LPN flag */ - const int16_t flag_spitch /* i : flag to indicate very short stable pitch */ -); -void ivas_find_wsp_fx( - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 L_subfr, /* i : length of subframe Q0*/ - const Word16 nb_subfr, /* i : number of subframes Q0*/ - const Word16 *A_fx, - /* i : A(z) filter coefficients */ // Q12 - Word16 *Aw_fx, - /* o : weighted A(z) filter coefficients */ // Q12 - const Word16 *speech_fx, - /* i : pointer to the denoised speech frame */ // Q_new - const Word16 tilt_fact, - /* i : tilt factor */ // Q15 - Word16 *wsp_fx, - /* o : poitnter to the weighted speech frame */ // Q_new - Word16 *mem_wsp_fx, - /* i/o: W(Z) denominator memory */ // Q_new - const Word16 gamma, - /* i : weighting factor */ // Q15 - const Word16 L_look /* i : look-ahead Q0*/ -); - -void gain_enc_amr_wb( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const float *xn, /* i : target vector */ - const float *y1, /* i : zero-memory filtered adaptive excitation */ - const float *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const float *code, /* i : algebraic excitation */ - const int32_t core_brate, /* i : core bitrate */ - float *gain_pit, /* i/o: Pitch gain / Quantized pitch gain */ - float *gain_code, /* o : Quantized codebook gain */ - float *gain_inov, /* o : innovation gain */ - float *norm_gain_code, /* o : norm. gain of the codebook excitation */ - float *coeff, /* i/o: correlations , -2,, -2 and 2 */ - const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - float *past_qua_en /* i/o: gain quantization memory (4 words) */ -); - -void gain_enc_lbr( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t gains_mode[], /* i : gain bits */ - const int16_t coder_type, /* i : coding type */ - const int16_t i_subfr, /* i : subframe index */ - const float *xn, /* i : target vector */ - const float *y1, /* i : zero-memory filtered adaptive excitation */ - const float *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const float *code, /* i : algebraic excitation */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - float *gain_inov, /* o : gain of the innovation (used for normalization) */ - float *norm_gain_code, /* o : norm. gain of the codebook excitation */ - float *g_corr, /* i/o: correlations , -2,, -2 and 2 */ - float gains_mem[], /* i/o: pitch gain and code gain from previous subframes */ - const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - const int16_t L_subfr /* i : subfr Lenght */ -); - -void gain_enc_mless( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t gains_mode[], /* i : gain bits */ - const int16_t element_mode, /* i : element mode */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t i_subfr, /* i : subframe index */ - const int16_t tc_subfr, /* i : TC subframe index */ - const float *xn, /* i : target vector */ - const float *y1, /* i : zero-memory filtered adaptive excitation */ - const float *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const float *code, /* i : algebraic excitation */ - const float Es_pred, /* i : predicted scaled innovation energy */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - float *gain_inov, /* o : innovation gain */ - float *norm_gain_code, /* o : norm. gain of the codebook excitation */ - float *coeff, /* i/o: correlations , -2,, -2 and 2 */ - const int16_t clip_gain /* i : gain pitch clipping flag (1 = clipping) */ -); - -void gain_enc_SQ( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t gains_mode[], /* i : gain bits */ - const int16_t i_subfr, /* i : subframe index */ - const float *xn, /* i : target vector */ - const float *yy1, /* i : zero-memory filtered adaptive excitation */ - const float *y2, /* i : zero-memory filtered algebraic codebook excitation */ - const float *code, /* i : algebraic excitation */ - const float Es_pred, /* i : predicted scaled innovation energy */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - float *gain_inov, /* o : gain of the innovation (used for normalization) */ - float *norm_gain_code, /* o : norm. gain of the codebook excitation */ - float *g_corr, /* i/o: correlations , -2,, -2 and 2 */ - const int16_t clip_gain /* i : gain pitch clipping flag (1 = clipping) */ -); - -/*! r: Return index of quantization */ -int16_t gain_enc_gaus( - float *gain, /* i/o: Code gain to quantize */ - const int16_t bits, /* i : number of bits to quantize */ - const float lowBound, /* i : lower bound of quantizer (dB) */ - const float topBound /* i : upper bound of quantizer (dB) */ -); - -void E_corr_xy2( - const float xn[], /* i : target vector */ - const float y1[], /* i : filtered excitation components 1 */ - const float y2[], /* i : filtered excitation components 2 */ - float g_corr[], /* o : correlations between x, y1, y2, y3, y4 */ - const int16_t L_subfr /* i : subframe size */ -); - - -/*! r: coding type */ -int16_t find_uv( - Encoder_State *st, /* i/o: encoder state structure */ - const float *pitch_fr, /* i : pointer to adjusted fractional pitch (4 val.) */ - const float *voicing_fr, /* i : refined correlation for each subframes */ - const float *speech, /* i : pointer to speech signal for E computation */ - const float *ee, /* i : lf/hf Energy ratio for present frame */ - float *dE1X, /* o : sudden energy increase for S/M classifier */ - const float corr_shift, /* i : normalized correlation correction in noise */ - const float relE, /* i : relative frame energy */ - const float Etot, /* i : total energy */ - const float hp_E[], /* i : energy in HF */ - int16_t *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */ - const int16_t last_core_orig, /* i : original last core */ - STEREO_CLASSIF_HANDLE hStereoClf /* i/o: stereo classifier structure */ -); - -/*! r: classification for current frames */ -int16_t signal_clas( - Encoder_State *st, /* i/o: encoder state structure */ - const float *speech, /* i : pointer to speech signal for E computation */ - const float *ee, /* i : lf/hf E ration for 2 half-frames */ - const float relE, /* i : frame relative E to the long term average */ - const int16_t L_look, /* i : look-ahead */ - int16_t *clas_mod /* o : class flag for NOOP detection */ -); - -void select_TC( - const int16_t codec_mode, /* i : codec mode */ - const int16_t tc_cnt, /* i : TC frame counter */ - int16_t *coder_type, /* i/o: coder type */ - const int16_t localVAD /* i : VAD without hangover */ -); - - -void wb_vad_init( - VAD_HANDLE hVAD /* i/o: VAD data handle */ -); - -int16_t dtx_hangover_addition( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t vad_flag, /* i : VAD flag */ - const float snr, /* i : input single SNR estimate */ - const int16_t cldfb_subtraction, /* i : */ - int16_t *vad_hover_flag, /* o : VAD hangover flag */ - VAD_HANDLE hVAD, /* i/o: VAD handle for L or R channel */ - NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ - int16_t *rem_dtx_ho /* o : Expected remaining hangover frames */ -); - -int16_t wb_vad( - Encoder_State *st, /* i/o: encoder state structure */ - const float fr_bands[], /* i : per band input energy (contains 2 vectors) */ - int16_t *noisy_speech_HO, /* o : SC-VBR noisy speech HO flag */ - int16_t *clean_speech_HO, /* o : SC-VBR clean speech HO flag */ - int16_t *NB_speech_HO, /* o : SC-VBR NB speech HO flag */ - float *snr_sum_he, /* i : voicing metric from SAD */ - int16_t *localVAD_HE_SAD, /* o : HE_SAD decision without hangovers */ - int16_t *flag_noisy_speech_snr, /* o : */ - VAD_HANDLE hVAD, /* i/o: VAD handle */ - NOISE_EST_HANDLE hNoiseEst, /* i/o: Noise estimation handle */ - float lp_speech, /* i : long term active speech energy average */ - float lp_noise /* i : long term noise energy */ -); - -void bw_detect( - Encoder_State *st, /* i/o: Encoder State */ - const float signal_in[], /* i : input signal */ - float *spectrum, /* i : MDCT spectrum */ - const float *enerBuffer, /* i : energy buffer */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t mct_on /* i : flag MCT mode */ -); - -void set_bw( - const int16_t element_mode, /* i : element mode */ - const int32_t element_brate, /* i : element bitrate */ - Encoder_State *st, /* i/o: Encoder State */ - const int16_t codec_mode /* i : codec mode */ -); - -float gaus_encode( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t i_subfr, /* i : subframe index */ - const float *h1, /* i : weighted filter input response */ - const float *xn, /* i : target vector */ - float *exc, /* o : pointer to excitation signal frame */ - float *mem_w0, /* o : weighting filter denominator memory */ - float *gp_clip_mem, /* o : memory of gain of pitch clipping algorithm */ - float *tilt_code, /* o : synthesis excitation spectrum tilt */ - float *code, /* o : algebraic excitation */ - float *gain_code, /* o : Code gain. */ - float *y2, /* o : zero-memory filtered adaptive excitation */ - float *gain_inov, /* o : innovation gain */ - float *voice_fac, /* o : voicing factor */ - float *gain_pit, /* o : adaptive excitation gain */ - float *norm_gain_code /* o : normalized innovative cb. gain */ -); - -void td_cng_enc_init( - TD_CNG_ENC_HANDLE hTdCngEnc, /* i/o: DTX/TD CNG data handle */ - const int16_t Opt_DTX_ON, /* i : flag indicating DTX operation */ - const int16_t max_bwidth /* i : maximum encoded bandwidth */ -); - -void dtx( - Encoder_State *st, /* i/o: encoder state structure */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t vad, /* i : VAD flag for DTX */ - const float speech[] /* i : Pointer to the speech frame */ -); - -void dtx_hangover_control( - Encoder_State *st, /* i/o: encoder state structure */ - const float lsp_new[M] /* i : current frame LSPs */ -); - - -void updt_enc_common( - Encoder_State *st /* i/o: encoder state structure */ -); - -void updt_IO_switch_enc( - Encoder_State *st, /* i/o: state structure */ - const int16_t input_frame /* i : input frame length */ -); - -void transition_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t i_subfr, /* i : subframe index */ - int16_t *tc_subfr, /* i/o: TC subframe index */ - int16_t *Jopt_flag, /* i : joint optimization flag */ - int16_t *position, /* i/o: maximum of residual signal index */ - int16_t *T0, /* i/o: close loop integer pitch */ - int16_t *T0_frac, /* i/o: close loop fractional part of the pitch */ - int16_t *T0_min, /* i/o: lower limit for close-loop search */ - int16_t *T0_max, /* i/o: higher limit for close-loop search */ - float *exc, /* i/o: pointer to excitation signal frame */ - float *y1, /* o : zero-memory filtered adaptive excitation */ - const float *h1, /* i : weighted filter input response */ - const float *xn, /* i : target vector */ - float *xn2, /* o : target vector for innovation search */ - float *gp_cl, /* i/o: memory of gain of pitch clipping algorithm */ - float *gain_pit, /* o : adaptive excitation gain */ - float *g_corr, /* o : ACELP correlation values */ - int16_t *clip_gain, /* i/o: adaptive gain clipping flag */ - float **pt_pitch, /* o : floating pitch values */ - float *bwe_exc, /* i/o: excitation for SWB TBE */ - int16_t *unbits /* i/o: unused bits */ -); - -void tc_classif_enc( - const int16_t L_frame, /* i : length of the frame */ - int16_t *tc_subfr, /* i/o: TC subframe index */ - int16_t *position, /* i/o: maximum of residual signal index */ - const int16_t attack_flag, /* i : attack flag */ - const int16_t pitch, /* i : open loop pitch estimates for first halfframe */ - const float *res /* i : pointer to the LP residual signal frame */ -); - - -void gain_enc_tc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t gains_mode[], /* i : gain bits */ - const int16_t i_subfr, /* i : subframe index */ - const float xn[], /* i : target vector */ - const float y2[], /* i : zero-memory filtered algebraic codebook excitation */ - const float code[], /* i : algebraic excitation */ - const float Es_pred, /* i : predicted scaled innovation energy */ - float *gain_pit, /* o : pitch gain / Quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - float *gain_inov, /* o : innovation gain */ - float *norm_gain_code /* o : norm. gain of the codebook excitation */ -); - - -/*! r: comfort noise gain factor */ -float AVQ_cod( - const float xri[], /* i : vector to quantize */ - int16_t xriq[], /* o : quantized normalized vector (assuming the bit budget is enough) */ - const int16_t nb_bits, /* i : number of allocated bits */ - const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */ -); - -void AVQ_encmux( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t extl, /* i : extension layer */ - int16_t xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */ - int16_t *nb_bits, /* i/o: number of allocated bits */ - const int16_t Nsv, /* i : number of subvectors */ - int16_t nq[], /* o : AVQ nq index */ - int16_t avq_bit_sFlag, /* i : flag indicating AVQ bit savings */ - int16_t trgtSvPos /* i : target SV for AVQ bit savings */ -); - -void ordr_esti( - const int16_t k, /* i : sub-vector index */ - int16_t *Mpos, /* i/o: dominant sub-vector position from ACV */ - int16_t svOrder[], /* i/o: AVQ sub-vector order */ - const int16_t Nsv /* i : total sub-vectors in a sub-frames */ -); - -void re8_cod( - int16_t x[], /* i : point in RE8 (8-dimensional integer vector) */ - int16_t *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */ - uint16_t *I, /* o : index of c (pointer to unsigned 16-bit word) */ - int16_t k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index */ -); - -void pre_exc( - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const int16_t L_frame, /* i : frame length */ - const float *speech, /* i : input speech */ - const float *p_Aq, /* i : 12k8 Lp coefficient */ - const float *p_A, /* i : unquantized A(q) filter with bandwidth expansion */ - const int16_t coder_type, /* i : coding type */ - const int16_t i_subfr, /* i : current sub frame indicator */ - float *Ap, /* o : weighted LP filter coefficients */ - const float *res, /* i : residual signal */ - float *h1, /* o : impulse response of weighted synthesis filter */ - float *xn, /* o : close-loop Pitch search target vector */ - float *cn, /* o : target vector in residual domain */ - float *mem_syn, /* i/o: memory of the synthesis filter */ - float *mem_w0, /* i/o: weighting filter denominator memory */ - const int16_t L_subfr /* i : subframe length */ -); - - -void encod_amr_wb( - Encoder_State *st, /* i/o: state structure */ - const float speech[], /* i : input speech */ - const float Aw[], /* i : weighted A(z) unquantized for subframes */ - const float Aq[], /* i : 12k8 Lp coefficient */ - const float *res, /* i : residual signal */ - float *syn, /* i/o: core synthesis */ - float *exc, /* i/o: current non-enhanced excitation */ - float *exc2, /* i/o: current enhanced excitation */ - float *pitch_buf, /* i/o: floating pitch values for each subframe */ - int16_t hf_gain[NB_SUBFR], /* o : decoded HF gain */ - const float *speech16k /* i : input speech @16kHz */ -); - -void stat_noise_uv_enc( - Encoder_State *st, /* i/o: state structure */ - const float *epsP, /* i : LP prediction errors */ - const float *isp_new, /* i : immittance spectral pairs at 4th sfr */ - const float *isp_mid, /* i : immittance spectral pairs at 2nd sfr */ - float *Aq, /* i/o: A(z) quantized for the 4 subframes */ - float *exc2, /* i/o: excitation buffer */ - const int16_t uc_two_stage_flag /* o : flag undicating two-stage UC */ -); - -void re8_compute_base_index( - const int16_t *x, /* i : Elemen of Q2, Q3 or Q4 */ - const int16_t ka, /* i : Identifier of the absolute leader related to x */ - uint16_t *I /* o : index */ -); - -void transf_cdbk_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */ - const int16_t i_subfr, /* i : subframe index */ - float cn[], /* i/o: target vector in residual domain */ - float exc[], /* i/o: pointer to excitation signal frame */ - const float *p_Aq, /* i : 12k8 Lp coefficient */ - const float Ap[], /* i : weighted LP filter coefficients */ - const float h1[], /* i : weighted filter input response */ - float xn[], /* i/o: target vector */ - float xn2[], /* i/o: target vector for innovation search */ - float y1[], /* i/o: zero-memory filtered adaptive excitation */ - const float y2[], /* i : zero-memory filtered innovative excitation */ - const float Es_pred, /* i : predicited scaled innovation energy */ - float *gain_pit, /* i/o: adaptive excitation gain */ - const float gain_code, /* i : innovative excitation gain */ - float g_corr[], /* o : ACELP correlation values */ - const int16_t clip_gain, /* i : adaptive gain clipping flag */ - float *gain_preQ, /* o : prequantizer excitation gain */ - float code_preQ[], /* o : prequantizer excitation */ - int16_t *unbits /* i/o: number of AVQ unused bits */ -); -void deemph_lpc( - float *p_Aq_cuerr, /* i : LP coefficients current frame */ - float *p_Aq_old, /* i : LP coefficients previous frame */ - float *LPC_de_curr, /* o : De-emphasized LP coefficients current frame */ - float *LPC_de_old, /* o : De-emphasized LP coefficients previous frame*/ - const int16_t deemph_old ); - -void Interpol_delay( - float *out, /* o : pitch interpolation output */ - float *last, /* i : last frame pitch lag */ - float *current, /* i : current frame pitch lag */ - int16_t SubNum, /* i : subframe number */ - const float *frac /* i : interpolation constant */ -); - -void dequantize_uvg( - int16_t iG1, /* i : gain 1 index */ - int16_t *iG2, /* i : gain 2 index */ - float *G, /* o : quantized gain */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void generate_nelp_excitation( - int16_t *seed, /* i/o: random number seed */ - float *Gains, /* i : excitation gains */ - float *output, /* o : excitation output */ - float gain_fac /* i : gain factor */ -); - -void nelp_encoder( - Encoder_State *st, /* i/o: encoder state */ - float *in, /* i : residual signal */ - float *exc, /* o : NELP quantized excitation signal */ - const int16_t reduce_gains ); - -void encod_nelp( - Encoder_State *st, /* i/o: state structure */ - const float *speech, /* i : input speech */ - const float Aw[], /* i : weighted A(z) unquantized for subframes */ - const float *Aq, /* i : 12k8 Lp coefficient */ - float *res, /* o : residual signal */ - float *synth, /* o : core synthesis */ - float *tmp_noise, /* o : long-term noise energy */ - float *exc, /* i/o: current non-enhanced excitation */ - float *exc2, /* i/o: current enhanced excitation */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc /* o : excitation for SWB TBE */ -); - -void realft( - float *data, /* i/o: data array */ - int16_t n, /* i : length of data array */ - int16_t isign /* i : sign +1 or -1 */ -); - -ivas_error DTFS_new( - DTFS_STRUCTURE **dtfs_out ); - -void DTFS_copy( - DTFS_STRUCTURE *Xout, /* o : DTFS */ - DTFS_STRUCTURE Xinp /* i : DTFS */ -); - -void DTFS_sub( - DTFS_STRUCTURE *tmp, /* o : output DFTS */ - DTFS_STRUCTURE X1, /* i : DTFS input 1 */ - DTFS_STRUCTURE X2 /* i : DTFS input 2 */ -); - -void DTFS_to_fs( - const float *x, /* i : Time domain signal */ - const int16_t N, /* i : Length of input vector */ - DTFS_STRUCTURE *X, /* o : DTFS structure with a, b, lag */ - const int32_t sampling_rate, - const int16_t FR_flag /* i : FR flag */ -); - -void DTFS_fs_inv( - DTFS_STRUCTURE *X, /* i : DTFS */ - float *x, /* o : time domain sig */ - const int16_t N, /* i : Output length */ - float ph0 /* i : Input phase */ -); - -void DTFS_car2pol( - DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag */ - /* input in Cartesion, output in Polar */ -); - -void DTFS_pol2car( - DTFS_STRUCTURE *X /* i/o: DTFS structure a, b, lag */ - /* input in Polar, output in Cartesian */ -); - -/*! r: Return Input RMS between f1/f2 b4 scaling */ -float DTFS_setEngyHarm( - float f1, /* i : lower band freq of input to control energy */ - float f2, /* i : upper band freq of input to control energy */ - float g1, /* i : lower band freq of output to control energy */ - float g2, /* i : upper band freq of output to control energy */ - float en2, /* i : Target Energy to set the DTFS to */ - DTFS_STRUCTURE *X /* i/o: DTFS to adjust the energy of */ -); - -void DTFS_to_erb( - DTFS_STRUCTURE X, /* i : DTFS input */ - float *out /* o : ERB output */ -); - -void DTFS_zeroPadd( - const int16_t N, /* i : Target lag */ - DTFS_STRUCTURE *X /* i/o: DTFS */ -); - -/*! r: Energy */ -float DTFS_getEngy( - DTFS_STRUCTURE X /* i : DTFS to compute energy of */ -); - -void DTFS_adjustLag( - DTFS_STRUCTURE *X_DTFS, /* i/o: DTFS to adjust lag for */ - const int16_t N /* i : Target lag */ -); - -void DTFS_poleFilter( - DTFS_STRUCTURE *X, /* i/o: DTFS to poleFilter inplace */ - const float *LPC, /* i : LPCs */ - const int16_t N /* i : LPCORDER */ -); - -void DTFS_zeroFilter( - DTFS_STRUCTURE *X, /* i/o: DTFS to zeroFilter inplace */ - const float *LPC, /* i : LPCs */ - const int16_t N /* i : LPCORDER */ -); - -float DTFS_alignment_full( - DTFS_STRUCTURE X1_DTFS, /* i : reference DTFS */ - DTFS_STRUCTURE X2_DTFS, /* i : DTFS to shift */ - const int16_t num_steps /* i : resolution */ -); - -void DTFS_phaseShift( - DTFS_STRUCTURE *X, /* i : DTFS to shift */ - float ph /* i : phase to shift */ -); - -void erb_add( - float *curr_erb, /* i/o: current ERB */ - const int16_t l, /* i : current lag */ - const float *prev_erb, /* i : previous ERB */ - const int16_t pl, /* i : previous lag */ - const int16_t *index, /* i : ERB index */ - const int16_t num_erb /* i : number of ERBs */ -); - -void erb_slot( - int16_t lag, /* i : input lag */ - int16_t *out, /* o : ERB slots */ - float *mfreq, /* i : ERB frequencies */ - int16_t num_erb /* i : number of ERBs */ -); - -void erb_diff( - const float *prev_erb, /* i : previous ERB */ - const int16_t pl, /* i : previous lag */ - const float *curr_erb, /* i : current ERB */ - const int16_t l, /* i : current lag */ - const float *curr_lsp, /* i : current LSP coefficients */ - float *out, /* o : ERB difference */ - int16_t *index, /* i : ERB index */ - const int16_t num_erb /* i : Number of ERBs */ -); - -void DTFS_erb_inv( - float *in, /* i : ERB inpt */ - int16_t *slot, /* i : ERB slots filled based on lag */ - float *mfreq, /* i : erb frequence edges */ - DTFS_STRUCTURE *X, /* o : DTFS after erb-inv */ - const int16_t num_erb /* i : Number of ERB bands */ -); - -ivas_error ppp_quarter_encoder( - int16_t *returnFlag, /* o : return value */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - DTFS_STRUCTURE *CURRCW_Q, /* o : Quantized (amp/phase) DTFS */ - DTFS_STRUCTURE *TARGETCW, /* o : DTFS with quant phase but unquant Amp */ - const int16_t prevCW_lag, /* i : previous lag */ - DTFS_STRUCTURE vCURRCW_NQ, /* i : Unquantized DTFS */ - const float *curr_lpc, /* i : LPCS */ - float *lastLgainE, /* i/o: last low band gain */ - float *lastHgainE, /* i/o: last high band gain */ - float *lasterbE, /* i/o: last ERB vector */ - DTFS_STRUCTURE PREV_CW_E /* i : past DTFS */ -); - -ivas_error WIsyn( - DTFS_STRUCTURE PREVCW, /* i : Prev frame DTFS */ - DTFS_STRUCTURE *CURR_CW_DTFS, /* i/o: Curr frame DTFS */ - const float *curr_lpc, /* i : LPC */ - float *ph_offset, /* i/o: Phase offset to line up at end of frame */ - float *out, /* o : Waveform Interpolated time domain signal */ - const int16_t N, /* i : Number of samples of output to generate */ - const int16_t FR_flag /* i : called for post-smoothing in FR */ -); - -void set_ppp_mode( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */ - const int16_t clean_speech_HO, /* i : SC-VBR clean speech HO flag */ - const int16_t NB_speech_HO, /* i : SC-VBR NB speech HO flag */ - const int16_t localVAD_he /* i : HE-SAD flag without hangover */ -); - -ivas_error ppp_voiced_encoder( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - SC_VBR_ENC_HANDLE hSC_VBR, /* i/o: SC-VBR state structure */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t last_coder_type_raw, /* i : raw last_coder_type */ - const float old_pitch_buf[], /* i : buffer of old subframe pitch values */ - float *in, /* i : residual signal */ - float *out, /* o : Quantized residual signal */ - const int16_t delay, /* i : open loop pitch */ - float *lpc1, /* i : prev frame de-emphasized LPC */ - float *lpc2, /* i : current frame de-emphasized LPC */ - float *exc, /* i : previous frame quantized excitation */ - float *pitch /* o : floating pitch values for each subframe */ -); - -ivas_error encod_ppp( - Encoder_State *st, /* i/o: state structure */ - const float speech[], /* i : input speech */ - const float Aw[], /* i : weighted A(z) unquantized for subframes */ - const float Aq[], /* i : 12k8 Lp coefficient */ - float *res, /* i/o: residual signal */ - float *synth, /* i/o: core synthesis */ - float *exc, /* i/o: current non-enhanced excitation */ - float *exc2, /* i/o: current enhanced excitation */ - float *pitch_buf, /* i/o: floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc /* o : excitation for SWB TBE */ -); - -void reset_rf_indices( - RF_ENC_HANDLE hRF, /* i/o: RF state structure */ - const int16_t L_frame, /* i : frame length */ - int16_t *rf_target_bits_write ); - -void signaling_enc_rf( - Encoder_State *st /* i/o: encoder state structure */ -); - -ivas_error acelp_core_dec( - Decoder_State *st, /* i/o: Decoder state structure */ - float output[], /* o : synthesis @internal Fs */ - float synth[], /* o : synthesis */ - float save_hb_synth[], /* o : HB synthesis */ - float bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - float *voice_factors, /* o : voicing factors */ - float old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ - const int16_t sharpFlag, /* i : formant sharpening flag */ - float pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe */ - int16_t *unbits, /* o : number of unused bits */ - int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const float tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ - const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t last_element_mode, /* i : last element mode */ - const int32_t last_element_brate, /* i : last element bitrate */ - const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ - const int16_t nchan_out, /* i : number of output channels */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t read_sid_info /* i : read SID info flag */ -); - -void bass_psfilter_init( - BPF_DEC_HANDLE hBPF /* o : BPF data handle */ -); - -void bass_psfilter( - BPF_DEC_HANDLE hBPF, /* o : BPF data handle */ - const int16_t Opt_AMR_WB, /* i : AMR-WB IO flag */ - const float synth_in[], /* i : synthesis (at 16kHz) */ - const int16_t L_frame, /* i : length of the last frame */ - const float pitch_buf[], /* i : pitch for every subfr [0,1,2,3] */ - const int16_t bpf_off, /* i : do not use BPF when set to 1 */ - float v_stab, /* i : stability factor */ - float *v_stab_smooth, /* i : smoothed stability factor */ - const int16_t coder_type, /* i : coder_type */ - float bpf_noise_buf[] /* o : BPF error signal (at int_fs) */ -); - -void CNG_reset_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float *pitch_buf, /* o : floating pitch for each subframe */ - float *voice_factors /* o : voicing factors */ -); - -void updt_dec( - Decoder_State *st, /* i/o: state structure */ - const float *old_exc, /* i : buffer of excitation */ - const float *pitch_buf, /* i : floating pitch values for each subframe */ - const float Es_pred, /* i : predicited scaled innovation energy */ - const float *Aq, /* i : A(z) quantized for all subframes */ - const float *lsf_new, /* i : current frame LSF vector */ - const float *lsp_new, /* i : current frame LSP vector */ - const float voice_factors[], /* i : voicing factors */ - const float *old_bwe_exc, /* i : buffer of excitation */ - const float *gain_buf /* o : floating pitch gain for each subframe */ -); - -void updt_IO_switch_dec( - const int16_t output_frame, /* i : output frame length */ - Decoder_State *st /* i/o: state structure */ -); - -void updt_dec_common( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t hq_core_type, /* i : HQ core type */ - const int16_t concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const float *synth /* i : decoded synthesis */ -); - -void td_cng_dec_init( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ -); - -void CNG_dec( - Decoder_State *st, /* i/o: State structure */ - const int16_t last_element_mode, /* i : last element mode */ - float Aq[], /* o : LP coefficients */ - float *lsp_new, /* i/o: current frame LSPs */ - float *lsf_new, /* i/o: current frame LSFs */ - int16_t *allow_cn_step, /* o : allow cn step */ - int16_t *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ - float *q_env ); - -void swb_CNG_dec( - Decoder_State *st, /* i/o: State structure */ - const float *synth, /* i : ACELP core synthesis at 32kHz */ - float *shb_synth, /* o : high-band CNG synthesis */ - const int16_t sid_bw /* i : 0-NB/WB, 1-SWB SID */ -); - -void lsf_dec( - Decoder_State *st, /* i/o: State structure */ - const int16_t tc_subfr, /* i : TC subframe index */ - float *Aq, /* o : quantized A(z) for 4 subframes */ - int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - float *lsf_new, /* o : de-quantized LSF vector */ - float *lsp_new, /* o : de-quantized LSP vector */ - float *lsp_mid, /* o : de-quantized mid-frame LSP vector */ - const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -); - -void isf_dec_amr_wb( - Decoder_State *st, /* i/o: State structure */ - float *Aq, /* o : quantized A(z) for 4 subframes */ - float *isf_new, /* o : de-quantized ISF vector */ - float *isp_new /* o : de-quantized ISP vector */ -); - -void Es_pred_dec( - float *Es_pred, /* o : predicted scaled innovation energy */ - const int16_t enr_idx, /* i : indice */ - const int16_t nb_bits, /* i : number of bits */ - const int16_t no_ltp /* i : no LTP flag */ -); - -void gaus_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t i_subfr, /* i : subframe index */ - float *code, /* o : gaussian excitation */ - float *norm_gain_code, /* o : gain of the normalized gaussian excitation */ - float *lp_gainp, /* i/o: lp filtered pitch gain(FER) */ - float *lp_gainc, /* i/o: lp filtered code gain (FER) */ - float *gain_inov, /* o : unscaled innovation gain */ - float *tilt_code, /* o : synthesis excitation spectrum tilt */ - float *voice_fac, /* o : estimated voicing factor */ - float *gain_pit, /* o : reset pitch gain */ - float *pt_pitch, /* o : reset floating pitch buffer */ - float *exc, /* o : excitation signal frame */ - float *gain_code, /* o : gain of the gaussian excitation */ - float *exc2 /* o : scaled excitation signal frame */ -); - -void gain_dec_amr_wb( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t core_brate, /* i : core bitrate */ - float *gain_pit, /* o : Quantized pitch gain */ - float *gain_code, /* o : Quantized codeebook gain */ - float *past_qua_en, /* i/o: gain quantization memory (4 words) */ - float *gain_inov, /* o : unscaled innovation gain */ - const float *code, /* i : algebraic code excitation */ - float *norm_gain_code /* o : norm. gain of the codebook excitation */ -); - -void gain_dec_lbr( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t coder_type, /* i : coding type */ - const int16_t i_subfr, /* i : subframe index */ - const float *code, /* i : algebraic excitation */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - float *gain_inov, /* o : gain of the innovation (used for normalization) */ - float *norm_gain_code, /* o : norm. gain of the codebook excitation */ - float gains_mem[], /* i/o: pitch gain and code gain from previous subframes */ - const int16_t L_subfr /* i : subframe length */ -); - -void gain_dec_mless( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t coder_type, /* i : coding type */ - const int16_t i_subfr, /* i : subframe number */ - const int16_t tc_subfr, /* i : TC subframe index */ - const float *code, /* i : algebraic code excitation */ - const float Es_pred, /* i : predicted scaled innov. energy */ - float *gain_pit, /* o : Quantized pitch gain */ - float *gain_code, /* o : Quantized codeebook gain */ - float *gain_inov, /* o : unscaled innovation gain */ - float *norm_gain_code /* o : norm. gain of the codebook excitation */ -); - -void gain_dec_SQ( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t i_subfr, /* i : subframe number */ - const float *code, /* i : algebraic code excitation */ - const float Es_pred, /* i : predicted scaled innov. energy */ - float *gain_pit, /* o : Quantized pitch gain */ - float *gain_code, /* o : Quantized codeebook gain */ - float *gain_inov, /* o : unscaled innovation gain */ - float *norm_gain_code /* o : norm. gain of the codebook excitation */ -); - -/*! r: quantized codebook gain */ -float gain_dec_gaus( - const int16_t index, /* i : quantization index */ - const int16_t bits, /* i : number of bits to quantize */ - const float lowBound, /* i : lower bound of quantizer (dB) */ - const float topBound, /* i : upper bound of quantizer (dB) */ - const float gain_inov, /* i : unscaled innovation gain */ - float *norm_gain_code /* o : gain of normalized gaus. excit. */ -); - -/*! r: floating pitch value */ -float pit_decode_flt( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const int16_t L_frame, /* i : length of the frame */ - int16_t i_subfr, /* i : subframe index */ - const int16_t coder_type, /* i : coding type */ - int16_t *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - int16_t *T0, /* o : close loop integer pitch */ - int16_t *T0_frac, /* o : close loop fractional part of the pitch */ - int16_t *T0_min, /* i/o: delta search min for sf 2 & 4 */ - int16_t *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const int16_t L_subfr, /* i : subframe length */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -); - -void abs_pit_dec_flt( - const int16_t fr_steps, /* i : fractional resolution steps (0, 2, 4) */ - int16_t pitch_index, /* i : pitch index */ - const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */ - int16_t *T0, /* o : integer pitch lag */ - int16_t *T0_frac /* o : pitch fraction */ -); - -void delta_pit_dec_flt( - const int16_t fr_steps, /* i : fractional resolution steps (0, 2, 4) */ - const int16_t pitch_index, /* i : pitch index */ - int16_t *T0, /* o : integer pitch lag */ - int16_t *T0_frac, /* o : pitch fraction */ - const int16_t T0_min /* i : delta search min */ -); - -void pit_Q_dec_flt( - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const int16_t pitch_index, /* i : pitch index */ - const int16_t nBits, /* i : # of Q bits */ - const int16_t delta, /* i : Half the CL searched interval */ - const int16_t pit_flag, /* i : absolute(0) or delta(1) pitch Q */ - const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */ - int16_t *T0, /* o : integer pitch lag */ - int16_t *T0_frac, /* o : pitch fraction */ - int16_t *T0_min, /* i/o: delta search min */ - int16_t *T0_max, /* i/o: delta search max */ - int16_t *BER_detect /* o : BER detect flag */ -); - -void pit16k_Q_dec_flt( - const int16_t pitch_index, /* i : pitch index */ - const int16_t nBits, /* i : # of Q bits */ - const int16_t limit_flag, /* i : restrained(0) or extended(1) Q limits */ - int16_t *T0, /* o : integer pitch lag */ - int16_t *T0_frac, /* o : pitch fraction */ - int16_t *T0_min, /* i/o: delta search min */ - int16_t *T0_max, /* i/o: delta search max */ - int16_t *BER_detect /* o : BER detect flag */ -); - - -void inov_decode( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t sharpFlag, /* i : formant sharpening flag */ - const int16_t i_subfr, /* i : subframe index */ - const float *p_Aq, /* i : LP filter coefficients */ - const float tilt_code, /* i : tilt of of the excitation of previous subframe */ - const float pt_pitch, /* i : pointer to current subframe fractional pitch */ - float *code, /* o : algebraic excitation */ - const int16_t L_subfr /* i : subframe length */ -); - -void dec_acelp_1t64( - Decoder_State *st, /* i/o: decoder state structure */ - float code[], /* o : algebraic (fixed) codebook excitation */ - const int16_t L_subfr /* i : subframe length */ -); - -void dec_acelp_2t32( - Decoder_State *st, /* i/o: decoder state structure */ - float code[] /* o : algebraic (fixed) codebook excitation */ -); - -void dec_acelp_4t64( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t nbbits, /* i : number of bits per codebook */ - float code[], /* o : algebraic (fixed) codebook excitation */ - const int16_t Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ -); - - -void FEC_exc_estim( - Decoder_State *st, /* i/o: Decoder static memory */ - const int16_t L_frame, /* i : length of the frame */ - float *old_exc, /* i/o: excitation buffer */ - float *exc2, /* o : excitation buffer (for synthesis) */ - float *exc_dct_in, /* o : GSC excitation in DCT domain */ - float *pitch_buf, /* o : Floating pitch for each subframe */ - float *tmp_tc, /* o : FEC pitch */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc, /* i/o: excitation for SWB TBE */ - float *lsf_new, /* i : ISFs at the end of the frame */ - float *tmp_noise /* o : long-term noise energy */ -); - -void FEC_lsf2lsp_interp_flt( - Decoder_State *st, /* i/o: Decoder static memory */ - const int16_t L_frame, /* i : length of the frame */ - float *Aq, /* o : calculated A(z) for 4 subframes */ - float *lsf, /* o : estimated LSF vector */ - float *lsp /* o : estimated LSP vector */ -); - -void FEC_lsf_estim_enc( - Encoder_State *st, /* i : Encoder static memory */ - float *lsf /* o : estimated LSF vector */ -); - -float frame_energy( - const int16_t L_frame, /* i : length of the frame */ - const float *pitch, /* i : pitch values for each subframe */ - const float *speech, /* i : pointer to speech signal for E computation */ - const float lp_speech, /* i : long term active speech energy average */ - float *frame_ener /* o : pitch-synchronous energy at frame end */ -); - -void FEC_SinOnset( - float *exc, /* i/o: exc vector to modify */ - int16_t puls_pos, /* i : Last pulse position desired */ - int16_t T0, /* i : decoded first frame pitch */ - float enr_q, /* i : energy provided by the encoder */ - float *Aq, /* i : Lsp coefficient */ - const int16_t L_frame /* i : Frame length */ -); - -int16_t FEC_enhACB( - const int16_t L_frame, /* i : Frame length */ - const int16_t last_L_frame, /* i : frame length of last frame */ - float *exc_io, /* i/o: Adaptive codebook memory */ - const int16_t new_pit, /* i : decoded first frame pitch */ - const int16_t puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */ - const float bfi_pitch /* i : Pitch used for concealment */ -); - -void FEC_scale_syn( - const int16_t L_frame, /* i : length of the frame */ - int16_t clas, /* i/o: frame classification */ - const int16_t last_good, /* i : last good frame classification */ - float *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */ - const float *pitch, /* i : pitch values for each subframe */ - float enr_old, /* i : energy at the end of prvious frame */ - float enr_q, /* i : transmitted energy for current frame */ - const int16_t coder_type, /* i : coding type */ - const int16_t LSF_Q_prediction, /* i : LSF prediction mode */ - int16_t *scaling_flag, /* i/o: flag to indicate energy control of syn */ - float *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */ - float *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */ - const int16_t bfi, /* i : current frame BFI */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t prev_bfi, /* i : previous frame BFI */ - const int32_t last_core_brate, /* i : previous frame core bitrate */ - float *exc, /* i/o: excitation signal without enhancement */ - float *exc2, /* i/o: excitation signal with enhancement */ - const float Aq[], /* i : LP filter coefs */ - float *old_enr_LP, /* i/o: LP filter E of last good voiced frame */ - const float *mem_tmp, /* i : temp. initial synthesis filter states */ - float *mem_syn, /* o : initial synthesis filter states */ - const int16_t avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ - const int16_t force_scaling /* i : force scaling */ -); - -void FEC_pitch_estim( - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const int16_t last_core, /* i : last core */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t clas, /* i : current frame classification */ - const int16_t last_good, /* i : last good clas information */ - const float pitch_buf[], /* i : Floating pitch for each subframe */ - const float old_pitch_buf[], /* i : buffer of old subframe pitch values */ - float *bfi_pitch, /* i/o: update of the estimated pitch for FEC */ - int16_t *bfi_pitch_frame, /* o : frame length when pitch was updated */ - int16_t *upd_cnt, /* i/o: update counter */ - const int16_t coder_type ); - -void FEC_encode( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i : configuration of the ACELP */ - const float *synth, /* i : pointer to synthesized speech for E computation */ - const int16_t coder_type, /* i : type of coder */ - int16_t clas, /* i : signal clas for current frame */ - const float *fpit, /* i : close loop fractional pitch buffer */ - const float *res, /* i : LP residual signal frame */ - int16_t *last_pulse_pos, /* i/o: Position of the last pulse */ - const int16_t L_frame, /* i : Frame length */ - const int32_t total_brate /* i : total codec bitrate */ -); - -int16_t FEC_pos_dec( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *last_pulse_pos, /* o : Last glottal pulse position in the lost ACB */ - float *enr_q, /* o : Decoded energy */ - const int16_t nBits_es_Pred /* i : number of bits for Es_pred Q */ -); - -void improv_amr_wb_gs( - const int16_t clas, /* i : bitrate allocated to the core */ - const int16_t coder_type, /* i : coder_type */ - const int32_t core_brate, /* i : bitrate allocated to the core */ - int16_t *seed_tcx, /* i/o: Seed used for noise generation */ - float *old_Aq, /* i/o: old LPC filter coefficient */ - float *mem_syn2, /* i/o: synthesis memory */ - const float lt_voice_fac, /* i/o: long term voice factor */ - const int16_t locattack, /* i : Flag for a detected attack */ - float *Aq, /* i/o: Decoded LP filter coefficient */ - float *exc2, /* i/o: Decoded complete excitation */ - float *mem_tmp, /* i/o: synthesis temporary memory */ - float *syn, /* i/o: Decoded synthesis to be updated */ - const float *pitch_buf, /* i : Decoded pitch buffer */ - const float Last_ener, /* i : Last energy */ - const int16_t rate_switching_reset, /* i : rate switching reset flag */ - const int16_t last_coder_type, /* i : Last coder_type */ - const int16_t VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */ -); - -int16_t tc_classif( - Decoder_State *st /* i/o: decoder state structure */ -); - -void transition_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t i_subfr, /* i : subframe index */ - const int16_t tc_subfr, /* i : TC subframe index */ - int16_t *Jopt_flag, /* i : joint optimization flag */ - float *exc, /* i/o: current frame excitation signal */ - int16_t *T0, /* o : close loop integer pitch */ - int16_t *T0_frac, /* o : close loop fractional part of the pitch */ - int16_t *T0_min, /* i/o: delta search min for sf 2 & 4 */ - int16_t *T0_max, /* i/o: delta search max for sf 2 & 4 */ - float **pt_pitch, /* o : floating pitch values */ - int16_t *position, /* i/o: first glottal impulse position in frame */ - float *bwe_exc /* i/o: excitation for SWB TBE */ -); - -void gain_dec_tc( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t i_subfr, /* i : subframe number */ - const float Es_pred, /* i : predicted scaled innov. energy */ - const float *code, /* i : algebraic code excitation */ - float *gain_pit, /* o : pitch gain */ - float *gain_code, /* o : Quantized codeebook gain */ - float *gain_inov, /* o : unscaled innovation gain */ - float *norm_gain_code /* o : norm. gain of the codebook excit. */ -); - -void stat_noise_uv_dec( - Decoder_State *st, /* i/o: decoder static memory */ - const float *lsp_new, /* i : end-frame LSP vector */ - const float *lsp_mid, /* i : mid-frame LSP vector */ - float *Aq, /* o : A(z) quantized for the 4 subframes */ - float *exc2, /* i/o: excitation buffer */ - const int16_t uc_two_stage_flag /* 1 : flag undicating two-stage UC */ -); - -void sc_vbr_dec_init_flt( - SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */ -); - -void decod_nelp( - Decoder_State *st, /* i/o: decoder static memory */ - float *tmp_noise, /* o : long term temporary noise energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *exc, /* o : adapt. excitation exc */ - float *exc2, /* o : adapt. excitation/total exc */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc, /* o : excitation for SWB TBE */ - const int16_t bfi, /* i : bad frame indicator */ - float *gain_buf /* o : floating pitch gain for each subframe */ -); - -void nelp_decoder( - Decoder_State *st, /* i/o: decoder static memory */ - float *exc_nelp, /* o : adapt. excitation/total exc */ - float *exc, /* o : adapt. excitation exc */ - int16_t bfi, /* i : frame error rate */ - const int16_t coder_type, /* i : coding type */ - float *gain_buf /* o : floating pitch gain for each subframe */ -); - -ivas_error decod_ppp( - Decoder_State *st, /* i/o: state structure */ - const float Aq[], /* i : 12k8 Lp coefficient */ - float *pitch_buf, /* i/o: floating pitch values for each subframe */ - float *exc, /* i/o: current non-enhanced excitation */ - float *exc2, /* i/o: current enhanced excitation */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc, /* o : excitation for SWB TBE */ - float *gain_buf, /* o : floating pitch gain for each subframe */ - const int16_t bfi /* i : BFI flag */ -); - -ivas_error ppp_quarter_decoder( - Decoder_State *st, /* i/o: decoder state structure */ - DTFS_STRUCTURE *CURRCW_Q_DTFS, /* i/o: Current CW DTFS */ - int16_t prevCW_lag, /* i : Previous lag */ - float *lastLgainD, /* i/o: Last gain lowband */ - float *lastHgainD, /* i/o: Last gain highwband */ - float *lasterbD, /* i/o: Last ERB vector */ - int16_t bfi, /* i : FER flag */ - DTFS_STRUCTURE PREV_CW_D /* i : Previous DTFS */ -); - -ivas_error ppp_voiced_decoder( - Decoder_State *st, /* i/o: state structure */ - float *out, /* o : residual signal */ - const float *lpc2, /* i : current frame LPC */ - float *exc, /* i : previous frame excitation */ - float *pitch, /* o : floating pitch values for each subframe */ - const int16_t bfi /* i : BFI flag */ -); - -void AVQ_demuxdec( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t xriq[], /* o : decoded subvectors [0..8*Nsv-1] */ - int16_t *nb_bits, /* i/o: number of allocated bits */ - const int16_t Nsv, /* i : number of subvectors */ - int16_t nq[], /* i/o: AVQ nq index */ - int16_t avq_bit_sFlag, /* i : flag for AVQ bit saving solution*/ - int16_t trgtSvPos /* i : target SV for AVQ bit savings */ -); - - -void Init_post_filter_ivas( - PFSTAT_HANDLE hPFstat /* i : post-filter state memories */ -); - -void nb_post_filt_ivas( - const int16_t L_frame, /* i : frame length */ - const int16_t L_subfr, /* i : sub-frame length */ - PFSTAT_HANDLE hPFstat, /* i/o: Post filter related memories */ - float *lp_noise, /* i/o: long term noise energy */ - const float tmp_noise, /* i : noise energy */ - float *synth, /* i/o: synthesis */ - const float *Aq, /* i : LP filter coefficient */ - const float *pitch_buf, /* i : Floating pitch for each subframe */ - const int16_t coder_type, /* i : coder_type -> deactivated in AUDIO */ - const int16_t BER_detect, /* i : BER detect flag */ - const int16_t disable_hpf /* i : flag to diabled HPF */ -); - -void decod_unvoiced( - Decoder_State *st, /* i/o: decoder static memory */ - const float *Aq, /* i : LP filter coefficient */ - const float Es_pred, /* i : predicted scaled innov. energy */ - const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */ - float *tmp_noise, /* o : long term temporary noise energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc, /* o : adapt. excitation exc */ - float *exc2, /* o : adapt. excitation/total exc */ - float *bwe_exc, /* i/o: excitation for SWB TBE */ - float *gain_buf /* o : floating pitch gain for each subfram */ -); - -void decod_tran( - Decoder_State *st, /* i/o: decoder static memory */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t tc_subfr, /* i : TC subframe index */ - const float *Aq, /* i : LP filter coefficient */ - const float Es_pred, /* i : predicted scaled innov. energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - float *bwe_exc, /* i/o: excitation for SWB TBE */ - int16_t *unbits, /* i/o: number of unused bits */ - const int16_t sharpFlag, /* i : formant sharpening flag */ - float *gain_buf /* o : floating pitch gain for each subframe */ -); - -ivas_error decod_gen_voic( - Decoder_State *st, /* i/o: decoder static memory */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t sharpFlag, /* i : formant sharpening flag */ - const float *Aq, /* i : LP filter coefficient */ - const float Es_pred, /* i : predicted scaled innov. energy */ - const int16_t do_WI, /* i : FEC fast recovery flag */ - float *pitch_buf, /* o : floating pitch for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - float *bwe_exc, /* i/o: excitation for SWB TBE */ - int16_t *unbits, /* i/o: number of unused bits */ - float *gain_buf, /* o : floating pitch gain for each subframe */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -); - -void decod_amr_wb( - Decoder_State *st, /* i/o: decoder static memory */ - const float *Aq, /* i : LP filter coefficients */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *exc, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - int16_t hf_gain[NB_SUBFR], /* o : decoded HF gain */ - float *voice_factors, /* o : voicing factors */ - float *gain_buf /* o : floating pitch gain for each subframe */ -); - -ivas_error init_decoder( - Decoder_State *st, /* o : Decoder static variables structure */ - const int16_t idchan, /* i : channel ID */ - const MC_MODE mc_mode /* i : MC mode */ -); - -void destroy_cldfb_decoder_flt( - Decoder_State *st /* o : Decoder static variables structure */ -); - -void HQ_core_dec_init_flt( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ -); - -void HQ_nbfec_init_flt( - HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */ -); - -ivas_error evs_dec( - Decoder_State *st, /* i/o: Decoder state structure */ - float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis */ - float *output, /* o : output synthesis signal */ - FRAME_MODE frameMode /* i : Decoder frame mode */ -); - -void get_next_frame_parameters( - Decoder_State *st /* i/o: Decoder state structure */ -); - -ivas_error amr_wb_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float mem_hp20_out[L_HP20_MEM], /* i/o: HP filter memory for synthesis */ - float *output /* o : synthesis output */ -); - -void transf_cdbk_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */ - const int16_t i_subfr, /* i : subframe index */ - const float Es_pred, /* i : predicited scaled innovation energy */ - const float gain_code, /* i : innovative excitation gain */ - float *gain_preQ, /* o : prequantizer excitation gain */ - float *norm_gain_preQ, /* o : normalized prequantizer excitation gain */ - float code_preQ[], /* o : prequantizer excitation */ - int16_t *unbits /* o : number of AVQ unused bits */ -); - -/*! r: decoded gain */ -float gain_dequant( - int16_t index, /* i : quantization index */ - const float min_val, /* i : value of lower limit */ - const float max_val, /* i : value of upper limit */ - const int16_t bits /* i : number of bits to dequantize */ -); - -void hq_core_enc( - Encoder_State *st, /* i/o: encoder state structure */ - const float *audio, /* i : input audio signal */ - const int16_t input_frame, /* i : frame length */ - const int16_t hq_core_type, /* i : HQ core type */ - const int16_t Voicing_flag, /* i : Voicing flag for FER method selection */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -int16_t detect_transient( - Encoder_State *st, /* i/o: encoder state structure */ - const float *in, /* i : input signal */ - const int16_t L /* i : length */ -); - -void wtda( - const float *new_audio, /* i : input audio */ - float *wtda_audio, /* o : windowed audio */ - float *old_wtda, /* i/o: windowed audio from previous frame */ - const int16_t left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ - const int16_t right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const int16_t L /* i : length */ -); - -void wtda_ext( - const float *new_audio, /* i : input audio */ - float *wtda_audio, /* o : windowed audio */ - const int16_t left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ - const int16_t right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const int16_t L, /* i : length */ - const uint16_t kernel_type /* i : transform kernel type (0 - 3) */ -); - -void tcx_get_windows_mode1_flt( - const int16_t left_mode, /* i : overlap mode of left window half */ - const int16_t right_mode, /* i : overlap mode of right window half */ - float *left_win, /* o : left overlap window */ - float *right_win, /* o : right overlap window */ - float *left_win_int, /* o : left overlap window */ - float *right_win_int, /* o : right overlap window */ - const int16_t L /* i : length */ -); - -void direct_transform( - const float *in32, /* i : input signal */ - float *out32, /* o : output transformation */ - const int16_t is_transient, /* i : transient flag */ - const int16_t L, /* i : length */ - const int16_t element_mode /* i : IVAS element mode */ -); - - -void interleave_spectrum( - float *coefs, /* i/o: input and output coefficients */ - const int16_t length /* i : length of spectrum */ -); - -void hq_hr_enc( - Encoder_State *st, /* i/o: encoder state structure */ - float *coefs, /* i/o: transform-domain coefficients */ - const int16_t length, /* i : length of spectrum */ - int16_t *num_bits, /* i/o: number of available bits */ - const int16_t is_transient, /* i : transient flag */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void huff_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t N, /* i : Number of codewords to decode */ - const int16_t buffer_len, /* i : Number of bits to read */ - const int16_t num_lengths, /* i : Number of different huffman codeword lengths */ - const int16_t *thres, /* i : Threshold of first codeword of each length */ - const int16_t *offset, /* i : Offset for first codeword */ - const int16_t *huff_tab, /* i : Huffman table order by codeword lengths */ - int16_t *index /* o : Decoded index */ -); - -void reordernorm( - const int16_t *ynrm, /* i : quantization indices for norms */ - const int16_t *normqlg2, /* i : quantized norms */ - int16_t *idxbuf, /* o : reordered quantization indices */ - int16_t *normbuf, /* o : reordered quantized norms */ - const int16_t nb_sfm /* i : number of bands */ -); - -void diffcod( - const int16_t N, /* i : number of sub-vectors */ - int16_t *y, /* i/o: indices of quantized norms */ - int16_t *difidx /* o : differential code */ -); - -void diffcod_lrmdct( - const int16_t N, /* i : number of sub-vectors */ - const int16_t be_ref, /* i : band energy reference */ - int16_t *y, /* i/o: indices of quantized norms */ - int16_t *difidx, /* o : differential code */ - const int16_t is_transient /* i : transient flag */ -); - -void bitallocsum( - int16_t *R, /* i : bit-allocation vector */ - const int16_t nb_sfm, /* i : number of sub-vectors */ - int16_t *sum, /* o : total number of bits allocated */ - int16_t *Rsubband, /* o : rate per subband (Q3) */ - const int16_t num_bits, /* i : number of bits */ - const int16_t length, /* i : length of spectrum */ - const int16_t *sfmsize /* i : Length of bands */ -); -/*! r: BWE class */ -int16_t swb_bwe_gain_deq_flt( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t core, /* i : core */ - float *SWB_tenv, /* o : time-domain BWE envelope */ - float *SWB_fenv, /* o : frequency-domain BWE envelope */ - const int16_t hr_flag, /* i : high rate flag */ - const int16_t hqswb_clas /* i : HQ BWE class */ -); - -void save_old_syn( - const int16_t L_frame, /* i : frame length */ - const float syn[], /* i : ACELP synthesis */ - float old_syn[], /* o : old synthesis buffer */ - float old_syn_12k8_16k[], /* i/o: old synthesis buffer */ - const float preemph_fac, /* i : preemphasis factor */ - float *mem_deemph /* i/o: deemphasis filter memory */ -); - -void hq_generic_hf_decoding( - const int16_t HQ_mode, /* i : HQ mode */ - float *coeff_out1, /* i/o: BWE input & temporary buffer */ - const float *hq_generic_fenv, /* i : SWB frequency envelopes */ - float *coeff_out, /* o : SWB signal in MDCT domain */ - const int16_t hq_generic_offset, /* i : frequency offset for representing hq swb bwe*/ - int16_t *prev_L_swb_norm, /* i/o: last normalize length */ - const int16_t hq_swb_bwe_exc_clas, /* i : bwe excitation class */ - const int16_t *R ); - -void hq_core_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float out[], /* o : output synthesis */ - const int16_t output_frame, /* i : output frame length */ - const int16_t hq_core_type, /* i : HQ core type */ - const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */ - float *output /* o : LB synthesis in case of ACELP-HQ switch */ -); - -void IMDCT( - float *x, - float *old_syn_overl, - float *syn_Overl_TDAC, - float *xn_buf, - const float *tcx_aldo_window_1_trunc, - const float *tcx_aldo_window_2, - const float *tcx_mdct_window_half, - const float *tcx_mdct_window_minimum, - const float *tcx_mdct_window_trans, - const int16_t tcx_mdct_window_half_length, - const int16_t tcx_mdct_window_min_length, - int16_t index, - const uint16_t kernel_type, /* i : TCX transform kernel type */ - const int16_t left_rect, - const int16_t tcx_offset, - const int16_t overlap, - const int16_t L_frame, - const int16_t L_frameTCX, - const int16_t L_spec_TCX5, - const int16_t L_frame_glob, - const int16_t frame_cnt, - const int16_t bfi, - float *old_out, - const int16_t FB_flag, - Decoder_State *st, - const int16_t fullband, - float *acelp_zir ); - -void hq_hr_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float *t_audio_q, /* o : transform-domain coefficients */ - const int16_t length, /* i : frame length */ - const int16_t num_bits, /* i : number of available bits */ - int16_t *ynrm, /* o : norm quantization index vector */ - int16_t *is_transient, /* o : transient flag */ - int16_t *hqswb_clas, /* o : HQ SWB class */ - float *SWB_fenv, /* o : SWB frequency envelopes */ - const int16_t core_switching_flag /* i : Core switching flag */ - -); - -void hdecnrm_context( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t N, /* i : number of norms */ - int16_t *index, /* o : indices of quantized norms */ - int16_t *n_length /* o : decoded stream length */ -); - -void hdecnrm_tran( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t N, /* i : number of norms */ - int16_t *index /* o : indices of quantized norms */ -); - -void hdecnrm_resize( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t N, /* i : number of SFMs */ - int16_t *index /* o : norm quantization index vector */ -); - -void hdecnrm( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t N, /* i : number of norms */ - int16_t *index /* o : indices of quantized norms */ -); - -/*! r: index of last band */ -int16_t find_last_band( - const int16_t *bitalloc, /* i : bit allocation */ - const int16_t nb_sfm /* i : number of possibly coded bands */ -); - -void fill_spectrum( - float *coeff, /* i/o: normalized MLT spectrum / nf spectrum */ - int16_t *R, /* i : number of pulses per band */ - const int16_t is_transient, /* i : transient flag */ - int16_t norm[], /* i : quantization indices for norms */ - const float *hq_generic_fenv, /* i : HQ GENERIC envelope */ - const int16_t hq_generic_offset, /* i : HQ GENERIC offset */ - const int16_t nf_idx, /* i : noise fill index */ - const int16_t length, /* i : Length of spectrum (32 or 48 kHz) */ - const float env_stab, /* i : Envelope stability measure [0..1] */ - int16_t *no_att_hangover, /* i/o: Frame counter for attenuation hangover */ - float *energy_lt, /* i/o: Long-term energy measure for transient detection */ - int16_t *bwe_seed, /* i/o: random seed for generating BWE input */ - const int16_t hq_generic_exc_clas, /* i : HF excitation class */ - const int16_t core_sfm, /* i : index of the end band for core */ - int16_t HQ_mode, /* i : HQ mode */ - float noise_level[], /* i : noise level for harmonic modes */ - int32_t core_brate, /* i : target bitrate */ - float prev_noise_level[], /* i/o: noise factor in previous frame */ - int16_t *prev_R, /* i/o: bit allocation info. in previous frame */ - float *prev_coeff_out, /* i/o: decoded spectrum in previous frame */ - const int16_t *peak_idx, /* i : peak positions */ - const int16_t Npeaks, /* i : number of peaks */ - const int16_t *npulses, /* i : Number of assigned pulses per band */ - int16_t prev_is_transient, /* i : previous transient flag */ - float *prev_normq, /* i : previous norms */ - float *prev_env, /* i : previous noise envelopes */ - int16_t prev_bfi, /* i : previous bad frame indicator */ - const int16_t *sfmsize, /* i : Length of bands */ - const int16_t *sfm_start, /* i : Start of bands */ - const int16_t *sfm_end, /* i : End of bands */ - int16_t *prev_L_swb_norm, /* i/o: last normalize length for harmonic mode */ - int16_t prev_hq_mode, /* i : previous HQ mode */ - const int16_t num_sfm, /* i : Number of bands */ - const int16_t num_env_bands, /* i : Number of envelope bands */ - const int16_t element_mode /* i : element mode */ -); - -void de_interleave_spectrum( - float *coefs, /* i/o: input and output coefficients */ - int16_t length /* i : length of spectrum */ -); - -void inverse_transform( - const float *InMDCT, /* i : input MDCT vector */ - float *Out, /* o : output vector */ - const int16_t IsTransient, /* i : transient flag */ - const int16_t L, /* i : output frame length */ - const int16_t L_inner, /* i : length of the transform */ - const int16_t element_mode /* i : IVAS element mode */ -); - -void window_ola( - const float *ImdctOut, /* i : input */ - float *auOut, /* o : output audio */ - float *OldauOut, /* i/o: audio from previous frame */ - const int16_t L, /* i : length */ - const int16_t right_mode, - const int16_t left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const int16_t use_bfi_win, /* i : use BFI windowing */ - const int16_t oldHqVoicing, /* i : previous HqVoicing */ - float *oldgapsynth /* i : previous gapsynth */ -); - -void window_ola_ext( - const float *ImdstOut, /* i : input */ - float *auOut, /* o : output audio */ - float *OldauOut, /* i/o: audio from previous frame */ - const int16_t L, /* i : length */ - const int16_t right_mode, - const int16_t left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const uint16_t kernel_type /* i : transform kernel type */ -); - -void map_quant_weight( - const int16_t normqlg2[], /* i : quantized norms */ - int16_t wnorm[], /* o : weighted norm */ - const int16_t is_transient /* i : transient flag */ -); - -void recovernorm( - const int16_t *const idxbuf, /* i : reordered quantization indices */ - int16_t *ynrm, /* o : recovered quantization indices */ - int16_t *normqlg2, /* o : recovered quantized norms */ - const int16_t nb_sfm /* i : number of subbands */ -); - -void reordvct( - int16_t *y, /* i/o: vector to rearrange */ - const int16_t N, /* i : dimensions */ - int16_t *idx /* o : reordered vector index */ -); - -void bitalloc( - int16_t *y, /* i : reordered norm of sub-vectors */ - int16_t *idx, /* i : reordered sub-vector indices */ - int16_t sum, /* i : number of available bits */ - int16_t N, /* i : number of norms */ - int16_t K, /* i : maximum number of bits per dimension */ - int16_t *r, /* o : bit-allacation vector */ - const int16_t *sfmsize, /* i : Length of bands */ - const int16_t hqswb_clas /* i : signal classification flag */ -); - -/*! r: Integer (truncated) number of allocated bits */ -int16_t BitAllocF( - int16_t *y, /* i : norm of sub-vectors */ - int32_t bit_rate, /* i : bitrate */ - int16_t B, /* i : number of available bits */ - int16_t N, /* i : number of sub-vectors */ - int16_t *R, /* o : bit-allocation indicator */ - int16_t *Rsubband, /* o : sub-band bit-allocation vector (Q3) */ - const int16_t hqswb_clas, /* i : hq swb class */ - const int16_t num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */ -); - -/*! r: Integer (truncated) number of allocated bits */ -int16_t BitAllocWB( - int16_t *y, /* i : norm of sub-vectors */ - int16_t B, /* i : number of available bits */ - int16_t N, /* i : number of sub-vectors */ - int16_t *R, /* o : bit-allocation indicator */ - int16_t *Rsubband ); /* o : sub-band bit-allocation vector (Q3) */ - -/*! r: Number of low frequency bands */ -int16_t hvq_pvq_bitalloc( - int16_t num_bits, /* i/o: Number of available bits (including gain bits) */ - const int32_t core_brate, /* i : bitrate */ - const int16_t bwidth, /* i : Encoded bandwidth */ - const int16_t *ynrm, /* i : Envelope coefficients */ - const int32_t manE_peak, /* i : Peak energy mantissa */ - const int16_t expE_peak, /* i : Peak energy exponent */ - int16_t *Rk, /* o : bit allocation for concatenated vector */ - int16_t *R, /* i/o: Global bit allocation */ - int16_t *sel_bands, /* o : Selected bands for encoding */ - int16_t *n_sel_bands /* o : No. of selected bands for encoding */ -); - -void floating_point_add_float( - int32_t *mx, /* i/o: mantissa of the addend Q31 */ - int16_t *ex, /* i/o: exponent of the addend Q0 */ - const int32_t my, /* i : mantissa of the adder Q31 */ - const int16_t ey /* i : exponent of the adder Q0 */ -); - -/*! r: Number of bits needed */ -int16_t rc_get_bits2( - const int16_t N, /* i : Number of bits currently used */ - const uint32_t range /* i : Range of range coder */ -); - -void rc_enc_init( - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - int16_t tot_bits /* i : Total bit budget */ -); - -void rc_encode( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const uint32_t cum_freq, /* i : Cumulative frequency up to symbol */ - const uint32_t sym_freq, /* i : Symbol probability */ - const uint32_t tot /* i : Total cumulative frequency */ -); - -void rc_enc_finish( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ -); - -void rc_enc_bits( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const uint32_t value, /* i : Value to encode */ - const int16_t bits /* i : Number of bits used */ -); - -void rc_enc_uniform( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - uint32_t value, /* i : Value to encode */ - uint32_t tot /* i : Maximum value */ -); - -void rc_dec_init( - Decoder_State *st, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - int16_t tot_bits /* i : Total bit budget */ -); - -/*! r: Decoded value */ -uint32_t rc_decode( - int16_t *BER_detect, /* o : Bit error detection flag */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - uint32_t tot /* i : Total cumulative frequency */ -); - -void rc_dec_update( - Decoder_State *st, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - const uint32_t cum_freq, /* i : Cumulative frequency */ - const uint32_t sym_freq /* i : Symbol frequency */ -); - -/*! r: Decoded value */ -uint32_t rc_dec_bits( - Decoder_State *st, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - const int16_t bits /* i : Number of bits */ -); - -/*! r: Decoded value */ -uint32_t rc_dec_uniform( - Decoder_State *st, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - const uint32_t tot /* i : Maximum value */ -); - -void rc_dec_finish( - Decoder_State *st, /* i/o: decoder state structure */ - PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */ -); - -/*! r: number of bits encoded */ -int16_t pvq_core_enc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - float coefs_norm[], /* i/o: normalized coefficients to encode */ - float coefs_quant[], /* o : quantized coefficients */ - const int16_t bits_tot, /* i : total number of bits */ - const int16_t nb_sfm, /* i : number of bands */ - const int16_t *sfm_start, /* i : Subband start coefficient */ - const int16_t *sfm_end, /* i : Subband end coefficient */ - const int16_t *sfmsize, /* i : subband width */ - int16_t *R, /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */ - int16_t *Rs, /* i/o: Integer bit allocation */ - int16_t *npulses, /* o : number of pulses */ - int16_t *maxpulse, /* i : maximum pulse per band */ - const int16_t core /* i : number of bands */ -); - -/*! r: number of bits decoded */ -int16_t pvq_core_dec( - Decoder_State *st, /* i/o: Decoder state */ - const int16_t *sfm_start, /* i : indices of first coeffs in the bands */ - const int16_t *sfm_end, /* i : indices of last coeffs in the bands */ - const int16_t *sfmsize, /* i : band sizes */ - float coefs_quant[], /* o : output MDCT */ - const int16_t bits_tot, /* i : bit budget */ - const int16_t nb_sfm, /* i : number of bands */ - int16_t *R, /* i/o: Bit allocation/Adjusted bit alloc.(Q3) */ - int16_t *Rs, /* i/o: Integer bit allocation */ - int16_t *npulses, /* o : number of pulses per band */ - int16_t *maxpulse, /* o : maximum pulse per band */ - const int16_t core /* i : core */ -); - -void pvq_encode( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const float *x, /* i : vector to quantize */ - int16_t *y, /* o : quantized vector (non-scaled integer)*/ - float *xq, /* o : quantized vector (scaled float) */ - const int16_t pulses, /* i : number of allocated pulses */ - const int16_t N, /* i : Length of vector */ - const float gain /* i : Gain */ -); - -void pvq_decode( - Decoder_State *st, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - float *xq, /* o : decoded vector (scaled float) */ - int16_t *y, /* o : decoded vector (non-scaled short)*/ - const int16_t K, /* i : number of allocated pulses */ - const int16_t N, /* i : Length of vector */ - const float gain /* i : Gain */ -); - -void rangeCoderFinalizationFBits( - const int16_t Brc, /* i : Current number of decoded bits */ - const uint32_t INTrc, /* i : Range coder state */ - int16_t *FBits /* i : Fractional finalization bits */ -); - -void bandBitsAdjustment( - const int16_t Brc, /* i : Current number of read quanta in range coder */ - const uint32_t INTrc, /* i : Range coder state */ - const int16_t Bavail, /* i : Available number of quanta */ - const int16_t Nbands, /* i : Number of bands */ - const int16_t D, /* i : Remaining number of bands to encode */ - const int16_t L, /* i : Size of current band */ - const int16_t Bband, /* i : Quanta allocation for current band */ - const int16_t Breserv, /* i : Quanta reservoir */ - int16_t *Bband_adj, /* o : Actual used number of quanta */ - int16_t *Brem, /* o : Quanta remaining */ - int16_t *Breservplus /* o : Quanta pool size */ -); - -void conservativeL1Norm( - const int16_t L, /* i : Length of vector segment */ - const int16_t Qvec, /* i : Assigned number of quanta */ - const int16_t Fcons, /* i : Conservative rounding flag */ - const int16_t Qavail, /* i : Input quanta remaining */ - const int16_t Qreserv, /* i : Input quanta in reservoir */ - const int16_t Dspec, /* i : assigned diracs from bitalloc */ - int16_t *Dvec, /* o : actual number of diracs */ - int16_t *Qspare, /* o : Output quanta remaining */ - int16_t *Qreservplus, /* o : Output quanta in reservoir */ - int16_t *Dspecplus /* o : Output number of diracs */ -); - -void NearOppSplitAdjustment( - const int16_t qband, /* i : quanta for current band */ - const int16_t qzero, /* i : range coder finalization quanta */ - const int16_t Qac, /* i : range coder current quanta */ - const uint32_t INTac, /* i : range coder state */ - const int16_t qglobal, /* i : quanta input */ - const int16_t FlagCons, /* i : conservative rounding flag */ - const int16_t Np, /* i : number of parts */ - const int16_t Nhead, /* i : first part */ - const int16_t Ntail, /* i : remaining parts */ - const int16_t Nnear, /* i : length of near component */ - const int16_t Nopp, /* i : length of opposite component */ - int16_t oppRQ3, /* i : ratio */ - int16_t *qnear, /* o : quantized near */ - int16_t *qopp, /* o : quantized opposite */ - int16_t *qglobalupd /* o : quanta remaining */ -); - -/*! r: Approximate integer division for positive input */ -int32_t intLimCDivPos( - const int32_t NUM, /* i : numerator */ - const int16_t DEN /* i : denominator */ -); - -/*! r: Approximate integer division */ -int16_t shrtCDivSignedApprox_flt( - const int16_t num, /* i : numerator */ - const int16_t den /* i : denominator */ -); - -void QuantaPerDsDirac( - const int16_t td, /* i : Length of vector segment */ - const int16_t dsDiracIndex, /* i : Quanta table index */ - const uint8_t *const *dimFrQuanta, /* i : Quanta lookup table */ - int16_t *Quanta /* i : Quanta */ -); - -void obtainEnergyQuantizerDensity( - const int16_t L_in, /* i : left vector energy */ - const int16_t R_in, /* i : right vector energy */ - int16_t *Density /* o : quantizer density */ -); - -void densityAngle2RmsProjDec( - const int16_t D, /* i : density */ - const int16_t indexphi, /* i : decoded index from AR dec */ - int16_t *oppQ15, /* o : opposite */ - int16_t *nearQ15, /* o : near */ - int16_t *oppRatioQ3 /* o : ratio */ -); - -void densityAngle2RmsProjEnc( - const int16_t D, /* i : density */ - const int16_t phiQ14uq, /* i : angle */ - int16_t *indexphi, /* o : index */ - int16_t *oppQ15, /* o : opposite */ - int16_t *nearQ15, /* o : near */ - int16_t *oppRatioQ3 /* o : ratio */ -); - -void env_adj( - const int16_t *pulses, /* i : number of pulses per band */ - const int16_t length, /* i : length of spectrum */ - const int16_t last_sfm, /* i : Index of last band */ - float *adj, /* o : Adjustment factors for the envelope */ - const float env_stab, /* i : Envelope stability parameter */ - const int16_t *sfmsize /* i : Length of bands */ -); - -float env_stability( - const int16_t *ynrm, /* i : Norm vector for current frame */ - const int16_t nb_sfm, /* i : Number of sub-bands */ - int16_t *mem_norm, /* i/o: Norm vector memory from past frame */ - int16_t *mem_env_delta, /* i/o: Envelope stability memory for smoothing*/ - const int16_t core_switching_flag /* i : Core switching flag */ -); - -/*! r: New speech/music state */ -float env_stab_smo( - float env_stab, /* i : env_stab value */ - float *env_stab_state_p, /* i/o: env_stab state probabilities */ - int16_t *ho_cnt /* i/o: hangover counter for speech state */ -); -void core_switching_post_enc( - Encoder_State *st, /* i/o: encoder state structure */ - // const float *old_inp_12k8, /* i : old input signal @12.8kHz */ - float *old_inp_12k8, /* i : old input signal @12.8kHz */ - // const float *old_inp_16k, /* i : old input signal @16kHz */ - float *old_inp_16k, /* i : old input signal @16kHz */ - // const float A[] /* i : unquant. LP filter coefs. */ - Word16 A_fx[], /* i : unquant. LP filter coefs. */ - Word16 Q_new ); -ivas_error core_switching_post_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float *synth, /* i/o: output synthesis */ - float *output, /* i/o: LB synth/upsampled LB synth */ - float output_mem[], /* i : OLA memory from last TCX/HQ frame */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t output_frame, /* i : frame length */ - const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */ - const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - const int16_t nchan_out, /* i : number of output channels */ - const int16_t last_element_mode /* i : element mode of previous frame */ -); - -ivas_error core_switching_pre_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t output_frame, /* i : frame length */ - const int32_t last_core_brate_st0, /* i : channel 0 last core bitrate */ - const int16_t nchan_out, /* i : number of output channels */ - const int16_t last_element_mode, /* i : last_element_mode */ - const int32_t last_element_brate /* i : last element bitrate */ -); - -void bandwidth_switching_detect( - Decoder_State *st /* i/o: decoder state structure */ -); - -void bw_switching_pre_proc( - Decoder_State *st, /* i/o: decoder state structure */ - const float *old_syn_12k8_16k, /* i : ACELP core synthesis @ 12.8kHz or 16kHz */ - const int32_t last_element_brate, /* i : last element bitrate */ - const int16_t nchan_out /* i : number of output channels */ -); - -void updt_bw_switching( - Decoder_State *st, /* i/o: decoder state structure */ - const float *synth /* i : float synthesis signal */ -); - -void swb_tbe_reset( - float mem_csfilt[], - float mem_genSHBexc_filt_down_shb[], - float state_lpc_syn[], - float syn_overlap[], - float state_syn_shbexc[], - float *tbe_demph, - float *tbe_premph, - float mem_stp_swb[], - float *gain_prec_swb ); - -void swb_tbe_reset_synth( - float genSHBsynth_Hilbert_Mem[], - float genSHBsynth_state_lsyn_filt_shb_local[] ); - -void find_td_envelope( - const float inp[], - const int16_t len, - const int16_t len_h, - float mem_h[], - float out[] ); - -void fb_tbe_reset_enc( - float elliptic_bpf_2_48k_mem[][4], - float *prev_fb_energy ); - -void fb_tbe_reset_synth( - float fbbwe_hpf_mem[][4], - float *prev_fbbwe_ratio ); - -void wb_tbe_extras_reset( - float mem_genSHBexc_filt_down_wb2[], - float mem_genSHBexc_filt_down_wb3[] ); - -void wb_tbe_extras_reset_synth( - float state_lsyn_filt_shb[], - float state_lsyn_filt_dwn_shb[], - float mem_resamp_HB[] ); - -void tbe_celp_exc_flt( - const int16_t element_mode, /* i : element mode */ - const int16_t idchan, /* i : channel ID */ - float *bwe_exc, /* i/o: BWE excitation */ - const int16_t L_frame, /* i : frame length */ - const int16_t L_subfr, /* i : subframe length */ - const int16_t i_subfr, /* i : subframe index */ - const int16_t T0, /* i : integer pitch lag */ - const int16_t T0_frac, /* i : fraction of lag */ - float *error, /* i/o: error */ - const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */ -); - -void prep_tbe_exc( - const int16_t L_frame, /* i : length of the frame */ - const int16_t L_subfr, /* i : subframe length */ - const int16_t i_subfr, /* i : subframe index */ - const float gain_pit, /* i : Pitch gain */ - const float gain_code, /* i : algebraic codebook gain */ - const float code[], /* i : algebraic excitation */ - const float voice_fac, /* i : voicing factor */ - float *voice_factors, /* o : TBE voicing factor */ - float bwe_exc[], /* i/o: excitation for TBE */ - const float gain_preQ, /* i : prequantizer excitation gain */ - const float code_preQ[], /* i : prequantizer excitation */ - const int16_t T0, /* i : integer pitch variables */ - const int16_t coder_type, /* i : coding type */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t element_mode, /* i : element mode */ - const int16_t idchan, /* i : channel ID */ - const int16_t flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ - const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */ -); - -void synthesise_fb_high_band( - const float excitation_in[], /* i : full band excitation */ - float output[], /* o : high band speech - 14.0 to 20 kHz */ - const float fb_exc_energy, /* i : full band excitation energy */ - const float ratio_float, /* i : energy ratio */ - const int16_t L_frame, /* i : ACELP frame length */ - const int16_t bfi, /* i : BFI flag */ - float *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ - float bpf_memory[][4] /* i/o: memory for elliptic bpf 48k */ -); - -void elliptic_bpf_48k_generic( - const float input[], /* i : input signal */ - float output[], /* o : output signal */ - float memory[][4], /* i/o: 4 arrays for memory */ - const float full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 */ -); - -void HQ_FEC_processing( - Decoder_State *st, /* i/o: decoder state structure */ - float *t_audio_q, /* o : MDCT coeffs. (for synthesis) */ - int16_t is_transient, /* i : Old flag for transient */ - float ynrm_values[][MAX_PGF], /* i : Old average Norm values for each group of bands */ - float r_p_values[][MAX_ROW], /* i : Computed y-intercept and slope by Regression */ - int16_t num_Sb, /* i : Number of sub-band group */ - int16_t nb_sfm, /* i : Number of sub-band */ - int16_t *Num_bands_p, /* i : Number of coeffs. for each sub-band */ - int16_t output_frame, /* i : Frame size */ - const int16_t *sfm_start, /* i : Start of bands */ - const int16_t *sfm_end /* i : End of bands */ -); - -void HQ_FEC_Mem_update( - Decoder_State *st, /* i/o: decoder state structure */ - const float *t_audio_q, - float *normq, - int16_t *ynrm, - const int16_t *Num_bands_p, - const int16_t is_transient, - const int16_t hqswb_clas, - const int16_t c_switching_flag, - const int16_t nb_sfm, - const int16_t num_Sb, - float *mean_en_high, - const int16_t hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ - const int16_t output_frame /* i : Frame size */ -); - -void time_domain_FEC_HQ( - Decoder_State *st, /* i : Decoder State */ - float *wtda_audio, /* i : input */ - float *out, /* o : output audio */ - const float mean_en_high, /* i : transient flag */ - const int16_t output_frame /* i : Frame size */ -); - -void save_synthesis_hq_fec( - Decoder_State *st, /* i/o: decoder state structure */ - const float *output, /* i : decoded synthesis */ - const int16_t output_frame, /* i : decoded synthesis */ - CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ -); - -void Next_good_after_burst_erasures( - const float *ImdctOut, /* i : input */ - float *auOut, /* o : output audio */ - float *OldauOut, /* i/o: audio from previous frame */ - const int16_t ol_size /* i : overlap size */ -); - - -void reset_preecho_dec( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ decoder handle */ -); - -void preecho_sb( - const int32_t core_brate, /* i : core bitrate */ - const float wtda_audio[], /* i : imdct signal */ - float *rec_sig, /* i : reconstructed signal, output of the imdct transform */ - const int16_t framelength, /* i : frame length */ - float *memfilt_lb, /* i/o: memory */ - float *mean_prev_hb, /* i/o: memory */ - float *smoothmem, /* i/o: memory */ - float *mean_prev, /* i/o: memory */ - float *mean_prev_nc, /* i/o: memory */ - float *wmold_hb, /* i/o: memory */ - int16_t *prevflag, /* i/o: flag */ - int16_t *pastpre, /* i/o: flag */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void hq2_core_configure( - const int16_t frame_length, /* i : frame length */ - const int16_t num_bits, /* i : number of bits */ - const int16_t is_transient, /* i : transient flag */ - int16_t *bands, - int16_t *length, - int16_t band_width[], - int16_t band_start[], - int16_t band_end[], - Word32 *L_qint, /* o : Q29 */ - Word16 *eref_fx, /* o : Q10 */ - Word16 *bit_alloc_weight_fx, /* o : Q13 */ - int16_t *gqlevs, - int16_t *Ngq, - int16_t *p2a_bands, - float *p2a_th, - float *pd_thresh, - float *ld_slope, - float *ni_coef, - float *ni_pd_th, - int32_t bwe_br ); - -void hq_lr_enc( - Encoder_State *st, /* i/o: encoder state structure */ - float t_audio[], /* i/o: transform-domain coefs. */ - const int16_t inner_frame, /* i : inner frame length */ - int16_t *num_bits, /* i/o: number of available bits */ - const int16_t is_transient /* i : transient flag */ -); - -void hq_lr_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float yout[], /* o : transform-domain output coefs. */ - const int16_t inner_frame, /* i : inner frame length */ - int16_t num_bits, /* i : number of available bits */ - int16_t *is_transient /* o : transient flag */ -); - -void hq2_bit_alloc( - const float band_energy[], /* i : band energy of each subband */ - const int16_t bands, /* i : total number of subbands in a frame */ - Word32 L_Rk[], /* i/o: Bit allocation/Adjusted bit alloc. */ - int16_t *bit_budget, /* i/o: bit bugdet */ - int16_t *p2a_flags, /* i : HF tonal indicator */ - const Word16 weight_fx, /* i : weight (Q13) */ - const int16_t band_width[], /* i : Sub band bandwidth */ - const int16_t num_bits, /* i : available bits */ - const int16_t hqswb_clas, /* i : HQ2 class information */ - const int16_t bwidth, /* i : input bandwidth */ - const int16_t is_transient /* i : indicator HQ_TRANSIENT or not */ -); - -void hq2_noise_inject( - float y2hat[], - const int16_t band_start[], - const int16_t band_end[], - const int16_t band_width[], - float Ep[], - float Rk[], - const int16_t npulses[], - int16_t ni_seed, - const int16_t bands, - const int16_t ni_start_band, - const int16_t bw_low, - const int16_t bw_high, - const float enerL, - const float enerH, - float last_ni_gain[], - float last_env[], - int16_t *last_max_pos_pulse, - int16_t *p2a_flags, - int16_t p2a_bands, - const int16_t hqswb_clas, - const int16_t bwidth, - const int32_t bwe_br ); - -void mdct_spectrum_denorm( - const int32_t inp_vector[], - float y2[], - const int16_t band_start[], - const int16_t band_end[], - const int16_t band_width[], - const float band_energy[], - const int16_t npulses[], - const int16_t bands, - const float ld_slope, - const float pd_thresh ); - -void reverse_transient_frame_energies( - float band_energy[], /* o : band energies */ - const int16_t bands /* i : number of bands */ -); - - -void hvq_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t num_bits, /* i : Number of available bits */ - const int32_t core_brate, /* i : Core bitrate */ - const int16_t *ynrm, /* i : Envelope coefficients */ - int16_t *R, /* i/o: Bit allocation/updated bit allocation */ - float *noise_level, /* o : Noise level */ - int16_t *peak_idx, /* o : Peak position vector */ - int16_t *Npeaks, /* o : Total number of peaks */ - float *coefsq_norm, /* o : Output vector */ - const int16_t core /* i : Core */ -); - -void hq_configure_bfi( - int16_t *nb_sfm, /* o : Number of sub bands */ - int16_t *num_Sb, /* o : Number of FEC sub bands ? */ - int16_t *num_bands_p, /* o : FEC sub bands */ - const int16_t **sfmsize, /* o : Subband bandwidths */ - const int16_t **sfm_start, /* o : Subband start coefficients */ - const int16_t **sfm_end /* o : Subband end coefficients */ -); - -void swb_bwe_enc_lr( - Encoder_State *st, /* i/o: encoder state structure */ - const float m_core[], /* i : core synthesis (MDCT) */ - const float m_orig[], /* i/o: scaled orig signal (MDCT) */ - float m[], /* o : output, SWB part (MDCT) */ - const int32_t total_brate, /* i : total bitrate for selecting subband pattern */ - int16_t BANDS, - int16_t *band_start, - int16_t *band_end, - float *band_energy, - int16_t *p2a_flags, - const int16_t hqswb_clas, - int16_t lowlength, - int16_t highlength, - int16_t *prev_frm_index, - const int16_t har_bands, - int16_t *prev_frm_hfe2, - int16_t *prev_stab_hfe2, - int16_t band_width[], - const float y2_ni[], - int16_t *ni_seed ); - -void swb_bwe_dec_lr( - Decoder_State *st, /* i/o: decoder state structure */ - const float m_core[], /* i : lowband synthesis */ - float m[], /* o : highband synthesis with lowband zeroed */ - const int32_t total_brate, /* i : total bitrate for selecting subband pattern */ - int16_t BANDS, - int16_t *band_start, - int16_t *band_end, - float *band_energy, - int16_t *p2a_flags, - const int16_t hqswb_clas, - int16_t lowlength, - int16_t highlength, - const int16_t har_bands, - int16_t *prev_frm_hfe2, - int16_t *prev_stab_hfe2, - int16_t band_width[], - const float y2_ni[], - int16_t *ni_seed ); - -int16_t get_usebit_npswb( - const int16_t hqswb_clas ); - -void GetPredictedSignal( - const float *predBuf, /* i : prediction buffer */ - float *outBuf, /* o : output buffer */ - const int16_t lag, /* i : prediction buffer offset */ - const int16_t fLen, /* i : length of loop (output) */ - const float gain /* i : gain to be applied */ -); - -void convert_lagIndices_pls2smp( - int16_t lagIndices_in[], - int16_t nBands_search, - int16_t lagIndices_out[], - const float sspectra[], - const int16_t sbWidth[], - const int16_t fLenLow ); - -void FindNBiggest2_simple( - const float *inBuf, /* i : input buffer (searched) */ - GainItem *g, /* o : N biggest components found */ - const int16_t nIdx, /* i : search length */ - int16_t *n, /* i : number of components searched (N biggest) */ - const int16_t N_NBIGGESTSEARCH ); - -void updat_prev_frm( - float y2[], - float t_audio[], - const int32_t bwe_br, - const int16_t length, - const int16_t inner_frame, - const int16_t bands, - const int16_t bwidth, - const int16_t is_transient, - const int16_t hqswb_clas, - int16_t *prev_hqswb_clas, - int16_t *prev_SWB_peak_pos, - int16_t prev_SWB_peak_pos_tmp[], - int16_t *prev_frm_hfe2, - int16_t *prev_stab_hfe2, - const int16_t bws_cnt ); - -void hf_parinitiz( - const int32_t total_brate, - const int16_t hqswb_clas, - int16_t lowlength, - int16_t highlength, - int16_t wBands[], - const int16_t **subband_search_offset, - const int16_t **subband_offsets, - int16_t *nBands, - int16_t *nBands_search, - int16_t *swb_lowband, - int16_t *swb_highband ); - -float spectrumsmooth_noiseton( - float spectra[], - const float spectra_ni[], - float sspectra[], - float sspectra_diff[], - float sspectra_ni[], - const int16_t fLenLow, - int16_t *ni_seed ); - -void noiseinj_hf( - float xSynth_har[], - const float th_g[], - const float band_energy[], - float *prev_En_sb, - const int16_t p2a_flags[], - const int16_t BANDS, - const int16_t band_start[], - const int16_t band_end[], - const int16_t fLenLow ); - -void noise_extr_corcod( - float spectra[], - const float spectra_ni[], - float sspectra[], - float sspectra_diff[], - float sspectra_ni[], - const int16_t fLenLow, - int16_t prev_hqswb_clas, - float *prev_ni_ratio ); - -void genhf_noise( - float noise_flr[], - float xSynth_har[], - float *predBuf, - int16_t bands, /* i : total number of subbands in a frame */ - int16_t harmonic_band, /* i : Number of LF harmonic frames */ - int16_t har_freq_est2, - int16_t pos_max_hfe2, - int16_t *pul_res, - GainItem pk_sf[], - const int16_t fLenLow, - const int16_t fLenHigh, - const int16_t sbWidth[], - const int16_t lagIndices[], - const int16_t subband_offsets[], - const int16_t subband_search_offset[] ); - -void ton_ene_est( - float xSynth_har[], - float be_tonal[], - float band_energy[], - int16_t band_start[], - int16_t band_end[], - int16_t band_width[], - const int16_t fLenLow, - const int16_t fLenHigh, - int16_t bands, - int16_t har_bands, - float ni_lvl, - GainItem pk_sf[], - int16_t *pul_res ); - -void Gettonl_scalfact( - float *outBuf, /* o : synthesized spectrum */ - const float *codbuf, /* i : core coder */ - const int16_t fLenLow, /* i : lowband length */ - const int16_t fLenHigh, /* i : highband length */ - int16_t harmonic_band, /* i : Number of LF harmonic frames */ - int16_t bands, /* i : total number of subbands in a frame */ - float *band_energy, /* i : band energy of each subband */ - int16_t *band_start, /* i : subband start indices */ - int16_t *band_end, /* i : subband end indices */ - const int16_t p2aflags[], - float be_tonal[], - GainItem *pk_sf, - int16_t *pul_res ); - -void SpectrumSmoothing( - float *inBuf, - float *outBuf, - const int16_t fLen, - const float th_cut ); - -void hq2_bit_alloc_har( - float *y, /* i : band energy of sub-vectors */ - int16_t B, /* i : number of available bits */ - int16_t N, /* i : number of sub-vectors */ - Word32 *L_Rsubband, - int16_t p2a_bands, - int32_t core_brate, /* i : core bitrate */ - int16_t p2a_flags[], - int16_t band_width[] ); - -void GetSynthesizedSpecThinOut( - const float *predBuf, - float *outBuf, - const int16_t nBands, - const int16_t *sbWidth, - const int16_t *lagIndices, - const float *lagGains, - const int16_t predBufLen ); - -void return_bits_normal2( - int16_t *bit_budget, - const int16_t p2a_flags[], - const int16_t bands, - const int16_t bits_lagIndices[] ); - -void GetlagGains( - const float *predBuf, - const float *band_energy, - const int16_t nBands, - const int16_t *sbWidth, - const int16_t *lagIndices, - const int16_t predBufLen, - float *lagGains ); - -void preset_hq2_swb( - const int16_t hqswb_clas, - const int16_t band_end[], - int16_t *har_bands, - int16_t p2a_bands, - const int16_t length, - const int16_t bands, - int16_t *lowlength, - int16_t *highlength, - float m[] ); - -void post_hq2_swb( - const float m[], - const int16_t lowlength, - const int16_t highlength, - const int16_t hqswb_clas, - const int16_t har_bands, - const int16_t bands, - const int16_t p2a_flags[], - const int16_t band_start[], - const int16_t band_end[], - float y2[], - int16_t npulses[] ); - -void har_denorm_pulcnt( - float spectra[], /* i/o: MDCT domain spectrum */ - const int16_t band_start[], /* i : Number subbands/Frame */ - const int16_t band_end[], /* i : Band Start of each SB */ - const float band_energy[], /* i : Band end of each SB */ - const int16_t band_width[], - const int16_t npulses[], - const int16_t har_bands /* i : No. of harmonic bands */ -); - -int16_t har_est( - float spectra[], - const int16_t N, - int16_t *har_freq_est1, - int16_t *har_freq_est2, - int16_t *flag_dis, - int16_t *prev_frm_hfe2, - const int16_t subband_search_offset[], - const int16_t sbWidth[], - int16_t *prev_stab_hfe2 ); - -void spt_shorten_domain_pre( - const int16_t band_start[], - const int16_t band_end[], - const int16_t prev_SWB_peak_pos[], - const int16_t BANDS, - const int32_t bwe_br, - int16_t new_band_start[], - int16_t new_band_end[], - int16_t new_band_width[] ); - -void spt_shorten_domain_band_save( - const int16_t bands, - const int16_t band_start[], - const int16_t band_end[], - const int16_t band_width[], - int16_t org_band_start[], - int16_t org_band_end[], - int16_t org_band_width[] ); - -void spt_shorten_domain_band_restore( - const int16_t bands, - int16_t band_start[], - int16_t band_end[], - int16_t band_width[], - const int16_t org_band_start[], - const int16_t org_band_end[], - const int16_t org_band_width[] ); - -void spt_swb_peakpos_tmp_save( - const float y2[], - const int16_t bands, - const int16_t band_start[], - const int16_t band_end[], - int16_t prev_SWB_peak_pos_tmp[] ); - -void hq_ecu( - const float *prevsynth, /* i : buffer of previously synthesized signal */ - float *ecu_rec, /* o : reconstructed frame in tda domain */ - int16_t *time_offs, /* i/o: Sample offset for consecutive frame losses*/ - float *X_sav, /* i/o: Stored spectrum of prototype frame */ - int16_t *num_p, /* i/o: Number of identified peaks */ - int16_t *plocs, /* i/o: Peak locations */ - float *plocsi, /* i/o: Interpolated peak locations */ - const float env_stab, /* i : Envelope stability parameter */ - int16_t *last_fec, /* i/o: Flag for usage of pitch dependent ECU */ - const int16_t ph_ecu_HqVoicing, /* i : HQ Voicing flag */ - int16_t *ph_ecu_active, /* i : Phase ECU active flag */ - float *gapsynth, /* o : Gap synthesis */ - const int16_t prev_bfi, /* i : indicating burst frame error */ - const int16_t old_is_transient[2], /* i : flags indicating previous transient frames*/ - float *mag_chg_1st, /* i/o: per band magnitude modifier for transients*/ - float Xavg[LGW_MAX], /* i/o: Frequency group average gain to fade to */ - float *beta_mute, /* o : Factor for long-term mute */ - const int16_t output_frame, /* i : frame length */ - Decoder_State *st /* i/o: decoder state structure */ -); - -void peakfinder( - const float *x0, /* i : vector from which the maxima will be found */ - const int16_t len0, /* i : length of input vector */ - int16_t *plocs, /* o : the indicies of the identified peaks in x0 */ - int16_t *cInd, /* o : number of identified peaks */ - const float sel, /* i : The amount above surrounding data for a peak to be identified */ - const int16_t endpoints /* i : Flag to include endpoints in peak search */ -); - -/*! r: interpolated maximum position */ -float imax_pos( - const float *y /* i : Input vector for peak interpolation */ -); - - -void fft3( - const float X[], /* i : input frame */ - float Y[], /* o : DFT of input frame */ - const int16_t n /* i : block length (must be radix 3) */ -); - -void ifft3( - const float X[], /* i : input frame */ - float Y[], /* o : iDFT of input frame */ - const int16_t n /* i : block length (must be radix 3) */ -); - -/*! r: updated estimate of background noise */ -void minimumStatistics( - float *noiseLevelMemory, /* i/o: internal state */ - int16_t *noiseLevelIndex, /* i/o: internal state */ - int16_t *currLevelIndex, /* i/o: internal state (circular buffer) */ - float *noiseEstimate, /* i/o: previous estimate of background noise */ - float *lastFrameLevel, /* i/o: level of the last frame */ - float currentFrameLevel, /* i : level of the current frame */ - const float minLev, /* i : minimum level */ - const int16_t buffSize /* i : buffer size */ -); - -void E_ACELP_toeplitz_mul( - const float R[], - const float c[], - float d[] ); - -void E_ACELP_innovative_codebook( - const float *exc, /* i : pointer to the excitation frame */ - const int16_t T0, /* i : integer pitch lag */ - const int16_t T0_frac, /* i : fraction of lag */ - const int16_t T0_res, /* i : pitch resolution */ - const float pitch_gain, /* i : adaptive codebook gain */ - const float tilt_code, /* i : tilt factor */ - ACELP_config *acelp_cfg, /* i/o: configuration of the ACELP */ - const int16_t i_subfr, /* i : subframe index */ - const float *Aq, /* i : quantized LPC coefficients */ - const float *h1, /* i : impulse response of weighted synthesis filter */ - const float *xn, /* i : Close-loop Pitch search target vector */ - const float *cn, /* i : Innovative codebook search target vector */ - const float *y1, /* i : zero-memory filtered adaptive excitation */ - float *y2, /* o : zero-memory filtered algebraic excitation */ - const int16_t acelpautoc, /* i : autocorrelation mode enabled */ - int16_t **pt_indice, /* i/o: quantization indices pointer */ - float *code, /* o : innovative codebook */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t last_L_frame, /* i : length of the last frame */ - const int32_t total_brate /* i : total bitrate */ -); - -int16_t E_ACELP_code43bit( - const float code[], - uint32_t *ps, - int16_t *p, - uint16_t idxs[] ); -void D_ACELP_indexing_ivas( - float code[], - PulseConfig config, - const int16_t num_tracks, - int16_t prm[], - int16_t *BER_detect ); - -void D_ACELP_decode_43bit( - uint16_t idxs[], - float code[], - int16_t *pulsestrack ); - -void fcb_pulse_track_joint_decode_ivas( - uint16_t *idxs, - const int16_t wordcnt, - uint32_t *index_n, - const int16_t *pulse_num, - const int16_t track_num ); - -void lag_wind_flt( - float r[], /* i/o: autocorrelations */ - const int16_t m, /* i : order of LP filter */ - const int32_t sr_core, /* i : sampling rate */ - const int16_t strength /* i : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */ -); - -void adapt_lag_wind_fx( - float r[], /* i/o: autocorrelations */ - const int16_t m, /* i : order of LP filter */ - const int16_t Top, /* i : open loop pitch lags from curr. frame (or NULL if n/a) */ - const float Tnc, /* i : open loop pitch gains from curr. frame (NULL if n/a) */ - const int32_t sr_core /* i : core sampling rate */ -); - -void core_coder_reconfig( - Encoder_State *st, /* i/o: encoder state structure */ - const int32_t last_total_brate /* i : last total bitrate */ -); - -void core_coder_mode_switch( - Encoder_State *st, /* i/o: encoder state structure */ - const int32_t last_total_brate, /* i : last bitrate */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ -); - -void enc_acelp_tcx_main( - Encoder_State *st, /* i/o: encoder state structure */ - const float new_samples[], /* i : new samples */ - float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/ - const float lsp_new[M], /* i : LSPs at the end of the frame */ - const float lsp_mid[M], /* i : LSPs at the middle of the frame */ - float bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - float *voice_factors, /* o : voicing factors */ - float pitch_buf[], /* o : floating pitch for each subframe */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void getTCXMode_ivas( - Decoder_State *st, /* i/o: decoder memory state */ - Decoder_State *st0, /* i : bitstream */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ -); - -void getTCXWindowing_ivas( - const Word16 core, /* i : current frame mode */ - const Word16 last_core, /* i : last frame mode */ - const Word16 element_mode, /* i : element mode */ - TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ - Decoder_State *st0 /* i : bitstream */ -); - -void getLPCparam_ivas( - Decoder_State *st, /* i/o: decoder memory state */ - int16_t param_lpc[], /* o : LTP parameters */ - Decoder_State *st0, /* i : bitstream */ - const int16_t ch, /* i : channel */ - const int16_t sns_low_br_mode /* i : SNS low-bitrate mode */ -); - -void getTCXparam_ivas( - Decoder_State *st, /* i/o: Decoder State handle */ - Decoder_State *st0, /* i : bitstream */ - CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */ - int16_t param[], /* o : decoded parameters */ - const int16_t bits_common, /* i : number of common bits */ - const int16_t start_bit_pos, /* i : position of the start bit */ - const int16_t *no_param_tns, /* i : number of TNS parameters per subframe */ - int16_t p_param[2], /* o : pointer to parameters for next round of bs reading*/ - int16_t nTnsBitsTCX10[2], - const int16_t pre_past_flag ); - -void pitch_pred_linear_fit_flt( - const int16_t nbLostCmpt, /* i : bfi counter */ - const int16_t last_good, /* i : last classification type */ - float *old_pitch_buf, /* i : pitch lag buffer */ - float *old_fpitch, /* i/o: pitch used for initial ACB generation */ - float *T0_out, /* o : estimated close loop pitch */ - const int16_t pit_min, /* i : Minimum pitch lag */ - const int16_t pit_max, /* i : Maximum pitch lag */ - float *mem_pitch_gain, /* i : lag pitch gain [0] is the most recent subfr lag */ - const int16_t limitation, - const int16_t plc_use_future_lag, /* i : number of subframes to predict */ - int16_t *extrapolationFailed, /* o : flag if extrap decides not to change the pitch */ - const int16_t nb_subfr /* i : number of ACELP subframes */ -); - -void get_subframe_pitch_flt( - const int16_t nSubframes, /* i : number of subframes */ - float pitchStart, /* i : starting pitch lag (in subframe -1) */ - float pitchEnd, /* i : ending pitch lag (in subframe nSubframes-1) */ - float *pitchBuf /* o : interpolated pitch lag per subframe */ -); - -void core_encode_openloop( - Encoder_State *st, /* i/o: encoder state structure */ - const float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/ - const float lsp_new[M], /* i : LSPs at the end of the frame */ - const float lsp_mid[M], /* i : LSPs at the middle of the frame */ - float *pitch_buf, /* i/o: floating pitch values for each subfr*/ - float *voice_factors, /* o : voicing factors */ - float *ptr_bwe_exc, /* o : excitation for SWB TBE */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void core_acelp_tcx20_switching( - Encoder_State *st, /* i/o: encoder state structure */ - float non_staX, /* i : unbound non-stationarity for sp/mu clas */ - float *pitch_fr, /* i/o: fraction pitch values */ - float *voicing_fr, /* i/o: fractional voicing values */ - const float currTempFlatness, /* i : flatness */ - const float lsp_mid[M], /* i : LSPs at the middle of the frame */ - const float stab_fac /* i : LP filter stability */ -); - -void core_encode_twodiv( - Encoder_State *st, /* i/o: coder memory state */ - const float new_samples[], /* i : new samples */ - float Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes*/ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void core_encode_update( - Encoder_State *st /* i/o: encoder state structure */ -); - -void core_encode_update_cng( - Encoder_State *st, /* i/o: encoder state structure */ - float *timeDomainBuffer, - float *A, - const float Aw[] /* i : weighted A(z) unquant. for subframes*/ -); - -void core_signal_analysis_high_bitrate( - const float *new_samples, - const int16_t T_op[3], /* i : open-loop pitch values for quantiz. */ - float lsp_new[], - float lsp_mid[], - Encoder_State *st, - float *mdst_spectrum[2], - int16_t pTnsSize[], - int16_t pTnsBits[], - int16_t param_core[], - int16_t *ltpBits, - float *windowed_samples, /* i/o: backup of windowed time signal */ - const int16_t L_frame, - const int16_t L_frameTCX, - const int16_t last_element_mode, - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void encode_acelp_gains( - const float *code, - const int16_t gains_mode, - const float mean_ener_code, - const int16_t clip_gain, - ACELP_CbkCorr *g_corr, - float *gain_pit, - float *gain_code, - int16_t **pt_indice, - float *past_gcode, - float *gain_inov, - const int16_t L_subfr, - float *code2, - float *gain_code2, - const int16_t noisy_speech_flag ); - -int16_t gain_enc_gacelp_uv( - const float *code, /* i : algebraic excitation */ - const float *code2, /* i : gaussian excitation */ - const int16_t lcode, /* i : Subframe size */ - const float mean_ener, /* i : quantized mean energy of the frame */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - float *gain_code2, /* o : quantized codebook gain */ - ACELP_CbkCorr *coeff, /* i/o: correlations , -2,, -2 and 2 */ - float *past_gcode, /* i/o: past gain of code */ - float *gain_inov, /* o : unscaled innovation gain */ - const int16_t noisy_speech_flag /* i : noisy speech flag */ -); - -int16_t Mode2_gain_enc_mless( - const float *code, /* i : algebraic excitation */ - const int16_t lcode, /* i : Subframe size */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - ACELP_CbkCorr *coeff, /* i/o: correlations , -2,, -2 and 2 */ - const float mean_ener, /* i : mean_ener defined in open-loop (3 bits) */ - const int16_t clip_gain, /* i : gain pitch clipping flag (1 = clipping) */ - float *past_gcode, /* i/o: past gain of code */ - float *gain_inov, /* o : unscaled innovation gain */ - const int16_t coder_type /* i : type of coder */ -); - -void decode_acelp_gains( - const float *code, - const int16_t gains_mode, - const float mean_ener_code, - float *gain_pit, - float *gain_code, - int16_t **pt_indice, - float *past_gpit, - float *past_gcode, - float *gain_inov, - const int16_t L_subfr, - float *code2, - float *gain_code2 ); - -void gain_dec_gacelp_uv( - int16_t index, /* i/o: Quantization index vector */ - const float *code, /* i : algebraic code excitation */ - const float *code2, /* i : algebraic code excitation */ - const float mean_ener, /* i : mean energy */ - const int16_t lcode, /* i : Subframe size */ - float *gain_pit, /* o : Quantized pitch gain */ - float *gain_code, /* o : Quantized codebook gain */ - float *gain_code2, /* o : Quantized codebook gain */ - float *past_gpit, /* i/o: past gain of pitch */ - float *past_gcode, /* i/o: past energy of code */ - float *gain_inov /* o : unscaled innovation gain */ -); - -void limit_T0_voiced_ivas( - const int16_t nbits, - const int16_t res, - const int16_t T0, /* i : rough pitch estimate around which the search is done */ - const int16_t T0_frac, /* i : pitch estimate fractional part */ - const int16_t T0_res, /* i : pitch resolution */ - int16_t *T0_min, /* o : lower pitch limit */ - int16_t *T0_min_frac, /* o : lower pitch limit */ - int16_t *T0_max, /* o : higher pitch limit */ - int16_t *T0_max_frac, /* o : higher pitch limit */ - const int16_t pit_min, /* i : Minimum pitch lag */ - const int16_t pit_max /* i : Maximum pitch lag */ -); - - -/*! r: floating pitch value */ -float Mode2_pit_decode_flt( - const int16_t coder_type, /* i : coding model */ - const int16_t i_subfr, /* i : subframe index */ - const int16_t L_subfr, /* i : sub-frame length */ - int16_t **pt_indice, /* i/o: quantization indices pointer */ - int16_t *T0, /* o : close loop integer pitch */ - int16_t *T0_frac, /* o : close loop fractional part of the pitch */ - int16_t *T0_res, /* i/o: pitch resolution */ - int16_t *T0_min, /* i/o: lower limit for close-loop search */ - int16_t *T0_min_frac, /* i/o: lower limit for close-loop search */ - int16_t *T0_max, /* i/o: higher limit for close-loop search */ - int16_t *T0_max_frac, /* i/o: higher limit for close-loop search */ - const int16_t pit_min, - const int16_t pit_fr1, - const int16_t pit_fr1b, - const int16_t pit_fr2, - const int16_t pit_max, - const int16_t pit_res_max ); - -void Mode2_abs_pit_dec_flt( - int16_t *T0, /* o : integer pitch lag */ - int16_t *T0_frac, /* o : pitch fraction */ - int16_t *T0_res, /* o : pitch resolution */ - int16_t **pt_indice, /* i/o: pointer to Vector of Q indexes */ - const int16_t pit_min, - const int16_t pit_fr1, - const int16_t pit_fr2, - const int16_t pit_res_max ); - -void Mode2_delta_pit_dec_flt( - int16_t *T0, /* o : integer pitch lag */ - int16_t *T0_frac, /* o : pitch fraction */ - int16_t T0_res, /* i : pitch resolution */ - int16_t *T0_min, /* i : delta search min */ - int16_t *T0_min_frac, /* i : delta search min */ - int16_t **pt_indice /* i/o: pointer to Vector of Q indexes */ -); - -void formant_post_filt_ivas( - PFSTAT_HANDLE hPFstat, /* i/o: Post filter related memories */ - float *synth_in, /* i : 12k8 synthesis */ - const float *Aq, /* i : LP filter coefficient */ - float *synth_out, /* i/o: input signal */ - const int16_t L_frame, /* i : frame length */ - const int16_t L_subfr, /* i : sub-frame length */ - const float lp_noise, /* i : background noise energy */ - const int32_t brate, /* i : bitrate */ - const int16_t off_flag /* i : Off flag */ -); - - -int16_t dlpc_avq( - int16_t *index, /* i : Quantization indices */ - float *LSF_Q, /* o : Quantized LSF vectors */ - const int16_t numlpc, /* i : Number of sets of lpc */ - const int32_t sr_core /* i : internal sampling rate */ -); - -int16_t decode_lpc_avq( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t numlpc, /* i : Number of sets of lpc */ - int16_t *param_lpc, /* o : lpc parameters */ - const int16_t ch, /* i : channel */ - const int16_t element_mode, /* i : element mode */ - const int16_t sns_low_br_mode /* i : SNS low-bitrate mode */ -); - - -void vlpc_2st_dec_flt( - float *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ - int16_t *indx, /* i : index[] (4 bits per words) */ - const int16_t mode, /* i : 0=abs, >0=rel */ - const int32_t sr_core /* i : internal sampling rate */ -); - -void lsf_weight_2st_flt( - const float *lsfq, - float *w, - const int16_t mode, - const int32_t sr_core ); - -void mdct_window_sine_flt( - float *window, - const int32_t Fs, - const int16_t n, - const int16_t window_type, - const int16_t element_mode ); - -void mdct_window_aldo_flt( - float *window1, - float *window2, - const int16_t n ); - -void AVQ_cod_lpc( - const float nvec[], /* i : vector to quantize */ - int16_t nvecq[], /* o : quantized normalized vector (assuming the bit budget is enough) */ - int16_t *indx, /* o : index[] (4 bits per words) */ - const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */ -); - -void AVQ_dec_lpc_ivas( - const int16_t indx[], /* i : index[] (4 bits per words) */ - int16_t nvecq[], /* o : vector quantized */ - const int16_t Nsv /* i : number of subvectors (lg=Nsv*8) */ -); - -void vlpc_1st_dec_flt( - const int16_t index, /* i : codebook index */ - float *lsfq, /* i/o: i:prediction o:quantized lsf */ - const int32_t sr_core ); - -void WindowSignal_flt( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - int16_t offset, /* i : left folding point offset relative to the input signal pointer */ - const int16_t left_overlap_mode, /* i : overlap mode of left window half */ - const int16_t right_overlap_mode, /* i : overlap mode of right window half */ - int16_t *left_overlap_length, /* o : TCX window left overlap length */ - int16_t *right_overlap_length, /* o : TCX window right overlap length */ - const float in[], /* i : input signal */ - int16_t *L_frame, /* i/o: frame length */ - float out[], /* o : output windowed signal */ - const int16_t truncate_aldo, /* i : nonzero to truncate long ALDO slope */ - const int16_t fullband /* i : fullband flag */ -); - -void HBAutocorrelation( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const int16_t left_mode, /* i : overlap mode of left window half */ - const int16_t right_mode, /* i : overlap mode of right window half */ - float speech[], /* i : speech */ - int16_t L_frame_glob, /* i/o: frame length */ - float *r /* o : autocorrelations vector */ -); - -void TNSAnalysis( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const int16_t L_frame, /* i : frame length */ - int16_t L_spec, /* i : length of the spectrum */ - const int16_t transform_type, /* i : transform type for the frame/subframe - TCX20 | TCX10 | TCX 5 (meaning 2 x TCX 5) */ - const int16_t isAfterACELP, /* i : Flag indicating if the last frame was ACELP. For the second TCX subframe it should be 0 */ - float spectrum[], /* i : MDCT spectrum of the subframe */ - TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */ - const float ltp_gain, /* i : ltp gain */ - STnsData *pTnsData, /* o : TNS data */ - int8_t *pfUseTns, /* o : Flag indicating if TNS is used */ - float *predictionGain /* o : TNS prediction gain */ -); - -void CalculateTnsFilt( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - const float pSpectrum[], /* i : MDCT spectrum */ - STnsData *pTnsData, /* o : TNS data struct */ - float *predictionGain /* o : TNS prediction gain */ -); - -void ShapeSpectrum( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const float A[], /* i : quantized coefficients NxAz_q[M+1] */ - float gainlpc[], /* o : MDCT gains for the previous frame */ - const int16_t L_frame_glob, /* i : frame length */ - int16_t L_spec, /* i : length of the spectrum */ - float spectrum[], /* i/o: MDCT spectrum */ - const int8_t fUseTns, /* i : Flag indicating if TNS is used */ - Encoder_State *st, /* i/o: encoder state structure */ - float *scf /* i : scale factors */ -); - -void QuantizeSpectrum( - Encoder_State *st, /* i/o: encoder state structure */ - const float A[], /* i : quantized coefficients NxAz_q[M+1] */ - const Word16 Aqind[], /* i : frame-independent quantized coeffs (M+1) */ - float gainlpc[], /* i : MDCT gains of the previous frame */ - float synth[], /* o : synthesis buffer */ - const int16_t nb_bits, /* i : bit budget */ - const int16_t tnsSize, /* i : number of tns parameters put into prm */ - int16_t prm[], /* o : tcx parameters */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - CONTEXT_HM_CONFIG *hm_cfg, /* i : HM configuration */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -/*! r: index of next coefficient */ -int16_t get_next_coeff_mapped_ivas( - int16_t ii[2], /* i/o: coefficient indexes */ - int32_t *pp, /* o : peak(1)/hole(0) indicator */ - int16_t *idx, /* o : index in unmapped domain */ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ -); - - -void ACcontextMapping_encode2_no_mem_s17_LC( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - int16_t *x, - int16_t nt, - int16_t lastnz, - int16_t nbbits, - int16_t resQMaxBits, - CONTEXT_HM_CONFIG *hm_cfg ); - -int16_t ACcontextMapping_decode2_no_mem_s17_LC_ivas( - Decoder_State *st, /* i/o: decoder state */ - int16_t *x, /* o : decoded spectrum */ - int16_t nt, /* i : size of spectrum */ - int16_t nbbits, /* i : bit budget */ - int16_t resQMaxBits, /* i : residual coding maximum bits */ - CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */ -); - -int16_t ACcontextMapping_encode2_estimate_no_mem_s17_LC( - const int16_t *x, - const int16_t nt, - int16_t *lastnz, - int16_t *nEncoded, - const int16_t target, - int16_t *stop, - CONTEXT_HM_CONFIG *hm_cfg ); - -void RCcontextMapping_encode2_no_mem_s17_LCS( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - int16_t *x, - const int16_t nt, - int16_t lastnz, - const int16_t nbbits, - const int16_t resQMaxBits, - CONTEXT_HM_CONFIG *hm_cfg ); - -int16_t RCcontextMapping_decode2_no_mem_s17_LCS( - Decoder_State *st, /* i/o: decoder state */ - int16_t *x, /* o : decoded spectrum */ - const int16_t nt, /* i : size of spectrum */ - const int16_t nbbits, /* i : bit budget */ - const int16_t resQMaxBits, /* i : residual coding maximum bits */ - CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration */ -); - -int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS( - int16_t *x, /* Spectral coefficients */ - const int16_t nt, /* L - size of spectrum (no. of spectral coefficients) */ - int16_t *lastnz_out, - int16_t *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring */ - const int16_t target, /* Target bits */ - int16_t *stop, - int16_t mode, - CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ -); - -Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( - Word16 *x, /* Q0 */ - const Word16 nt, /* Q0 */ - const Word16 target, /* Q0 */ - HANDLE_RC_CONTEXT_MEM hContextMem ); - -Word16 RCcontextMapping_encode2_estimate_bandWise_fx( - Word16 *x, /* Q0 */ - const Word16 start_line, /* Q0 */ - const Word16 end_line, /* Q0 */ - HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */ -); - -void tcx_get_windows_flt( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ - const int16_t left_mode, /* i : overlap mode of left window half */ - const int16_t right_mode, /* i : overlap mode of right window half */ - int16_t *left_overlap, /* o : left overlap length */ - const float **left_win, /* o : left overlap window */ - int16_t *right_overlap, /* o : right overlap length */ - const float **right_win, /* o : right overlap window */ - const int16_t fullband /* i : fullband flag */ -); - -void tcx_windowing_analysis_flt( - const float *signal, /* i : signal vector */ - const int16_t L_frame, /* i : frame length */ - const int16_t left_overlap, /* i : left overlap length */ - const float *left_win, /* i : left overlap window */ - const int16_t right_overlap, /* i : right overlap length */ - const float *right_win, /* i : right overlap window */ - float *output /* o : windowed signal vector */ -); - -void tcx_windowing_synthesis_current_frame_flt( - float *signal, /* i/o: signal vector */ - const float *window, /* i : TCX window vector */ - const float *window_half, /* i : TCX window vector for half-overlap window */ - const float *window_min, /* i : TCX minimum overlap window */ - const int16_t window_length, /* i : TCX window length */ - const int16_t window_half_length, /* i : TCX half window length */ - const int16_t window_min_length, /* i : TCX minimum overlap length */ - const int16_t left_rect, /* i : left part is rectangular */ - const int16_t left_mode, /* i : overlap mode of left window half */ - float *acelp_zir, /* i/o: acelp ZIR */ - const float *old_syn, /* i : old synthesis */ - const float *syn_overl, /* i : overlap synthesis */ - const float *A_zir, - const float *window_trans, /* i : window for transition from ACELP */ - int16_t acelp_zir_len, - const int16_t acelp_mem_len, - const int16_t last_core_bfi, /* i : last mode */ - const int16_t last_is_cng, - const int16_t fullbandScale ); - -void tcx_windowing_synthesis_past_frame_flt( - float *signal, /* i/o: signal vector */ - const float *window, /* i : TCX window vector */ - const float *window_half, /* i : TCX window vector for half-overlap window */ - const float *window_min, /* i : TCX minimum overlap window */ - const int16_t window_length, /* i : TCX window length */ - const int16_t window_half_length, /* i : TCX half window length */ - const int16_t window_min_length, /* i : TCX minimum overlap length */ - const int16_t right_mode /* i : overlap mode (left_mode of current frame) */ -); - -void ProcessIGF( - Encoder_State *st, /* i : Encoder state */ - float *pMDCTSpectrum, /* i : MDCT spectrum */ - const float *pITFMDCTSpectrum, /* i : MDCT spectrum fir ITF */ - float *pPowerSpectrum, /* i : MDCT^2 + MDST^2 spectrum, or estimate */ - const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ - const int16_t frameno, /* i : flag indicating index of current subframe */ - const int16_t sp_aud_decision0, /* i : first stage switching decision */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void ProcessStereoIGF( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - float *pITFMDCTSpectrum[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */ - float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ - float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ - const int16_t frameno, /* i : flag indicating index of current subframe*/ - const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ -); - -void AnalyzePowerSpectrum( - Encoder_State *st, /* i/o: encoder states */ - const int16_t L_frame, /* i : frame length */ - const int16_t L_frameTCX, /* i : full band frame length */ - const int16_t left_overlap, /* i : left overlap length */ - const int16_t right_overlap, /* i : right overlap length */ - const float mdctSpectrum[], /* i : MDCT spectrum */ - const float signal[], /* i : windowed signal corresponding to mdctSpectrum */ - float powerSpec[] /* o : Power spectrum */ -); - -void lpc2mdct_flt( - float *lpcCoeffs, - const int16_t lpcOrder, - float mdct_gains[], - const int16_t length, - const int16_t noInverse ); - -void mdct_preShaping( - float x[], - const int16_t lg, - const float gains[] ); - -void mdct_noiseShaping_flt( - float x[], - const int16_t lg, - const float gains[], - const int16_t nBands ); - - -void PsychAdaptLowFreqDeemph_flt( - float x[], - const float lpcGains[], - float lf_deemph_factors[] ); - -void AdaptLowFreqDeemph_flt( - float x[], - int16_t tcx_lpc_shaped_ari, - const float lpcGains[], - const int16_t lg, - float lf_deemph_factors[] ); - - -void tcx_noise_filling_flt( - float *Q, - const int16_t noiseFillSeed, - const int16_t iFirstLine, - const int16_t lowpassLine, - const int16_t nTransWidth, - const int16_t L_frame, - const float tiltCompFactor, - float fac_ns, - Word16 *infoTCXNoise, - const int16_t element_mode /* i : IVAS element mode */ -); - - -void tcx_decoder_memory_update_flt( - Decoder_State *st, /* i/o: decoder memory state */ - const float *xn_buf, /* i : mdct output buffer */ - float *synth, /* i/o: synth */ - const float *A /* i : Quantized LPC coefficients */ -); - - -/*! r: number of bits used (including "bits") */ -int16_t tcx_ari_res_invQ_spec_flt( - float x_Q[], /* i/o: quantized spectrum */ - const int16_t L_frame, /* i : number of lines */ - const int16_t prm[], /* i : bitstream */ - int16_t target_bits, /* i : number of bits available */ - int16_t bits, /* i : number of bits used so far */ - const float deadzone, /* i : quantizer deadzone */ - const float x_fac[] /* i : spectrum post-quantization factors */ -); - - -void ari_copy_states( - Tastat *source, - Tastat *dest ); - - -void ari_start_encoding_14bits( - Tastat *s ); - - -void ari_start_decoding_14bits_ivas( - Decoder_State *st, - Tastat *s ); - -int16_t ari_start_decoding_14bits_prm_ivas( - const int16_t *ptr, - int16_t bp, - Tastat *s ); - -void ari_decode_14bits_s17_ext_ivas( - Decoder_State *st, - uint16_t *res, - Tastat *s, - const uint16_t *cum_freq ); - -void ari_decode_14bits_s27_ext_ivas( - Decoder_State *st, - uint16_t *res, - Tastat *s, - const uint16_t *cum_freq ); - -void ari_decode_14bits_bit_ext_ivas( - Decoder_State *st, - uint16_t *res, - Tastat *s ); - -/*! r: Q15 */ -Word16 expfp_evs_fx( - const Word16 x, /* i : mantissa Q15-e */ - const Word16 x_e /* i : exponent Q0 */ -); - - -void tcx_arith_render_envelope_ivas_fx( - const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i : number of spectral lines Q0*/ - const Word16 L_spec, /* i : length of the coded spectrum Q0*/ - const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o : shaped signal envelope Q16*/ -); - -int16_t ari_encode_14bits_range( - int16_t *ptr, - int16_t bp, - int32_t bits, - Tastat *s, - uint16_t cum_freq_low, - uint16_t cum_freq_high ); - - -int16_t ari_done_cbr_encoding_14bits( - int16_t *ptr, - int16_t bp, - int32_t bits, - Tastat *s ); - - -void tcx_arith_encode_envelope( - float spectrum[], /* i/o: MDCT coefficients */ - int16_t signs[], /* o : signs (spectrum[.]<0) */ - const int16_t L_frame, /* i : frame or MDCT length */ - const int16_t L_spec, /* i : length w/o BW limitation */ - Encoder_State *st, /* i/o: coder state */ - const Word16 A_ind[], /* i : quantised LPC coefficients */ - int16_t target_bits, /* i : number of available bits */ - int16_t prm[], /* o : bitstream parameters */ - const int16_t use_hm, /* i : use HM in current frame? */ - int16_t prm_hm[], /* o : HM parameter area */ - const int16_t tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ - int16_t *arith_bits, /* o : bits used for ari. coding */ - int16_t *signaling_bits, /* o : bits used for signaling */ - const int16_t low_complexity /* i : low-complexity flag */ -); - -void tcx_arith_decode_envelope( - Decoder_State *st, /* i/o: coder state */ - float q_spectrum[], /* o : quantised MDCT coefficients */ - const int16_t L_frame, /* i : frame or MDCT length */ - int16_t L_spec, /* i : length w/o BW limitation */ - const Word16 A_ind[], /* i : quantised LPC coefficients */ - const int16_t target_bits, /* i : number of available bits */ - const int16_t prm[], /* i : bitstream parameters */ - const int16_t use_hm, /* i : use HM in current frame? */ - const int16_t prm_hm[], /* i : HM parameter area */ - int16_t tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ - int16_t *arith_bits, /* o : bits used for ari. coding */ - int16_t *signaling_bits, /* o : bits used for signaling */ - const int16_t low_complexity /* i : low-complexity flag */ -); - -void tcx_arith_decode_envelope_ivas_fx( - Decoder_State *st, /* i/o: coder state */ - Word32 q_spectrum[], /* o : quantised MDCT coefficients */ - Word16 *q_spectrum_e, /* o : MDCT exponent */ - const Word16 L_frame, /* i : frame or MDCT length */ - Word16 L_spec, /* i : length w/o BW limitation */ - const Word16 A_ind[], /* i : quantised LPC coefficients */ - const Word16 target_bits, /* i : number of available bits */ - Word16 prm[], /* i : bitstream parameters */ - const Word16 use_hm, /* i : use HM in current frame? */ - const Word16 prm_hm[], /* i : HM parameter area */ - Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ - Word16 *arith_bits, /* o : bits used for ari. coding */ - Word16 *signaling_bits, /* o : bits used for signaling */ - const Word16 low_complexity /* i : low-complexity flag */ -); - - -void UnmapIndex_fx( - const Word16 PeriodicityIndex, /* Q0 */ - const Word16 Bandwidth, /* Q0 */ - const Word16 LtpPitchLag, /* Q0 */ - const Word8 SmallerLags, /* Q0 */ - Word16 *FractionalResolution, /* Q0 */ - Word32 *Lag /* Q0 */ -); - -/*! r: PeriodicityIndex */ -int16_t SearchPeriodicityIndex( - const float Mdct[], /* i : Coefficients, Mdct[0..NumCoeffs-1] */ - const float UnfilteredMdct[], /* i : Unfiltered coefficients, UnfilteredMdct[0..NumCoeffs-1] */ - const int16_t NumCoeffs, /* i : Number of coefficients */ - const int16_t shortTargetBits, /* i : Target bit budget (excl. Done flag) */ - const int16_t LtpPitchLag, /* i : TCX-LTP pitch */ - const float LtpGain, /* i : LTP gain */ - float *RelativeScore /* o : Energy concentration factor */ -); - - -int16_t EncodeIndex( - const int16_t Bandwidth, /* o : NB, 1: (S)WB */ - int16_t PeriodicityIndex, - BSTR_ENC_HANDLE hBstr ); - - -Word16 CountIndexBits_fx( - Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ - Word16 PeriodicityIndex /* Q0 */ -); - -int16_t DecodeIndex( - Decoder_State *st, - const int16_t Bandwidth, /* o : NB, 1: (S)WB */ - int16_t *PeriodicityIndex ); - -#define GET_ADJ( T, L ) GET_ADJ2( T, L, *FractionalResolution ) -#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) - - -Word32 tcx_hm_render_fx( - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[] /* o: harmonic model Q13 */ -); - - -void tcx_hm_modify_envelope_fx( - const Word16 gain, /* i: HM gain Q11 */ - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - const Word16 p[], /* i: harmonic model Q13 */ - Word32 env[], /* i/o: envelope Q16 */ - const Word16 L_frame /* i: number of spectral lines Q0 */ -); - -void tcx_hm_analyse( - const float abs_spectrum[], /* i : absolute spectrum */ - const int16_t L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const int16_t targetBits, /* i : target bit budget */ - const int16_t coder_type, /* i : GC/VC coder type */ - int16_t prm_hm[], /* o : HM parameters */ - int16_t LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - const float LtpGain, /* i : LTP gain */ - int16_t *hm_bits /* o : bit consumption */ -); - -void tcx_hm_decode_ivas( - const int16_t L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const int16_t targetBits, /* i : target bit budget */ - const int16_t coder_type, /* i : GC/VC coder type */ - const int16_t prm_hm[], /* i : HM parameters */ - const int16_t LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - int16_t *hm_bits /* o : bit consumption */ -); - -void tcx_hm_decode( - const Word16 L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const Word16 targetBits, /* i : target bit budget */ - const Word16 coder_type, /* i : GC/VC coder type */ - const Word16 prm_hm[], /* i : HM parameters */ - const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - Word16 *hm_bits /* o : bit consumption */ -); - -void coder_tcx( - Encoder_State *st, /* i/o: encoder state structure */ - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const float A[], /* i : quantized coefficients NxAz_q[M+1] */ - const Word16 Aqind[], /* i : frame-independent quantized coefficients (M+1) */ - float synth[], /* o : decoded synthesis */ - const int16_t L_frame_glob, /* i : frame length */ - const int16_t L_frameTCX_glob, - const int16_t L_spec, - int16_t nb_bits, /* i : bit budget */ - float spectrum[], /* i/o: MDCT spectrum */ - int16_t prm[], /* o : tcx parameters */ - CONTEXT_HM_CONFIG *hm_cfg, - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void coder_tcx_post( - Encoder_State *st, /* i/o: encoder memory state */ - float *A, /* o : Quantized LPC coefficients */ - const float *Ai /* i : Unquantized (interpolated) LPC coefficients */ -); - -void decoder_tcx( - Decoder_State *st, /* i/o: coder memory state */ - int16_t prm[], /* i : parameters */ - float A[], /* i : coefficients NxAz[M+1] */ - Word16 Aind[], /* i : frame-independent coefficients Az[M+1]*/ - float synth[], /* i/o: synth[-M..lg] */ - float synthFB[], /* i/o: encoder memory state */ - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void decoder_tcx_post( - Decoder_State *st, /* i/o: decoder memory state */ - float *synth, - float *synthFB, - float *A, /* i : A(z) filter coefficients */ - const int16_t bfi, - const int16_t isMCT ); - -void coder_acelp( - Encoder_State *st, /* i/o: coder memory state */ - const float A[], /* i : coefficients 4xAz[M+1] */ - const float Aq[], /* i : coefficients 4xAz_q[M+1] */ - const float speech[], /* i : speech[-M..lg] */ - LPD_state *LPDmem, /* i/o: ACELP memories */ - int16_t *prm, /* o : acelp parameters */ - const float stab_fac, - const int16_t target_bits, - float *gain_pitch_buf, /* o : gain pitch values */ - float *gain_code_buf, /* o : gain code values */ - float *pitch_buf, /* o : pitch values for each subfr.*/ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc /* o : excitation for SWB TBE */ -); - -void coder_acelp_rf( - const int16_t target_bits, /* i : target bits */ - const float speech[], /* i : speech[-M..lg] */ - const int16_t coder_type, /* i : coding type */ - const int16_t rf_frame_type, /* i : rf_frame_type */ - const float A[], /* i : coefficients 4xAz[M+1] */ - const float Aq[], /* i : coefficients 4xAz_q[M+1] */ - const float voicing[], /* i : open-loop LTP gain */ - const int16_t T_op[], /* i : open-loop LTP lag */ - const float stab_fac, /* i : LP stability factor */ - Encoder_State *st, /* i/o: coder memory state */ - ACELP_config *acelp_cfg, /* i/o: configuration of the ACELP */ - float *exc_rf, /* i/o: pointer to RF excitation */ - float *syn_rf /* i/o: pointer to RF synthesis */ -); - -void decoder_acelp( - Decoder_State *st, /* i/o: coder memory state */ - int16_t prm[], /* i : parameters */ - const float A[], /* i : coefficients NxAz[M+1] */ - ACELP_config acelp_cfg, /* i : ACELP config */ - float synth[], /* i/o: synthesis */ - int16_t *pT, /* o : pitch for all subframe */ - float *pgainT, /* o : pitch gain for all subfr */ - const float stab_fac, /* i : stability of isf */ - float *pitch_buffer, /* o : pitch values for each subfr.*/ - float *voice_factors, /* o : voicing factors */ - const int16_t LSF_Q_prediction, /* i : LSF prediction mode */ - float *bwe_exc /* o : excitation for SWB TBE */ -); - -void writeTCXMode_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - Word16 *nbits_start /* o : nbits start Q0*/ -); - -void writeTCXWindowing_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 overlap_mode /* i : overlap mode Q0*/ -); - -void writeLPCparam( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const int16_t param_lpc[], /* i : LPC parameters to write */ - const int16_t bits_param_lpc[], /* i : bits per LPC parameter */ - const int16_t no_param_lpc, /* i : number of LPC parameters */ - int16_t *nbits_lpc /* o : LPC bits written */ -); - -void enc_prm( - Encoder_State *st, /* i/o: encoder state structure */ - int16_t param[], /* i : parameters */ - int16_t param_lpc[], /* i : LPC parameters */ - CONTEXT_HM_CONFIG hm_cfg[], - const int16_t bits_param_lpc[], - const int16_t no_param_lpc ); - -void writeTCXparam( - Encoder_State *st, /* i/o: Encoder State handle */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */ - int16_t param[], /* i : parameters */ - const int16_t nbits_header, - const int16_t nbits_start, - const int16_t nbits_lpc, - const int16_t *no_param_tns, /* i : number of TNS parameters per subframe */ - int16_t p_param[2], /* i/o: pointer to parameters from previous bs writing */ - const int16_t target_bitsTCX10[2], - const int16_t pre_past_flag ); - -void enc_prm_rf( - Encoder_State *st, /* i/o: encoder memory state */ - const int16_t rf_frame_type, - const int16_t fec_offset ); - -void dec_prm_hm_ivas( - Decoder_State *st, /* i/o: decoder memory state */ - int16_t *prm_hm, - const int16_t hm_size ); - -void dec_prm_ivas( - Decoder_State *st, /* i/o: decoder memory state */ - int16_t param[], /* o : decoded parameters */ - int16_t param_lpc[], /* i : LPC parameters */ - int16_t *total_nbbits, /* i/o: number of bits / decoded bits */ - int16_t *bitsRead ); -void gaus_L2_dec_flt( - float *code, /* o : decoded gaussian codevector */ - float tilt_code, - const float *A, - float formant_enh_num, - int16_t *seed_acelp /* i/o: random seed */ -); - -/*! r: interpolated value */ -float interpolation( - const float *x, /* i : input vector */ - const float *win, /* i : interpolation window */ - const int16_t frac, /* i : fraction */ - const int16_t up_samp, /* i : upsampling factor */ - const int16_t nb_coef /* i : nb of filter coef */ -); - -void predict_signal_flt( - const float excI[], /* i : input excitation buffer */ - float excO[], /* o : output excitation buffer */ - const int16_t T0, /* i : integer pitch lag */ - int16_t frac, /* i : fraction of lag */ - const int16_t frac_max, /* i : max fraction */ - const int16_t L_subfr /* i : subframe size */ -); - -void tcx_ltp_encode( - Encoder_State *st, - const int16_t tcxMode, - const int16_t L_frame, - const float *speech, - float *speech_ltp, - const float *wsp, - const int16_t Top[], - int16_t *ltp_param, - int16_t *ltp_bits, - float *A, - const int16_t disable_ltp, - const int16_t element_mode ); - -void tcx_ltp_post_flt( - Decoder_State *st, - TCX_LTP_DEC_HANDLE hTcxLtpDec, - const int16_t core, - const int16_t output_frame, - const int16_t L_frame, - float sig[], - const float tcx_buf[] ); - -int16_t tcx_ltp_decode_params_flt( - int16_t *ltp_param, - int16_t *pitch_int, - int16_t *pitch_fr, - float *gain, - const int16_t pitmin, - const int16_t pitfr1, - const int16_t pitfr2, - const int16_t pitmax, - const int16_t pitres ); - -void create_IDCT_N_Matrix( - float *inv_matrixFloatQ, /* i/o: RAM buffer */ - const int16_t N, /* i : DCT length, number of time samples */ - const int16_t n_cols, /* i : number of dct coeffs (as DCT may be truncated) */ - const int16_t alloc_size /* i : RAM buffer size in elements */ -); - -void dctT2_N_apply_matrix( - const float *input, /* i : input in fdcng or DCT(fdcng) domain */ - float *output, /* o : output in DCT(fdcng) or fdcng ordomain */ - const int16_t dct_dim, /* i : dct processing dim possibly truncated */ - const int16_t fdcngvq_dim, /* i : fdcng domain length */ - const float *matrix, /* i : IDCT matrix */ - const int16_t matrix_row_dim, /* i : */ - const DCTTYPE dcttype /* i : matrix operation type */ -); - -void extend_dctN_input( - const float *input, /* i : input in fdcng domain */ - const float *dct_input, /* i : input in dctN(fdcng) domain */ - const int16_t in_dim, /* i : in_dim == N */ - float *ext_sig, /* o : extended output in fdcng domain */ - const int16_t out_dim, /* i : output total dim */ - float *matrix, /* i : idct synthesis matrix N rows, n_cols columns */ - const int16_t n_cols, /* i : number of columns == DCT truncation length */ - const DCTTYPE dcttype /* i : matrix operation type */ -); - - -void PulseResynchronization( - const float *src_exc, /* i : Input excitation buffer */ - float *dst_exc, /* o : output excitation buffer */ - const int16_t nFrameLength, /* i : frame length */ - const int16_t nSubframes, /* i : Number of subframes */ - const float pitchStart, /* i : Pitch at the end of the last frame */ - const float pitchEnd /* i : Pitch at the end of the current frame */ -); - -void con_acelp( - float A[], /* i : coefficients NxAz[M+1] */ - const int16_t coder_type, /* i : ACELP coder type */ - float synth[], /* i/o: synthesis */ - int16_t *pT, /* o : pitch for all subframe */ - float *pgainT, /* o : pitch gain for all subfr */ - float stab_fac, /* i : stability of isf */ - Decoder_State *st, /* i/o: coder memory state */ - float pitch_buffer[], /* i/o: floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc /* o : excitation for SWB TBE */ -); - -void con_tcx( - Decoder_State *st, /* i/o: coder memory state */ - float synth[], /* i/o: synth[] */ - const float coh, /* i : coherence of stereo signal */ - int16_t *noise_seed, /* i/o: noise seed for stereo */ - const int16_t only_left, /* i : TD-PLC only in left channel */ - const float A_cng[] /* i : CNG LP filter coefficients */ -); - -int16_t lsf_msvq_ma_decprm_ivas( - Decoder_State *st, - int16_t *param_lpc ); - -int16_t dec_lsf_tcxlpc_ivas( - Decoder_State *st, /* i : Decoder state */ - int16_t **indices, /* o : Ptr to VQ indices */ - const int16_t narrowband, /* i : narrowband flag */ - const int16_t cdk /* i : codebook selector */ -); - -int16_t D_lsf_tcxlpc_ivas( - const int16_t indices[], /* i : VQ indices */ - float lsf_q[], /* o : quantized lsf */ - Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */ - const int16_t narrowband, /* i : narrowband flag */ - const int16_t cdk, /* i : codebook selector */ - const float mem_MA[] /* i : MA memory */ -); - -int16_t Q_lsf_tcxlpc( - /* const */ float lsf[], /* i : original lsf */ - float lsf_q[], /* o : quantized lsf */ - Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */ - int16_t indices[], /* o : VQ indices */ - const int16_t narrowband, /* i : narrowband flag */ - const int16_t cdk, /* i : codebook selector */ - const float mem_MA[], /* i : MA memory */ - const int16_t coder_type, /* i : acelp extended mode */ - const float *Bin_Ener /* i : Spectrum energy */ -); - -void midlsf_enc( - const float qlsf0[], - const float qlsf1[], - const float lsf[], - int16_t *idx, - const int16_t N, - const float *Bin_Ener, - const int16_t narrowBand, - const int32_t sr_core, - const int16_t coder_type ); - -void lsf_end_enc( - Encoder_State *st, - const float *lsf, - float *qlsf, - const int16_t nBits, - const int16_t coder_type_org, - const int16_t force_sf, - int16_t *lpc_param, - int16_t *no_stages, - int16_t *bits_param_lpc, - const int16_t coder_type_raw, - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -); - -void lsf_end_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t coder_type_org, /* i : coding type */ - const int16_t bwidth, /* i : input signal bandwidth */ - const int16_t nBits, /* i : number of bits used for ISF quantization*/ - float *qlsf, /* o : quantized LSFs in the cosine domain */ - int16_t *lpc_param, /* i : LPC parameters */ - int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - int16_t *nb_indices, /* o : number of indices */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ -); - -void lpc_quantization( - Encoder_State *st, - const float lsp[], - const float lspmid[], - float lsp_q[], - float lsf_q[], - float lspmid_q[], - const int16_t coder_type, - const int16_t acelp_midLpc, - int16_t param_lpc[], - int16_t nbits_lpc[], - int16_t *bits_param_lpc, - int16_t *no_param_lpc ); - -void lpc_unquantize( - Decoder_State *st, - float *lsf, - float *lsp, - int16_t *param_lpc, - float *lspmid, - float *lsfmid, - const int16_t coder_type, - int16_t *LSF_Q_prediction /* o : LSF prediction mode */ -); - -void dlpc_bfi_flt( - const int16_t L_frame, - float *lsf_q, /* o : quantized lsfs */ - const float *lsfold, /* i : past quantized lsf */ - const int16_t last_good, /* i : last good received frame */ - const int16_t nbLostCmpt, /* i : counter of consecutive bad frames */ - float mem_MA[], /* i/o: quantizer memory for MA model */ - float mem_AR[], /* i/o: quantizer memory for MA model */ - float *stab_fac, /* i : lsf stability factor */ - float *lsf_adaptive_mean, /* i : lsf adaptive mean, updated when BFI==0 */ - const int16_t numlpc, /* i : Number of division per superframe */ - float lsf_cng[], - const int16_t plcBackgroundNoiseUpdated, - float *lsf_q_cng, /* o : quantized lsfs of background noise */ - float *old_lsf_q_cng, /* o : old quantized lsfs for background noise */ - const float lsfBase[] /* i : base for differential lsf coding */ -); - -void Unified_weighting( - const float Bin_Ener_128[], /* i : FFT Bin energy 128 bins in two sets */ - const float lsf[], /* i : LSF vector */ - float w[], /* o : LP weighting filter (numerator) */ - const int16_t narrowBand, /* i : flag for Narrowband */ - const int16_t unvoiced, /* i : flag for Unvoiced frame */ - const int32_t sr_core, /* i : sampling rate of core-coder */ - const int16_t order /* i : LP order */ -); - -int16_t vad_init( - VAD_CLDFB_HANDLE hVAD_CLDFB /* i/o: CLDFB VAD state */ -); - -int16_t vad_proc( - float realValues[16][60], /* i : CLDFB real values */ - float imagValues[16][60], /* i : CLDFB imag values */ - float *sb_power, /* i/o: Energy of CLDFB data */ - const int16_t numBands, /* i : number of input bands */ - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - int16_t *cldfb_addition, - const int16_t vada_flag /* i : VAD flag */ -); - - -int16_t update_decision( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - const float snr, /* i : frequency domain SNR */ - const float tsnr, /* i : time domain SNR */ - const float frame_energy, /* i : current frame energy */ - const float high_eng, /* i : current frame high frequency energy */ - const int16_t vad_flag, /* i : VAD flag */ - const int16_t music_backgound_f /* i : background music flag */ -); - -void frame_spec_dif_cor_rate( - float spec_amp[], /* i : spectral amplitude */ - float pre_spec_low_dif[], /* i/o: low spectrum different */ - float f_tonality_rate[] /* o : tonality rate */ -); - - -void SNR_calc( - const float frame_sb_energy[], /* i : energy of sub-band divided non-uniformly*/ - const float sb_bg_energy[], /* i : sub-band background energy */ - const float t_bg_energy, /* i : time background energy of several frames*/ - float *snr, /* o : frequency domain SNR */ - float *tsnr, /* o : time domain SNR */ - const float frame_energy, /* i : current frame energy */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void background_update( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - float frame_energy, /* i : current frame energy 2 */ - const int16_t update_flag, /* i : current frame update flag */ - const int16_t music_backgound_f, /* i : background music flag */ - const float snr ); - -void bg_music_decision( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - int16_t *music_backgound_f, /* i : background music flag */ - const float frame_energy /* i : current frame energy 1 */ -); - -void est_energy( - float sb_power[], /* o : energy of sub-band divided uniformly */ - float frame_sb_energy[], /* o : energy of sub-band divided non-uniformly*/ - float *p_frame_energy, /* o : frame energy 1 */ - float *p_frame_energy2, /* o : frame energy 2 */ - float *p_high_energy, /* o : high frequency energy */ - const int16_t bw /* i : bandwidth */ -); - - -int16_t comvad_decision( - VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ - const float snr, /* i : frequency domain SNR */ - const float tsnr, /* i : time domain SNR */ - const float snr_flux, /* i : average tsnr of several frames */ - const float lt_snr, /* i : long time SNR calculated by fg_energy and bg_energy*/ - const float lt_snr_org, /* i : original long time SNR */ - const float lf_snr, /* i : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/ - const float frame_energy, /* i : current frame energy */ - const int16_t music_backgound_f, /* i : background music flag */ - int16_t *cldfb_addition, - const int16_t vada_flag /* i : VAD flag */ -); - -void calc_snr_flux( - float tsnr, /* i : time-domain SNR */ - float pre_snr[], /* i/o: time-domain SNR storage */ - float *snr_flux /* o : average tsnr */ -); - -void calc_lt_snr( - float *lt_snr_org, /* o : original long time SNR */ - float *lt_snr, /* o : long time SNR calculated by fg_energy and bg_energy*/ - const float fg_energy, /* i : foreground energy sum */ - const int16_t fg_energy_count, /* i : number of the foreground energy frame */ - const float bg_energy, /* i : background energy sum */ - const int16_t bg_energy_count, /* i : number of the background energy frame */ - const int16_t bw_index, /* i : band width index */ - const float lt_noise_sp_center0 /* i : long time noise spectral center by 0 */ -); - -void calc_lf_snr( - float *lf_snr_smooth, /* o : smoothed lf_snr */ - float *lf_snr, /* o : long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/ - const float l_speech_snr, /* i : sum of active frames snr */ - const int16_t l_speech_snr_count, /* i : number of the active frame */ - const float l_silence_snr, /* i : sum of the nonactive frames snr */ - const int16_t l_silence_snr_count, /* i : number of the nonactive frame */ - const int16_t fg_energy_count, /* i : number of the foreground energy frame */ - const int16_t bg_energy_count, /* i : number of the background energy frame */ - const int16_t bw_index /* i : band width index */ -); - -float construct_snr_thresh( - const float sp_center[], /* i : spectral center */ - const float snr_flux, /* i : snr flux */ - const float lt_snr, /* i : long time time domain snr */ - const float lf_snr, /* i : long time frequency domain snr */ - const int16_t continuous_speech_num, /* i : continuous speech number */ - const int16_t continuous_noise_num, /* i : continuous noise number */ - const int16_t fg_energy_est_start, /* i : whether if estimated energy */ - const int16_t bw_index /* i : band width index */ -); - -void minimum_statistics_flt( - const int16_t len, /* i : Vector length */ - const int16_t lenFFT, /* i : Length of the FFT part of the vectors */ - float *psize_flt, - float *msPeriodog, /* i : Periodograms */ - float *msNoiseFloor, - float *msNoiseEst, /* o : Noise estimates */ - float *msAlpha, - float *msPsd, - float *msPsdFirstMoment, - float *msPsdSecondMoment, - float *msMinBuf, - float *msBminWin, - float *msBminSubWin, - float *msCurrentMin, - float *msCurrentMinOut, - float *msCurrentMinSubWindow, - int16_t *msLocalMinFlag, - int16_t *msNewMinFlag, - float *msPeriodogBuf, - int16_t *msPeriodogBufPtr, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const int16_t enc_dec, /* i : encoder/decoder indicator */ - const int16_t element_mode /* i : IVAS element mode */ -); - -void generate_comfort_noise_enc( - Encoder_State *st /* i/o: encoder state structure */ -); - -void generate_comfort_noise_dec( - float **bufferReal, /* o : Real part of input bands */ - float **bufferImag, /* o : Imaginary part of input bands */ - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t nchan_out /* i : number of output channels */ -); - -void generate_comfort_noise_dec_hf( - float **bufferReal, /* o : Real part of input bands */ - float **bufferImag, /* o : Imaginary part of input bands */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const int16_t cng_flag /* i : CNG Flag */ -); - -void generate_masking_noise( - float *timeDomainBuffer, /* i/o: time-domain signal */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const int16_t length, /* i : frame size */ - const int16_t core, /* i : core */ - const int16_t return_noise, /* i : noise is returned instead of added */ - const int16_t secondary, /* i : indicator for secondary channel */ - const int16_t element_mode, /* i : element mode */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ -); - -void generate_masking_noise_update_seed( - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void generate_masking_noise_mdct( - float *mdctBuffer, /* i/o: time-domain signal */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void SynthesisSTFT_dirac_flt( - float *fftBuffer, /* i : FFT bins */ - float *timeDomainOutput, - float *olapBuffer, - const float *olapWin, - const int16_t samples_out, - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void generate_masking_noise_dirac( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ - float *Cldfb_RealBuffer, /* o : CLDFD real buffer */ - float *Cldfb_ImagBuffer, /* o : CLDFD imaginary buffer */ - const int16_t slot_index, /* i : CLDFB slot index */ - const int16_t cna_flag, /* i : CNA flag for LB and HB */ - const int16_t fd_cng_flag /* i : FD-CNG flag for HB */ -); - -void generate_stereo_masking_noise( - float *syn, /* i/o: time-domain signal */ - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ - const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ - const int16_t fadeOut, /* i : only fade out of previous state */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ -); - -void apply_scale_flt( - float *scale, /* i : scale factor */ - const int16_t bwidth, /* i : audio bandwidth */ - const int32_t brate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const int16_t scaleTableSize /* i : Size of scale table */ -); - -void compress_range_flt( - float *in, - float *out, - const int16_t len ); - -void expand_range_flt( - float *in, - float *out, - const int16_t len ); - -void bandcombinepow_flt( - const float *bandpow, /* i : Power for each band */ - const int16_t nband, /* i : Number of bands */ - int16_t *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const int16_t npart, /* i : Number of partitions */ - const float *psize_inv_flt, /* i : Inverse partition sizes */ - float *partpow /* o : Power for each partition */ -); - -void scalebands_flt( - const float *partpow, /* i : Power for each partition */ - int16_t *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const int16_t npart, /* i : Number of partitions */ - int16_t *midband, /* i : Central band of each partition */ - const int16_t nFFTpart, /* i : Number of FFT partitions */ - const int16_t nband, /* i : Number of bands */ - float *bandpow, /* o : Power for each band */ - const int16_t flag_fft_en ); - -void AnalysisSTFT_flt( - const float *timeDomainInput, - float *fftBuffer, /* o : FFT bins */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void SynthesisSTFT_flt( - float *fftBuffer, - float *timeDomainOutput, - float *olapBuffer, - const float *olapWin, - const int16_t tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, - const int16_t element_mode, /* i : element mode */ - const int16_t nchan_out /* i : number of output channels */ -); - -void lpc_from_spectrum_flt( - HANDLE_FD_CNG_COM hFdCngCom, - const int16_t start, - const int16_t stop, - const float preemph_fac ); - -ivas_error createFdCngDec( - HANDLE_FD_CNG_DEC *hFdCngDec ); - -void deleteFdCngDec( - HANDLE_FD_CNG_DEC *hFdCngDec ); - -void initFdCngDec( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ -); - -void configureFdCngDec( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ - const int16_t bwidth, - const int32_t total_brate, - const int16_t L_frame, - const int16_t last_L_frame, - const int16_t element_mode ); - -void ApplyFdCng( - float *timeDomainInput, - float *powerSpectrum, - float **realBuffer, /* i/o: Real part of the buffer */ - float **imagBuffer, /* i/o: Imaginary part of the buffer */ - Decoder_State *st, - const int16_t concealWholeFrame, /* i : binary flag indicating frame loss */ - const int16_t is_music ); - -void generate_comfort_noise_dec( - float **bufferReal, /* o : Real part of input bands */ - float **bufferImag, /* o : Imaginary part of input bands */ - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t nchan_out /* i : number of output channels */ -); - -/*! r: CNG energy */ -float cng_energy( - const int16_t element_mode, /* i : element mode */ - const int16_t bwidth, /* i : audio bandwidh */ - const int16_t CNG_mode, /* i : mode for DTX configuration */ - const float CNG_att, /* i : attenuation factor for CNG */ - const float *inputBuffer, /* i : input signal */ - const int16_t len /* i : vector length */ -); - -void FdCng_decodeSID( - Decoder_State *st /* i/o: decoder state structure */ -); - -void FdCng_exc_flt( - HANDLE_FD_CNG_COM hFdCngCom, - int16_t *CNG_mode, - const int16_t L_frame, - const float *lsp_old, - const int16_t first_CNG, - float *lsp_CNG, - float *Aq, /* o : LPC coeffs */ - float *lsp_new, /* o : lsp */ - float *lsf_new, /* o : lsf */ - float *exc, /* o : LP excitation */ - float *exc2, /* o : LP excitation */ - float *bwe_exc /* o : LP excitation for BWE */ -); - -void noisy_speech_detection( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ - const int16_t vad, /* i : VAD flag */ - const float syn[] /* i : input time-domain frame */ -); - -void deleteFdCngEnc( - HANDLE_FD_CNG_ENC *hFdCngEnc /* i/o: FD_CNG structure */ -); - - -void resetFdCngEnc( - Encoder_State *st /* i/o: encoder state structure */ -); - -void perform_noise_estimation_enc( - float *band_energies, /* i : energy in critical bands without minimum noise floor E_MIN */ - float *enerBuffer, /* i : energy buffer */ - HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: CNG structure containing all buffers and variables */ - const int32_t input_Fs, /* i : input sampling rate */ - CPE_ENC_HANDLE hCPE ); - -void AdjustFirstSID( - Encoder_State *st /* i/o: encoder state structure */ -); - -void FdCng_encodeSID( - Encoder_State *st /* i/o: encoder state structure */ -); - -void GetParameters( - ParamsBitMap const *paramsBitMap, - const int16_t nParams, - void const *pParameter, - int16_t **pStream, - int16_t *pnSize, - int16_t *pnBits ); - -void SetParameters( - ParamsBitMap const *paramsBitMap, - const int16_t nParams, - void *pParameter, - const int16_t **pStream, - int16_t *pnSize ); - -void WriteToBitstream( - ParamsBitMap const *paramsBitMap, - const int16_t nParams, - const int16_t **pStream, - int16_t *pnSize, - BSTR_ENC_HANDLE hBstr, - int16_t *pnBits ); - -void ReadFromBitstream( - ParamsBitMap const *paramsBitMap, - const int16_t nArrayLength, - Decoder_State *st, - int16_t **pStream, - int16_t *pnSize ); - -void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue ); -void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value ); -void const *GetNumOfTnsFilters_flt( void const *p, const int16_t index, int16_t *pValue ); -void *SetNumOfTnsFilters_flt( void *p, const int16_t index, const int16_t value ); - -int16_t DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); -int16_t DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); - -int16_t DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); - -int16_t DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); -int16_t DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); - -int16_t EncodeTnsFilterOrderSWBTCX10_flt( const int16_t value, const int16_t index ); - -int16_t GetTnsFilterOrderBitsSWBTCX10_flt( const int16_t value, const int16_t index ); -int16_t DecodeTnsFilterOrder_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); - -void ResetTnsData_flt( - STnsData *pTnsData ); - -void ClearTnsFilterCoefficients_flt( - STnsFilter *pTnsFilter ); - - -int16_t DetectTnsFilt( - const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ - const float pSpectrum[], /* i : MDCT spectrum */ - TRAN_DET_HANDLE hTranDet, /* i : transient detection handle */ - const int16_t isTCX10, /* i : TCX10 or TCX20? */ - const float ltp_gain, /* i : LTP gain */ - STnsData *pTnsData, /* o : TNS data struct */ - float *predictionGain /* o : TNS prediction gain */ -); - -void EncodeTnsData( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - int16_t *stream, /* o : internal data stream */ - int16_t *pnSize, /* o : number of written parameters */ - int16_t *pnBits /* o : number of written bits */ -); - -int16_t DecodeTnsData_ivas( - STnsConfig const *pTnsConfig, - const int16_t *stream, - int16_t *pnSize, - STnsData *pTnsData ); - -void WriteTnsData( - const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ - const int16_t *stream, /* i : internal data stream */ - int16_t *pnSize, /* o : number of written parameters */ - BSTR_ENC_HANDLE hBstr, /* o : bitstream */ - int16_t *pnBits /* o : number of written bits */ -); - -void ReadTnsData_ivas( - STnsConfig const *pTnsConfig, - Decoder_State *st, - int16_t *pnBits, - int16_t *stream, - int16_t *pnSize ); - -void cldfbAnalysis_ivas( - const float *timeIn, /* i : time buffer */ - float **realBuffer, /* o : real value buffer */ - float **imagBuffer, /* o : imag value buffer */ - const int16_t samplesToProcess, /* i : number of input samples */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ -); - -void cldfbAnalysis_ts_ivas( - const float *timeIn, /* i : time buffer */ - float realBuffer[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ - float imagBuffer[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ - const int16_t samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ -); - -void cldfbSynthesis_ivas( - float **realBuffer, /* i : real values */ - float **imagBuffer, /* i : imag values */ - float *timeOut, /* o : synthesized output */ - const int16_t samplesToProcess, /* i : number of samples */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ -); - -void configureCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ - const int32_t sampling_rate /* i : sampling rate */ -); - - -void analysisCldfbEncoder_ivas( - Encoder_State *st, /* i/o: encoder state structure */ - const float *timeIn, - const int16_t samplesToProcess, - float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float *ppBuf_Ener ); - -void analysisCldfbEncoder_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word32 *timeIn, /*q11*/ - Word16 timeInq, /*q0*/ - Word16 samplesToProcess, /*q0*/ - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 *ppBuf_Ener, - Word16 *enerBuffSum_exp, - CLDFB_SCALE_FACTOR *scale ); - -ivas_error openCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const int32_t sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -); - -ivas_error openCldfb_ivas_enc( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -); - -void resampleCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ - const int32_t newSamplerate /* i : new samplerate to operate */ -); - -ivas_error cldfb_save_memory_ivas( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -void cldfb_restore_memory_ivas( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -void cldfb_reset_memory_ivas( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -void deleteCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ -); - -void fft_cldfb( - float *data, /* i/o: input/output vector */ - const int16_t size /* i : size of fft operation */ -); - -void BITS_ALLOC_init_config_acelp_IVAS( - const int32_t bit_rate, - const int16_t narrowBand, - const int16_t nb_subfr, - ACELP_config *acelp_cfg /* o : configuration structure of ACELP */ -); - -int16_t BITS_ALLOC_config_acelp_IVAS( - const int16_t bits_frame, /* i : remaining bit budget for the frame */ - const int16_t coder_type, /* i : acelp coder type */ - ACELP_config *acelp_cfg, /* i/o: configuration structure of ACELP */ - const int16_t narrowband, /* i : narrowband flag */ - const int16_t nb_subfr /* i : number of subframes */ -); - - -void FEC_clas_estim( - const float *syn, - const float *pitch, /* i : pitch values for each subframe */ - const int16_t L_frame, /* i : length of the frame */ - const int16_t coder_type, /* i : coder type */ - const int16_t codec_mode, /* i : codec mode */ - float *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */ - int16_t *clas, /* i/o: frame classification */ - float *lp_speech, /* i/o: long term active speech energy average */ - const int16_t Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - int16_t *decision_hyst, /* i/o: hysteresis of the music/speech decision */ - int16_t *locattack, /* i/o: detection of attack (mainly to localized speech burst) */ - int16_t *UV_cnt, /* i/o: number of consecutives frames classified as UV */ - float *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV */ - float *Last_ener, /* i/o: last_energy frame */ - int16_t *amr_io_class, /* i/o: classification for AMR-WB IO mode */ - float *lt_diff_etot, /* i/o: long-term total energy variation */ - float *class_para, /* o : classification para. fmerit1 */ - const float LTP_Gain, /* i : */ - const int16_t narrowBand, /* i : */ - const SIGNAL_CLASSIFIER_MODE mode, /* i : */ - const int16_t bfi, /* i : */ - const float preemph_fac, /* i : */ - const int16_t tcxonly, /* i : */ - const int32_t last_core_brate, /* i : last core bitrate */ - const int16_t FEC_mode /* i : ACELP FEC mode */ -); - - -void SetTCXModeInfo( - Encoder_State *st, /* i/o: encoder state structure */ - TRAN_DET_HANDLE hTranDet, /* i/o: transient detection handle */ - int16_t *tcxModeOverlap /* o : window overlap of current frame */ -); - -void TCX_MDCT_flt( - const float *x, - float *y, - const int16_t l, - const int16_t m, - const int16_t r, - const int16_t element_mode ); - -void TCX_MDST_flt( - const float *x, - float *y, - const int16_t l, - const int16_t m, - const int16_t r, - const int16_t element_mode ); - -void TCX_MDCT_Inverse_flt( - const float *x, - float *y, - const int16_t l, - const int16_t m, - const int16_t r, - const int16_t element_mode ); - -void TCX_MDST_Inverse_flt( - const float *x, - float *y, - const int16_t l, - const int16_t m, - const int16_t r, - const int16_t element_mode ); - -void TCX_MDXT_Inverse_flt( - const float *x, - float *y, - const int16_t l, - const int16_t m, - const int16_t r, - const uint16_t kernel_type ); - -void post_decoder_flt( - Decoder_State *st, - float synth_buf[], - const float pit_gain[], - const int16_t pitch[], - float signal_out[], - float bpf_noise_buf[] ); -void cldfb_synth_set_bandsToZero_flt( - Decoder_State *st, /* i/o: decoder state structure */ - float **rAnalysis, - float **iAnalysis, - const int16_t nTimeSlots ); - -void longadd( - uint16_t a[], /* i/o: vector of the length lena */ - const uint16_t b[], /* i/o: vector of the length lenb */ - const int16_t lena, /* i/o: length of vector a[] */ - const int16_t lenb /* i/o: length of vector b[] */ -); - -void longshiftright( - uint16_t a[], /* i : vector of the length lena */ - const int16_t b, /* i : number of bit positions to shift right */ - uint16_t d[], /* o : vector of the length lend */ - int16_t lena, /* i : length of vector a[] */ - const int16_t lend /* i : length of vector d[] */ -); - -void longshiftleft( - const uint16_t a[], /* i : vector of the length len */ - const int16_t b, /* i : number of bit positions to shift left */ - uint16_t d[], /* o : vector of the length len */ - const int16_t len /* i : length of vector a[] and d[] */ -); - -void open_decoder_LPD( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t total_brate, /* i : total bitrate */ - const int32_t last_total_brate, /* i : last total bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t last_element_mode, /* i : last element mode */ - const int16_t is_init /* i : indicate call during initialization */ -); - -void acelp_plc_mdct_transition( - Decoder_State *st /* i/o: Decoder state */ -); - -void tcxltp_dec_init( - TCX_LTP_DEC_HANDLE hTcxLtpDec, - const int16_t ini_frame, - const int16_t last_codec_mode, - const int16_t element_mode, - const int16_t pit_max, - const int32_t sr_core ); - -void reset_tcx_overl_buf( - TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ -); - -void update_decoder_LPD_cng_flt( - Decoder_State *st, /* i/o: decoder state structure */ - float *timeDomainBuffer, - float *A, - float *bpf_noise_buf ); - -void reconfig_decoder_LPD_ivas( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t bits_frame, /* i : bit budget */ - const int16_t bwidth, /* i : audio bandwidth */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t L_frame_old /* i : frame length */ -); - -void mode_switch_decoder_LPD( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t bwidth, /* i : audio bandwidth */ - const int32_t total_brate, /* i : total bitrate */ - const int32_t last_total_brate, /* i : last frame total bitrate */ - const int16_t frame_size_index, /* i : index determining the frame size */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const int16_t last_element_mode /* i : last element mode */ -); - -void dec_acelp_tcx_frame( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *concealWholeFrame, /* i/o: concealment flag */ - float *output, /* o : synthesis */ - float *bpf_noise_buf, /* i/o: BPF noise buffer */ - float *pcmbufFB, /* o : synthesis @output_FS */ - float bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - float *voice_factors, /* o : voicing factors */ - float pitch_buf[], /* o : floating pitch for each subframe */ - STEREO_CNG_DEC_HANDLE hStereoCng /* i : stereo CNG handle */ -); - -void decoder_LPD( - Decoder_State *st, /* i/o: decoder memory state pointer */ - float signal_out[], /* o : signal with LPD delay (7 subfrs) */ - float signal_outFB[], /* o : synthesis @output_FS */ - int16_t *total_nbbits, /* i/o: number of bits / decoded bits */ - float *bpf_noise_buf, /* i/o: BPF noise buffer */ - int16_t bfi, /* i : BFI flag */ - int16_t *bitsRead, /* o : number of read bits */ - int16_t param[], /* o : buffer of parameters */ - float *pitch_buf, /* i/o: floating pitch values for each subfr*/ - float *voice_factors, /* o : voicing factors */ - float *ptr_bwe_exc /* o : excitation for SWB TBE */ -); - -int16_t tcxGetNoiseFillingTilt_flt( - const float A[], - const int16_t L_frame, - const int16_t mode, - float *noiseTiltFactor ); - -void tcxFormantEnhancement_flt( - float xn_buf[], - const float *gainlpc, - float spectrum[], - const int16_t L_frame ); - -void tcxInvertWindowGrouping_flt( - TCX_CONFIG_HANDLE hTcxCfg, - float xn_buf[], - float spectrum[], - const int16_t L_frame, - const int8_t fUseTns, - const int16_t last_core, - const int16_t index, - const int16_t frame_cnt, - const int16_t bfi ); - -void tcx5SpectrumInterleaving( - const int16_t tcx5Size, - float *spectrum ); - -void tcx5SpectrumDeinterleaving( - const int16_t tcx5Size, - float *spectrum ); - -void tcx5TnsGrouping( - const int16_t L_frame, - const int16_t L_spec, - float *spectrum ); - -void tcx5TnsUngrouping( - const int16_t L_frame, - const int16_t L_spec, - float *spectrum, - const int16_t enc_dec ); - -void lerp_flt( - const float *f, - float *f_out, - const int16_t bufferNewSize, - const int16_t bufferOldSize ); - -void encoderSideLossSimulation( - Encoder_State *st, - PLC_ENC_EVS_HANDLE hPlc_Ext, - float *isf_q, - const float stab_fac, - const int16_t calcOnlyISF, - const int16_t L_frame ); - -void enc_prm_side_Info( - PLC_ENC_EVS_HANDLE hPlc_Ext, - Encoder_State *st ); - -void GplcTcxEncSetup( - const int16_t tcxltp_pitch_int, - PLC_ENC_EVS_HANDLE hPlc_Ext ); - -int16_t encSideSpecPowDiffuseDetector( - float *isf_ref, - float *isf_con, - const int32_t sr_core, - float *prev_isf4_mean, - const int16_t sw, - const int16_t coder_type ); - -void updateSpecPowDiffuseIdx( - const float gain_pitch_buf[], /* i : gain pitch values */ - const float gain_code_buf[], /* i : gain pitch values */ - int16_t glr_idx[2], /* o : */ - float mean_gc[2] /* o : */ -); - -void getLookAheadResSig_flt( - float *speechLookAhead, - const float *A, - float *res, - const int16_t L_frame, - const int16_t L_subfr, - const int16_t m, - const int16_t numSubFrame ); - -void updatelsfForConcealment_flt( - PLC_ENC_EVS_HANDLE decState, - float *lsf ); - -void getConcealedLP_flt( - PLC_ENC_EVS_HANDLE memDecState, - float *AqCon, - const float xsfBase[], - const int32_t sr_core, - const int16_t last_good, - const int16_t L_frame ); - -void RecLpcSpecPowDiffuseLc_flt( - float *ispq, - float *isp_old, - float *isfq, - Decoder_State *st, - const int16_t reset_q ); - -void modify_lsf_flt( - float *lsf, - const int16_t n, - const int32_t sr_core, - const int16_t reset_q ); - -void init_PLC_enc( - PLC_ENC_EVS_HANDLE hPlcExt, - const int32_t sr_core ); - -void gPLC_encInfo( - PLC_ENC_EVS_HANDLE hPlcExt, - const int32_t total_brate, - const int16_t bwidth, - const int16_t last_clas, - const int16_t coder_type ); - -void resetTecDec( - TEC_DEC_HANDLE hTecDec ); - -void calcGainTemp_TBE( - float **pCldfbRealSrc, - float **pCldfbImagSrc, - float *loBuffer, - const int16_t startPos, /*!< Start position of the current envelope. */ - const int16_t stopPos, /*!< Stop position of the current envelope. */ - const int16_t lowSubband, /* lowSubband */ - float *pGainTemp, - const int16_t code ); - -void procTecTfa_TBE( - float *hb_synth, - float *gain, - const int16_t flat_flag, - const int16_t last_core, - const int16_t L_subfr, - const int16_t code ); - -void resetTecEnc( - TEC_ENC_HANDLE hTecEnc, - const int16_t flag ); - -void calcHiEnvLoBuff( - const int16_t noCols, - const int16_t *pFreqBandTable, /* i : freqbandTable */ - const int16_t nSfb, /* i : Number of scalefactors */ - float **pYBuf, - float *loBuf, - float *hiTempEnv ); - -void calcLoEnvCheckCorrHiLo( - const int16_t noCols, - const int16_t *pFreqBandTable, /* i : freqbandTable */ - float *loBuf, - float *loTempEnv, - float *loTempEnv_ns, - float *hiTempEnv, - int16_t *corr_flag /* o : 0 for original, 1 for TEC */ -); - - -void tecEnc_TBE( - int16_t *corrFlag, - const float *voicing, - const int16_t coder_type ); - -void set_TEC_TFA_code( - const int16_t corrFlag, - int16_t *tec_flag, - int16_t *tfa_flag ); - -float Damping_fact_flt( - const int16_t coder_type, /* i : ACELP core coder type */ - const int16_t nbLostCmpt, /* i : compt for number of consecutive lost frame */ - int16_t last_good, /* i : class of last good received frame */ - float stab_fac, /* i : LSF stability factor */ - float *lp_gainp, /* i/o: low passed pitch gain used for concealment */ - const int16_t core /* i : current core: ACELP = 0, TCX20 = 1, TCX10 = 2 */ -); - -float getLevelSynDeemph( - const float h1Init[], /* i : input value or vector to be processed */ - const float A[], /* i : LPC coefficients */ - const int16_t lenLpcExc, /* i : length of the LPC excitation buffer */ - const float preemph_fac, /* i : preemphasis factor */ - const int16_t numLoops /* i : number of loops */ -); - -void genPlcFiltBWAdap( - const int32_t sr_core, /* i : core sampling rate */ - float *lpFiltAdapt, /* o : filter coefficients for filtering codebooks in case of flc */ - const int16_t type, /* i : type of filter, either 0 : lowpass or 1 : highpass */ - const float alpha /* i : fade out factor [0 1) used decrease filter tilt */ -); - -void highPassFiltering( - const int16_t last_good, /* i : last classification type */ - const int16_t L_buffer, /* i : buffer length */ - float exc2[], /* i/o: unvoiced excitation before the high pass filtering */ - const float hp_filt[], /* i : high pass filter coefficients */ - const int16_t l_fir_fer /* i : high pass filter length */ -); - -int16_t GetPLCModeDecision( - Decoder_State *st /* i/o: decoder memory state pointer */ -); - -void addBassPostFilter( - const float *harm_timeIn, - const int16_t samplesToProcess, - float **rAnalysis, - float **iAnalysis, - HANDLE_CLDFB_FILTER_BANK cldfb ); - -ivas_error TonalMDCTConceal_Init_ivas( - TonalMDCTConcealPtr hTonalMDCTConc, - const uint16_t samplesPerBlock, - const uint16_t nSamplesCore, - const uint16_t nScaleFactors, - TCX_CONFIG_HANDLE hTcxCfg ); - -void TonalMDCTConceal_SaveFreqSignal_ivas( - TonalMDCTConcealPtr hTonalMDCTConc, - const float *mdctSpectrum, - const uint16_t numSamples, - const uint16_t nNewSamplesCore, - const float *scaleFactors, - const int16_t infoIGFStartLine ); - -void TonalMDCTConceal_UpdateState_ivas( - TonalMDCTConcealPtr hTonalMDCTConc, - const int16_t numSamples, - const float pitchLag, - const int16_t badBlock, - const int16_t tonalConcealmentActive ); - -void TonalMDCTConceal_SaveTimeSignal_ivas( - TonalMDCTConcealPtr hTonalMDCTConc, - float *timeSignal, - const int16_t numSamples ); - -void TonalMDCTConceal_Detect_ivas( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - const float pitchLag, /*IN */ - int16_t *umIndices, /*OUT*/ - const PsychoacousticParameters *psychParamsCurrent /*IN*/ -); - -void TonalMDCTConceal_Apply_ivas( - TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - float *mdctSpectrum, /*OUT*/ - const PsychoacousticParameters *psychParamsCurrent /*IN*/ -); - -void TonalMDCTConceal_InsertNoise_ivas( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - float *mdctSpectrum, /*OUT*/ - const int16_t tonalConcealmentActive, - int16_t *pSeed, /*IN/OUT*/ - const float tiltCompFactor, - const float crossfadeGain, - const float concealment_noise[L_FRAME48k], - const float cngLevelBackgroundTrace_bfi, - const int16_t crossOverFreq ); - -void DetectTonalComponents_flt( - uint16_t indexOfTonalPeak[], - uint16_t lowerIndex[], - uint16_t upperIndex[], - uint16_t *pNumIndexes, - const float lastPitchLag, - const float currentPitchLag, - const float lastMDCTSpectrum[], - const float scaleFactors[], - const float secondLastPowerSpectrum[], - const uint16_t nSamples, - const uint16_t nSamplesCore, - float floorPowerSpectrum, - const PsychoacousticParameters *psychParamsCurrent ); - -void RefineTonalComponents_flt( - uint16_t indexOfTonalPeak[], - uint16_t lowerIndex[], - uint16_t upperIndex[], - float phaseDiff[], - float phases[], - uint16_t *pNumIndexes, - const float lastPitchLag, - const float currentPitchLag, - const float lastMDCTSpectrum[], - const float scaleFactors[], - const float secondLastPowerSpectrum[], - const uint16_t nSamples, - const uint16_t nSamplesCore, - float floorPowerSpectrum, - const PsychoacousticParameters *psychParamsCurrent ); - -ivas_error PsychoacousticParameters_Init( - const int32_t sr_core, /* i : sampling rate of core-coder */ - const int16_t nBins, /* i : Number of bins (spectral lines) */ - const int8_t nBands, /* i : Number of spectrum subbands */ - const int16_t isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ - const int16_t isWarped, /* i : Flag indicating if the scale is linear or warped */ - PsychoacousticParameters *pPsychParams ); - -void concealment_init( - const int16_t L_frameTCX, - T_PLCInfo_HANDLE hPlcInfo ); - -void concealment_decode( - const int16_t core, - float *invkoef, - T_PLCInfo_HANDLE hPlcInfo ); - -void concealment_update( - const int16_t bfi, - const int16_t core, - const int16_t harmonic, - float *invkoef, - T_PLCInfo_HANDLE hPlcInfo ); - -void concealment_update2( - const float *outx_new, - T_PLCInfo_HANDLE hPlcInfo, - const int16_t L_frameTCX ); - -void concealment_signal_tuning( - Decoder_State *st, - const int16_t bfi, - float *outx_new, - const int16_t past_core_mode ); - -void waveform_adj2( - T_PLCInfo_HANDLE hPlcInfo, - float *overlapbuf, - float *outx_new, - const int16_t delay, - const int16_t bfi_cnt, - const int16_t bfi ); - -float SFM_Cal( - const float fcoef[], - const int16_t n ); - -void set_state_ivas( - int16_t *state, - const int16_t num, - const int16_t N ); - -int16_t RFFTN( - float *afftData, - const float *trigPtr, - const int16_t len, - const int16_t isign ); - -void DoFFT( - float *re2, - float *im2, - const int16_t length ); - -/*! r: flag indicating a valid bitrate */ -int16_t is_EVS_bitrate( - const int32_t ivas_total_brate, /* i : EVS total bitrate */ - int16_t *Opt_AMR_WB /* i : AMR-WB IO flag */ -); - -int16_t getTcxonly_ivas( - const int16_t element_mode, /* i : IVAS element mode */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const int16_t is_ism_format /* i : flag indicating ISM format */ -); - -int16_t getTnsAllowed( - const int32_t total_brate, /* i : total bitrate */ - const int16_t igf, /* i : flag indicating IGF activity*/ - const int16_t element_mode /* i : IVAS element mode */ -); - -int16_t getCtxHm( - const int16_t element_mode, /* i : IVAS element mode */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t rf_flag /* i : flag to signal the RF mode */ -); - -int16_t getResq( - const int32_t total_brate /* i : total bitrate */ -); - -int16_t getMdctWindowLength( - const int16_t fscale ); - -int16_t sr2fscale( - const int32_t sr_core /* i : internal sampling rate */ -); - -int32_t getCoreSamplerateMode2_flt( - const int16_t element_mode, /* i : IVAS element mode */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */ - const int16_t rf_mode, /* i : flag to signal the RF mode */ - const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ -); - -float getTcxBandwidth_flt( - const int16_t bwidth /* i : audio bandwidth */ -); - - -int16_t getCnaPresent( - const int16_t element_mode, /* i : element mode */ - const int32_t element_brate, /* i : element bitrate */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t bwidth /* i : audio bandwidth */ -); - -int16_t getTcxLtp( - const int32_t sr_core /* i : internal sampling rate */ -); - -int16_t initPitchLagParameters( - const int32_t sr_core, /* i : internal sampling rate */ - int16_t *pit_min, - int16_t *pit_fr1, - int16_t *pit_fr1b, - int16_t *pit_fr2, - int16_t *pit_max ); - -void attenuateNbSpectrum( - const int16_t L_frame, - float *spectrum ); - -void SetModeIndex( - Encoder_State *st, /* i : Encoder state */ - const int32_t last_total_brate, /* i : last total bitrate */ - const int16_t last_element_mode, /* i : last IVAS element mode */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -int16_t getNumTcxCodedLines( - const int16_t bwidth /* i : audio bandwidth */ -); - -int16_t getTcxLpcShapedAri( - const int32_t total_brate, /* i : total bitrate */ - const int16_t rf_mode, /* i : flag to signal the RF mode */ - const int16_t element_mode /* i : IVAS element mode */ -); - -void IGFEncApplyMono( - Encoder_State *st, /* i : Encoder state */ - const int16_t igfGridIdx, /* i : IGF grid index */ - float *pMDCTSpectrum, /* i/o: MDCT spectrum */ - float *pPowerSpectrum, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ - const int16_t isTNSActive, /* i : flag indicating if the TNS is active */ - const int16_t sp_aud_decision0, /* i : first stage switching decision */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ -); - -void IGFEncApplyStereo( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */ - int16_t ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */ - const int16_t igfGridIdx, /* i : IGF grid index */ - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - float *pPowerSpectrum[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - float *pPowerSpectrumMsInv[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ - float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ - const int16_t frameno, /* i : flag indicating index of current subframe */ - const int16_t sp_aud_decision0, /* i : sp_aud_decision0 */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ -); - - -void IGFEncResetTCX10BitCounter_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i : instance handle of IGF Encoder */ -); - -ivas_error IGF_Reconfig( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const int16_t igf, /* i : IGF on/off */ - const int16_t reset, /* i : reset flag */ - const int32_t brate, /* i : bitrate for configuration */ - const int16_t bwidth, /* i : signal bandwidth */ - const int16_t element_mode, /* i : IVAS element mode */ - const int16_t rf_mode /* i : flag to signal the RF mode */ -); - -void IGFEncSetMode( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - const int32_t total_brate, /* i : encoder total bitrate */ - const int16_t bwidth, /* i : encoder audio bandwidth */ - const int16_t element_mode, /* i : IVAS element mode */ - const int16_t rf_mode /* i : flag to signal the RF mode */ -); - -/*! r: number of bits written per frame */ -int16_t IGFEncWriteBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - int16_t *pBitOffset, /* i : ptr to bitOffset counter */ - const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const int16_t isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ -); - -/*! r: total number of bits written */ -int16_t IGFEncWriteConcatenatedBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -); - -void IGFDecApplyMono_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ - float *spectrum, /* i/o: MDCT spectrum */ - const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const int16_t bfi, /* i : frame loss == 1, frame good == 0 */ - const int16_t element_mode /* i : IVAS element mode */ -); - -void IGFDecCopyLPCFlatSpectrum_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ - const float *pSpectrumFlat, /* i : LPC flattend spectrum from TCX dec */ - const int16_t igfGridIdx /* i : IGF grid index */ -); - -void IGFDecReadData_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */ - Decoder_State *st, /* i : decoder state */ - const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */ -); - -/*! r: return igfAllZero flag indicating if no envelope is transmitted */ -int16_t IGFDecReadLevel_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Deccoder */ - Decoder_State *st, /* i : decoder state */ - const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const int16_t isIndepFrame /* i : if 1: arith dec force reset, if 0: no reset */ -); - -void IGFDecRestoreTCX10SubFrameData_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ - const int16_t subFrameIdx /* i : index of subframe */ -); - -void init_igf_dec_flt( - IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ -); - -void IGFDecSetMode_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ - const int32_t total_brate, /* i : bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t element_mode, /* i : IVAS element mode */ - const int16_t defaultStartLine, /* i : default start subband index */ - const int16_t defaultStopLine, /* i : default stop subband index */ - const int16_t rf_mode /* i : flag to signal the RF mode */ -); - -void IGFDecStoreTCX10SubFrameData_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ - const int16_t subFrameIdx /* i : index of subframe */ -); - -void IGFDecUpdateInfo_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ - const int16_t subFrameIdx, /* i : subframe index */ - const int16_t igfGridIdx /* i : IGF grid index */ -); - -/*! r: error value: 0 -> error, 1 -> ok */ -int16_t IGFCommonFuncsIGFConfiguration_flt( - const int32_t total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t element_mode, /* i : IVAS element mode */ - H_IGF_INFO hIGFInfo, /* o : IGF info handle */ - const int16_t rf_mode /* i : flag to signal the RF mode */ -); - -/*! r: error value: 0 -> error, 1 -> ok */ -int16_t IGFCommonFuncsIGFGetCFTables_flt( - const int32_t total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t element_mode, /* i : element mode */ - const int16_t rf_mode, /* i : flag to signal the RF mode */ - const uint16_t **cf_se00, /* i : CF table for t == 0 and f == 0 */ - const uint16_t **cf_se01, /* i : CF table for t == 0 and f == 1 */ - int16_t *cf_off_se01, /* o : offset for CF table above */ - const uint16_t **cf_se02, /* i : CF tables for t == 0 and f >= 2 */ - const int16_t **cf_off_se02, /* o : offsets for CF tables above */ - const uint16_t **cf_se10, /* i : CF table for t == 1 and f == 0 */ - int16_t *cf_off_se10, /* o : offset for CF table above */ - const uint16_t **cf_se11, /* i : CF tables for t == 1 and f >= 1 */ - const int16_t **cf_off_se11 /* o : offsets for CF tables above */ -); - -/*! r: multiplication factor */ -int16_t IGF_ApplyTransFac_flt( - const int16_t val, /* i : input value for multiplication, Q15 */ - const float transFac /* i : multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */ -); - -/*! r: return bitrate index */ -int16_t IGF_MapBitRateToIndex_flt( - const int32_t brate, /* i : bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t element_mode, /* i : element mode */ - const int16_t rf_mode /* i : flag to signal the RF mode */ -); - - -void IGFSCFDecoderOpen_ivas( - IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ - H_IGF_INFO hIgfInfo, /* i : IGF info handle */ - const int32_t total_brate, - const int16_t bwidth, - const int16_t element_mode, - const int16_t rf_mode ); - -void IGFSCFDecoderReset_ivas( - IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i : handle to public data or NULL in case there was no instance created */ -); - -void IGFSCFDecoderDecode_ivas( - IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */ - Decoder_State *st, /* i/o: pointer to decoder state */ - int16_t *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */ - const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const int16_t indepFlag /* i : if 1 on input the decoder will be forced to reset, - if 0 on input the decoder will be forced to encode without a reset */ -); - -/*! r: offset value */ -int16_t tbe_celp_exc_offset_flt( - const int16_t T0, /* i : Integer pitch */ - const int16_t T0_frac /* i : Fractional part of the pitch */ -); - -void blend_subfr2_flt( - float *sigIn1, /* i : input signal for fade-out */ - float *sigIn2, /* i : input signal for fade-in */ - float *sigOut /* o : output signal */ -); - -void init_tcx_window_cfg( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */ - const int32_t sr_core, /* i : SR core */ - const int32_t input_Fs, /* i : input/output SR */ - const int16_t L_frame, /* i : L_frame at sr_core */ - const int16_t L_frameTCX, /* i : L_frame at i/o SR */ - const int16_t encoderLookahead_enc, /* i : encoder LA at sr_core */ - const int16_t encoderLookahead_FB, /* i : encoder LA at i/o SR */ - const int16_t mdctWindowLength, /* i : window length at sr_core */ - const int16_t mdctWindowLengthFB, /* i : window length at i/o SR */ - const int16_t element_mode /* i : mode of CPE/SCE */ -); - -void init_tcx_cfg( - TCX_CONFIG_HANDLE hTcxCfg, - const int32_t total_brate, - const int32_t sr_core, - const int32_t input_Fs, - const int16_t L_frame, - const int16_t bwidth, - const int16_t L_frameTCX, - const int16_t fscale, - const int16_t encoderLookahead_enc, - const int16_t encoderLookahead_FB, - const float preemph_fac, - const int16_t tcxonly, - const int16_t rf_mode, - const int16_t igf, - const int16_t infoIGFStopFreq, - const int16_t element_mode, - const int16_t ini_frame, - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -#endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 51fbb12d5..9b596ca42 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -49,14 +49,63 @@ #include "ivas_cnst.h" #include "stat_enc.h" #include "stat_dec.h" +#include "stat_com.h" #include "ivas_stat_enc.h" #include "ivas_stat_dec.h" +#include "ivas_stat_com.h" #include "ivas_error.h" #include "ivas_error_utils.h" #include "complex_basop.h" #define TCX_IMDCT_SCALE 15 #define TCX_IMDCT_HEADROOM 1 + +/*----------------------------------------------------------------------------------* + * Prototypes of global macros + *----------------------------------------------------------------------------------*/ + +#ifndef min +#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) +#endif + +#ifndef max +#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) +#endif + +#ifndef TRUNC +#define TRUNC( x ) ( (int16_t) ( ( ( x ) >= 32767. ? 32767 : ( ( x ) <= -32768. ? -32768 : ( x ) ) ) + 0.5 ) ) +#endif + +#define log_base_2( x ) ( (double) log( (double) ( x ) ) * 1.4426950408889634074f ) +#define round_f( x ) ( ( ( x ) > 0 ) ? (int32_t) ( ( x ) + 0.5f ) : ( -(int32_t) ( ( -x ) + 0.5f ) ) ) + +#ifndef ABSVAL +#define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) ) +#endif + +#ifndef SQR +#define SQR( a ) ( ( a ) * ( a ) ) +#endif + +#ifndef SWAP +#define SWAP( a, b ) \ + { \ + tempr = ( a ); \ + ( a ) = ( b ); \ + ( b ) = tempr; \ + } +#endif + +#ifndef swap +#define swap( x, y, type ) \ + { \ + type u__p; \ + u__p = x; \ + x = y; \ + y = u__p; \ + } +#endif + /*================================================================================*/ /* conversion functions: */ /*================================================================================*/ @@ -10920,7 +10969,6 @@ void IGFEncConcatenateBitstream( BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ ); -#endif void hq_generic_hf_encoding_fx( const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ @@ -11205,3 +11253,746 @@ void WriteToBitstream_ivas_fx( Word16 *pnSize, BSTR_ENC_HANDLE hBstr, Word16 *pnBits ); + + +/*===========================================================================================*/ +/*----------------------------------------------------------------------------------* + * MODE1 prototypes + *----------------------------------------------------------------------------------*/ + +/*! r: inverse square root of input value */ +float inv_sqrt( + const float x /* i : input value */ +); + +/*! r: output random value */ +int16_t own_random( + int16_t *seed /* i/o: random seed */ +); + +/*! r: sign of x (+1/-1) */ +float sign( + const float x /* i : input value of x */ +); + +/*! r: logarithm2 of x */ +float log2_f( + const float x /* i : input value of x */ +); + +int16_t norm_ul_float( + uint32_t UL_var1 ); + +/*! r: sum of all vector elements */ +int16_t sum_s( + const int16_t *vec, /* i : input vector */ + const int16_t lvec /* i : length of input vector */ +); + +/*! r: sum of all vector elements */ +int32_t sum_l( + const int32_t *vec, /* i : input vector */ + const int16_t lvec /* i : length of input vector */ +); + +/*! r: sum of all squared vector elements */ +float sum2_f( + const float *vec, /* i : input vector */ + const int16_t lvec /* i : length of input vector */ +); + +void set_c( + int8_t y[], /* i/o: Vector to set */ + const int8_t a, /* i : Value to set the vector to */ + const int32_t N /* i : Length of the vector */ +); + +void set_s( + int16_t y[], /* i/o: Vector to set */ + const int16_t a, /* i : Value to set the vector to */ + const int16_t N /* i : Lenght of the vector */ +); + +void set_l( + int32_t y[], /* i/o: Vector to set */ + const int32_t a, /* i : Value to set the vector to */ + const int16_t N /* i : Length of the vector */ +); + +void set_f( + float y[], /* i/o: Vector to set */ + const float a, /* i : Value to set the vector to */ + const int16_t N /* i : Lenght of the vector */ +); + +void set_zero_fx( + Word32 *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ +); +void set_zero2_fx( + Word32 *vec, /* o : input vector */ + const Word32 lvec /* i : length of the vector */ +); +void set16_zero_fx( + Word16 *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ +); + +void set_zero( + float *vec, /* o : input vector */ + const int16_t lvec /* i : length of the vector */ +); + +void mvr2r( + const float x[], /* i : input vector */ + float y[], /* o : output vector */ + const int16_t n /* i : vector size */ +); + +void mvs2s( + const int16_t x[], /* i : input vector */ + int16_t y[], /* o : output vector */ + const int16_t n /* i : vector size */ +); + +uint32_t mvr2s( + const float x[], /* i : input vector */ + int16_t y[], /* o : output vector */ + const int16_t n /* i : vector size */ +); + +void mvs2r( + const int16_t x[], /* i : input vector */ + float y[], /* o : output vector */ + const int16_t n /* i : vector size */ +); + +void mvl2l( + const int32_t x[], /* i : input vector */ + int32_t y[], /* o : output vector */ + const int16_t n /* i : vector size */ +); + + +/*! r: index of the maximum value in the input vector */ +int16_t maximum( + const float *vec, /* i : input vector */ + const int16_t lvec, /* i : length of input vector */ + float *max_val /* o : maximum value in the input vector */ +); +/*! r: index of the maximum value in the input vector */ +int16_t maximumAbs( + const float *vec, /* i : input vector */ + const int16_t lvec, /* i : length of input vector */ + float *max_val /* o : maximum value in the input vector */ +); + +Word16 maximumAbs_l( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ +); + +/*! r: index of the minimum value in the input vector */ +int16_t minimum( + const float *vec, /* i : input vector */ + const int16_t lvec, /* i : length of input vector */ + float *min_val /* o : minimum value in the input vector */ +); + +/*! r: index of the minimum value in the input vector */ +int16_t minimum_s( + const int16_t *vec, /* i : Input vector */ + const int16_t lvec, /* i : Vector length */ + int16_t *min_val /* o : minimum value in the input vector */ +); + +/*! r: return index with max energy value in vector */ +int16_t emaximum( + const float *vec, /* i : input vector */ + const int16_t lvec, /* i : length of input vector */ + float *ener_max /* o : maximum energy value */ +); + +/*! r: vector mean */ +float mean( + const float *vec, /* i : input vector */ + const int16_t lvec /* i : length of input vector */ +); + +/*! r: dot product of x[] and y[] */ +float dotp( + const float x[], /* i : vector x[] */ + const float y[], /* i : vector y[] */ + const int16_t n /* i : vector length */ +); + +void v_add( + const float x1[], /* i : Input vector 1 */ + const float x2[], /* i : Input vector 2 */ + float y[], /* o : Output vector that contains vector 1 + vector 2 */ + const int16_t N /* i : Vector length */ +); + +void v_sub( + const float x1[], /* i : Input vector 1 */ + const float x2[], /* i : Input vector 2 */ + float y[], /* o : Output vector that contains vector 1 - vector 2 */ + const int16_t N /* i : Vector length */ +); + +/*! r: dequanzited gain */ +float usdequant( + const int16_t idx, /* i : quantizer index */ + const float qlow, /* i : lowest codebook entry (index 0) */ + const float delta /* i : quantization step */ +); + +void sort( + uint16_t *x, /* i/o: Vector to be sorted */ + uint16_t len /* i/o: vector length */ +); + +void sort_l( + Word32 *x, /* i/o: Vector to be sorted */ + Word16 len /* i/o: vector length */ +); + + +ivas_error push_indice( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + int16_t id, /* i : ID of the indice */ + uint16_t value, /* i : value of the quantized indice */ + int16_t nb_bits /* i : number of bits used to quantize the indice */ +); + +ivas_error push_next_indice( + BSTR_ENC_HANDLE hBstr, + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ +); + +ivas_error push_next_bits( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ + const Word16 nb_bits /* i : number of bits to pack */ +); + +/*! r: maximum number of indices */ +Word16 get_ivas_max_num_indices_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); + +/*! r: maximum number of indices */ +int16_t get_BWE_max_num_indices( + const int32_t extl_brate /* i : extensiona layer bitrate */ +); + +/*! r: maximum number of indices */ +Word16 get_ivas_max_num_indices_metadata_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); +ivas_error ind_list_realloc( + INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ + const int16_t max_num_indices, /* i : new maximum number of allowed indices in the list */ + Encoder_Struct *st_ivas /* i : IVAS encoder structure */ +); + +ivas_error check_ind_list_limits( + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ +); + +void move_indices( + INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ + INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ + const int16_t nb_indices /* i : number of moved indices */ +); + +/*! r: index of the indice in the list, -1 if not found */ +int16_t find_indice( + BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ + const int16_t id, /* i : ID of the indice */ + uint16_t *value, /* o : value of the quantized indice */ + int16_t *nb_bits /* o : number of bits used to quantize the indice */ +); + +/*! r: number of deleted indices */ +uint16_t delete_indice( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const int16_t id /* i : ID of the indice */ +); + +/*! r: value of the indice */ +uint16_t get_next_indice( + Decoder_State *st, /* i/o: decoder state structure */ + int16_t nb_bits /* i : number of bits that were used to quantize the indice */ +); + +/*! r: value of the indice */ +uint16_t get_next_indice_1( + Decoder_State *st /* i/o: decoder state structure */ +); + +void get_next_indice_tmp( + Decoder_State *st, /* o : decoder state structure */ + int16_t nb_bits /* i : number of bits that were used to quantize the indice */ +); + +/*! r: value of the indice */ +uint16_t get_indice( + Decoder_State *st, /* i/o: decoder state structure */ + int16_t pos, /* i : absolute position in the bitstream */ + int16_t nb_bits /* i : number of bits that were used to quantize the indice */ +); + +void reset_indices_enc( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const int16_t max_num_indices /* i : max number of indices */ +); + +void reset_indices_dec( + Decoder_State *st /* i/o: decoder state structure */ +); + +Word16 rate2EVSmode_float( + const Word32 brate, /* i : bitrate */ + int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ +); + + +/*! r: 1 = OK, 0 = something wrong */ +ivas_error read_indices( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + uint16_t bit_stream[], /* i : bitstream buffer */ + UWord16 num_bits, /* i : number of bits in bitstream */ + int16_t *prev_ft_speech, + int16_t *CNG, + int16_t bfi /* i : bad frame indicator */ +); + + +void ivas_set_bitstream_pointers( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +Decoder_State **reset_elements( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void mdct_switching_dec_ivas_fx( + Decoder_State *st /* i/o: decoder state structure */ +); + +int16_t print_disclaimer( + FILE *fPtr ); + +void fft_rel( + float x[], /* i/o: input/output vector */ + const int16_t n, /* i : vector length */ + const int16_t m /* i : log2 of vector length */ +); + +void preemph_ivas_fx( + Word32 *signal, /* i/o: signal Qx*/ + const Word16 mu, /* i : preemphasis factor Q15*/ + const Word16 L, /* i : vector size Q0*/ + Word32 *mem /* i/o: memory (x[-1]) Qx*/ +); + +void create_offset( + UWord32 *offset_scale1, + UWord32 *offset_scale2, + const int16_t mode, + const int16_t prediction_flag ); + +void BASOP_cfft_ivas( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + Word16 s, /* i : stride real and imag part */ + Word16 *scale /* i : scalefactor */ +); + +Word32 ar_div_ivas( + Word32 num, + Word32 denum ); + +Word32 Mult_32_16( + Word32 a, + Word16 b ); + +Word32 Mult_32_32( + Word32 a, + Word32 b ); + + +void bit_allocation_second_fx2( + Word32 *Rk, + Word32 *Rk_sort, + Word16 BANDS, + const Word16 *band_width, + Word16 *k_sort, + Word16 *k_num, + const Word16 *p2a_flags, + const Word16 p2a_bands, + const Word16 *last_bitalloc, + const Word16 input_frame ); + +void bit_allocation_second_fx2( + Word32 *Rk, + Word32 *Rk_sort, + Word16 BANDS, + const Word16 *band_width, + Word16 *k_sort, + Word16 *k_num, + const Word16 *p2a_flags, + const Word16 p2a_bands, + const Word16 *last_bitalloc, + const Word16 input_frame ); + +#ifdef DEBUGGING +void read_next_force( + int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/ + FILE *f_force, /* i : force switching profile (0 if N/A) */ + int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */ +); +#endif + +ivas_error init_encoder_ivas_fx( + Encoder_State *st, /* i/o: state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + const Word16 idchan, /* i : channel ID */ + const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ + const Word16 interval_SID, /* i : interval for SID update */ + const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const Word32 element_brate /* i : element bitrate */ +); + +ivas_error acelp_core_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 inp[], /* i : input signal of the current frame Q_new*/ + Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ + Word16 *q_old_syn_12k8_16, + Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ + Word16 *unbits, /* o : number of unused bits Q0*/ + STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ + Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ + Word16 Q_new ); + +void flip_and_downmix_generic_fx_32( + Word32 input[], /* i : input spectrum Qx*/ + Word32 output[], /* o : output spectrum Qx*/ + const Word16 length, /* i : length of spectra */ + Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ + Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ + Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ + Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ +); + +void GenTransition_fixed( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs, /* i : output sampling rate : Q0 */ + const Word16 element_mode, /* i : element mode : Q0 */ + const Word16 L_frame, /* i : ACELP frame length : Q0 */ + const Word16 rf_flag, /* i : RF flag : Q0 */ + const Word32 total_brate, /* i : total bitrate : Q0 */ + const Word16 prev_Qx ); + +void GenTransition_WB_fixed( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs /* i : output sampling rate */ +); + +Word16 quant_2p_2N1_fx( /* o: return (2*N)+1 bits */ + const Word16 pos1, /* i: position of the pulse 1 */ + const Word16 pos2, /* i: position of the pulse 2 */ + const Word16 N /* i: number of bits FOR position */ +); + +void bands_and_bit_alloc_ivas_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 noise_lev, /* i : dwn scaling factor */ + const Word32 core_brate, /* i : core bit rate */ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q */ + Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ + const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ + Word16 *max_ener_band, /* o : Sorted order */ + Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ + Word16 *nb_subbands, /* o : Number of subband allowed */ + const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ + Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */ + Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ +); + +void ivas_find_wsp_fx( + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 L_subfr, /* i : length of subframe Q0*/ + const Word16 nb_subfr, /* i : number of subframes Q0*/ + const Word16 *A_fx, + /* i : A(z) filter coefficients */ // Q12 + Word16 *Aw_fx, + /* o : weighted A(z) filter coefficients */ // Q12 + const Word16 *speech_fx, + /* i : pointer to the denoised speech frame */ // Q_new + const Word16 tilt_fact, + /* i : tilt factor */ // Q15 + Word16 *wsp_fx, + /* o : poitnter to the weighted speech frame */ // Q_new + Word16 *mem_wsp_fx, + /* i/o: W(Z) denominator memory */ // Q_new + const Word16 gamma, + /* i : weighting factor */ // Q15 + const Word16 L_look /* i : look-ahead Q0*/ +); + +Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( + Word16 *x, /* Q0 */ + const Word16 nt, /* Q0 */ + const Word16 target, /* Q0 */ + HANDLE_RC_CONTEXT_MEM hContextMem ); + +Word16 RCcontextMapping_encode2_estimate_bandWise_fx( + Word16 *x, /* Q0 */ + const Word16 start_line, /* Q0 */ + const Word16 end_line, /* Q0 */ + HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */ +); + + +/*! r: Q15 */ +Word16 expfp_evs_fx( + const Word16 x, /* i : mantissa Q15-e */ + const Word16 x_e /* i : exponent Q0 */ +); + + +void tcx_arith_render_envelope_ivas_fx( + const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i : number of spectral lines Q0*/ + const Word16 L_spec, /* i : length of the coded spectrum Q0*/ + const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o : shaped signal envelope Q16*/ +); + +void tcx_arith_decode_envelope_ivas_fx( + Decoder_State *st, /* i/o: coder state */ + Word32 q_spectrum[], /* o : quantised MDCT coefficients */ + Word16 *q_spectrum_e, /* o : MDCT exponent */ + const Word16 L_frame, /* i : frame or MDCT length */ + Word16 L_spec, /* i : length w/o BW limitation */ + const Word16 A_ind[], /* i : quantised LPC coefficients */ + const Word16 target_bits, /* i : number of available bits */ + Word16 prm[], /* i : bitstream parameters */ + const Word16 use_hm, /* i : use HM in current frame? */ + const Word16 prm_hm[], /* i : HM parameter area */ + Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ + Word16 *arith_bits, /* o : bits used for ari. coding */ + Word16 *signaling_bits, /* o : bits used for signaling */ + const Word16 low_complexity /* i : low-complexity flag */ +); + + +void UnmapIndex_fx( + const Word16 PeriodicityIndex, /* Q0 */ + const Word16 Bandwidth, /* Q0 */ + const Word16 LtpPitchLag, /* Q0 */ + const Word8 SmallerLags, /* Q0 */ + Word16 *FractionalResolution, /* Q0 */ + Word32 *Lag /* Q0 */ +); + +#define GET_ADJ( T, L ) GET_ADJ2( T, L, *FractionalResolution ) +#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) + + +Word32 tcx_hm_render_fx( + const Word32 lag, /* i: pitch lag Q0 */ + const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[] /* o: harmonic model Q13 */ +); + + +void tcx_hm_modify_envelope_fx( + const Word16 gain, /* i: HM gain Q11 */ + const Word32 lag, /* i: pitch lag Q0 */ + const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + const Word16 p[], /* i: harmonic model Q13 */ + Word32 env[], /* i/o: envelope Q16 */ + const Word16 L_frame /* i: number of spectral lines Q0 */ +); + +void tcx_hm_decode( + const Word16 L_frame, /* i : number of spectral lines */ + Word32 env[], /* i/o: envelope shape (Q16) */ + const Word16 targetBits, /* i : target bit budget */ + const Word16 coder_type, /* i : GC/VC coder type */ + const Word16 prm_hm[], /* i : HM parameters */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ + Word16 *hm_bits /* o : bit consumption */ +); + +void writeTCXMode_fx( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + Word16 *nbits_start /* o : nbits start Q0*/ +); + +void writeTCXWindowing_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 overlap_mode /* i : overlap mode Q0*/ +); + +void writeLPCparam( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const int16_t param_lpc[], /* i : LPC parameters to write */ + const int16_t bits_param_lpc[], /* i : bits per LPC parameter */ + const int16_t no_param_lpc, /* i : number of LPC parameters */ + int16_t *nbits_lpc /* o : LPC bits written */ +); + +void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue ); +void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value ); +void const *GetNumOfTnsFilters_flt( void const *p, const int16_t index, int16_t *pValue ); +void *SetNumOfTnsFilters_flt( void *p, const int16_t index, const int16_t value ); + +int16_t DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); +int16_t DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); + +int16_t DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); + +int16_t DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); +int16_t DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); + +int16_t EncodeTnsFilterOrderSWBTCX10_flt( const int16_t value, const int16_t index ); + +int16_t GetTnsFilterOrderBitsSWBTCX10_flt( const int16_t value, const int16_t index ); +int16_t DecodeTnsFilterOrder_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); + +void ResetTnsData_flt( + STnsData *pTnsData ); + +void ClearTnsFilterCoefficients_flt( + STnsFilter *pTnsFilter ); + +void EncodeTnsData( + STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ + STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ + Word16 *stream, /* o : internal data stream */ + Word16 *pnSize, /* o : number of written parameters */ + Word16 *pnBits /* o : number of written bits */ +); + +Word16 DecodeTnsData_ivas( + STnsConfig const *pTnsConfig, + const Word16 *stream, + Word16 *pnSize, + STnsData *pTnsData ); + +void WriteTnsData( + const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ + const Word16 *stream, /* i : internal data stream */ + Word16 *pnSize, /* o : number of written parameters */ + BSTR_ENC_HANDLE hBstr, /* o : bitstream */ + Word16 *pnBits /* o : number of written bits */ +); + +void ReadTnsData_ivas( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + +void analysisCldfbEncoder_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word32 *timeIn, /*q11*/ + Word16 timeInq, /*q0*/ + Word16 samplesToProcess, /*q0*/ + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 *ppBuf_Ener, + Word16 *enerBuffSum_exp, + CLDFB_SCALE_FACTOR *scale ); + +ivas_error openCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const int32_t sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ +); + +ivas_error openCldfb_ivas_enc( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const Word32 sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ +); + +void resampleCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ + const Word32 newSamplerate /* i : new samplerate to operate */ +); + +ivas_error cldfb_save_memory_ivas( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ +); + +void deleteCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ +); + +/*! r: flag indicating a valid bitrate */ +Word16 is_EVS_bitrate( + const Word32 ivas_total_brate, /* i : EVS total bitrate */ + Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ +); + +void IGFEncResetTCX10BitCounter_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc /* i : instance handle of IGF Encoder */ +); + +ivas_error IGF_Reconfig( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void ordr_esti( + const Word16 k, /* i : sub-vector index */ + Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ + Word16 svOrder[], /* i/o: AVQ sub-vector order */ + const Word16 Nsv /* i : total sub-vectors in a sub-frames */ +); + +/*===========================================================================================*/ +#endif diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c index ed914f2a1..479bc04d9 100644 --- a/lib_com/pvq_com_fx.c +++ b/lib_com/pvq_com_fx.c @@ -4,7 +4,6 @@ #include #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c index 665dbfae6..32d18d1fe 100644 --- a/lib_com/residu_fx.c +++ b/lib_com/residu_fx.c @@ -7,7 +7,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" -#include "prot.h" /*--------------------------------------------------------------------* * residu_ivas_fx() diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index bad47f065..172dadf82 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -38,10 +38,9 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "basop_util.h" #include "wmc_auto.h" -#include "prot_fx.h" /* clang-format off */ diff --git a/lib_com/rom_com_fx.c b/lib_com/rom_com_fx.c index 611658884..49f50e162 100644 --- a/lib_com/rom_com_fx.c +++ b/lib_com/rom_com_fx.c @@ -38,7 +38,7 @@ EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 ====================================================================================*/ -#include "prot.h" +#include "prot_fx.h" #include "basop_util.h" #include "wmc_auto.h" #include "rom_com_fx.h" diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index 2aa781a43..1f112c911 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -38,7 +38,6 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 6cdf1185a..7e9471c45 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -7,7 +7,6 @@ #include "options.h" #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" #include "prot_fx.h" #include "basop_util.h" #include "ivas_prot_fx.h" diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window.c index cececd8f5..44ce806f7 100644 --- a/lib_com/tcx_mdct_window.c +++ b/lib_com/tcx_mdct_window.c @@ -39,7 +39,6 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index 4e40e4ab2..c5ff95e04 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -9,7 +9,6 @@ #include "rom_com.h" #include "rom_basop_util.h" #include "basop_util.h" -#include "prot.h" #define inv_int InvIntTable diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index 515746bd5..101bc1df8 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -12,7 +12,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "basop_util.h" -#include "prot.h" /*---------------------------------------------------------------------------- * Local constants diff --git a/lib_com/tools.c b/lib_com/tools.c index 4d9f5e956..e4ccd9955 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -37,7 +37,6 @@ #include #include "options.h" #include -#include "prot.h" #include "prot_fx.h" #include "wmc_auto.h" @@ -136,23 +135,6 @@ int16_t sum_s( return tmp; } -/*! r: sum of all vector elements */ -int32_t sum_l( - const int32_t *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -) -{ - int16_t i; - int32_t tmpL; - - tmpL = 0; - for ( i = 0; i < lvec; i++ ) - { - tmpL += vec[i]; - } - - return tmpL; -} /*! r: sum of all vector elements */ Word32 sum_l_fx( const Word32 *vec, /* i : input vector */ @@ -171,23 +153,6 @@ Word32 sum_l_fx( return tmpL; } -/*! r: sum of all vector elements */ -float sum_f( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -) -{ - int16_t i; - float tmp; - - tmp = 0.0f; - for ( i = 0; i < lvec; i++ ) - { - tmp += vec[i]; - } - - return tmp; -} /*---------------------------------------------------------------------- * sum2_f() @@ -228,22 +193,6 @@ Word32 sum2_f_16_gb_fx( return tmp; } -float sum2_f( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -) -{ - int16_t i; - float tmp; - - tmp = 0.0f; - for ( i = 0; i < lvec; i++ ) - { - tmp += vec[i] * vec[i]; - } - - return tmp; -} Word32 sum2_16_exp_fx( const Word16 *vec, /* i : input vector Q(15 - exp) */ @@ -532,101 +481,6 @@ void mvs2s( return; } -uint32_t mvr2s( - const float x[], /* i : input vector */ - int16_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -) -{ - int16_t i; - float temp; - uint32_t noClipping = 0; - - if ( n <= 0 ) - { - /* cannot transfer vectors with size 0 */ - return 0; - } - - if ( (void *) y <= (const void *) x ) - { - for ( i = 0; i < n; i++ ) - { - temp = x[i]; - temp = (float) floor( temp + 0.5f ); - - if ( temp > MAX16B_FLT ) - { - temp = MAX16B_FLT; - noClipping++; - } - else if ( temp < MIN16B_FLT ) - { - temp = MIN16B_FLT; - noClipping++; - } - - y[i] = (int16_t) temp; - } - } - else - { - for ( i = n - 1; i >= 0; i-- ) - { - temp = x[i]; - temp = (float) floor( temp + 0.5f ); - - if ( temp > MAX16B_FLT ) - { - temp = MAX16B_FLT; - noClipping++; - } - else if ( temp < MIN16B_FLT ) - { - temp = MIN16B_FLT; - noClipping++; - } - - y[i] = (int16_t) temp; - } - } - - return noClipping; -} - -void mvs2r( - const int16_t x[], /* i : input vector */ - float y[], /* o : output vector */ - const int16_t n /* i : vector size */ -) -{ - int16_t i; - - if ( n <= 0 ) - { - /* cannot transfer vectors with size 0 */ - return; - } - - if ( (void *) y < (const void *) x ) - { - for ( i = 0; i < n; i++ ) - { - y[i] = (float) x[i]; - } - } - else - { - for ( i = n - 1; i >= 0; i-- ) - { - y[i] = (float) x[i]; - } - } - - return; -} - - void mvl2l( const int32_t x[], /* i : input vector */ int32_t y[], /* o : output vector */ @@ -659,44 +513,6 @@ void mvl2l( return; } - -/*---------------------------------------------------------------------* - * maximum() - * - * Find index and value of the maximum in a vector - *---------------------------------------------------------------------*/ - -/*! r: index of the maximum value in the input vector */ -int16_t maximum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *max_val /* o : maximum value in the input vector */ -) -{ - int16_t j, ind; - float tmp; - - ind = 0; - tmp = vec[0]; - - for ( j = 1; j < lvec; j++ ) - { - if ( vec[j] > tmp ) - { - ind = j; - tmp = vec[j]; - } - } - - if ( max_val != NULL ) - { - *max_val = tmp; - } - - return ind; -} - - /*! r: index of the maximum value in the input vector */ Word16 maximum_s( const Word16 *vec, /* i : input vector */ @@ -766,42 +582,6 @@ Word16 maximum_l( return ind; } -/*---------------------------------------------------------------------* - * maximumAbs() - * - * Find index and value of the maximum in a vector - *---------------------------------------------------------------------*/ - -/*! r: index of the maximum value in the input vector */ -int16_t maximumAbs( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *max_val /* o : maximum value in the input vector */ -) -{ - int16_t j, ind; - float tmp; - - ind = 0; - tmp = (float) fabs( vec[0] ); - - for ( j = 1; j < lvec; j++ ) - { - if ( (float) fabs( vec[j] ) > tmp ) - { - ind = j; - tmp = (float) fabs( vec[j] ); - } - } - - if ( max_val != NULL ) - { - *max_val = tmp; - } - - return ind; -} - /*! r: index of the maximum value in the input vector */ Word16 maximumAbs_l( const Word32 *vec, /* i : input vector */ @@ -835,42 +615,6 @@ Word16 maximumAbs_l( return ind; } -/*---------------------------------------------------------------------* - * minimum() - * - * Find index of a minimum in a vector - *---------------------------------------------------------------------*/ - -/*! r: index of the minimum value in the input vector */ -int16_t minimum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *min_val /* o : minimum value in the input vector */ -) -{ - int16_t j, ind; - float tmp; - - ind = 0; - tmp = vec[0]; - - for ( j = 1; j < lvec; j++ ) - { - if ( vec[j] < tmp ) - { - ind = j; - tmp = vec[j]; - } - } - - if ( min_val != NULL ) - { - *min_val = tmp; - } - - return ind; -} - /*-------------------------------------------------------------------* * minimum_s() * @@ -988,59 +732,6 @@ Word16 minimum_l( return ind; } -/*---------------------------------------------------------------------* - * emaximum() - * - * Find index of a maximum energy in a vector - *---------------------------------------------------------------------*/ - -/*! r: return index with max energy value in vector */ -int16_t emaximum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *ener_max /* o : maximum energy value */ -) -{ - int16_t j, ind; - float temp; - - *ener_max = 0.0f; - ind = 0; - - for ( j = 0; j < lvec; j++ ) - { - temp = vec[j] * vec[j]; - - if ( temp > *ener_max ) - { - ind = j; - *ener_max = temp; - } - } - - return ind; -} - - -/*---------------------------------------------------------------------* - * mean() - * - * Find the mean of the vector - *---------------------------------------------------------------------*/ - -/*! r: mean of vector */ -float mean( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -) -{ - float tmp; - - tmp = sum_f( vec, lvec ) / (float) lvec; - - return tmp; -} - /*---------------------------------------------------------------------* * dotp() * @@ -1168,114 +859,6 @@ float inv_sqrt( return (float) ( 1.0 / sqrt( x ) ); } - -/*-------------------------------------------------------------------* - * conv() - * - * Convolution between vectors x[] and h[] written to y[] - * All vectors are of length L. Only the first L samples of the - * convolution are considered. - *-------------------------------------------------------------------*/ - -void conv( - const float x[], /* i : input vector */ - const float h[], /* i : impulse response (or second input vector) */ - float y[], /* o : output vetor (result of convolution) */ - const int16_t L /* i : vector size */ -) -{ - float temp; - int16_t i, n; - for ( n = 0; n < L; n++ ) - { - temp = x[0] * h[n]; - for ( i = 1; i <= n; i++ ) - { - temp += x[i] * h[n - i]; - } - y[n] = temp; - } - - return; -} - -/*-------------------------------------------------------------------* - * fir() - * - * FIR filtering of vector x[] with filter having impulse response h[] - * written to y[] - * The input vector has length L and the FIR filter has an order of K, i.e. - * K+1 coefficients. The memory of the input signal is provided in the vector mem[] - * which has K values - * The maximum length of the input signal is L_FRAME32k and the maximum order - * of the FIR filter is L_FILT_MAX - *-------------------------------------------------------------------*/ - -void fir( - const float x[], /* i : input vector */ - const float h[], /* i : impulse response of the FIR filter */ - float y[], /* o : output vector (result of filtering) */ - float mem[], /* i/o: memory of the input signal (L samples) */ - const int16_t L, /* i : input vector size */ - const int16_t K, /* i : order of the FIR filter (K+1 coefs.) */ - const int16_t upd /* i : 1 = update the memory, 0 = not */ -) -{ - float buf_in[L_FRAME48k + 60], buf_out[L_FRAME48k], s; - int16_t i, j; - - /* prepare the input buffer (copy and update memory) */ - mvr2r( mem, buf_in, K ); - mvr2r( x, buf_in + K, L ); - - if ( upd ) - { - mvr2r( buf_in + L, mem, K ); - } - - /* do the filtering */ - for ( i = 0; i < L; i++ ) - { - s = buf_in[K + i] * h[0]; - - for ( j = 1; j <= K; j++ ) - { - s += h[j] * buf_in[K + i - j]; - } - - buf_out[i] = s; - } - - /* copy to the output buffer */ - mvr2r( buf_out, y, L ); - - return; -} - -/*-------------------------------------------------------------------* - * v_add() - * - * Addition of two vectors sample by sample - *-------------------------------------------------------------------*/ - -void v_add( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 + vector 2 */ - const int16_t N /* i : Vector length */ -) -{ - int16_t i; - - for ( i = 0; i < N; i++ ) - { - y[i] = x1[i] + x2[i]; - } - - return; -} - - /*-------------------------------------------------------------------* * v_add_w64() * @@ -1351,55 +934,9 @@ void v_sub_fixed( } /*-------------------------------------------------------------------* - * v_mult() + * v_multc_fixed() * - * Multiplication of two vectors - *-------------------------------------------------------------------*/ - -void v_mult( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const int16_t N /* i : Vector length */ -) -{ - int16_t i; - - for ( i = 0; i < N; i++ ) - { - y[i] = x1[i] * x2[i]; - } - - return; -} - -/*-------------------------------------------------------------------* - * v_multc() - * - * Multiplication of vector by constant - *-------------------------------------------------------------------*/ - -void v_multc( - const float x[], /* i : Input vector */ - const float c, /* i : Constant */ - float y[], /* o : Output vector that contains c*x */ - const int16_t N /* i : Vector length */ -) -{ - int16_t i; - - for ( i = 0; i < N; i++ ) - { - y[i] = c * x[i]; - } - - return; -} - -/*-------------------------------------------------------------------* - * v_multc_fixed() - * - * Multiplication of vector by constant + * Multiplication of vector by constant *-------------------------------------------------------------------*/ void v_multc_fixed( @@ -1456,102 +993,6 @@ void v_multc_fixed_16_16( return; } -/*-------------------------------------------------------------------* - * squant() - * - * Scalar quantizer according to MMSE criterion (nearest neighbour in Euclidean space) - * - * Searches a given codebook to find the nearest neighbour in Euclidean space. - * Index of the winning codeword and the winning codeword itself are returned. - *-------------------------------------------------------------------*/ - -/*! r: index of the winning codeword */ -int16_t squant( - const float x, /* i : scalar value to quantize */ - float *xq, /* o : quantized value */ - const float cb[], /* i : codebook */ - const int16_t cbsize /* i : codebook size */ -) -{ - float dist, mindist, tmp; - int16_t c, idx; - - idx = 0; - mindist = 1e16f; - - for ( c = 0; c < cbsize; c++ ) - { - dist = 0.0f; - tmp = x - cb[c]; - dist += tmp * tmp; - if ( dist < mindist ) - { - mindist = dist; - idx = c; - } - } - - *xq = cb[idx]; - - return idx; -} - -/*! r: index of the winning codeword */ -int16_t squant_int( - uint8_t x, /* i : scalar value to quantize */ - uint8_t *xq, /* o : quantized value */ - const uint8_t *cb, /* i : codebook */ - const int16_t cbsize /* i : codebook size */ -) -{ - int16_t i, idx; - float mindist, d; - - idx = 0; - mindist = 10000000.0f; - for ( i = 0; i < cbsize; i++ ) - { - d = (float) ( x - cb[i] ) * ( x - cb[i] ); - if ( d < mindist ) - { - mindist = d; - idx = i; - } - } - *xq = cb[idx]; - - return idx; -} - - -/*-------------------------------------------------------------------* - * usquant() - * - * Uniform scalar quantizer according to MMSE criterion - * (nearest neighbour in Euclidean space) - * - * Applies quantization based on scale and round operations. - * Index of the winning codeword and the winning codeword itself are returned. - *-------------------------------------------------------------------*/ - -/*! r: index of the winning codeword */ -int16_t usquant( - const float x, /* i : scalar value to quantize */ - float *xq, /* o : quantized value */ - const float qlow, /* i : lowest codebook entry (index 0) */ - const float delta, /* i : quantization step */ - const int16_t cbsize /* i : codebook size */ -) -{ - int16_t idx; - - idx = (int16_t) max( 0.f, min( cbsize - 1, ( ( x - qlow ) / delta + 0.5f ) ) ); - *xq = idx * delta + qlow; - - return idx; -} - - /*-------------------------------------------------------------------* * usdequant() * @@ -1573,219 +1014,6 @@ float usdequant( return ( g ); } - -/*-------------------------------------------------------------------* - * vquant() - * - * Vector quantizer according to MMSE criterion (nearest neighbour in Euclidean space) - * - * Searches a given codebook to find the nearest neighbour in Euclidean space. - * Index of the winning codevector and the winning vector itself are returned. - *-------------------------------------------------------------------*/ - -/*! r: index of the winning codevector */ -int16_t vquant( - float x[], /* i : vector to quantize */ - const float x_mean[], /* i : vector mean to subtract (0 if none) */ - float xq[], /* o : quantized vector */ - const float cb[], /* i : codebook */ - const int16_t dim, /* i : dimension of codebook vectors */ - const int16_t cbsize /* i : codebook size */ -) -{ - float dist, mindist, tmp; - int16_t c, d, idx, j; - - idx = 0; - mindist = 1e16f; - - if ( x_mean != 0 ) - { - for ( d = 0; d < dim; d++ ) - { - x[d] -= x_mean[d]; - } - } - - j = 0; - for ( c = 0; c < cbsize; c++ ) - { - dist = 0.0f; - for ( d = 0; d < dim; d++ ) - { - tmp = x[d] - cb[j++]; - dist += tmp * tmp; - } - - if ( dist < mindist ) - { - mindist = dist; - idx = c; - } - } - - if ( xq == 0 ) - { - return idx; - } - - j = idx * dim; - for ( d = 0; d < dim; d++ ) - { - xq[d] = cb[j++]; - } - - if ( x_mean != 0 ) - { - for ( d = 0; d < dim; d++ ) - { - xq[d] += x_mean[d]; - } - } - - return idx; -} - -/*-------------------------------------------------------------------* - * w_vquant() - * - * Vector quantizer according to MMSE criterion (nearest neighbour in Euclidean space) - * - * Searches a given codebook to find the nearest neighbour in Euclidean space. - * Weights are put on the error for each vector element. - * Index of the winning codevector and the winning vector itself are returned. - *-------------------------------------------------------------------*/ - -/*! r: index of the winning codevector */ -int16_t w_vquant( - float x[], /* i : vector to quantize */ - const float x_mean[], /* i : vector mean to subtract (0 if none) */ - const int16_t weights[], /* i : error weights */ - float xq[], /* o : quantized vector */ - const float cb[], /* i : codebook */ - const int16_t dim, /* i : dimension of codebook vectors */ - const int16_t cbsize, /* i : codebook size */ - const int16_t rev_vect /* i : reverse codebook vectors */ -) -{ - float dist, mindist, tmp; - int16_t c, d, idx, j, k; - - idx = 0; - mindist = 1e16f; - - if ( x_mean != 0 ) - { - for ( d = 0; d < dim; d++ ) - { - x[d] -= x_mean[d]; - } - } - - j = 0; - if ( rev_vect ) - { - k = dim - 1; - for ( c = 0; c < cbsize; c++ ) - { - dist = 0.0f; - - for ( d = k; d >= 0; d-- ) - { - tmp = x[d] - cb[j++]; - dist += weights[d] * ( tmp * tmp ); - } - - if ( dist < mindist ) - { - mindist = dist; - idx = c; - } - } - - if ( xq == 0 ) - { - return idx; - } - - j = idx * dim; - for ( d = k; d >= 0; d-- ) - { - xq[d] = cb[j++]; - } - } - else - { - for ( c = 0; c < cbsize; c++ ) - { - dist = 0.0f; - - for ( d = 0; d < dim; d++ ) - { - tmp = x[d] - cb[j++]; - dist += weights[d] * ( tmp * tmp ); - } - - if ( dist < mindist ) - { - mindist = dist; - idx = c; - } - } - - if ( xq == 0 ) - { - return idx; - } - - j = idx * dim; - for ( d = 0; d < dim; d++ ) - { - xq[d] = cb[j++]; - } - } - - if ( x_mean != 0 ) - { - for ( d = 0; d < dim; d++ ) - { - xq[d] += x_mean[d]; - } - } - - return idx; -} - - -/*----------------------------------------------------------------------------------* - * v_sort() - * - * Sorting of vectors. This is very fast with almost ordered vectors. - *----------------------------------------------------------------------------------*/ - -void v_sort_float( - float *r, /* i/o: Vector to be sorted in place */ - const int16_t lo, /* i : Low limit of sorting range */ - const int16_t up /* I : High limit of sorting range */ -) -{ - int16_t i, j; - float tempr; - - for ( i = up - 1; i >= lo; i-- ) - { - tempr = r[i]; - for ( j = i + 1; j <= up && ( tempr > r[j] ); j++ ) - { - r[j - 1] = r[j]; - } - - r[j - 1] = tempr; - } - - return; -} - void sort( UWord16 *x, /* i/o: Vector to be sorted */ UWord16 len /* i/o: vector length */ @@ -1810,426 +1038,3 @@ void sort( return; } - -/*---------------------------------------------------------------------* - * var() - * - * Calculate the variance of a vector - *---------------------------------------------------------------------*/ - -/*! r: variance of vector */ -float var( - const float *x, /* i : input vector */ - const int16_t len /* i : length of inputvector */ -) -{ - float m; - float v; - int16_t i; - - m = mean( x, len ); - - v = 0.0f; - for ( i = 0; i < len; i++ ) - { - v += ( x[i] - m ) * ( x[i] - m ); - } - v /= len; - - return v; -} - - -/*---------------------------------------------------------------------* - * std_dev() - * - * Calculate the standard deviation of a vector - *---------------------------------------------------------------------*/ - -/*! r: standard deviation */ -float std_dev( - const float *x, /* i : input vector */ - const int16_t len /* i : length of the input vector */ -) -{ - int16_t i; - float std; - - std = 1e-16f; - for ( i = 0; i < len; i++ ) - { - std += x[i] * x[i]; - } - - std = (float) sqrt( std / len ); - - return std; -} - - -/*---------------------------------------------------------------------* - * dot_product_mat() - * - * Calculates dot product of type x'*A*x, where x is column vector of size m, - * and A is square matrix of size m*m - *---------------------------------------------------------------------*/ - -/*! r: the dot product x'*A*x */ -float dot_product_mat( - const float *x, /* i : vector x */ - const float *A, /* i : matrix A */ - const int16_t m /* i : vector & matrix size */ -) -{ - int16_t i, j; - float suma, tmp_sum; - const float *pt_x, *pt_A; - - pt_A = A; - suma = 0; - - for ( i = 0; i < m; i++ ) - { - tmp_sum = 0; - pt_x = x; - for ( j = 0; j < m; j++ ) - { - tmp_sum += *pt_x++ * *pt_A++; - } - - suma += x[i] * tmp_sum; - } - - return suma; -} - - -/*--------------------------------------------------------------------------------* - * polezero_filter() - * - * Y(Z)=X(Z)(b[0]+b[1]z^(-1)+..+b[L]z^(-L))/(a[0]+a[1]z^(-1)+..+a[M]z^(-M)) - * mem[n]=x[n]+cp[0]mem[n-1]+..+cp[M-1]mem[n-M], where cp[i]=-a[i+1]/a[0] - * y[n]=cz[0]mem[n]+cz[1]mem[n-1]+..+cz[L]mem[n-L], where cz[i]=b[i]/a[0] - * mem={mem[n-K] mem[n-K+1] . . . . mem[n-2] mem[n-1]}, where K=max(L,M) - * - * a[0] must be equal to 1.0f! - *---------------------------------------------------------------------------------*/ - -void polezero_filter( - const float *in, /* i : input vector */ - float *out, /* o : output vector */ - const int16_t N, /* i : input vector size */ - const float *b, /* i : numerator coefficients */ - const float *a, /* i : denominator coefficients */ - const int16_t order, /* i : filter order */ - float *mem /* i/o: filter memory */ -) -{ - int16_t i, j, k; - - - for ( i = 0; i < order; i++ ) - { - out[i] = in[i] * b[0]; - for ( j = 0; j < i; j++ ) - { - out[i] += in[i - 1 - j] * b[j + 1] - out[i - 1 - j] * a[j + 1]; - } - - for ( k = order - 1; j < order; j++, k-- ) - { - out[i] += mem[k] * b[j + 1] - mem[k + order] * a[j + 1]; - } - } - - for ( ; i < N; i++ ) - { - out[i] = in[i] * b[0]; - for ( j = 0; j < order; j++ ) - { - out[i] += in[i - 1 - j] * b[j + 1] - out[i - 1 - j] * a[j + 1]; - } - } - - for ( i = 0; i < order; i++ ) - { - mem[i] = in[N - order + i]; - mem[i + order] = out[N - order + i]; - } - - return; -} - -#define WMC_TOOL_SKIP -static float fleft_shift( float input, const int16_t shift ) -{ - return ( input * (float) pow( 2.0, (double) shift ) ); -} - -static float fright_shift( float input, const int16_t shift ) -{ - return ( input * (float) pow( 0.5, (double) shift ) ); -} -#undef WMC_TOOL_SKIP - - -/*--------------------------------------------------------------------------------* - * root_a() - * - * Implements a quadratic approximation to sqrt(a) - * Firstly, a is normalized to lie between 0.25 & 1.0 - * by shifting the input left or right by an even number of - * shifts. Even shifts represent powers of 4 which, after - * the sqrt, can easily be converted to powers of 2 and are - * easily dealt with. - * At the heart of the algorithm is a quadratic - * approximation of the curve sqrt(a) for 0.25 <= a <= 1.0. - * Sqrt(a) approx = 0.27 + 1.0127 * a - 0.2864 * a^2 - * - *---------------------------------------------------------------------------------*/ - -float root_a( - float a ) -{ - int16_t shift_a; - float mod_a; - float approx; - - if ( a <= 0.0f ) - { - return 0.0; - } - -#define WMC_TOOL_SKIP - /* This next piece of code implements a "norm" function */ - /* and returns the shift needed to scale "a" to have a */ - /* 1 in the (MSB-1) position. This is equivalent to */ - /* giving a value between 0.5 & 1.0. */ - mod_a = a; - - shift_a = 0; - while ( mod_a > 1.0 ) - { - mod_a /= 2.0; - shift_a--; - } - - while ( mod_a < 0.5 ) - { - mod_a *= 2.0; - shift_a++; - } -#undef WMC_TOOL_SKIP - - shift_a &= 0xfffe; - mod_a = fleft_shift( a, shift_a ); - - approx = 0.27f + 1.0127f * mod_a - 0.2864f * mod_a * mod_a; - - approx = fright_shift( approx, ( shift_a >> 1 ) ); - - return ( approx ); -} - -/*--------------------------------------------------------------------------------* - * root_a_over_b() - * - * Implements an approximation to sqrt(a/b) - * Firstly a & b are normalized to lie between 0.25 & 1.0 - * by shifting the inputs left or right by an even number - * of shifts. - * Even shifts represent powers of 4 which, after the sqrt, - * become powers of 2 and are easily dealt with. - * At the heart of the algorithm is an approximation of the - * curve sqrt(a/b) for 0.25 <= a <= 1.0 & 0.25 <= b <= 1.0. - * Given the value of b, the 2nd order coefficients p0, p1 - * & p2 can be determined so that... - * Sqrt(a/b) approx = p0 + p1 * a + p2 * a^2 - * where p0 approx = 0.7176 - 0.8815 * b + 0.4429 * b^2 - * p1 approx = 2.6908 - 3.3056 * b + 1.6608 * b^2 - * p2 approx = -0.7609 + 0.9346 * b - 0.4695 * b^2 - * - *---------------------------------------------------------------------------------*/ - -float root_a_over_b( - float a, - float b ) -{ - int16_t shift_a, shift_b, shift; - float mod_a, mod_b; - float p2 = -0.7609f; - float p1 = 2.6908f; - float p0 = 0.7176f; - float b_sqr; - float approx; - - if ( ( a <= 0.0f ) || ( b <= 0.0f ) ) - { - return 0.0; - } -#define WMC_TOOL_SKIP - if ( isinf( a ) ) -#undef WMC_TOOL_SKIP - { - return FLT_MAX; - } -#define WMC_TOOL_SKIP - if ( isinf( b ) ) -#undef WMC_TOOL_SKIP - { - return 0.f; - } - - a += 0x00000001; - b += 0x00000001; - -#define WMC_TOOL_SKIP - /* This next piece of code implements a "norm" function */ - /* and returns the shift needed to scale "a" to have a */ - /* 1 in the (MSB-1) position. This is equivalent to */ - /* giving a value between 0.5 & 1.0. */ - mod_a = a; - - shift_a = 0; - while ( mod_a > 1.0 ) - { - mod_a /= 2.0; - shift_a--; - } - - while ( mod_a < 0.5 ) - { - mod_a *= 2.0; - shift_a++; - } -#undef WMC_TOOL_SKIP - - shift_a &= 0xfffe; - mod_a = fleft_shift( a, shift_a ); - -#define WMC_TOOL_SKIP - /* This next piece of code implements a "norm" function */ - /* and returns the shift needed to scale "b" to have a */ - /* 1 in the (MSB-1) position. This is equivalent to */ - /* giving a value between 0.5 & 1.0. */ - mod_b = b; - - shift_b = 0; - while ( mod_b > 1.0 ) - { - mod_b /= 2.0; - shift_b--; - } - - while ( mod_b < 0.5 ) - { - mod_b *= 2.0; - shift_b++; - } -#undef WMC_TOOL_SKIP - - shift_b &= 0xfffe; - mod_b = fleft_shift( b, shift_b ); - - shift = ( shift_b - shift_a ) >> 1; - - b_sqr = mod_b * mod_b; - - p2 += 0.9346f * mod_b + -0.4695f * b_sqr; - p1 += -3.3056f * mod_b + 1.6608f * b_sqr; - p0 += -0.8815f * mod_b + 0.4429f * b_sqr; - - approx = p0 + p1 * mod_a + p2 * mod_a * mod_a; - - approx = fleft_shift( approx, shift ); - - return ( approx ); -} - -/*--------------------------------------------------------------------------------* - * rint_new() - * - * Round to the nearest integer with mid-point exception - *---------------------------------------------------------------------------------*/ - -double rint_new( - double x ) -{ - int16_t a; - - /* middle value point test */ - if ( ceil( x + 0.5 ) == floor( x + 0.5 ) ) - { - a = (int16_t) ceil( x ); - - if ( a % 2 == 0 ) - { - return ceil( x ); - } - else - { - return floor( x ); - } - } - else - { - return floor( x + 0.5 ); - } -} - - -/*-------------------------------------------------------------------* - * anint() - * - * Round to the nearest integer. - *-------------------------------------------------------------------*/ - -double anint( - double x ) -{ - return ( x ) >= 0 ? (int32_t) ( ( x ) + 0.5 ) : (int32_t) ( (x) -0.5 ); -} - -/*-------------------------------------------------------------------* - * is_numeric_float() - * - * Returns 0 for all NaN and Inf values defined according to IEEE 754 - * floating point number's definition. Returns 1 for numeric values. - *-------------------------------------------------------------------*/ - -int16_t is_numeric_float( - float x ) -{ - union float_int - { - float float_val; - int32_t int_val; - } float_int; - - float_int.float_val = x; - - return ( ( float_int.int_val & 0x7f800000 ) != 0x7f800000 ); -} - -/*-------------------------------------------------------------------* - * delay_signal_float() - * - * Delay buffer by defined number of samples - *-------------------------------------------------------------------*/ - -void delay_signal_float( - float x[], /* i/o: signal to be delayed */ - const int16_t len, /* i : length of the input signal */ - float mem[], /* i/o: synchronization memory */ - const int16_t delay /* i : delay in samples */ -) -{ - float tmp_buffer[L_FRAME48k]; - - mvr2r( mem, tmp_buffer, delay ); - mvr2r( x + len - delay, mem, delay ); - mvr2r( x, x + delay, len - delay ); - mvr2r( tmp_buffer, x, delay ); - - return; -} diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index efa9d7e5a..1aa0bb84a 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -50,7 +50,6 @@ #include "basop32.h" #include "wmc_auto.h" #include "prot_fx_enc.h" -#include "prot.h" #include "ivas_prot_fx.h" #define INV_BANDS10 3277 /* 1/10 in Q15 */ diff --git a/lib_com/wtda.c b/lib_com/wtda.c index a7ea5314c..3fb408138 100644 --- a/lib_com/wtda.c +++ b/lib_com/wtda.c @@ -37,11 +37,10 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include #include "wmc_auto.h" -#include "prot_fx.h" void wtda_fx32( diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 9597a97ae..11379a62d 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -39,7 +39,6 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot.h" diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index f1772b9a7..fc8aba043 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -7,7 +7,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ diff --git a/lib_dec/ari_hm_dec.c b/lib_dec/ari_hm_dec.c index da7722325..ef4fb62d5 100644 --- a/lib_dec/ari_hm_dec.c +++ b/lib_dec/ari_hm_dec.c @@ -40,10 +40,9 @@ #include "cnst.h" #include "stl.h" #include "basop_util.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" Word16 DecodeIndex_fx( diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index e5a1220e0..60a59c4da 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -10,7 +10,6 @@ #include "prot_fx.h" #include "basop_util.h" #include "basop_proto_func.h" -#include "prot.h" /* Returns: number of bits consumed */ static Word16 tcx_arith_decode_fx( diff --git a/lib_dec/avq_dec_fx.c b/lib_dec/avq_dec_fx.c index 3bf7e3eb6..a8ba2bfc3 100644 --- a/lib_dec/avq_dec_fx.c +++ b/lib_dec/avq_dec_fx.c @@ -7,7 +7,6 @@ #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ /*-------------------------------------------------------------------* diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index e3401739e..ab349773e 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -6,7 +6,6 @@ #include "options.h" /* Compilation switches */ #include "cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_cnst.h" diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 8fefa3bb2..dd268fe08 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -7,7 +7,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "basop_util.h" #include "rom_com.h" diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c index c7d2c5265..2fd3f1d2e 100644 --- a/lib_dec/core_dec_switch_fx.c +++ b/lib_dec/core_dec_switch_fx.c @@ -8,7 +8,6 @@ #include "basop_util.h" #include "prot_fx.h" #include "rom_com.h" -#include "prot.h" void mode_switch_decoder_LPD_fx( Decoder_State *st, /* i/o: decoder state structure */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index e71157a1e..20f7a0adf 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -9,7 +9,6 @@ #include "basop_util.h" #include "stl.h" #include "options.h" -#include "prot.h" #include "math.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 385339664..6c63377fd 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -6,7 +6,6 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_cnst.h" /*=========================================================================*/ diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index c61bf95ce..ee7a7eca6 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -7,7 +7,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ #include "basop32.h" -#include "prot.h" /*---------------------------------------------------------------------* * Local constants diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 626f25ef4..86cf9784a 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -6,7 +6,6 @@ #include "cnst.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------------- * hq_core_dec() diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 4f74c31ca..907a4a350 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -8,10 +8,9 @@ #include #include "options.h" #include "stl.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "cnst.h" #include "stat_dec.h" #include "basop_util.h" diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 4f1db90ff..3865cd61c 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -8,7 +8,6 @@ #include "rom_com.h" /* Static table prototypes */ #include "stl.h" /* required for wmc_tool */ #include "basop_util.h" -#include "prot.h" #include "ivas_prot_fx.h" /*----------------------------------------------------------------------* diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index f5418abc6..e73d89158 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -34,7 +34,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index a6e03eee3..3fe40c1f3 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "cnst.h" @@ -43,7 +43,6 @@ #include "ivas_rom_com.h" #include "ivas_rom_binauralRenderer.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" #include "debug.h" diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 261a3c74e..5bb4736e9 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -36,12 +36,11 @@ #include #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_corecoder_dec_reconfig_fx.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c index 89ca9a5ba..697f9d715 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig_fx.c +++ b/lib_dec/ivas_corecoder_dec_reconfig_fx.c @@ -35,7 +35,6 @@ #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" -#include "prot.h" #include #include "wmc_auto.h" diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index c22c617c0..9bf53f1de 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -36,10 +36,9 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include diff --git a/lib_dec/ivas_decision_matrix_dec_fx.c b/lib_dec/ivas_decision_matrix_dec_fx.c index a8c151edb..f7fd5e8e2 100644 --- a/lib_dec/ivas_decision_matrix_dec_fx.c +++ b/lib_dec/ivas_decision_matrix_dec_fx.c @@ -35,11 +35,10 @@ #include "stat_dec.h" #include "rom_com.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-----------------------------------------------------------------* * ivas_decision_matrix_dec() diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 9849647ea..7dd7371fd 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" @@ -43,7 +43,6 @@ #include "ivas_rom_dec.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" -#include "prot_fx.h" /* Function prototypes */ #include "ivas_rom_com_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index afbde5a60..e03913f8a 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -40,7 +40,7 @@ #include "cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" @@ -48,7 +48,6 @@ #include "ivas_rom_dec.h" #include "wmc_auto.h" #include "rom_dec.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_entropy_decoder_fx.c b/lib_dec/ivas_entropy_decoder_fx.c index 0c489fb04..e637a6a93 100644 --- a/lib_dec/ivas_entropy_decoder_fx.c +++ b/lib_dec/ivas_entropy_decoder_fx.c @@ -32,13 +32,12 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 037ef4eb9..8db782c4e 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -40,9 +40,8 @@ #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 14e83fe83..664e3eeac 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -32,13 +32,12 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index 0365005be..cbf088597 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -35,10 +35,9 @@ #include "options.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* * ivas_ism_dtx_dec_fx() diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 833ed5e16..a6f5e47b6 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -37,7 +37,6 @@ #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_stat_enc.h" #include diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 424e6fb86..9040a8a71 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -36,13 +36,12 @@ #include "options.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "debug.h" #include "ivas_rom_com_fx.h" diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 738e5a598..a19ba70ec 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3b66d3107..f632d86c8 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -35,7 +35,7 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" @@ -46,7 +46,6 @@ #ifdef DEBUGGING #include "debug.h" #endif -#include "prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 616b15c6e..e68c0142d 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index f5e7816ad..a8b54d3fb 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_ls_custom_dec_fx.c b/lib_dec/ivas_ls_custom_dec_fx.c index eabee357b..45f59d82f 100644 --- a/lib_dec/ivas_ls_custom_dec_fx.c +++ b/lib_dec/ivas_ls_custom_dec_fx.c @@ -32,10 +32,9 @@ #include #include "options.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 4ca5c05b0..806785c15 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -40,7 +40,6 @@ #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" -#include "prot.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 4c1d5d190..897fd4433 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -36,7 +36,7 @@ #include "cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" @@ -45,7 +45,6 @@ #include "math.h" #include "wmc_auto.h" #include "rom_dec.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #define INV_EPSILON_MANT 214748365 diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index be53d79c8..e03b385b7 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot.h" diff --git a/lib_dec/ivas_mcmasa_dec_fx.c b/lib_dec/ivas_mcmasa_dec_fx.c index 687efb3ce..c2228b610 100644 --- a/lib_dec/ivas_mcmasa_dec_fx.c +++ b/lib_dec/ivas_mcmasa_dec_fx.c @@ -35,7 +35,7 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index 824370bb8..be457da47 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -33,7 +33,7 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" #include "cnst.h" @@ -42,7 +42,6 @@ #include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_stat_com.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index c95a5285a..081eca88d 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -38,7 +38,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c index 331bdc253..69f601724 100644 --- a/lib_dec/ivas_mct_dec_mct_fx_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c @@ -34,11 +34,10 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include #include "stat_enc.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*----------------------------------------------------------* diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 190cc6b14..7f079277a 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -33,7 +33,7 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" @@ -44,7 +44,6 @@ #include "ivas_stat_dec.h" #include "ivas_stat_com.h" #include -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 231aee8aa..bb5dead22 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 3a6480386..391a27522 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -32,14 +32,13 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "debug.h" diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 0fb4163be..bf7fba094 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -35,12 +35,11 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index a5285b5cb..07ea14ea2 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -34,12 +34,11 @@ #include #include "ivas_cnst.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 02f37672d..4811911fd 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -34,13 +34,12 @@ #include "options.h" #include #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "debug.h" diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c index 4a0c62e8d..08ac17799 100644 --- a/lib_dec/ivas_pca_dec_fx.c +++ b/lib_dec/ivas_pca_dec_fx.c @@ -32,12 +32,11 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include #include "ivas_cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "math.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index 853aa365f..397f26bbc 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index c225f126a..4bebcda5c 100644 --- a/lib_dec/ivas_qmetadata_dec_fx.c +++ b/lib_dec/ivas_qmetadata_dec_fx.c @@ -39,9 +39,8 @@ #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" -#include "prot.h" - #include "prot_fx.h" + #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_dec/ivas_qspherical_dec_fx.c b/lib_dec/ivas_qspherical_dec_fx.c index 43ac60305..d34b5402a 100644 --- a/lib_dec/ivas_qspherical_dec_fx.c +++ b/lib_dec/ivas_qspherical_dec_fx.c @@ -37,7 +37,7 @@ #include "ivas_rom_com.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_rom_com_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_range_uni_dec_fx.c b/lib_dec/ivas_range_uni_dec_fx.c index 6d6631f73..e629111ce 100644 --- a/lib_dec/ivas_range_uni_dec_fx.c +++ b/lib_dec/ivas_range_uni_dec_fx.c @@ -38,10 +38,9 @@ #include "rom_com.h" #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /* diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 417079541..efd766f76 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "rom_com.h" @@ -44,7 +44,6 @@ #include #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* * ivas_sba_set_cna_cng_flag() * diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index 434fdf5fa..a42c67389 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" @@ -40,7 +40,6 @@ #include #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index ce4992046..89581565c 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index 37489e58f..170256181 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -32,14 +32,13 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index cddbf8cdf..812027468 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -35,7 +35,7 @@ #include #include "options.h" #include "ivas_stat_dec.h" -#include "prot.h" +#include "prot_fx.h" #include "string.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" @@ -45,7 +45,6 @@ #include "ivas_stat_com.h" #include "stat_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 3ad16b981..2b6b145f9 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -33,13 +33,12 @@ #include #include "options.h" #include "math.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" #include "ivas_stat_dec.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c index c67a52b6c..8446af47d 100644 --- a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c +++ b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c @@ -32,12 +32,11 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "rom_dec.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*---------------------------------------------------------------------* diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index b3bddae59..15885a661 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -34,13 +34,12 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" /*------------------------------------------------------------------- diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index b0100063a..166ac72e5 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "rom_com.h" #include "rom_dec.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c index 0db9ab09f..0781d49a6 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" @@ -43,7 +43,6 @@ #include "rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 7c1c892aa..c806f358a 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "rom_com.h" #include "rom_dec.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index 9e6878faf..d3415a8eb 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot.h" diff --git a/lib_dec/ivas_stereo_eclvq_dec_fx.c b/lib_dec/ivas_stereo_eclvq_dec_fx.c index ed26543d3..693df8c77 100644 --- a/lib_dec/ivas_stereo_eclvq_dec_fx.c +++ b/lib_dec/ivas_stereo_eclvq_dec_fx.c @@ -37,7 +37,7 @@ #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index 08ac60ffc..b49ab5399 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -36,12 +36,11 @@ #include #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "basop32.h" #include "ivas_stat_dec.h" diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index b634d4557..22a8c4a90 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index bf343da7f..04781a9cb 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -34,13 +34,12 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "stat_com.h" #include "ivas_prot.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 20fa578f8..69083a078 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -36,10 +36,9 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index c8a59cd6a..2dd2a30c3 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" @@ -42,7 +42,6 @@ #include "wmc_auto.h" #include #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_stereo_td_dec_fx.c b/lib_dec/ivas_stereo_td_dec_fx.c index e31c9f6bc..8ab7da035 100644 --- a/lib_dec/ivas_stereo_td_dec_fx.c +++ b/lib_dec/ivas_stereo_td_dec_fx.c @@ -35,7 +35,6 @@ #include #include "cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index a22502188..bb73fe7f0 100644 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -32,13 +32,12 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 37ffc5128..c908e4dc3 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -34,14 +34,13 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "stat_dec.h" #include "wmc_auto.h" #include "basop_proto_func.h" #include "stat_com.h" #include "ivas_prot.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------* diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index a4380bd4e..63819b056 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -37,7 +37,6 @@ #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" diff --git a/lib_dec/jbm_jb4_circularbuffer.c b/lib_dec/jbm_jb4_circularbuffer.c index cdabe4700..f9d6d1ca1 100644 --- a/lib_dec/jbm_jb4_circularbuffer.c +++ b/lib_dec/jbm_jb4_circularbuffer.c @@ -38,7 +38,7 @@ #include #include "options.h" #include "string.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" /* local includes */ #include "jbm_jb4_circularbuffer.h" diff --git a/lib_dec/jbm_jb4_circularbuffer.h b/lib_dec/jbm_jb4_circularbuffer.h index de614eeea..9e3102feb 100644 --- a/lib_dec/jbm_jb4_circularbuffer.h +++ b/lib_dec/jbm_jb4_circularbuffer.h @@ -37,7 +37,7 @@ #ifndef JBM_JB4_CIRCULARBUFFER_H #define JBM_JB4_CIRCULARBUFFER_H JBM_JB4_CIRCULARBUFFER_H -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" /** handle for circular buffer (FIFO) with fixed capacity */ diff --git a/lib_dec/jbm_jb4_inputbuffer.c b/lib_dec/jbm_jb4_inputbuffer.c index 55113ee13..5497a4371 100644 --- a/lib_dec/jbm_jb4_inputbuffer.c +++ b/lib_dec/jbm_jb4_inputbuffer.c @@ -39,7 +39,7 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "string.h" #include "jbm_jb4_inputbuffer.h" #include "wmc_auto.h" diff --git a/lib_dec/jbm_jb4_jmf.c b/lib_dec/jbm_jb4_jmf.c index 940df5ecb..5ab8242c7 100644 --- a/lib_dec/jbm_jb4_jmf.c +++ b/lib_dec/jbm_jb4_jmf.c @@ -42,7 +42,7 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" /* local includes */ diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index 4878b7d64..002b4bc10 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -48,7 +48,6 @@ #include "jbm_jb4_inputbuffer.h" #include "jbm_jb4_jmf.h" #include "jbm_jb4sb.h" -#include "prot.h" #include "prot_fx.h" #define WMC_TOOL_SKIP diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index 10b91a60c..ac6a28b86 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -44,7 +44,7 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" /* local headers */ #include "jbm_pcmdsp_apa.h" @@ -54,7 +54,6 @@ #include "rom_dec.h" -#include "prot_fx.h" #define INV_100_Q15 328 #define INV_400_Q15 82 #define INV_80_Q15 410 diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 2cc4c6387..66109b555 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -37,9 +37,8 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" -#include "prot.h" -#include "ivas_prot_fx.h" #include "prot_fx.h" +#include "ivas_prot_fx.h" #include "jbm_jb4sb.h" #include "jbm_pcmdsp_apa.h" @@ -3398,7 +3397,7 @@ static ivas_error evs_dec_main_fx( move32(); hCoreCoder[0]->output_frame_fx = extract_l( Mult_32_16( hCoreCoder[0]->output_Fs, 0x0290 /*Q0*/ ) ); // Q0 move16(); - mdct_switching_dec( hCoreCoder[0] ); + mdct_switching_dec_ivas_fx( hCoreCoder[0] ); FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; ch++ ) { diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index bc8ef03cb..cc9b681fb 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -7,7 +7,6 @@ #include "options.h" #include "rom_com.h" #include "prot_fx.h" -#include "prot.h" #include "rom_dec.h" #include "stl.h" diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index 3cf5f51f3..36cadf6ff 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -14,7 +14,6 @@ #include "cnst.h" #include "prot_fx.h" #include "stat_com.h" -#include "prot.h" #include "ivas_prot_fx.h" #define CROSSFADE_THRESHOLD ( 32762 ) // close to 1.0f in Q15 such that (x == 1.0f) is true diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 203f39707..1e8bef488 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -7,7 +7,6 @@ #include "options.h" #include "basop_util.h" #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "rom_com.h" diff --git a/lib_enc/FEC_enc_fx.c b/lib_enc/FEC_enc_fx.c index 9106e23e7..87243e8d2 100644 --- a/lib_enc/FEC_enc_fx.c +++ b/lib_enc/FEC_enc_fx.c @@ -9,7 +9,6 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ diff --git a/lib_enc/SNR_calc_fx.c b/lib_enc/SNR_calc_fx.c index f44530c84..09acfd5dc 100644 --- a/lib_enc/SNR_calc_fx.c +++ b/lib_enc/SNR_calc_fx.c @@ -10,7 +10,6 @@ #include "prot_fx_enc.h" /* Function prototypes */ #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 94d7f0471..0f58bcdad 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -6,7 +6,6 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "stat_enc.h" #include "rom_com.h" diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 8268d48b1..90768aca1 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -11,7 +11,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ -#include "prot.h" /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c index a94f45528..76d48ccf4 100644 --- a/lib_enc/ari_hm_enc_fx.c +++ b/lib_enc/ari_hm_enc_fx.c @@ -10,9 +10,7 @@ #include "basop_util.h" #include "rom_com.h" #include "rom_enc.h" -#include "prot.h" -//#include "prot_fx.h" -#include "prot_fx.h" /* Function prototypes */ +#include "prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ /*-------------------------------------------------------------------* diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 202d60e51..93a0146f3 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -5,9 +5,7 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" -#include /* Compilation switches */ -#include "prot.h" /* Function prototypes */ -//#include "prot_fx.h" /* Function prototypes */ +#include /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "rom_com.h" /* Static table prototypes */ diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 1721476b4..e1b5ca562 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -2,12 +2,10 @@ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ #include -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -#include "rom_enc.h" /* Encoder static table prototypes */ -#include "rom_com.h" /* Static table prototypes */ -//#include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ +#include "rom_enc.h" /* Encoder static table prototypes */ +#include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ //#include "basop_mpy.h" diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index c9bbe5f30..a948a4656 100644 --- a/lib_enc/cod2t32_fx.c +++ b/lib_enc/cod2t32_fx.c @@ -5,7 +5,6 @@ #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Common constants */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast.c index 16651b8f2..a901690e3 100644 --- a/lib_enc/cod4t64_fast.c +++ b/lib_enc/cod4t64_fast.c @@ -34,7 +34,6 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c index 44cde6f27..99b794b42 100644 --- a/lib_enc/cod4t64_fx.c +++ b/lib_enc/cod4t64_fx.c @@ -5,10 +5,9 @@ #include "options.h" /* VMR-WB compilation switches */ #include "cnst.h" /* Common constants */ #include "rom_enc.h" /* Encoder static table prototypes */ -#include "prot.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index de9763df0..c54e8ccf4 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -16,11 +16,9 @@ #include "prot_fx_enc.h" #ifdef IVAS_FLOAT_FIXED_CONVERSIONS #include -#include "prot.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" -#include "prot.h" #endif #ifdef DEBUGGING #include "debug.h" diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index c2b1c22e1..a2995245d 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -13,7 +13,6 @@ #include "ivas_cnst.h" #include #include "rom_com.h" /* Common constants */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ diff --git a/lib_enc/core_enc_switch_fx.c b/lib_enc/core_enc_switch_fx.c index 82bb5fca9..f3b4aea6b 100644 --- a/lib_enc/core_enc_switch_fx.c +++ b/lib_enc/core_enc_switch_fx.c @@ -4,14 +4,11 @@ #include #include #include "options.h" -#include "prot.h" -//#include "prot_fx.h" -//#include "basop_mpy.h" +#include "prot_fx.h" #include "cnst.h" /* Common constants */ #include "ivas_cnst.h" #include "rom_com_fx.h" #include "rom_com.h" /* Common constants */ -#include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index a6b9e0aa4..6e4d2a043 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -10,7 +10,6 @@ #include #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot.h" /*-------------------------------------------------------------------* * Local constants diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 1053f8b00..06c49a8d3 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -4,10 +4,9 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ -#include "prot.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ /*======================================================================*/ diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index a01550978..64a11be5b 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -4,10 +4,9 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ -#include "prot.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot_fx.h" #include "prot_fx_enc.h" /*---------------------------------------------------------------------* diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 18948a93f..3ed50017c 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -6,7 +6,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index da2ea5863..ecd4e2f01 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -11,8 +11,7 @@ #include "rom_com_fx.h" #include "rom_com.h" #include "stl.h" -#include "prot.h" -#include "prot_fx.h" /* Function prototypes */ +#include "prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index bf04daff5..5b9f67503 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -7,7 +7,6 @@ // #include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 2a621f1d5..cd23c1a6f 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -5,9 +5,8 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ -#include "prot.h" /* Function prototypes */ +#include "prot_fx.h" /* Function prototypes */ #include "rom_com.h" -#include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ /*-------------------------------------------------------------------* diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index e49463a5c..75e82409e 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -6,7 +6,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 6970597c8..c86b7e061 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -5,10 +5,9 @@ #include #include #include "options.h" /* Compilation switches */ -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Common constants */ -#include "prot_fx.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ #include "prot_fx_enc.h" #ifdef DEBUGGING diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 9cb2cd8e0..307d42078 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -11,7 +11,6 @@ #include "rom_com_fx.h" #include "rom_com.h" #include "rom_enc.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/find_wsp_fx.c b/lib_enc/find_wsp_fx.c index d08922a2a..155e49904 100644 --- a/lib_enc/find_wsp_fx.c +++ b/lib_enc/find_wsp_fx.c @@ -6,8 +6,7 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" -#include "prot_fx.h" /* Function prototypes */ +#include "prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 6af068bae..0321cd763 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -7,7 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ //#include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index a7d60642b..f943b104d 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -7,7 +7,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ #include "rom_enc.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ //#include "basop_mpy.h" diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 8ed7e9d6c..375d4c2cf 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -6,8 +6,6 @@ #include "cnst.h" #include "rom_com_fx.h" #include "rom_com.h" -//#include "prot_fx.h" -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c index 53ad3dbb2..944cb2649 100644 --- a/lib_enc/hq_classifier_enc_fx.c +++ b/lib_enc/hq_classifier_enc_fx.c @@ -8,7 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ /*-----------------------------------------------------------------* diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c index 11583ea11..f22218d13 100644 --- a/lib_enc/hq_core_enc_fx.c +++ b/lib_enc/hq_core_enc_fx.c @@ -2,12 +2,10 @@ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ #include -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -#include "rom_com_fx.h" /* Static table prototypes */ -#include "rom_com.h" /* Static table prototypes */ -//#include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ +#include "rom_com_fx.h" /* Static table prototypes */ +#include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/hq_env_enc_fx.c b/lib_enc/hq_env_enc_fx.c index b0875968e..5d47710ed 100644 --- a/lib_enc/hq_env_enc_fx.c +++ b/lib_enc/hq_env_enc_fx.c @@ -10,7 +10,6 @@ #include "stl.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ /*--------------------------------------------------------------------------------------* * encode_envelope_indices_fx() diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c index 4d4742cc1..1cd516b43 100644 --- a/lib_enc/hq_hr_enc_fx.c +++ b/lib_enc/hq_hr_enc_fx.c @@ -7,7 +7,6 @@ //#include "prot_fx.h" /* Function prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 424689804..9aca0f646 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -12,7 +12,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ -#include "prot.h" /*--------------------------------------------------------------------------* * Local function prototypes diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 54bc4fb58..b06a1734d 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -8,7 +8,6 @@ //#include "prot_fx.h" #include "rom_com.h" #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #define HVQ_ENC_NOISE_DELTA ( (Word16) 3277 ) /* 0.1 in Q15 */ diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 6ac6e6811..f6adb0f31 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -38,13 +38,12 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "cnst.h" #include "stat_enc.h" #include "wmc_auto.h" #include "prot_fx_enc.h" -#include "prot_fx.h" #define INV_Log2_10_Q15 9864 /*1/log2(10) in Q15*/ @@ -2535,41 +2534,6 @@ void IGFEncResetTCX10BitCounter_ivas_fx( } -/*-------------------------------------------------------------------* - * IGFEncWriteConcatenatedBitstream() - * - * - *-------------------------------------------------------------------*/ - -/*! r: total number of bits written */ -Word16 IGFEncWriteConcatenatedBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -) -{ - IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; - Word16 i; - Word16 bitsLeft; - UWord8 *pBitstream; - - hPrivateData = &hIGFEnc->igfData; - pBitstream = hPrivateData->igfBitstream; - - for ( i = 0; i < ( hPrivateData->igfBitstreamBits >> 3 ); i++ ) - { - push_next_indice( hBstr, pBitstream[i], 8 ); - } - - bitsLeft = hPrivateData->igfBitstreamBits & 0x7; - if ( bitsLeft > 0 ) - { - push_next_indice( hBstr, shr( pBitstream[i], sub( 8, bitsLeft ) ), bitsLeft ); - } - - return hIGFEnc->infoTotalBitsWritten; -} - - /*-------------------------------------------------------------------* * IGFEncApplyMono() * diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index ca1759c89..cc4840876 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -8,8 +8,7 @@ #include "options.h" #include "cnst.h" #include "stl.h" -#include "prot.h" -#include "prot_fx.h" /* Function prototypes */ +#include "prot_fx.h" #include "prot_fx_enc.h" /* Function prototypes */ #include "stat_enc.h" #include "basop_util.h" diff --git a/lib_enc/igf_scf_enc.c b/lib_enc/igf_scf_enc.c index 192d7e597..2921b5886 100644 --- a/lib_enc/igf_scf_enc.c +++ b/lib_enc/igf_scf_enc.c @@ -36,12 +36,11 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "stat_enc.h" #include "stat_com.h" #include "cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 5de4e8e92..615ca1b33 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -10,7 +10,6 @@ #include "stl.h" #include "ivas_cnst.h" #include "ivas_error.h" -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "ivas_prot_fx.h" diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 7bb13239f..46bec5f4d 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -10,7 +10,6 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/ivas_agc_enc_fx.c b/lib_enc/ivas_agc_enc_fx.c index 649c5bae5..37d25c508 100644 --- a/lib_enc/ivas_agc_enc_fx.c +++ b/lib_enc/ivas_agc_enc_fx.c @@ -36,10 +36,9 @@ #include #include "options.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "basop_util.h" diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 303adecfd..5f318e959 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -34,12 +34,11 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot.h" #include "wmc_auto.h" #include -#include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index f963b55a4..f41eb7f9c 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot.h" @@ -50,7 +49,6 @@ #include "prot_fx_enc.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*---------------------------------------------------------------* * Local constants diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 1234a6876..a9da7f342 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -37,9 +37,8 @@ #include "ivas_prot.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" #include "basop_util.h" diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 1b4d5da4a..32e3e7107 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot.h" diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 3fd9c2d7a..811e53d12 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -36,7 +36,7 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "prot_fx_enc.h" #include "ivas_rom_com.h" @@ -45,7 +45,6 @@ #endif #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_enc.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index a3194a9d0..1158f72fa 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -35,11 +35,10 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index ec55850fd..7bfa9f268 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c index 95a114b67..576bbb2c6 100644 --- a/lib_enc/ivas_enc_cov_handler_fx.c +++ b/lib_enc/ivas_enc_cov_handler_fx.c @@ -32,11 +32,10 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*------------------------------------------------------------------------------------------* diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index 2bab65c42..0a2d976e1 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -36,14 +36,13 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" #endif #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_entropy_coder_fx.c b/lib_enc/ivas_entropy_coder_fx.c index eb82aa78a..a95f2884c 100644 --- a/lib_enc/ivas_entropy_coder_fx.c +++ b/lib_enc/ivas_entropy_coder_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 3844598c6..f1aeb5398 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -36,14 +36,13 @@ #include "ivas_cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "prot_fx_enc.h" #include #include "wmc_auto.h" #include #include "prot_fx_enc.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------------------------------* diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 9d31297bd..3eeb45d14 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -34,7 +34,7 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_stat_enc.h" @@ -42,7 +42,6 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 615660761..64b8991d6 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -34,10 +34,9 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 51af4e5a9..22bf88df8 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -33,12 +33,11 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "prot_fx_enc.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index a5a1286a2..a36ee78e2 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -38,10 +38,9 @@ #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index bef6912bd..e6b23fcfc 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -36,7 +36,6 @@ #include "options.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" #include "prot_fx.h" #include "cnst.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index fee34abd8..86237fb31 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -33,12 +33,11 @@ #include #include "options.h" #include "math.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index f4fe68c59..21c23c34a 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -38,7 +38,6 @@ #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 36324ae0f..2797fa5e4 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -37,7 +37,6 @@ #include "rom_enc.h" #include "ivas_rom_enc.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" @@ -46,7 +45,6 @@ #include "wmc_auto.h" #include "prot_fx_enc.h" -#include "prot_fx.h" /*------------------------------------------------------------------------- * Local function prototypes diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c index 392f1d9ab..9060c786b 100644 --- a/lib_enc/ivas_mc_paramupmix_enc_fx.c +++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c @@ -36,10 +36,9 @@ #include "cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "basop_util.h" #include "ivas_rom_com_fx.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index b3f99e27c..bb6ef0d01 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -38,7 +38,6 @@ #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index d11447c03..439c227ae 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -34,14 +34,12 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index dbced19fd..55da30e73 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -36,10 +36,9 @@ #include #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" #include "rom_com.h" diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 7e8547841..88d773b53 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index edfc607ed..403d379fa 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -36,13 +36,12 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "prot_fx_enc.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index f09d4513d..7c8b78ffb 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -37,7 +37,6 @@ #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 5eee0975a..648dcdb73 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -36,12 +36,11 @@ #include #include "ivas_cnst.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_enc/ivas_pca_enc_fx.c b/lib_enc/ivas_pca_enc_fx.c index 8b61cb6c8..410d5dd52 100644 --- a/lib_enc/ivas_pca_enc_fx.c +++ b/lib_enc/ivas_pca_enc_fx.c @@ -32,14 +32,13 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" #include #include #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 3f0218e97..7a2a28767 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -35,15 +35,13 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" -#include "prot.h" -#include "prot_fx.h" #include "basop_util.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_qspherical_enc_fx.c b/lib_enc/ivas_qspherical_enc_fx.c index eb60d4849..a6f40c8f0 100644 --- a/lib_enc/ivas_qspherical_enc_fx.c +++ b/lib_enc/ivas_qspherical_enc_fx.c @@ -39,7 +39,6 @@ #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_range_uni_enc_fx.c b/lib_enc/ivas_range_uni_enc_fx.c index 35ecad69c..cf32c644d 100644 --- a/lib_enc/ivas_range_uni_enc_fx.c +++ b/lib_enc/ivas_range_uni_enc_fx.c @@ -39,7 +39,7 @@ #include "rom_com.h" #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_sba_enc_fx.c b/lib_enc/ivas_sba_enc_fx.c index b247900a0..86427eb2d 100644 --- a/lib_enc/ivas_sba_enc_fx.c +++ b/lib_enc/ivas_sba_enc_fx.c @@ -37,13 +37,12 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 9f63c4fc7..8c2c945d6 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot.h" diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index 8f93c4d76..e6038186e 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -35,10 +35,9 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index a0c5be842..674a80549 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -38,7 +38,6 @@ #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_stat_com.h" -#include "prot.h" #include "math.h" #include "wmc_auto.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index 8b23eca5f..925f4e702 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" @@ -42,7 +41,6 @@ #include "ivas_rom_com_fx.h" #include #include "wmc_auto.h" -#include "prot_fx.h" /*------------------------------------------------------------------------------------------* * PreProcessor diff --git a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c index 62fed34f7..70c2165f8 100644 --- a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c +++ b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include "cnst.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "stat_enc.h" #include "wmc_auto.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c index 0c90d5fdc..bfe683d6b 100644 --- a/lib_enc/ivas_stereo_classifier_fx.c +++ b/lib_enc/ivas_stereo_classifier_fx.c @@ -38,13 +38,12 @@ #endif #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "ivas_cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_cng_enc_fx.c b/lib_enc/ivas_stereo_cng_enc_fx.c index 4727cd188..255b6e938 100644 --- a/lib_enc/ivas_stereo_cng_enc_fx.c +++ b/lib_enc/ivas_stereo_cng_enc_fx.c @@ -36,12 +36,11 @@ #include "cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index 8578a46ae..3f7237ce5 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -37,10 +37,9 @@ #include "cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index 70a467232..7900033f4 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "rom_enc.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index dd7f575b7..58e66a01a 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "ivas_prot.h" #include "ivas_rom_com.h" @@ -43,7 +43,6 @@ #include "ivas_cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 7b0e7df62..a3388db61 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "rom_com.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" @@ -45,7 +44,6 @@ #include "ivas_rom_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_eclvq_enc_fx.c b/lib_enc/ivas_stereo_eclvq_enc_fx.c index cd0e6fe2d..f4962c802 100644 --- a/lib_enc/ivas_stereo_eclvq_enc_fx.c +++ b/lib_enc/ivas_stereo_eclvq_enc_fx.c @@ -39,7 +39,6 @@ #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include -#include "prot.h" #include "prot_fx.h" #include "wmc_auto.h" /* used only for norm_s in the code_length_from_count function */ diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index e0a8a8ed4..351b87cd0 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -36,12 +36,11 @@ #include #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 8c2d136b7..78891c5f7 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -35,12 +35,11 @@ #include #include "cnst.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index 2a87ea4f9..28b0e41b9 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "rom_com.h" diff --git a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c index 38be1a6a4..57bb18e80 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include -#include "prot.h" #include "prot_fx.h" #include "cnst.h" #include "stat_enc.h" diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index 9c729709d..b1213a750 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -38,7 +38,6 @@ #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" -#include "prot.h" #include "prot_fx_enc.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 190adbf1c..f3ceb2757 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -34,14 +34,13 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com_fx.h" #include "ivas_rom_com.h" #include "assert.h" #include "wmc_auto.h" #include "prot_fx_enc.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c index 79e05bf09..efae1e80d 100644 --- a/lib_enc/ivas_stereo_td_analysis_fx.c +++ b/lib_enc/ivas_stereo_td_analysis_fx.c @@ -35,14 +35,13 @@ #include #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" #include "rom_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index 304754fc3..f8d600276 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include "cnst.h" #include "rom_com.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" @@ -44,7 +44,6 @@ #endif #include "prot_fx_enc.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 84bffa87c..28044b45d 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -35,13 +35,12 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "rom_com.h" #include "basop_proto_func.h" #include "wmc_auto.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "prot_fx_enc.h" #include "rom_com_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 4d6a908b3..34215025f 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -37,7 +37,6 @@ #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot.h" diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 1f2fee684..211c53f8c 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -41,7 +41,6 @@ #include "lib_enc.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "wmc_auto.h" diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 709bb47e0..a61b2ebff 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -8,7 +8,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ //#include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 830f1ecd6..7f58a9501 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -38,7 +38,6 @@ #include "options.h" #include "cnst.h" #include "ivas_prot.h" -#include "prot.h" #include "prot_fx.h" #include "rom_com.h" #include "rom_enc.h" diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index 265fce7f2..eec85c254 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -9,7 +9,6 @@ #include "rom_com.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ diff --git a/lib_enc/mslvq_enc_fx.c b/lib_enc/mslvq_enc_fx.c index d8a78c525..771ef480b 100644 --- a/lib_enc/mslvq_enc_fx.c +++ b/lib_enc/mslvq_enc_fx.c @@ -6,9 +6,8 @@ #include "rom_com_fx.h" #include "rom_com.h" #include "stl.h" -#include "prot.h" /* Function prototypes */ -#include "basop32.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ +#include "basop32.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index 3bd8e340d..a7588283a 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "rom_com.h" diff --git a/lib_enc/peak_vq_enc_fx.c b/lib_enc/peak_vq_enc_fx.c index 9ea1af949..aa4763aa6 100644 --- a/lib_enc/peak_vq_enc_fx.c +++ b/lib_enc/peak_vq_enc_fx.c @@ -11,7 +11,6 @@ #include "rom_com_fx.h" #include "rom_com.h" #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ /*-------------------------------------------------------------------------- diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index d53e2eb6e..bcf7d33bb 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -10,7 +10,6 @@ #include "rom_com.h" /* Static table prototypes */ //#include "prot_fx.h" /* Function prototypes */ #include "rom_basop_util.h" -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/range_enc_fx.c b/lib_enc/range_enc_fx.c index 05916e801..689b313d8 100644 --- a/lib_enc/range_enc_fx.c +++ b/lib_enc/range_enc_fx.c @@ -10,7 +10,6 @@ #include "rom_com.h" /* Static table prototypes */ //#include "prot_fx.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index a735c498d..353de8ec9 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -19,7 +19,6 @@ #include #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" /*---------------------------------------------------------------------* diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 91dca8d63..0a20db8ed 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -11,7 +11,6 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot.h" /*======================================================================*/ /* FUNCTION : stat_noise_uv_enc_fx */ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 3ca3f3f3f..2ca0b6d74 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -4,12 +4,11 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "rom_com_fx.h" #include "rom_com.h" #include "stl.h" -#include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ /*---------------------------------------------------------------------* diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index acd984509..1a397c514 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -36,7 +36,6 @@ #include "prot_fx_enc.h" /* Function prototypes */ #include "rom_com.h" #include "stl.h" -#include "prot.h" /*--------------------------------------------------------------------------* * GetSubbandCorrIndex2_har() diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c deleted file mode 100644 index db4e51127..000000000 --- a/lib_enc/swb_tbe_enc.c +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#include -#include "options.h" -#include -#include "cnst.h" -#include "prot.h" -#include "prot_fx.h" -#include "rom_com.h" -#include "rom_enc.h" -#include "wmc_auto.h" -#include "ivas_prot.h" diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index a5e4e902b..61ca9b101 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -8,7 +8,6 @@ #include "cnst.h" #include "rom_com_fx.h" #include "rom_com.h" -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "ivas_prot.h" /* Function prototypes */ diff --git a/lib_enc/tcq_core_enc_fx.c b/lib_enc/tcq_core_enc_fx.c index fbd9775c4..82088be50 100644 --- a/lib_enc/tcq_core_enc_fx.c +++ b/lib_enc/tcq_core_enc_fx.c @@ -10,7 +10,6 @@ #include "ivas_error.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "prot.h" #define IVAS_FLOAT ivas_error tcq_core_LR_enc_fx( diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index f1881a427..cf6e5dd64 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -12,7 +12,6 @@ #include #include "rom_com_fx.h" #include "rom_com.h" -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 0089fc745..9911d766a 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -7,7 +7,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -#include "prot.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ diff --git a/lib_rend/ivas_allrad_dec_fx.c b/lib_rend/ivas_allrad_dec_fx.c index 4a4c1ff89..008e27d6c 100644 --- a/lib_rend/ivas_allrad_dec_fx.c +++ b/lib_rend/ivas_allrad_dec_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 67d47e89d..81437c49d 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -33,7 +33,7 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" @@ -41,7 +41,6 @@ #include "ivas_rom_binaural_crend_head.h" #include "ivas_stat_rend.h" #include "lib_rend.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" #ifdef DEBUGGING diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 06744dc6e..9cc764afb 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -35,11 +35,10 @@ #include "ivas_cnst.h" #include "ivas_prot_rend.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index e2ab6cd3e..7e41581f4 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include #include -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index 01fd1e610..4ea5c5e96 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -35,13 +35,12 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_dirac_onsets_dec_fx.c b/lib_rend/ivas_dirac_onsets_dec_fx.c index c6119cc34..4eae9c286 100644 --- a/lib_rend/ivas_dirac_onsets_dec_fx.c +++ b/lib_rend/ivas_dirac_onsets_dec_fx.c @@ -34,14 +34,13 @@ #include #include "options.h" #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" -#include "prot_fx.h" /*------------------------------------------------------------------------- * ivas_dirac_dec_onset_detection_open() diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index d6c999aa0..29eac3635 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" @@ -43,7 +43,6 @@ #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" -#include "prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index b563d4399..882c6e5b8 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -35,13 +35,12 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_binaural_crend_head.h" diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 8947809d1..52ca3e6f9 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -35,7 +35,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 506d76efd..5d53d2ae3 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_error.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_limiter_fx.c b/lib_rend/ivas_limiter_fx.c index 595573016..b66127e09 100644 --- a/lib_rend/ivas_limiter_fx.c +++ b/lib_rend/ivas_limiter_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index e8d06d0bb..8b7e6575d 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -36,9 +36,8 @@ #include "ivas_prot_rend.h" #include "ivas_prot.h" #include "ivas_cnst.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 0b0c8ffeb..25fddaa80 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -37,12 +37,11 @@ #include "options.h" #include "ivas_prot_rend.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "ivas_rom_com_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 8b689b94b..93fe67436 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -33,14 +33,13 @@ #include "ivas_stat_rend.h" #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" #include "debug.h" #include "ivas_rom_com_fx.h" #define float_to_fixed( n, factor ) ( round( n * ( 1 << factor ) ) ) diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index ab09a82b5..a7f46b2a4 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -33,13 +33,12 @@ #include #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "ivas_cnst.h" #include "wmc_auto.h" -#include "prot_fx.h" /*---------------------------------------------------------------------* * Local function prototypes diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index a328a51bf..7ee6c828b 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -32,14 +32,13 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_TdBinauralRenderer.h" #include "ivas_error.h" #include "wmc_auto.h" #include "ivas_rom_rend.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*-------------------------------------------------------------------* * Local constants diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index caa393355..971e2c2d1 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -35,9 +35,8 @@ #include #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" /*---------------------------------------------------------------------* diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index af60f7746..307d38351 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -33,11 +33,10 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" /*---------------------------------------------------------------------* diff --git a/lib_rend/ivas_objectRenderer_vec_fx.c b/lib_rend/ivas_objectRenderer_vec_fx.c index c8efd80ad..4d259a68e 100644 --- a/lib_rend/ivas_objectRenderer_vec_fx.c +++ b/lib_rend/ivas_objectRenderer_vec_fx.c @@ -33,10 +33,9 @@ #include #include "options.h" #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 7d6129d20..d7387ecd4 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -37,11 +37,10 @@ #include "ivas_prot_rend.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 980e5ca17..054e5e981 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c index e5e8cdb56..a02a29d0d 100644 --- a/lib_rend/ivas_reflections_fx.c +++ b/lib_rend/ivas_reflections_fx.c @@ -33,7 +33,7 @@ #include "options.h" #include #include -#include "prot.h" +#include "prot_fx.h" #include "rom_dec.h" #include "lib_rend.h" #include "ivas_prot_rend.h" @@ -42,7 +42,6 @@ #include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "debug.h" #include "ivas_rom_com_fx.h" diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index 792b485a7..b730b1510 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -32,12 +32,11 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "ivas_rom_TdBinauralRenderer.h" #include "wmc_auto.h" -#include "prot_fx.h" /*-----------------------------------------------------------------------* * Local constants diff --git a/lib_rend/ivas_reverb_delay_line_fx.c b/lib_rend/ivas_reverb_delay_line_fx.c index 3eeb4ede4..44550803a 100644 --- a/lib_rend/ivas_reverb_delay_line_fx.c +++ b/lib_rend/ivas_reverb_delay_line_fx.c @@ -34,9 +34,8 @@ #include "options.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" -#include "prot.h" -#include "wmc_auto.h" #include "prot_fx.h" +#include "wmc_auto.h" #include "debug.h" /*-----------------------------------------------------------------------------------------* * Function ivas_rev_delay_line_init() diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c index 3befcde91..2d0722ceb 100644 --- a/lib_rend/ivas_reverb_fft_filter_fx.c +++ b/lib_rend/ivas_reverb_fft_filter_fx.c @@ -32,11 +32,10 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "debug.h" #define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) #define fix_to_float( n, factor ) ( (float) n / ( 1 << factor ) ) diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index 428cf3353..652fc898f 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_rend.h" #include diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 9e621ce83..6b41815c4 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -32,14 +32,13 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "math.h" #include "ivas_rom_rend.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "debug.h" #define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) #define float_to_fixQ31( n ) ( round( n * 0x7fffffff ) ) diff --git a/lib_rend/ivas_reverb_iir_filter_fx.c b/lib_rend/ivas_reverb_iir_filter_fx.c index 217e16dd8..98b66e0c7 100644 --- a/lib_rend/ivas_reverb_iir_filter_fx.c +++ b/lib_rend/ivas_reverb_iir_filter_fx.c @@ -32,10 +32,9 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "debug.h" #define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) #define fix_to_float( n, factor ) ( (float) n / ( 1 << factor ) ) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 46ef576a8..ee2bada9d 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -32,12 +32,11 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include #include "wmc_auto.h" -#include "prot_fx.h" #include "options_warnings.h" /*-----------------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 39720469b..7ad4c4ccb 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -37,11 +37,10 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" #include -#include "prot_fx.h" #include "ivas_prot_fx.h" #include "debug.h" #include "ivas_rom_binaural_crend_head.h" diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c index 7c7a20223..4323fc96f 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" diff --git a/lib_rend/ivas_shoebox_fx.c b/lib_rend/ivas_shoebox_fx.c index 9ed0d8d33..7c930104a 100644 --- a/lib_rend/ivas_shoebox_fx.c +++ b/lib_rend/ivas_shoebox_fx.c @@ -36,7 +36,6 @@ #include "ivas_prot_rend.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" -#include "prot.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_td_decorr_fx.c b/lib_rend/ivas_td_decorr_fx.c index af51a7820..6d5b23f12 100644 --- a/lib_rend/ivas_td_decorr_fx.c +++ b/lib_rend/ivas_td_decorr_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot.h" diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c index e1a6868d8..06cbd83a6 100644 --- a/lib_rend/ivas_vbap_fx.c +++ b/lib_rend/ivas_vbap_fx.c @@ -34,12 +34,11 @@ #include "options.h" #include #include -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" -#include "prot_fx.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 493979e30..0cda39d62 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -32,7 +32,6 @@ #include "basop_util.h" #include "options.h" #include "lib_rend.h" -#include "prot.h" #include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 8920e6780..930bb79dc 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -32,9 +32,8 @@ #include "hrtf_file_reader.h" #include -#include "prot.h" -#include "ivas_prot_rend.h" #include "prot_fx.h" +#include "ivas_prot_rend.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 01d1f0307..90d47b7c9 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -34,7 +34,7 @@ #include #include #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" struct LsCustomFileReader diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c index 782f818d0..2976e1895 100644 --- a/lib_util/mime_io.c +++ b/lib_util/mime_io.c @@ -32,7 +32,7 @@ #include "mime_io.h" #include "mime.h" -#include "prot.h" +#include "prot_fx.h" #include "string.h" #include #include diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index b6122ec0f..e099842be 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -37,7 +37,7 @@ #include #include #include "cmdl_tools.h" -#include "prot.h" +#include "prot_fx.h" /*------------------------------------------------------------------------------------------* diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index 468f80765..2299f3265 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -34,7 +34,6 @@ #include #include #include -#include "prot.h" #include "prot_fx.h" diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index ec14ebc71..5745e9595 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -35,7 +35,6 @@ #include #include #include -#include "prot.h" #include "options.h" /* only included to get access to the feature-defines */ #include "prot_fx.h" #include "ivas_prot_fx.h" -- GitLab From 1411ee404ff299ce7211e7cd1325aa27e2d9ad6b Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 7 Mar 2025 10:13:00 +0530 Subject: [PATCH 47/97] Fix for 3GPP issue 1140: Missing conversion of some flt. pt. functions in the BASOP code Link #1140 --- lib_com/float_to_fix_ops.c | 8 ++--- lib_com/ivas_spar_com_fx.c | 39 ++++++++++++++++--------- lib_dec/dec_tcx_fx.c | 19 ++++++------ lib_dec/ivas_lfe_plc_fx.c | 12 ++++---- lib_dec/ivas_mc_paramupmix_dec_fx.c | 6 ++-- lib_dec/ivas_qmetadata_dec_fx.c | 3 +- lib_dec/ivas_spar_md_dec_fx.c | 7 +++-- lib_dec/ivas_stereo_cng_dec.c | 6 ++-- lib_dec/ivas_stereo_dft_dec_fx.c | 38 +++++++++++++++--------- lib_enc/ACcontextMapping_enc_fx.c | 7 +++-- lib_enc/fd_cng_enc_fx.c | 2 +- lib_enc/ivas_agc_enc_fx.c | 2 +- lib_enc/ivas_core_pre_proc_fx.c | 2 +- lib_enc/ivas_cpe_enc_fx.c | 2 +- lib_enc/ivas_init_enc_fx.c | 2 +- lib_enc/ivas_lfe_enc_fx.c | 20 ++++++------- lib_enc/ivas_mc_paramupmix_enc_fx.c | 10 +++---- lib_enc/ivas_osba_enc_fx.c | 2 +- lib_enc/ivas_qmetadata_enc_fx.c | 3 +- lib_enc/ivas_sba_enc_fx.c | 2 +- lib_enc/ivas_stereo_dft_enc_itd_fx.c | 9 ++++-- lib_enc/ivas_stereo_dmx_evs_fx.c | 6 ++-- lib_enc/ivas_stereo_ica_enc_fx.c | 4 +-- lib_enc/ivas_stereo_switching_enc_fx.c | 2 +- lib_rend/ivas_dirac_decorr_dec_fx.c | 4 +-- lib_rend/ivas_dirac_rend_fx.c | 2 +- lib_rend/ivas_reverb_filter_design_fx.c | 6 ++-- lib_rend/ivas_rotation_fx.c | 2 +- lib_rend/lib_rend.c | 12 ++++---- 29 files changed, 137 insertions(+), 102 deletions(-) diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 1f7c28fd8..8b69e05e8 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -183,14 +183,14 @@ Word16 Q_factor( float x ) { Word16 Q = 15; if ( x >= 1 || x <= -1 ) - Q = norm_s( (Word16) abs( (Word32) x ) ); + Q = norm_s( (Word16) L_abs( (Word32) x ) ); return Q; } Word16 Q_factor_L( float x ) { Word16 Q = 31; if ( x >= 1 || x <= -1 ) - Q = norm_l( abs( (Word32) x ) ); + Q = norm_l( L_abs( (Word32) x ) ); return Q; } Word16 Q_factor_L_32( Word32 x ) @@ -206,7 +206,7 @@ Word16 Q_factor_arr( float *x, Word16 l ) for ( int i = 0; i < l; i++ ) { if ( x[i] >= 1 || x[i] <= -1 ) - Q = s_min( Q, norm_s( (Word16) abs( (Word32) x[i] ) ) ); + Q = s_min( Q, norm_s( (Word16) L_abs( (Word32) x[i] ) ) ); } return Q; } @@ -216,7 +216,7 @@ Word16 Q_factor_arrL( float *x, Word16 l ) for ( int i = 0; i < l; i++ ) { if ( x[i] >= 1 || x[i] <= -1 ) - Q = s_min( Q, norm_l( (Word32) abs( (Word32) x[i] ) ) ); + Q = s_min( Q, norm_l( (Word32) L_abs( (Word32) x[i] ) ) ); } return Q; } diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index fc6e60310..6c80c1898 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -4004,7 +4004,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( move16(); P_norm_fx[0] = 0; move32(); - FOR( i = 0; i < max( 0, sub( foa_ch, ndm ) ); i++ ) + Word16 len = s_max( 0, sub( foa_ch, ndm ) ); + FOR( i = 0; i < len; i++ ) { P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); @@ -4014,7 +4015,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( P_norm_fx[1] = 0; move32(); - FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ ) + len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) ); + FOR( ; i < len; i++ ) // max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) { P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); @@ -4031,8 +4033,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( } P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31 move32(); - - FOR( i = 0; i < max( 0, ( foa_ch - ndm ) ); i++ ) + len = s_max( 0, sub( foa_ch, ndm ) ); + FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) ) { idx = sub( remix_order[i + ndm], ndm ); P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31 @@ -4045,7 +4047,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( move32(); } } - FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ ) + len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) ); + FOR( ; i < len; i++ ) // i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) { idx = sub( remix_order[i + ndm], ndm ); P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31 @@ -4057,6 +4060,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( move32(); } } + FOR( ; i < ( num_ch - ndm ); i++ ) { idx = sub( remix_order[i + ndm], ndm ); @@ -4222,7 +4226,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( /*normalize 2nd order*/ norm_fx = 0; move32(); - FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ ) + Word16 min_ch_order = s_min( hoa2_ch_order, num_ch_order ); + FOR( ch = foa_ch; ch < min_ch_order; ch++ ) { norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29 } @@ -4243,7 +4248,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( move16(); } norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30 - FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ ) + min_ch_order = s_min( hoa2_ch_order, num_ch_order ); + FOR( ch = foa_ch; ch < min_ch_order; ch++ ) { IF( LT_32( norm_fx, EPSILON_FX_THR ) ) { @@ -4557,7 +4563,8 @@ void ivas_get_spar_md_from_dirac_fx( move16(); P_norm_fx[0] = 0; move32(); - FOR( i = 0; i < max( 0, sub( foa_ch, ndm ) ); i++ ) + Word16 len = s_max( 0, sub( foa_ch, ndm ) ); + FOR( i = 0; i < len; i++ ) // i < max( 0, sub( foa_ch, ndm ) ) { P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); @@ -4567,7 +4574,8 @@ void ivas_get_spar_md_from_dirac_fx( P_norm_fx[1] = 0; move32(); - FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ ) + len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) ); + FOR( ; i < len; i++ ) // i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) { P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); @@ -4584,8 +4592,8 @@ void ivas_get_spar_md_from_dirac_fx( } P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31 move32(); - - FOR( i = 0; i < max( 0, ( foa_ch - ndm ) ); i++ ) + len = s_max( 0, sub( foa_ch, ndm ) ); + FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) ) { idx = sub( remix_order[i + ndm], ndm ); P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31 @@ -4598,7 +4606,8 @@ void ivas_get_spar_md_from_dirac_fx( move32(); } } - FOR( ; i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ); i++ ) + len = s_max( 0, sub( s_min( num_ch, hoa2_ch ), ndm ) ); + FOR( ; i < len; i++ ) // i < max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) { idx = sub( remix_order[i + ndm], ndm ); P_dir_fact_fx[idx] = Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ); // 2*q_P_re - 31 @@ -4775,7 +4784,8 @@ void ivas_get_spar_md_from_dirac_fx( /*normalize 2nd order*/ norm_fx = 0; move32(); - FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ ) + Word16 min_ch_order = s_min( hoa2_ch_order, num_ch_order ); + FOR( ch = foa_ch; ch < min_ch_order; ch++ ) { norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29 } @@ -4796,7 +4806,8 @@ void ivas_get_spar_md_from_dirac_fx( move16(); } norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30 - FOR( ch = foa_ch; ch < min( hoa2_ch_order, num_ch_order ); ch++ ) + min_ch_order = s_min( hoa2_ch_order, num_ch_order ); + FOR( ch = foa_ch; ch < min_ch_order; ch++ ) { IF( LT_32( norm_fx, EPSILON_FX_THR ) ) { diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 20f7a0adf..00f372154 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3807,7 +3807,7 @@ void decoder_tcx_invQ_fx( FOR( i = 0; i < noiseFillingSize; ++i ) { tmp32 = L_shr( x[i], sub( 31, *x_e ) ); - *nf_seed = add_o( *nf_seed, (Word16) abs( tmp32 ) * i * 2, &Overflow ); + *nf_seed = add_o( *nf_seed, shl( i_mult( (Word16) L_abs( tmp32 ), i ), 1 ), &Overflow ); // abs( tmp32 ) * i * 2 move16(); } } @@ -3875,7 +3875,8 @@ void decoder_tcx_invQ_fx( test(); IF( !st->tcxonly || ( hTcxCfg->resq && hTcxDec->tcx_lpc_shaped_ari ) ) { - FOR( i = 0; i < max( L_spec, L_frameTCX ); i++ ) + Word16 len = s_max( L_spec, L_frameTCX ); + FOR( i = 0; i < len; i++ ) { xn_buf[i] = ONE_IN_Q14; move16(); @@ -4891,11 +4892,11 @@ void decoder_tcx_tns_fx( move16(); test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) ) + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 ) { test(); test(); - IF( NE_16( frame_cnt, 0 ) && EQ_16( bfi, 0 ) && NE_16( st->last_core, ACELP_CORE ) ) + IF( frame_cnt != 0 && bfi == 0 && st->last_core != ACELP_CORE ) { /* fix sub-window overlap */ hTcxCfg->tcx_last_overlap_mode = hTcxCfg->tcx_curr_overlap_mode; @@ -4940,14 +4941,14 @@ void decoder_tcx_tns_fx( test(); test(); test(); - IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) ) + IF( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && fUseTns != 0 && NE_16( bfi, 1 ) && EQ_16( tnsData->tnsOnWhitenedSpectra, whitenedDomain ) ) { /* Apply TNS to get the reconstructed signal */ SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) ); test(); test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) ) + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 && isTCX5 != 0 ) { tcx5TnsGrouping_fx( shr( L, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx ); } @@ -4956,10 +4957,10 @@ void decoder_tcx_tns_fx( test(); test(); - IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) && NE_16( isTCX5, 0 ) ) + IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 && isTCX5 != 0 ) { test(); - IF( EQ_16( st->element_mode, EVS_MONO ) || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ + IF( st->element_mode == EVS_MONO || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ { tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); tmp = L_frameTCX; @@ -5232,7 +5233,7 @@ void decoder_tcx_imdct_fx( { IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); } ELSE { diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index a8b54d3fb..018f99fe7 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -396,7 +396,7 @@ static Word16 lfeplc_lev_dur_fx( IF( LT_16( rc_q_fx[i - 1], 31 ) ) { - IF( GT_32( abs( rc_fx[i - 1] ), L_shr( 2146302532, sub( 31, rc_q_fx[i - 1] ) ) ) ) // 2146302532 = 0.99945f in Q31 + IF( GT_32( L_abs( rc_fx[i - 1] ), L_shr( 2146302532, sub( 31, rc_q_fx[i - 1] ) ) ) ) // 2146302532 = 0.99945f in Q31 { return 1; } @@ -413,7 +413,7 @@ static Word16 lfeplc_lev_dur_fx( } ELSE { - IF( GT_32( abs( L_shr( rc_fx[i - 1], sub( rc_q_fx[i - 1], 31 ) ) ), 2146302532 ) ) // 2146302532 = 0.00045f in Q31 + IF( GT_32( L_abs( L_shr( rc_fx[i - 1], sub( rc_q_fx[i - 1], 31 ) ) ), 2146302532 ) ) // 2146302532 = 0.00045f in Q31 { return 1; } @@ -465,7 +465,7 @@ static Word16 d_a2rc_fx( move32(); km_q_fx = ff_q_fx[m]; move16(); - IF( GE_64( W_shr( abs( km_fx ), sub( ff_q_fx[m], Q30 ) ), W_deposit32_l( ONE_IN_Q30 ) ) ) + IF( GE_64( W_shr( L_abs( km_fx ), sub( ff_q_fx[m], Q30 ) ), W_deposit32_l( ONE_IN_Q30 ) ) ) { FOR( j = 0; j < lpcorder; j++ ) { @@ -826,7 +826,7 @@ static Word32 find_max_delta_fx( IF( !stable ) { - temp = abs( eps_fx ); + temp = L_abs( eps_fx ); IF( GT_32( L_shr( temp, sub( eps_q_fx, 31 ) ), EPS_STOP_Q31 ) ) { exp1 = norm_l( -temp ); @@ -836,12 +836,12 @@ static Word32 find_max_delta_fx( } ELSE { - eps_fx = L_negate( abs( eps_fx ) ); + eps_fx = L_negate( L_abs( eps_fx ) ); } } ELSE { - temp = abs( eps_fx ); + temp = L_abs( eps_fx ); if ( LT_32( L_shr( temp, sub( eps_q_fx, 31 ) ), EPS_STOP_Q31 ) ) { BREAK; diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index e03b385b7..9ea666237 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -132,7 +132,8 @@ void ivas_mc_paramupmix_dec_read_BS( nb_bits_read_orig = 0; move16(); last_bit_pos = sub( last_bit_pos, nb_bits_read_orig ); /* reverse the bitstream for easier reading of indices */ - FOR( i = 0; i < min( MAX_BITS_METADATA, last_bit_pos ); i++ ) + Word16 len = s_min( MAX_BITS_METADATA, last_bit_pos ); + FOR( i = 0; i < len; i++ ) { bstr_meta[i] = st_ivas->bit_stream[last_bit_pos - i]; move16(); @@ -269,7 +270,8 @@ void ivas_mc_paramupmix_dec_render( ivas_mc_paramupmix_dec_sf( st_ivas, output_local_fx ); - FOR( ch = 0; ch < min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) ); ch++ ) + Word16 num_ch = s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) ); + FOR( ch = 0; ch < num_ch; ch++ ) { output_local_fx[ch] += n_samples_sf; } diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index 4bebcda5c..81768af44 100644 --- a/lib_dec/ivas_qmetadata_dec_fx.c +++ b/lib_dec/ivas_qmetadata_dec_fx.c @@ -3257,7 +3257,8 @@ static Word16 read_truncGR_azimuth_fx( move16(); IF( LE_16( allowed_bits, add( no_subframes, 1 ) ) ) { - FOR( i = 0; i < min( allowed_bits, no_subframes ); i++ ) + Word16 len = s_min( allowed_bits, no_subframes ); + FOR( i = 0; i < len; i++ ) { IF( bitstream[( *pbit_pos )--] == 0 ) { diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 2b6b145f9..d1efbbd2c 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -936,9 +936,10 @@ Word16 ivas_spar_chk_zero_coefs_fx( ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[0]; /*Q0*/ move16(); - FOR( b = 0; b < min( hMdDec->spar_md.num_bands, SPAR_DIRAC_SPLIT_START_BAND ); b++ ) + Word16 min_bands = s_min( hMdDec->spar_md.num_bands, SPAR_DIRAC_SPLIT_START_BAND ); + FOR( b = 0; b < min_bands; b++ ) { - FOR( j = 0; j < sub( add( ndm, ndec ), 1 ); j++ ) + FOR( j = 0; j < ( ( ndm + ndec ) - 1 ); j++ ) { if ( hMdDec->spar_md.band_coeffs[b].pred_re_fx[j] != 0 ) { @@ -948,7 +949,7 @@ Word16 ivas_spar_chk_zero_coefs_fx( } FOR( j = 0; j < ndec; j++ ) { - FOR( k = 0; k < sub( ndm, 1 ); k++ ) + FOR( k = 0; k < ( ndm - 1 ); k++ ) { if ( hMdDec->spar_md.band_coeffs[b].C_re_fx[j][k] != 0 ) { diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 15885a661..4d50ba350 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -585,7 +585,8 @@ static void stereo_dft_generate_comfort_noise_fx( ptr_r = DFT[chan] + add( hFdCngCom->stopFFTbin, i_mult( k, STEREO_DFT32MS_N_MAX ) ); /* q_dft */ ptr_i = ptr_r + 1; - FOR( i = 0; i < ( min( output_frame, hFdCngCom->regularStopBand * 16 ) - hFdCngCom->stopFFTbin ) / 2; i++ ) + Word16 len = shr( ( sub( s_min( output_frame, i_mult( hFdCngCom->regularStopBand, 16 ) ), hFdCngCom->stopFFTbin ) ), 1 ); + FOR( i = 0; i < len; i++ ) { /* Real part in FFT bins */ rand_gauss_fx( ptr_r, &st->hTdCngDec->cng_seed, q_dft ); @@ -622,7 +623,8 @@ static void stereo_dft_generate_comfort_noise_fx( ptr_r = DFT[chan] + add( hFdCngCom->stopFFTbin, i_mult( k, STEREO_DFT32MS_N_MAX ) ); /* q_dft */ ptr_i = ptr_r + 1; - FOR( i = 0; i < ( min( output_frame, hFdCngCom->regularStopBand * 16 ) - hFdCngCom->stopFFTbin ) / 2; i++ ) + tmp = shr( sub( s_min( output_frame, i_mult( hFdCngCom->regularStopBand, 16 ) ), hFdCngCom->stopFFTbin ), 1 ); + FOR( i = 0; i < tmp; i++ ) { ( *ptr_r ) = L_shl( Mpy_32_32( ( *ptr_r ), tmp32_1 ), q_shift ); /* q_dft + q_shift */ move32(); diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index c806f358a..8dcc7ada9 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -1522,6 +1522,7 @@ void stereo_dft_dec_fx( Word16 q_samp_ratio = Q15; move16(); #endif /* OPT_STEREO_32KBPS_V1 */ + Word16 len; output_frame = (Word16) Mpy_32_32( L_add( st0->output_Fs, FRAMES_PER_SEC_BY_2 ), ONE_BY_FRAMES_PER_SEC_Q31 ); /* Q0 */ @@ -1890,7 +1891,8 @@ void stereo_dft_dec_fx( DFT_R[2 * i + 1] = L_sub( DFT_W, DFT_Y ); /* qDFT */ move32(); } - FOR( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) + len = s_min( stop, hStereoDft->band_limits[b + 1] ); + FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { DFT_W = Madd_32_32( Mpy_32_32( hStereoDft->mixer_mat_smooth_fx[0][0][b + k * IVAS_MAX_NUM_BANDS], pDFT_DMX[2 * i] ), L_add( hStereoDft->mixer_mat_smooth_fx[0][1][b + k * IVAS_MAX_NUM_BANDS], @@ -1997,7 +1999,8 @@ void stereo_dft_dec_fx( } ELSE { - FOR( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) + len = s_min( stop, hStereoDft->band_limits[b + 1] ); + FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { tmp = L_add( Madd_32_16( pDFT_RES[2 * i], pDFT_DMX[2 * i], g ), DFT_PRED_RES[2 * i] ); /* qDFT */ @@ -2218,8 +2221,8 @@ void stereo_dft_dec_fx( gamma = 0; move16(); } - - FOR( i = max( hFdCngDec->cna_band_limits[b], ( hFdCngCom->startBand / 2 ) ); i < min( hFdCngDec->cna_band_limits[b + 1], ( L_FRAME16k ) >> 1 ); i++ ) + len = s_min( hFdCngDec->cna_band_limits[b + 1], ( L_FRAME16k ) >> 1 ); + FOR( i = s_max( hFdCngDec->cna_band_limits[b], ( hFdCngCom->startBand >> 1 ) ); i < len; i++ ) // i < min( hFdCngDec->cna_band_limits[b + 1], ( L_FRAME16k ) >> 1 ); { Word32 l_tmp; lev1 = *ptr_per++; @@ -2597,6 +2600,7 @@ void stereo_dft_generate_res_pred_fx( q_norm_fac = 0; move16(); #endif /* OPT_STEREO_32KBPS_V1 */ + Word16 len; push_wmops( "gen_respred" ); /* smoothing and limiting parameters */ @@ -2665,7 +2669,8 @@ void stereo_dft_generate_res_pred_fx( move64(); /* calculate band energies (low band only in case of ACELP) */ - FOR( i = hStereoDft->band_limits[b]; i < min( hStereoDft->band_limits[b + 1], bin0 ); i++ ) + len = s_min( hStereoDft->band_limits[b + 1], bin0 ); + FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { #ifdef OPT_STEREO_32KBPS_V1 dmx_nrg_64bit = W_mac_32_32( W_mac_32_32( dmx_nrg_64bit, pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), @@ -2847,7 +2852,8 @@ void stereo_dft_generate_res_pred_fx( } #endif /* OPT_STEREO_32KBPS_V1 */ - FOR( i = hStereoDft->band_limits[b]; i < min( hStereoDft->band_limits[b + 1], bin0 ); i++ ) + len = s_min( hStereoDft->band_limits[b + 1], bin0 ); + FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { #ifdef OPT_STEREO_32KBPS_V1 DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), 1 ); /* q_dft */ @@ -2969,7 +2975,8 @@ void stereo_dft_generate_res_pred_fx( move32(); dmx_nrg = EPSILON_FIX; move32(); - FOR( i = hStereoDft->band_limits[b]; i < min( bin0, hStereoDft->band_limits[b + 1] ); i++ ) + len = s_min( bin0, hStereoDft->band_limits[b + 1] ); + FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { dmx_nrg = Madd_32_32( Madd_32_32( dmx_nrg, pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ); /* 2 * q_dft - 31 */ @@ -3010,8 +3017,8 @@ void stereo_dft_generate_res_pred_fx( q_sqrt = 0; move16(); } - - FOR( i = hStereoDft->band_limits[b]; i < min( bin0, hStereoDft->band_limits[b + 1] ); i++ ) + len = s_min( bin0, hStereoDft->band_limits[b + 1] ); + FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( g2, DFT_PRED_RES[2 * i] ), q_sqrt ); /* q_dft */ move32(); @@ -3068,7 +3075,8 @@ void stereo_dft_generate_res_pred_fx( // past_dmx_nrg = EPSILON_FIX; past_dmx_nrg = 0; move32(); - FOR( i = bin0; i < min( ( hStereoDft->NFFT / 2 ), ( STEREO_DFT32MS_N_32k / 2 ) ); i++ ) + len = s_min( shr( hStereoDft->NFFT, 1 ), ( STEREO_DFT32MS_N_32k >> 1 ) ); + FOR( i = bin0; i < len; i++ ) // i < min( ( hStereoDft->NFFT / 2 ), ( hStereoDft->NFFT / 2 ) ) { past_dmx_nrg = L_add( past_dmx_nrg, Madd_32_32( Mpy_32_32( hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i], hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i] ), hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i + 1], hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i + 1] ) ); /* 2 * hStereoDft->q_DFT_past_DMX_fx[d_short_ind] - 31 */ } @@ -3129,7 +3137,8 @@ void stereo_dft_generate_res_pred_fx( } q_shift = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[d_short_ind] ); move16(); - FOR( i = max( hStereoDft->band_limits[b], bin0 ); i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) + len = s_min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k >> 1 ); + FOR( i = s_max( hStereoDft->band_limits[b], bin0 ); i < len; i++ ) // i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ) { DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( g2, hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i] ), q_shift ); /* q_dft */ move32(); @@ -3243,7 +3252,8 @@ void stereo_dft_generate_res_pred_fx( move32(); dmx_nrg = EPSILON_FIX; move32(); - FOR( i = max( hStereoDft->band_limits[b], bin0 ); i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) + len = s_min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k >> 1 ); + FOR( i = s_max( hStereoDft->band_limits[b], bin0 ); i < len; i++ ) // i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ) { dmx_nrg = L_add( dmx_nrg, L_shr( Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ), 1 ) ); /* 2 * q_dft - 31 - 1 */ @@ -3269,8 +3279,8 @@ void stereo_dft_generate_res_pred_fx( g2 = L_min( Mpy_32_16_1( pred_gain_avg, STEREO_DFT_STEFFI_GAIN_AMP_FX ), Madd_32_16( Mpy_32_16_1( pred_gain_avg, sub( (Word16) ( 0x7FFF ), STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ), g2, STEREO_DFT_STEFFI_GAIN_REST_AMT_FX ) ); /* Q31 */ - - FOR( i = max( hStereoDft->band_limits[b], bin0 ); i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) + len = s_min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k >> 1 ); + FOR( i = s_max( hStereoDft->band_limits[b], bin0 ); i < len; i++ ) // i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ) { DFT_PRED_RES[2 * i] = Mpy_32_32( g2, DFT_PRED_RES[2 * i] ); /* Q31 */ move32(); diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 1e8bef488..44439540f 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1341,8 +1341,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } /* Init current 2-tuple encoding */ - a1 = (Word16) abs( x[a1_i] ); - b1 = (Word16) abs( x[b1_i] ); + a1 = abs_s( x[a1_i] ); + b1 = abs_s( x[b1_i] ); lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); bit_estimate_fx = W_add( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) ); @@ -1731,7 +1731,8 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( /* Main Loop through the 2-tuples */ /*hContextMem->nt_half = end_line >> 1;*/ - FOR( k = start_line; k < min( hContextMem->lastnz, end_line ); k += 2 ) + Word16 len = s_min( hContextMem->lastnz, end_line ); + FOR( k = start_line; k < len; k += 2 ) { a1_i = k; /* Q0 */ move16(); diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 307d42078..2db8b956b 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -3039,7 +3039,7 @@ void FdCngEncodeMDCTStereoSID_fx( /* quantize channel coherence */ coh_idx = mult_r( sts[0]->hFdCngEnc->hFdCngCom->coherence_fx, 15 ); - coh_idx = max( 0, min( coh_idx, 15 ) ); + coh_idx = s_max( 0, s_min( coh_idx, 15 ) ); /* ---- Write SID bitstream ---- */ diff --git a/lib_enc/ivas_agc_enc_fx.c b/lib_enc/ivas_agc_enc_fx.c index 37d25c508..104eeb998 100644 --- a/lib_enc/ivas_agc_enc_fx.c +++ b/lib_enc/ivas_agc_enc_fx.c @@ -623,7 +623,7 @@ void ivas_agc_enc_process_fx( temp_16 = BASOP_Util_Divide3232_Scale( temp1, temp2, &div_e ); /* exp(div_e) */ IF( div_e < 0 ) { - temp_16 = shr( temp_16, (Word16) abs( div_e ) ); + temp_16 = shr( temp_16, abs_s( div_e ) ); div_e = 0; move16(); } diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index a9da7f342..73403a848 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -184,7 +184,7 @@ ivas_error pre_proc_ivas_fx( } 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, max( st->input_bwidth, WB ), flag_1 ); + configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), flag_1 ); } if ( st->ini_frame == 0 ) diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 811e53d12..a9d62a2b0 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -856,7 +856,7 @@ ivas_error ivas_cpe_enc_fx( } ELSE { - internal_Fs = max( INT_FS_16k, sts[0]->sr_core ); + internal_Fs = L_max( INT_FS_16k, sts[0]->sr_core ); } /* iDFT at input sampling rate */ diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 3eeb45d14..c65c85356 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -493,7 +493,7 @@ ivas_error ivas_init_encoder( if ( NE_32( ivas_format, MONO_FORMAT ) ) { /* In IVAS, ensure that minimum coded bandwidth is WB */ - hEncoderConfig->max_bwidth = max( hEncoderConfig->max_bwidth, WB ); /* Q0 */ + hEncoderConfig->max_bwidth = s_max( hEncoderConfig->max_bwidth, WB ); /* Q0 */ move16(); } st_ivas->ism_mode = ISM_MODE_NONE; diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 86237fb31..11056b535 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -170,17 +170,17 @@ static void ivas_lfe_enc_quant_fx( { temp_lfe_dct[4 * i] = pLfe_dct[2 * i]; move32(); - lfe_abs_sum = W_add( lfe_abs_sum, abs( temp_lfe_dct[4 * i] ) ); + lfe_abs_sum = W_add( lfe_abs_sum, L_abs( temp_lfe_dct[4 * i] ) ); temp_lfe_dct[4 * i + 1] = pLfe_dct[2 * i + 1]; move32(); - lfe_abs_sum = W_add( lfe_abs_sum, abs( temp_lfe_dct[4 * i + 1] ) ); + lfe_abs_sum = W_add( lfe_abs_sum, L_abs( temp_lfe_dct[4 * i + 1] ) ); temp_lfe_dct[4 * i + 2] = pLfe_dct[2 * i + num_dct_pass_bins]; move32(); - lfe_abs_sum = W_add( lfe_abs_sum, abs( temp_lfe_dct[4 * i + 2] ) ); + lfe_abs_sum = W_add( lfe_abs_sum, L_abs( temp_lfe_dct[4 * i + 2] ) ); temp_lfe_dct[4 * i + 3] = pLfe_dct[2 * i + num_dct_pass_bins + 1]; move32(); - lfe_abs_sum = W_add( lfe_abs_sum, abs( temp_lfe_dct[4 * i + 3] ) ); + lfe_abs_sum = W_add( lfe_abs_sum, L_abs( temp_lfe_dct[4 * i + 3] ) ); } IF( LE_64( lfe_abs_sum, W_shr( IVAS_LFE_ABS_SUM_FLT_THR_Q42, sub( 42, q_pLfe_dct ) ) ) ) @@ -250,9 +250,9 @@ static void ivas_lfe_enc_quant_fx( move16(); } - IF( LT_32( max_of_vals, abs( values[i] ) ) ) + IF( LT_32( max_of_vals, abs_s( values[i] ) ) ) { - max_of_vals = (Word16) abs( values[i] ); + max_of_vals = abs_s( values[i] ); move16(); } } @@ -475,8 +475,8 @@ void ivas_lfe_enc_fx( IF( GT_16( q_out1, q_out2 ) ) { - Scale_sig32( lfe_dct_fx + num_dct_pass_bins, num_dct_pass_bins, min( q_tmp2, sub( q_out1, q_out2 ) ) ); - q_out2 = add( q_out2, min( q_tmp2, sub( q_out1, q_out2 ) ) ); + Scale_sig32( lfe_dct_fx + num_dct_pass_bins, num_dct_pass_bins, s_min( q_tmp2, sub( q_out1, q_out2 ) ) ); + q_out2 = add( q_out2, s_min( q_tmp2, sub( q_out1, q_out2 ) ) ); IF( GT_16( q_out1, q_out2 ) ) { Scale_sig32( lfe_dct_fx, num_dct_pass_bins, sub( q_out2, q_out1 ) ); // q_out2 @@ -486,8 +486,8 @@ void ivas_lfe_enc_fx( } ELSE IF( LT_16( q_out1, q_out2 ) ) { - Scale_sig32( lfe_dct_fx, num_dct_pass_bins, min( q_tmp1, sub( q_out2, q_out1 ) ) ); - q_out1 = add( q_out1, min( q_tmp1, sub( q_out2, q_out1 ) ) ); + Scale_sig32( lfe_dct_fx, num_dct_pass_bins, s_min( q_tmp1, sub( q_out2, q_out1 ) ) ); + q_out1 = add( q_out1, s_min( q_tmp1, sub( q_out2, q_out1 ) ) ); IF( LT_16( q_out1, q_out2 ) ) { Scale_sig32( lfe_dct_fx + num_dct_pass_bins, num_dct_pass_bins, sub( q_out1, q_out2 ) ); // q_out1 diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c index 9060c786b..abd09cbbd 100644 --- a/lib_enc/ivas_mc_paramupmix_enc_fx.c +++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c @@ -201,7 +201,7 @@ ivas_error ivas_mc_paramupmix_enc_open_fx( /* still 1.5ms off, since MCT delay is not large enough */ /* param at end of frame */ fb_cfg->prior_input_length = (Word16) ( NS2SA_FX2( input_Fs, 12000000L ) + NS2SA_FX2( input_Fs, DELAY_FB_4_NS / 2 ) - input_frame / 2 - NS2SA_FX2( input_Fs, DELAY_FB_1_NS / 2 ) ); - fb_cfg->prior_input_length = (Word16) max( fb_cfg->prior_input_length, input_frame / MAX_PARAM_SPATIAL_SUBFRAMES ); + fb_cfg->prior_input_length = s_max( fb_cfg->prior_input_length, (Word16) input_frame / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Allocate and initialize FB mixer handle */ IF( NE_32( ( error = ivas_FB_mixer_open_fx( &( hMCParamUpmix->hFbMixer ), input_Fs, fb_cfg, 0 ) ), IVAS_ERR_OK ) ) @@ -496,12 +496,12 @@ static void quantize_pars_fx( Word16 exp_var1 = 0; move16(); Word32 var1 = BASOP_Util_Add_Mant32Exp( v_fx[iv], exp_v, L_negate( data_fx[iq0] ), 31 - Q28, &exp_var1 ); - var1 = abs( var1 ); + var1 = L_abs( var1 ); Word16 exp_var2 = 0; move16(); Word32 var2 = BASOP_Util_Add_Mant32Exp( v_fx[iv], exp_v, L_negate( data_fx[iq1] ), 31 - Q28, &exp_var2 ); - var2 = abs( var2 ); + var2 = L_abs( var2 ); Word16 cmp_2 = BASOP_Util_Cmp_Mant32Exp( var1, exp_var1, var2, exp_var2 ); @@ -591,12 +591,12 @@ static void quantize_beta_fx( Word16 exp_var1 = 0; move16(); Word32 var1 = BASOP_Util_Add_Mant32Exp( beta_fx[iv], exp_beta, L_negate( quant_table_fx.data[iq0] ), 31 - Q28, &exp_var1 ); - var1 = abs( var1 ); + var1 = L_abs( var1 ); Word16 exp_var2 = 0; move16(); Word32 var2 = BASOP_Util_Add_Mant32Exp( beta_fx[iv], exp_beta, L_negate( quant_table_fx.data[iq1] ), 31 - Q28, &exp_var2 ); - var2 = abs( var2 ); + var2 = L_abs( var2 ); Word16 cmp_2 = BASOP_Util_Cmp_Mant32Exp( var1, exp_var1, var2, exp_var2 ); diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 648dcdb73..1229624de 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -300,7 +300,7 @@ ivas_error ivas_osba_enc_reconfig( } } - ivas_spar_config_fx( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + ivas_spar_config_fx( ivas_total_brate, s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); hSpar = st_ivas->hSpar; diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 7a2a28767..3416ab279 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -4089,7 +4089,8 @@ static ivas_error requantize_direction_EC_3_fx( IF( LE_16( allowed_bits, add( no_subframes, 1 ) ) ) { - FOR( k = 0; k < min( no_subframes, allowed_bits ); k++ ) + Word16 len = s_min( no_subframes, allowed_bits ); + FOR( k = 0; k < len; k++ ) { push_next_indice( hMetaData, q_direction->band_data[j].azimuth_index[k], 1 ); } diff --git a/lib_enc/ivas_sba_enc_fx.c b/lib_enc/ivas_sba_enc_fx.c index 86427eb2d..8fdca5815 100644 --- a/lib_enc/ivas_sba_enc_fx.c +++ b/lib_enc/ivas_sba_enc_fx.c @@ -199,7 +199,7 @@ ivas_error ivas_sba_enc_reconfigure_fx( } } - ivas_spar_config_fx( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + ivas_spar_config_fx( ivas_total_brate, s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); hSpar = st_ivas->hSpar; diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index 7900033f4..862102d3b 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -547,7 +547,8 @@ static Word32 calc_mean_E_ratio_fx( sum_nrg_R_e = 0; move16(); - FOR( i = band_limits[b]; i < min( band_limits[b + 1], STEREO_DFT_N_32k_ENC / 2 ); i++ ) + Word16 len = s_min( band_limits[b + 1], STEREO_DFT_N_32k_ENC >> 1 ); + FOR( i = band_limits[b]; i < len; i++ ) { // sum_xcorr[0] += hItd->xcorr_smooth[2 * i]; sum_xcorr[0] = BASOP_Util_Add_Mant32Exp( sum_xcorr[0], sum_xcorr_e[0], hItd->xcorr_smooth_fx[2 * i], hItd->xcorr_smooth_fx_e[2 * i], &sum_xcorr_e[0] ); @@ -2568,7 +2569,11 @@ void stereo_dft_enc_compute_itd_fx( prev_itd_max = hItd->hybrid_itd_max; move16(); /* enable hybrid ITD handling for very large ITDs*/ - hItd->hybrid_itd_max = ( abs( itd ) > STEREO_DFT_ITD_MAX && abs( itd ) < STEREO_DFT_ITD_MAX_ANA && !hCPE->hCoreCoder[0]->sp_aud_decision0 && hCPE->element_brate < IVAS_32k ); + // hItd->hybrid_itd_max = ( abs_s( itd ) > STEREO_DFT_ITD_MAX && abs_s( itd ) < STEREO_DFT_ITD_MAX_ANA && !hCPE->hCoreCoder[0]->sp_aud_decision0 && hCPE->element_brate < IVAS_32k ); + test(); + test(); + test(); + hItd->hybrid_itd_max = ( GT_16( abs_s( itd ), STEREO_DFT_ITD_MAX ) && LT_16( abs_s( itd ), STEREO_DFT_ITD_MAX_ANA ) && !hCPE->hCoreCoder[0]->sp_aud_decision0 && LT_32( hCPE->element_brate, IVAS_32k ) ); move16(); /* Update memory */ hItd->prev_itd = itd; diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index a3388db61..c3cb68719 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -1203,7 +1203,7 @@ static Word32 find_poc_peak_fx( /*compute peak_range*/ tmp1 = idiv1616( hPOC->shift_limit, STEREO_DMX_EVS_FIND_POC_PEAK_TAU ); - peak_range = idiv1616( add( extract_l( abs( itd_cand[n] ) ), tmp1 ), STEREO_DMX_EVS_FIND_POC_PEAK_TAU2 ); // Q0 + peak_range = idiv1616( add( extract_l( abs_s( itd_cand[n] ) ), tmp1 ), STEREO_DMX_EVS_FIND_POC_PEAK_TAU2 ); // Q0 FOR( i = 1; i <= peak_range; i++ ) { @@ -1250,7 +1250,7 @@ static Word32 find_poc_peak_fx( IF( on[n] ) /*if channel n was active (likely to be preceding) in the previous frame*/ { tmp13_e = 0, tmp15_e = 0; - tmp13 = BASOP_Util_Divide1616_Scale( (Word16) abs( itd_cand[n] ), hPOC->shift_limit, &tmp13_e ); + tmp13 = BASOP_Util_Divide1616_Scale( abs_s( itd_cand[n] ), hPOC->shift_limit, &tmp13_e ); tmp14 = L_mult( 6554 /*0.2f Q15*/, tmp13 ); // tmp13_e tmp15 = BASOP_Util_Add_Mant32Exp( 644245120 /*0.75f in Q31*/, 0, L_negate( tmp14 ), tmp13_e, &tmp15_e ); tmp15 = Mpy_32_32( tmp15, peakQ_fx[n] ); // tmp15_e + peakQ_e[n] @@ -1299,7 +1299,7 @@ static Word32 find_poc_peak_fx( tmp13_e = 0, tmp15_e = 0; move16(); move16(); - tmp13 = BASOP_Util_Divide1616_Scale( (Word16) abs( itd_cand[n] ), hPOC->shift_limit, &tmp13_e ); + tmp13 = BASOP_Util_Divide1616_Scale( abs_s( itd_cand[n] ), hPOC->shift_limit, &tmp13_e ); tmp14 = L_mult( 6554 /*0.2f Q15*/, tmp13 ); // tmp13_e tmp15 = BASOP_Util_Add_Mant32Exp( 1610612736 /*0.75f in Q31*/, 0, L_negate( tmp14 ), tmp13_e, &tmp15_e ); diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index 351b87cd0..78c324cce 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -1737,7 +1737,7 @@ void stereo_tca_enc_fx( prev_ICA_flag = 0; move16(); test(); - if ( hCPE->hStereoTD->prev_fr_LRTD_TD_dec && abs( hStereoTCA->prevCorrLagStats[2] ) != 0 ) + if ( hCPE->hStereoTD->prev_fr_LRTD_TD_dec && abs_s( hStereoTCA->prevCorrLagStats[2] ) != 0 ) { prev_ICA_flag = 1; move16(); @@ -1924,7 +1924,7 @@ void stereo_tca_enc_fx( /* Note!! : Always keep the assert (prevNCShift>>1) below according to the equation used here to get tempS */ tempS = shr( currentNCShift, 1 ); /* Q0 */ - IF( LE_32( abs( sub( currentNCShift, prevNCShift ) ), L_min( N_MAX_SHIFT_CHANGE, Mpy_32_32( imult3216( input_Fs, N_MAX_SHIFT_CHANGE ), 67109 /* 1/32000.0f in Q31*/ ) ) ) ) + IF( LE_32( abs_s( sub( currentNCShift, prevNCShift ) ), L_min( N_MAX_SHIFT_CHANGE, Mpy_32_32( imult3216( input_Fs, N_MAX_SHIFT_CHANGE ), 67109 /* 1/32000.0f in Q31*/ ) ) ) ) { adjustTargetSignal_fx( ( target_fx - tempS ), prevNCShift, currentNCShift, L_shift_adapt, 0 ); } diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index f3ceb2757..6513a3fa7 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -241,7 +241,7 @@ ivas_error stereo_memory_enc_fx( IF( hCPE->hStereoTCA != NULL && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { #ifdef FIX_1132_STACK_CORRUPTION - Word16 tmp = extract_h( abs( hCPE->hStereoDft->hItd->itd_fx[1] ) ); + Word16 tmp = extract_h( L_abs( hCPE->hStereoDft->hItd->itd_fx[1] ) ); if ( hCPE->hStereoDft->hItd->itd_fx[1] < 0 ) { tmp = negate( tmp ); diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index 4ea5c5e96..32803f6c3 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -949,8 +949,8 @@ void ivas_dirac_dec_decorr_process_fx( h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = add( h_freq_domain_decorr_ap_state->q_reverb_energy_smooth, q_shift ); move16(); } - h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); - h_freq_domain_decorr_ap_state->q_direct_energy_smooth = min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_direct_energy_smooth ); + h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = s_min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); + h_freq_domain_decorr_ap_state->q_direct_energy_smooth = s_min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_direct_energy_smooth ); #endif e_reverb_energy_smooth = sub( 31, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 882c6e5b8..cc8e4d8bd 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -3811,7 +3811,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, hDirACRend->num_protos_diff, hDirACRend->proto_index_diff, - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff + 2 * hSpatParamRendCom->num_freq_bands * min( 4, nchan_transport ), + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff + 2 * hSpatParamRendCom->num_freq_bands * s_min( 4, nchan_transport ), &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, onset_filter_fx, hDirACRend->h_freq_domain_decorr_ap_params, diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index 652fc898f..45e492fc8 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -740,7 +740,7 @@ void ivas_reverb_calc_color_levels_fx( Word16 temp = 0, result_e = 0; move16(); move16(); - cos_w = getCosWord16R2( (Word16) abs( L_shl( Mpy_32_32( pFc[freq_idx], fs_inverted ), 3 ) ) ); // q = 15 + cos_w = getCosWord16R2( (Word16) L_abs( L_shl( Mpy_32_32( pFc[freq_idx], fs_inverted ), 3 ) ) ); // q = 15 H_filter = L_add( L_shr( L_add( L_shr( Mpy_32_32( coefB[0], coefB[0] ), 1 ), L_shr( Mpy_32_32( coefB[1], coefB[1] ), 1 ) ), 2 ), L_shr( Mpy_32_32( coefB[0], Mpy_32_32( coefB[1], L_shl( cos_w, 15 ) ) ), 1 ) ); // q = 28 H_filter = BASOP_Util_Divide3232_Scale_cadence( H_filter, L_add( ONE_IN_Q28, L_shr( L_add( L_shr( Mpy_32_32( coefA[1], coefA[1] ), 2 ), Mpy_32_32( coefA[1], L_shl( cos_w, 15 ) ) ), 1 ) ), &temp ); H_filter = Sqrt32( H_filter, &temp ); @@ -1155,9 +1155,9 @@ void ivas_reverb_get_hrtf_set_properties_fx( IA_coherence[freq_idx] = L_shl( IA_coherence[freq_idx], sub( 27, sub( 15, temp ) ) ); // q = 27 move32(); /* Limiting to (0...1) range in case of small numerical errors or negative values */ - IA_coherence[freq_idx] = min( IA_coherence[freq_idx], ONE_IN_Q27 ); // Q27 + IA_coherence[freq_idx] = L_min( IA_coherence[freq_idx], ONE_IN_Q27 ); // Q27 move32(); - IA_coherence[freq_idx] = max( IA_coherence[freq_idx], 0 ); // Q27 + IA_coherence[freq_idx] = L_max( IA_coherence[freq_idx], 0 ); // Q27 move32(); } diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 7ad4c4ccb..8b352218b 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -399,7 +399,7 @@ void rotateAziEle_fx( angle = extract_l( L_shr( Mpy_32_16_1( _180_OVER_PI_Q25, radian ), 24 ) ); // Q0 } - *azi = s_max( -180, min( 180, angle ) ); + *azi = s_max( -180, s_min( 180, angle ) ); move16(); IF( isPlanar == 0 ) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 0cda39d62..ae3166520 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1177,8 +1177,8 @@ static Word8 checkObjectPositionChanged_fx( IVAS_ISM_METADATA *previousPos ) { test(); - return !( LT_32( abs( L_sub( currentPos->azimuth_fx, previousPos->azimuth_fx ) ), EPSILLON_FX ) && - LT_32( abs( L_sub( currentPos->elevation_fx, previousPos->elevation_fx ) ), EPSILLON_FX ) ); + return !( LT_32( L_abs( L_sub( currentPos->azimuth_fx, previousPos->azimuth_fx ) ), EPSILLON_FX ) && + LT_32( L_abs( L_sub( currentPos->elevation_fx, previousPos->elevation_fx ) ), EPSILLON_FX ) ); } static rendering_context getRendCtx( @@ -2018,7 +2018,7 @@ static ivas_error updateMcPanGainsForAmbiOut( Word32 temp = inputMc->panGains_fx[ch_out][i]; move32(); - IF( GE_32( abs( temp ), ONE_IN_Q29 ) ) + IF( GE_32( L_abs( temp ), ONE_IN_Q29 ) ) { IF( temp > 0 ) { @@ -2066,7 +2066,7 @@ static ivas_error updateMcPanGainsForAmbiOut( { Word32 temp = inputMc->panGains_fx[ch_out][i]; move32(); - IF( GE_32( abs( temp ), ONE_IN_Q29 ) ) + IF( GE_32( L_abs( temp ), ONE_IN_Q29 ) ) { IF( temp > 0 ) { @@ -4537,7 +4537,7 @@ static void renderBufferChannelLerp_fx( /* Process current output channel only if applying non-zero gains */ test(); test(); - IF( GT_32( abs( currentGain ), EPSILON_FX ) || ( gainsPrev != NULL && GT_32( abs( previousGain ), EPSILON_FX ) ) ) + IF( GT_32( L_abs( currentGain ), EPSILON_FX ) || ( gainsPrev != NULL && GT_32( L_abs( previousGain ), EPSILON_FX ) ) ) { /* Reset input pointer to the beginning of input channel */ inSmpl = getSmplPtr_fx( inAudio, inChannelIdx, 0 ); @@ -4546,7 +4546,7 @@ static void renderBufferChannelLerp_fx( outSmpl = getSmplPtr_fx( outAudio, outChnlIdx, 0 ); test(); - IF( gainsPrev == NULL || LE_32( abs( L_sub( L_shr( previousGain, 1 ), L_shr( currentGain, 1 ) ) ), EPSILON_FX ) ) + IF( gainsPrev == NULL || LE_32( L_abs( L_sub( L_shr( previousGain, 1 ), L_shr( currentGain, 1 ) ) ), EPSILON_FX ) ) { /* If no interpolation from previous frame, apply current gain */ DO -- GitLab From 7a5cb1ab39d2b4053aa3ad960201a0e82542acb7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 7 Mar 2025 10:45:15 +0530 Subject: [PATCH 48/97] Fix for 3GPP issue 1347: Saturation of energies memory for dtx path Link #1347 --- lib_enc/ivas_core_pre_proc_front_fx.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index f41eb7f9c..46de4e232 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1016,14 +1016,14 @@ ivas_error pre_proc_front_ivas_fx( Word16 msNoiseEst_Q = Q31; move16(); move16(); - zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_fx, NPART ); + zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); IF( zero_flag ) { - msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_fx, NPART ); + msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); + scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */ + st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q ); + move16(); } - Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */ - st->hFdCngEnc->msNoiseEst_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q ); - move16(); perform_noise_estimation_enc_ivas_fx( band_energies_LR_fx, sub( Q31, band_energies_LR_fx_q ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE ); } ELSE @@ -1049,14 +1049,14 @@ ivas_error pre_proc_front_ivas_fx( move16(); Word16 msNoiseEst_Q = Q31; move16(); - zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_fx, NPART ); /* Q0 */ + zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); /* Q0 */ IF( zero_flag ) { - msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_fx, NPART ); + msNoiseEst_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); + scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */ + st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q ); + move16(); } - Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); /* exp(st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_Q) */ - st->hFdCngEnc->msNoiseEst_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q ); - move16(); zero_flag = get_zero_flag( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN ); /* Q0 */ Word16 normmsperiodog = 31; move16(); -- GitLab From 9a19ecf2e21bcafd8553cce25ad5e0154b88399c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 7 Mar 2025 11:49:53 +0530 Subject: [PATCH 49/97] ASAN issue fix for decoder --- lib_dec/evs_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index aa997d4c0..f20ff77f3 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -36,7 +36,7 @@ ivas_error evs_dec_fx( Word16 exp, fra; Word16 tmp_buffer_fx[L_FRAME48k]; Word16 tmp16, tmp16_2; - Word16 synth_fx[L_FRAME48k]; + Word16 synth_fx[L_FRAME48k + HQ_DELTA_MAX * HQ_DELAY_COMP]; Word16 fb_exc_fx[L_FRAME16k]; Word16 pitch_buf_fx[NB_SUBFR16k] = { 0 }; Word16 Q_fb_exc; -- GitLab From 99ee84bae7b22a7366a33bbf804308b8eb0ce60f Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 7 Mar 2025 10:16:53 +0100 Subject: [PATCH 50/97] port FIX_923_EXTERNAL_REND_COMMAND_LINE --- lib_com/options.h | 1 + lib_util/cmdln_parser.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 8eb059537..b57c3beb6 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -181,6 +181,7 @@ #define SPLIT_REND_POSE_CORRECTION_UNUSED_BITS #define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ #endif +#define FIX_923_EXTERNAL_REND_COMMAND_LINE /* VA: issue 923: enable external renderer command-line options in UPPER case letters */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_util/cmdln_parser.c b/lib_util/cmdln_parser.c index b2c8f85bc..432db36a5 100644 --- a/lib_util/cmdln_parser.c +++ b/lib_util/cmdln_parser.c @@ -150,7 +150,26 @@ static int8_t optionMatchesString( const char *optionName = stringToOptionName( str ); +#ifdef FIX_923_EXTERNAL_REND_COMMAND_LINE + char optionName_to_upper[FILENAME_MAX]; + strncpy( optionName_to_upper, optionName, sizeof( optionName_to_upper ) - 1 ); + optionName_to_upper[sizeof( optionName_to_upper ) - 1] = '\0'; + to_upper( optionName_to_upper ); + + char match_to_upper[FILENAME_MAX]; + strncpy( match_to_upper, opt.props.match, sizeof( match_to_upper ) - 1 ); + optionName_to_upper[sizeof( match_to_upper ) - 1] = '\0'; + to_upper( match_to_upper ); + + char matchShort_to_upper[FILENAME_MAX]; + strncpy( matchShort_to_upper, opt.props.matchShort, sizeof( matchShort_to_upper ) - 1 ); + optionName_to_upper[sizeof( matchShort_to_upper ) - 1] = '\0'; + to_upper( matchShort_to_upper ); + + if ( strncmp( optionName_to_upper, match_to_upper, MAX_OPTION_LENGTH ) == 0 || strncmp( optionName_to_upper, matchShort_to_upper, MAX_OPTION_LENGTH ) == 0 ) +#else if ( strncmp( optionName, opt.props.match, MAX_OPTION_LENGTH ) == 0 || strncmp( optionName, opt.props.matchShort, MAX_OPTION_LENGTH ) == 0 ) +#endif { return 1; } -- GitLab From 7ad3ba2cbf01ffbfc70feb1c499fceafa669cda1 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 7 Mar 2025 14:58:16 +0530 Subject: [PATCH 51/97] Fix for LTV crash issue Fix for LTV crash : 4 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, DTX on, BINAURAL ROOM IR out, random FER at 5% --- lib_dec/dec_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 00f372154..191065855 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3807,7 +3807,7 @@ void decoder_tcx_invQ_fx( FOR( i = 0; i < noiseFillingSize; ++i ) { tmp32 = L_shr( x[i], sub( 31, *x_e ) ); - *nf_seed = add_o( *nf_seed, shl( i_mult( (Word16) L_abs( tmp32 ), i ), 1 ), &Overflow ); // abs( tmp32 ) * i * 2 + *nf_seed = add_o( *nf_seed, extract_l( L_shl( i_mult( (Word16) L_abs( tmp32 ), i ), 1 ) ), &Overflow ); // abs( tmp32 ) * i * 2 move16(); } } -- GitLab From 617ebe4d741ed8b312a516dd000bcbd481cebddd Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 7 Mar 2025 10:49:04 +0100 Subject: [PATCH 52/97] port FIX_921_OMASA_DELAY_PRINTOUT --- lib_com/options.h | 1 + lib_dec/lib_dec_fx.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 8eb059537..0685b3ae8 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -181,6 +181,7 @@ #define SPLIT_REND_POSE_CORRECTION_UNUSED_BITS #define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ #endif +#define FIX_921_OMASA_DELAY_PRINTOUT /* VA: issue 921: correct OMASA decoder delay printout */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 9753893e2..23cd54a62 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2843,7 +2843,12 @@ ivas_error IVAS_DEC_GetDelay( nSamples[0] = add( nSamples[1], nSamples[2] ); move16(); +#ifdef FIX_921_OMASA_DELAY_PRINTOUT + test(); + IF( EQ_16( (Word16) st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( (Word16) st_ivas->ivas_format, MASA_ISM_FORMAT ) ) +#else IF( EQ_16( (Word16) st_ivas->ivas_format, MASA_FORMAT ) ) +#endif { /* note: in MASA, all delay is compensated at the decoder by default, so subtract the encoder delay for print-out */ nSamples[1] = sub( nSamples[1], NS2SA_FX2( hDecoderConfig->output_Fs, IVAS_ENC_DELAY_NS ) ); -- GitLab From 2687fb430e76ef5d563281f682de1edf86bd5448 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 7 Mar 2025 11:14:59 +0100 Subject: [PATCH 53/97] run clang-format --- lib_dec/ivas_binRenderer_internal_fx.c | 10 +- lib_dec/lib_dec_fx.c | 184 ++++++++++++------------- 2 files changed, 96 insertions(+), 98 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index e3a66da49..192d42033 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1857,8 +1857,8 @@ void ivas_binRenderer_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, #endif - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - const Word16 numTimeSlots, /* i : number of time slots to render */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ + const Word16 numTimeSlots, /* i : number of time slots to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ @@ -1866,9 +1866,9 @@ void ivas_binRenderer_fx( Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ #endif - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word16 *Q_in /* i : LS signals exp */ + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word16 *Q_in /* i : LS signals exp */ ) { Word16 chIdx, i, j, k; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index df3981a37..80eff327c 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1183,125 +1183,123 @@ ivas_error IVAS_DEC_GetSamples( { /* check if we need to run the setup function */ test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) - { + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ){ /* setup */ - IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ){ + return error; + } +} +{ + /* check if we need to run the setup function, tc decoding and feeding the renderer */ + test(); + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) + { + Word16 nResidualSamples, nSamplesTcsScaled; + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + + test(); + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) + { + IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) { return error; } } - { - /* check if we need to run the setup function, tc decoding and feeding the renderer */ - test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) - { - Word16 nResidualSamples, nSamplesTcsScaled; - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - test(); - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) - { - IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) - { - return error; - } - } + /* IVAS decoder */ + IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* IVAS decoder */ - IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* JBM */ + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } - /* JBM */ - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + // tmp apaExecBuffer + IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) + { + Word16 tmp_apaExecBuffer[APA_BUF]; + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) { - IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - - // tmp apaExecBuffer - IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) - { - Word16 tmp_apaExecBuffer[APA_BUF]; - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) - { - tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 - } - IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) - { - hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 - } - } - ELSE - { - IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - } - assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); - nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); + tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 } - ELSE + IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) { - nSamplesTcsScaled = hIvasDec->nSamplesFrame; - move16(); + return IVAS_ERR_UNKNOWN; } - - /* Feed decoded transport channels samples to the renderer */ - IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) { - return error; + hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 } - - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + } + ELSE + { + IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) { - /* feed residual samples to TSM for the next call */ - IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } + return IVAS_ERR_UNKNOWN; } - hIvasDec->hasBeenFedFrame = false; - move16(); } + assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); + nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); + } + ELSE + { + nSamplesTcsScaled = hIvasDec->nSamplesFrame; + move16(); + } - /* render IVAS frames directly to the output buffer */ - nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); - IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* Feed decoded transport channels samples to the renderer */ + IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) + { + return error; + } - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); - IF( hIvasDec->nSamplesAvailableNext == 0 ) - { - *needNewFrame = true; - hIvasDec->needNewFrame = true; - move16(); - move16(); - } - ELSE + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + /* feed residual samples to TSM for the next call */ + IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) { - *needNewFrame = false; - move16(); + return IVAS_ERR_UNKNOWN; } } + hIvasDec->hasBeenFedFrame = false; + move16(); } - *nOutSamples = nSamplesRendered; - move16(); + /* render IVAS frames directly to the output buffer */ + nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); + IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) + { + return error; + } - return IVAS_ERR_OK; + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); + IF( hIvasDec->nSamplesAvailableNext == 0 ) + { + *needNewFrame = true; + hIvasDec->needNewFrame = true; + move16(); + move16(); + } + ELSE + { + *needNewFrame = false; + move16(); + } +} +} + +*nOutSamples = nSamplesRendered; +move16(); + +return IVAS_ERR_OK; } -- GitLab From 40d41173a5b485a8aa746d775b8dd7d6c5fd9c13 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 7 Mar 2025 12:24:09 +0100 Subject: [PATCH 54/97] fix compilation --- apps/renderer.c | 2 +- lib_com/ivas_rotation_com.c | 2 +- lib_com/options.h | 2 +- lib_dec/ivas_binRenderer_internal_fx.c | 15 +++--- lib_dec/ivas_mc_param_dec_fx.c | 65 +++++++++++++++++++++++++ lib_isar/isar_NoiseGen.c | 2 +- lib_isar/isar_PerceptualModel.c | 2 +- lib_isar/isar_PredDecoder.c | 2 +- lib_isar/isar_PredEncoder.c | 2 +- lib_isar/isar_RMSEnvGrouping.c | 2 +- lib_isar/isar_lc3plus_dec.c | 2 +- lib_isar/isar_lc3plus_enc.c | 2 +- lib_isar/isar_lcld_decoder.c | 2 +- lib_isar/isar_lcld_encoder.c | 2 +- lib_isar/isar_lcld_prot.h | 1 - lib_isar/isar_lcld_rom_tables.c | 2 +- lib_isar/isar_splitRend_lcld_dec.c | 2 +- lib_isar/isar_splitRendererPLC.c | 2 +- lib_isar/isar_splitRendererPost.c | 2 +- lib_isar/isar_splitRendererPre.c | 2 +- lib_isar/isar_splitRenderer_utils.c | 2 +- lib_isar/lib_isar_post_rend.c | 2 +- lib_isar/lib_isar_pre_rend.c | 2 +- lib_rend/ivas_stat_rend.h | 7 ++- lib_util/split_rend_bfi_file_reader.c | 2 +- lib_util/split_render_file_read_write.c | 2 +- 26 files changed, 102 insertions(+), 30 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 365d45689..0ee2ac94d 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -3918,8 +3918,8 @@ static void convertInputBuffer_fx( ++i; } } - *out_q_factor = in_q_factor; #ifdef SPLIT_REND_WITH_HEAD_ROT + *out_q_factor = in_q_factor; } #endif diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index e6f1808e4..d33d3119d 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -36,7 +36,7 @@ #include "options.h" #include #include "cnst.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING diff --git a/lib_com/options.h b/lib_com/options.h index 7aeea040f..0320c6a57 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -181,5 +181,5 @@ //#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ #define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ -#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ +//#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ #endif diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 192d42033..81608189d 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -98,6 +98,7 @@ static void ivas_binRenderer_filterModule_fx( #ifndef OPT_BASOP_ADD_v1 Q_filterStates = (Word16 *) &( hBinRenderer->hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx][0] ); #endif /* OPT_BASOP_ADD_v1 */ +#endif /* SPLIT_REND_WITH_HEAD_ROT */ filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 @@ -153,7 +154,7 @@ static void ivas_binRenderer_filterModule_fx( #ifdef OPT_BASOP_ADD_v1 IF( shift_q != 0 ) { -#endif /* OPT_BASOP_ADD_v1 */ +#endif /* OPT_BASOP_ADD_v1 */ outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr @@ -532,6 +533,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( #else /* OPT_BASOP_ADD_v1 */ set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); #endif /* OPT_BASOP_ADD_v1 */ +#endif /* !SPLIT_REND_WITH_HEAD_ROT */ IF( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; @@ -552,6 +554,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( #else /* OPT_BASOP_ADD_v1 */ set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); #endif /* OPT_BASOP_ADD_v1 */ +#endif /* SPLIT_REND_WITH_HEAD_ROT */ IF( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; @@ -1857,8 +1860,8 @@ void ivas_binRenderer_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, #endif - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - const Word16 numTimeSlots, /* i : number of time slots to render */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ + const Word16 numTimeSlots, /* i : number of time slots to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ @@ -1866,9 +1869,9 @@ void ivas_binRenderer_fx( Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ #endif - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word16 *Q_in /* i : LS signals exp */ + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word16 *Q_in /* i : LS signals exp */ ) { Word16 chIdx, i, j, k; diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 897fd4433..f407baf2e 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1843,8 +1843,13 @@ void ivas_param_mc_dec_render_fx( /*CLDFB*/ Word32 Cldfb_RealBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#ifdef SPLIT_REND_WITH_HEAD_ROT + Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#else Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; +#endif Word32 *p_output_f_fx[MAX_OUTPUT_CHANNELS]; FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { @@ -2178,8 +2183,31 @@ void ivas_param_mc_dec_render_fx( { Word16 input_q = 6; move16(); + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + IF( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) + { + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + FOR( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) + { + Copy32( Cldfb_RealBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_RealBuffer_fx[ch][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_fx[ch][slot_idx], st_ivas->hSplitBinRend->hCldfbDataOut->Cldfb_ImagBuffer_fx[ch][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); + } + } + st_ivas->hSplitBinRend->hCldfbDataOut->config = st_ivas->hIntSetup.output_config; + move16(); + } + } +#endif + /* Implement binaural rendering */ ivas_binRenderer_fx( st_ivas->hBinRenderer, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, +#endif st_ivas->hCombinedOrientationData, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, @@ -2198,6 +2226,20 @@ void ivas_param_mc_dec_render_fx( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t pos_idx; + FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) + { + FOR( Word16 idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) + { + Scale_sig32( Cldfb_RealBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 + Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 + } + } + } +#else FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) { FOR( Word16 idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) @@ -2206,6 +2248,24 @@ void ivas_param_mc_dec_render_fx( Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 } } +#endif + +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) + { + FOR( slot_idx = 0; slot_idx < hParamMC->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) + { + Copy32( Cldfb_RealBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][ch][slot_idx], st_ivas->hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural_fx[add( i_mult( pos_idx, BINAURAL_CHANNELS ), ch )][add( slot_idx_start, slot_idx )], hParamMC->num_freq_bands ); + } + } + } + } +#endif /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); } @@ -2229,8 +2289,13 @@ void ivas_param_mc_dec_render_fx( { IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[0][ch][i]; // Q6 + ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[0][ch][i]; // Q6 +#else RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[ch][i]; // Q6 ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[ch][i]; // Q6 +#endif } ELSE { diff --git a/lib_isar/isar_NoiseGen.c b/lib_isar/isar_NoiseGen.c index b872e89c9..7273b0e81 100644 --- a/lib_isar/isar_NoiseGen.c +++ b/lib_isar/isar_NoiseGen.c @@ -34,7 +34,7 @@ #include "options.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include -#include "prot.h" +#include "prot_fx.h" #include "isar_lcld_prot.h" #include "wmc_auto.h" diff --git a/lib_isar/isar_PerceptualModel.c b/lib_isar/isar_PerceptualModel.c index ad3329500..16558dd36 100644 --- a/lib_isar/isar_PerceptualModel.c +++ b/lib_isar/isar_PerceptualModel.c @@ -34,7 +34,7 @@ #include "options.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_lcld_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "isar_lcld_rom_tables.h" #include #include "wmc_auto.h" diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c index c55a88011..b30a6e0a8 100644 --- a/lib_isar/isar_PredDecoder.c +++ b/lib_isar/isar_PredDecoder.c @@ -34,7 +34,7 @@ #include "options.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include -#include "prot.h" +#include "prot_fx.h" #include "isar_prot.h" #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c index 85dc5f8f8..0cd32b70c 100644 --- a/lib_isar/isar_PredEncoder.c +++ b/lib_isar/isar_PredEncoder.c @@ -36,7 +36,7 @@ #include #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" -#include "prot.h" +#include "prot_fx.h" #include "isar_prot.h" #include "wmc_auto.h" #include "prot_fx.h" diff --git a/lib_isar/isar_RMSEnvGrouping.c b/lib_isar/isar_RMSEnvGrouping.c index 3c40cb096..9b5de2574 100644 --- a/lib_isar/isar_RMSEnvGrouping.c +++ b/lib_isar/isar_RMSEnvGrouping.c @@ -36,7 +36,7 @@ #include "options.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include -#include "prot.h" +#include "prot_fx.h" #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" #include "wmc_auto.h" diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index bad857764..17143ec3b 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "isar_lc3plus_dec.h" #include "isar_lc3plus_common.h" diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index 2f9ab6f01..08ec7c0a8 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -34,7 +34,7 @@ #include "isar_lc3plus_common.h" #include "lc3.h" #include "ivas_error_utils.h" -#include "prot.h" +#include "prot_fx.h" #include "wmc_auto.h" #include "options.h" diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index 682176a91..a64a12aea 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -35,7 +35,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" -#include "prot.h" +#include "prot_fx.h" #include #include "isar_prot.h" #include "wmc_auto.h" diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index b9c60b8d4..48445d080 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -37,7 +37,7 @@ #include #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" -#include "prot.h" +#include "prot_fx.h" #include "prot_fx.h" #include "isar_prot.h" #include "wmc_auto.h" diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index fffeb6c5c..49e03f5ef 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -38,7 +38,6 @@ #include "typedef.h" #include "common_api_types.h" #include "isar_lcld_rom_tables.h" -// #include "prot.h" /* clang-format off */ typedef struct LCLD_ENCODER LCLDEncoder; diff --git a/lib_isar/isar_lcld_rom_tables.c b/lib_isar/isar_lcld_rom_tables.c index 3b35a3282..8ecf74336 100644 --- a/lib_isar/isar_lcld_rom_tables.c +++ b/lib_isar/isar_lcld_rom_tables.c @@ -34,7 +34,7 @@ #include "options.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include "wmc_auto.h" -#include "prot.h" +#include "prot_fx.h" #include "isar_lcld_prot.h" #include diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c index d275a0aff..d96e5b3ec 100644 --- a/lib_isar/isar_splitRend_lcld_dec.c +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -35,7 +35,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_prot.h" #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "prot_fx.h" //#include "control.h" #ifdef DEBUGGING diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index 037c43048..c5f5300af 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -35,7 +35,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "isar_cnst.h" #include "isar_prot.h" #include "enh64.h" diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 6f6af1484..f8cf7c571 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -39,7 +39,7 @@ #endif #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" +#include "prot_fx.h" #include "isar_rom_post_rend.h" #include "isar_prot.h" #ifdef DEBUGGING diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index a766418d1..74484eb62 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -39,7 +39,7 @@ #endif #include "ivas_prot.h" #include "ivas_prot_fx.h" -#include "prot.h" +#include "prot_fx.h" #include "lib_isar_pre_rend.h" #include "isar_rom_post_rend.h" #include "isar_prot.h" diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index fa51d44ef..0c4238ac6 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -35,7 +35,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "cnst.h" #include "isar_cnst.h" #include "ivas_rom_rend.h" diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index dd2884731..57317269a 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -35,7 +35,7 @@ #include "lib_isar_post_rend.h" #include "isar_stat.h" #include "isar_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index c44767404..367e0be5b 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -35,7 +35,7 @@ #include "options.h" #include #include "ivas_prot.h" -#include "prot.h" +#include "prot_fx.h" #include "prot_fx.h" #include "isar_cnst.h" #include "isar_rom_post_rend.h" diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 370a5452c..993ad40b2 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -667,7 +667,11 @@ typedef struct ivas_binaural_rendering_conv_module_struct_fx #ifdef SPLIT_REND_WITH_HEAD_ROT Word32 ****filterStatesLeftReal_fx; Word32 ****filterStatesLeftImag_fx; +#ifdef OPT_BASOP_ADD_v1 + Word16 Q_filterStatesLeft; +#else Word16 ****Q_filterStatesLeft; +#endif #else Word32 ***filterStatesLeftReal_fx; Word32 ***filterStatesLeftImag_fx; @@ -676,6 +680,7 @@ typedef struct ivas_binaural_rendering_conv_module_struct_fx #else /* OPT_BASOP_ADD_v1 */ Word16 ***Q_filterStatesLeft; #endif /* OPT_BASOP_ADD_v1 */ +#endif /* SPLIT_REND_WITH_HEAD_ROT */ Word16 numTapsArray[BINAURAL_CONVBANDS]; Word16 numTaps; @@ -835,7 +840,7 @@ typedef struct ivas_combined_orientation_struct Word32 Rmat_prev_fx[MAX_HEAD_ROT_POSES][3][3]; #else Word32 Rmat_prev_fx[3][3]; -#endif /* Q30 */ +#endif /* Q30 */ Word32 chEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ /* Q(q_chEneIIR) */ Word16 q_chEneIIR; Word32 procChEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* Q(q_procChEneIIR) */ diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index 3fc633317..4c5770f45 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -35,7 +35,7 @@ #include "split_rend_bfi_file_reader.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include -#include "prot.h" +#include "prot_fx.h" struct SplitRendBFIFileReader { diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index e52f9fe86..065300c10 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -35,7 +35,7 @@ #include "split_render_file_read_write.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include -#include "prot.h" +#include "prot_fx.h" /*------------------------------------------------------------------------------------------* -- GitLab From 20f818d290df750af39d29c345878d3a8abce5b8 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 7 Mar 2025 12:25:13 +0100 Subject: [PATCH 55/97] remove unaccessed variable to fix compiler warning --- lib_dec/dec_uv_fx.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index aa898956a..ed54a32af 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -44,7 +44,6 @@ void decod_unvoiced_fx( Word16 voice_fac_fx; /* Voicing factor */ Word16 code_fx[L_SUBFR]; /* algebraic codevector */ Word16 i_subfr_fx; - const Word16 *p_Aq_fx; Word16 *pt_pitch_fx; gain_pit_fx = 0; @@ -57,7 +56,6 @@ void decod_unvoiced_fx( CNG_reset_dec_fx( st_fx, pitch_buf_fx, voice_factors_fx ); } - p_Aq_fx = Aq_fx; move16(); /*Q12*/ /* pointer to interpolated LPC parameters */ pt_pitch_fx = pitch_buf_fx; move16(); /* pointer to the pitch buffer */ @@ -92,7 +90,6 @@ void decod_unvoiced_fx( interp_code_5over2_fx( &exc_fx[i_subfr_fx], &bwe_exc_fx[( ( i_subfr_fx * 2 * HIBND_ACB_L_FAC ) >> 1 )], L_SUBFR ); - p_Aq_fx += ( M + 1 ); pt_pitch_fx++; st_fx->tilt_code_dec_fx[tmp_idx] = st_fx->tilt_code_fx; move16(); -- GitLab From 14a2604be045b47a5bcb014c410b46c36292070b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 7 Mar 2025 13:25:36 +0100 Subject: [PATCH 56/97] fix compiler warning --- lib_com/prot_fx.h | 1 - lib_dec/acelp_core_dec_fx.c | 2 +- lib_dec/dec_uv_fx.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 7bc835807..310237884 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8560,7 +8560,6 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag // dec_uv_fx.c void decod_unvoiced_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ const Word16 coder_type, /* Q0 i : coding type */ Word16 *tmp_noise_fx, /* Q5 o : long term temporary noise energy */ Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index c0ad52a48..daec97ba8 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -801,7 +801,7 @@ ivas_error acelp_core_dec_fx( ELSE IF( EQ_16( st_fx->coder_type, UNVOICED ) ) { /* UNVOICED frames */ - decod_unvoiced_fx( st_fx, Aq_fx, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf ); + decod_unvoiced_fx( st_fx, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf ); } ELSE IF( EQ_16( st_fx->ppp_mode_dec, 1 ) ) { diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index ed54a32af..f39deaf16 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -27,7 +27,6 @@ static void gain_dec_gacelp_uv_fx( void decod_unvoiced_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ const Word16 coder_type, /* Q0 i : coding type */ Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ -- GitLab From 55424144763042ec79028d5748e7435e8593b286 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 7 Mar 2025 14:59:35 +0100 Subject: [PATCH 57/97] activate OPT_BASOP_ADD_v1 again and make everything compile --- lib_com/options.h | 2 +- lib_dec/ivas_binRenderer_internal_fx.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0320c6a57..7aeea040f 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -181,5 +181,5 @@ //#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ #define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ -//#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ +#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ #endif diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 81608189d..c442e29f5 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -91,7 +91,9 @@ static void ivas_binRenderer_filterModule_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx][0] ); filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx][0] ); +#ifndef OPT_BASOP_ADD_v1 Q_filterStates = (Word16 *) &( hBinRenderer->hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx][0] ); +#endif #else filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx][0] ); filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx][0] ); @@ -367,10 +369,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ****) malloc( num_poses * sizeof( Word16 *** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { @@ -384,10 +388,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx] = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -401,10 +407,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { @@ -418,10 +426,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#ifndef OPT_BASOP_ADD_v1 IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } +#endif /* OPT_BASOP_ADD_v1 */ } } } @@ -609,7 +619,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( /* set the memories to zero */ set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); +#ifdef OPT_BASOP_ADD_v1 + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); +#else /* OPT_BASOP_ADD_v1 */ set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); +#endif /* OPT_BASOP_ADD_v1 */ } } } @@ -625,7 +640,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( /* set the memories to zero */ set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); +#ifdef OPT_BASOP_ADD_v1 + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); +#else /* OPT_BASOP_ADD_v1 */ set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); +#endif /* OPT_BASOP_ADD_v1 */ } } } @@ -1596,9 +1616,11 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] = NULL; +#ifndef OPT_BASOP_ADD_v1 free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] ); hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] = NULL; +#endif /* OPT_BASOP_ADD_v1 */ } free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] ); @@ -1606,18 +1628,22 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] = NULL; +#ifndef OPT_BASOP_ADD_v1 free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] ); hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] = NULL; +#endif /* OPT_BASOP_ADD_v1 */ } free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx] ); hBinRenConvModule->filterStatesLeftReal_fx[posIdx] = NULL; free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; +#ifndef OPT_BASOP_ADD_v1 free( hBinRenConvModule->Q_filterStatesLeft[posIdx] ); hBinRenConvModule->Q_filterStatesLeft[posIdx] = NULL; +#endif /* OPT_BASOP_ADD_v1 */ } #else FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) -- GitLab From 6ca11d89314921e6c09f6ff4200a69e8b50946bf Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 7 Mar 2025 15:11:41 +0100 Subject: [PATCH 58/97] fix windows build --- Workspace_msvc/lib_com.vcxproj | 16 ++++++++++++++-- Workspace_msvc/lib_com.vcxproj.filters | 13 +++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 9bb04c835..4f40c8799 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -222,6 +222,7 @@ + @@ -229,7 +230,7 @@ - + @@ -309,10 +310,13 @@ + + + @@ -320,10 +324,17 @@ + + + + + + + @@ -332,6 +343,7 @@ + @@ -341,4 +353,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index b9769e3ec..eaacf1ba7 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -538,6 +538,8 @@ common_ivas_c + + @@ -621,6 +623,17 @@ common_all_c + + + + + + + + + + + -- GitLab From a58d5ed734a3394bd99eb84c056023f4a9707fc8 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 10 Mar 2025 08:43:15 +0100 Subject: [PATCH 59/97] use long testvectors for USAN tests too --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 58547f2ab..cb532dd7d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1307,7 +1307,7 @@ ivas-pytest-enc-usan: before_script: - CLANG_NUM=3 - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE=$SHORT_TEST_SUITE_ENCODER + - TEST_SUITE=$LONG_TEST_SUITE_ENCODER <<: *ivas-pytest-sanitizers-anchor ### jobs that test flt encoder -> fx decoder @@ -1397,7 +1397,7 @@ ivas-pytest-dec-usan: before_script: - CLANG_NUM=3 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH - - TEST_SUITE=$SHORT_TEST_SUITE + - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER <<: *ivas-pytest-sanitizers-anchor # --------------------------------------------------------------- -- GitLab From 629b1639d0b5383c62d8f0b35352ba1ca19f898a Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 11 Mar 2025 12:42:14 +1100 Subject: [PATCH 60/97] Q filter state per pose --- lib_dec/ivas_binRenderer_internal_fx.c | 2864 ++++++++++++------------ lib_rend/ivas_stat_rend.h | 2 +- 2 files changed, 1442 insertions(+), 1424 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index c442e29f5..c561ea3df 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -79,10 +79,17 @@ static void ivas_binRenderer_filterModule_fx( #endif /* OPT_BASOP_ADD_v1 */ const Word32 *filterTapsLeftRealPtr_fx, *filterTapsLeftImagPtr_fx, *filterTapsRightRealPtr_fx, *filterTapsRightImagPtr_fx; Word16 shift_q; +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef OPT_BASOP_ADD_v1 + Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx]; + move16(); +#endif /* OPT_BASOP_ADD_v1 */ +#else #ifdef OPT_BASOP_ADD_v1 Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStatesLeft; move16(); #endif /* OPT_BASOP_ADD_v1 */ +#endif FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -162,279 +169,288 @@ static void ivas_binRenderer_filterModule_fx( outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr #ifdef OPT_BASOP_ADD_v1 +#ifdef SPLIT_REND_WITH_HEAD_ROT + hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx] = Q_curr; +#else hBinRenderer->hBinRenConvModule->Q_filterStatesLeft = Q_curr; +#endif move16(); } #endif /* OPT_BASOP_ADD_v1 */ - filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; - move32(); - filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; - move32(); + filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; + move32(); + filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; + move32(); #ifndef OPT_BASOP_ADD_v1 - Q_filterStates[0] = Q_curr; - move16(); + Q_filterStates[0] = Q_curr; + move16(); #endif /* OPT_BASOP_ADD_v1 */ - /* Left Real and Imag */ - // Q29 + Q_curr + /* Left Real and Imag */ + // Q29 + Q_curr - Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); - Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); + Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); + Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( temp2 ), filterTapsLeftImagPtr_fx[0] ); - out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], outRealLeft_fx ); // Q29 - move64(); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( temp2 ), filterTapsLeftImagPtr_fx[0] ); + out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], outRealLeft_fx ); // Q29 + move64(); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); - out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], outImagLeft_fx ); // Q29 - move64(); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); + out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], outImagLeft_fx ); // Q29 + move64(); - /* Right Real and Imag */ - outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); - outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( temp2 ), filterTapsRightImagPtr_fx[0] ); - out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], outRealRight_fx ); // Q29 - move64(); + /* Right Real and Imag */ + outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); + outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( temp2 ), filterTapsRightImagPtr_fx[0] ); + out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], outRealRight_fx ); // Q29 + move64(); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); - out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], outImagRight_fx ); // Q29 - move64(); + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); + out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], outImagRight_fx ); // Q29 + move64(); + } } } - } - return; -} + return; + } -/*------------------------------------------------------------------------- - * ivas_binRenderer_convModuleOpen() - * - * Open convolution module handle of fastconv binaural renderer - *-------------------------------------------------------------------------*/ -static ivas_error ivas_binRenderer_convModuleOpen( - BINAURAL_RENDERER_HANDLE hBinRenderer, - const Word16 renderer_type, - const Word16 isLoudspeaker, - const AUDIO_CONFIG input_config, + /*------------------------------------------------------------------------- + * ivas_binRenderer_convModuleOpen() + * + * Open convolution module handle of fastconv binaural renderer + *-------------------------------------------------------------------------*/ + static ivas_error ivas_binRenderer_convModuleOpen( + BINAURAL_RENDERER_HANDLE hBinRenderer, + const Word16 renderer_type, + const Word16 isLoudspeaker, + const AUDIO_CONFIG input_config, #ifdef SPLIT_REND_WITH_HEAD_ROT - const HRTFS_FASTCONV_HANDLE hHrtf, - const Word16 num_poses + const HRTFS_FASTCONV_HANDLE hHrtf, + const Word16 num_poses #else const HRTFS_FASTCONV_HANDLE hHrtf #endif -) -{ - Word16 bandIdx, chIdx; + ) + { + Word16 bandIdx, chIdx; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 pos_idx; + Word16 pos_idx; #endif - BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; - - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ - - IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( !isLoudspeaker ) - { - hBinRenderer->nInChannels = audioCfg2channels( input_config ); - move16(); - } - ELSE - { - /* Note: needs to be revisited if multiple LFE support is required */ - hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); - move16(); - } + BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; - move16(); + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ - /* Use variable order filtering */ - bandIdx = 0; - move16(); - FOR( ; bandIdx < 5; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; - move16(); - } - FOR( ; bandIdx < 10; bandIdx++ ) + IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; - move16(); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - FOR( ; bandIdx < 20; bandIdx++ ) + + IF( !isLoudspeaker ) { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; + hBinRenderer->nInChannels = audioCfg2channels( input_config ); move16(); } - FOR( ; bandIdx < 30; bandIdx++ ) + ELSE { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; + /* Note: needs to be revisited if multiple LFE support is required */ + hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); move16(); } - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; + hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; move16(); - } - } - ELSE - { - IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; + + /* Use variable order filtering */ + bandIdx = 0; move16(); + FOR( ; bandIdx < 5; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); + } + FOR( ; bandIdx < 10; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; + move16(); + } + FOR( ; bandIdx < 20; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; + move16(); + } + FOR( ; bandIdx < 30; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; + move16(); + } + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; + move16(); + } } ELSE { - hBinRenConvModule->numTaps = BINAURAL_NTAPS; - move16(); - } + IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; + move16(); + } + ELSE + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS; + move16(); + } - /* Use fixed order filtering */ - bandIdx = 0; - move16(); - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + /* Use fixed order filtering */ + bandIdx = 0; move16(); + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); + } } - } - - /* allocate memory for filter states */ - IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + /* allocate memory for filter states */ + IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - } -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } -#ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ****) malloc( num_poses * sizeof( Word16 *** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#endif /* OPT_BASOP_ADD_v1 */ + IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } -#ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx] = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) +#ifdef OPT_BASOP_ADD_v1 + IF( ( hBinRenConvModule->Q_filterStates = (Word16 *) malloc( num_poses * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } +#else + IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ****) malloc( num_poses * sizeof( Word16 *** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #endif /* OPT_BASOP_ADD_v1 */ - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx] = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #endif /* OPT_BASOP_ADD_v1 */ - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #endif /* OPT_BASOP_ADD_v1 */ + + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + +#ifndef OPT_BASOP_ADD_v1 + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } +#endif /* OPT_BASOP_ADD_v1 */ + } } } - } #else IF( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) @@ -494,960 +510,962 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } #endif - /* set memories */ - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + /* set memories */ + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - Word16 tmp = 0; - move16(); - - IF( isLoudspeaker ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) - { - tmp = channelIndex_CICP6[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) - { - tmp = channelIndex_CICP12[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) - { - tmp = channelIndex_CICP14[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) - { - tmp = channelIndex_CICP16[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) + Word16 tmp = 0; + move16(); + + IF( isLoudspeaker ) { - tmp = channelIndex_CICP19[chIdx]; - move16(); + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) + { + tmp = channelIndex_CICP6[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) + { + tmp = channelIndex_CICP12[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) + { + tmp = channelIndex_CICP14[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) + { + tmp = channelIndex_CICP16[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) + { + tmp = channelIndex_CICP19[chIdx]; + move16(); + } } - } - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - /* set the memories to zero */ + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + /* set the memories to zero */ #ifndef SPLIT_REND_WITH_HEAD_ROT - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); #else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); #endif /* OPT_BASOP_ADD_v1 */ #endif /* !SPLIT_REND_WITH_HEAD_ROT */ - IF( isLoudspeaker ) - { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; + IF( isLoudspeaker ) + { + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; + } } - } - ELSE - { + ELSE + { #ifndef SPLIT_REND_WITH_HEAD_ROT - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); #else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); #endif /* OPT_BASOP_ADD_v1 */ #endif /* SPLIT_REND_WITH_HEAD_ROT */ - IF( isLoudspeaker ) - { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; - } - ELSE - { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - /* HOA3 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + IF( isLoudspeaker ) { - /* HOA2 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) - { - /* FOA filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; } ELSE { - return IVAS_ERR_INVALID_INPUT_FORMAT; + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + /* HOA3 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + { + /* HOA2 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + /* FOA filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; + } + ELSE + { + return IVAS_ERR_INVALID_INPUT_FORMAT; + } } } } } - } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); -#else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); + hBinRenConvModule->Q_filterStates[pos_idx] = 31; + move16(); +#endif + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); +#ifndef OPT_BASOP_ADD_v1 + set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); #endif /* OPT_BASOP_ADD_v1 */ + } } } } - } - ELSE - { - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + ELSE { - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); -#else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); -#endif /* OPT_BASOP_ADD_v1 */ - } + hBinRenConvModule->Q_filterStates[pos_idx] = 31; + move16(); +#endif + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); +#ifndef OPT_BASOP_ADD_v1 + set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); +#endif /* OPT_BASOP_ADD_v1 */ + } + } } } - } #endif - hBinRenderer->hBinRenConvModule = hBinRenConvModule; - - return IVAS_ERR_OK; -} + hBinRenderer->hBinRenConvModule = hBinRenConvModule; -/*-------------------------------------------------------------------------* - * ivas_init_binaural_hrtf() - * - * initialize memory for HrtfFastConv structure elements - *-------------------------------------------------------------------------*/ -void ivas_init_binaural_hrtf_fx( - HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ -) -{ - Word16 i; - - HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; - HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; - move32(); - - HrtfFastConv->leftHRIRReal_fx = NULL; - HrtfFastConv->leftHRIRImag_fx = NULL; - HrtfFastConv->rightHRIRReal_fx = NULL; - HrtfFastConv->rightHRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; - move32(); - - HrtfFastConv->leftBRIRReal_fx = NULL; - HrtfFastConv->leftBRIRImag_fx = NULL; - HrtfFastConv->rightBRIRReal_fx = NULL; - HrtfFastConv->rightBRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; - move32(); - - HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; - HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; - move32(); - - HrtfFastConv->leftHRIRReal_FOA_fx = NULL; - HrtfFastConv->leftHRIRImag_FOA_fx = NULL; - HrtfFastConv->rightHRIRReal_FOA_fx = NULL; - HrtfFastConv->rightHRIRImag_FOA_fx = NULL; - HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; - move32(); - - HrtfFastConv->allocate_init_flag = 0; - move16(); + return IVAS_ERR_OK; + } - FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + /*-------------------------------------------------------------------------* + * ivas_init_binaural_hrtf() + * + * initialize memory for HrtfFastConv structure elements + *-------------------------------------------------------------------------*/ + void ivas_init_binaural_hrtf_fx( + HRTFS_FASTCONV * HrtfFastConv /* i/o: FASTCONV HRTF structure */ + ) { - HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; + Word16 i; + + HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; + HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; move32(); - HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; + + HrtfFastConv->leftHRIRReal_fx = NULL; + HrtfFastConv->leftHRIRImag_fx = NULL; + HrtfFastConv->rightHRIRReal_fx = NULL; + HrtfFastConv->rightHRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; move32(); - } - return; -} + HrtfFastConv->leftBRIRReal_fx = NULL; + HrtfFastConv->leftBRIRImag_fx = NULL; + HrtfFastConv->rightBRIRReal_fx = NULL; + HrtfFastConv->rightBRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; + move32(); -/*-------------------------------------------------------------------------* - * ivas_alloc_pppMem() - * - * Allocate memory for tripple pointer elements - *-------------------------------------------------------------------------*/ -static ivas_error ivas_alloc_pppMem_fx( - Word32 ****pppMem, /*Qx*/ - const Word16 dim1, - const Word16 dim2, - const Word16 dim3, - const Word16 allocate_init_flag ) -{ - Word16 i, j; - Word32 ***localMem = NULL; + HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; + HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; + move32(); - IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + HrtfFastConv->leftHRIRReal_FOA_fx = NULL; + HrtfFastConv->leftHRIRImag_FOA_fx = NULL; + HrtfFastConv->rightHRIRReal_FOA_fx = NULL; + HrtfFastConv->rightHRIRImag_FOA_fx = NULL; + HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; + move32(); + + HrtfFastConv->allocate_init_flag = 0; + move16(); + + FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; + move32(); + HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; + move32(); + } + + return; } - for ( i = 0; i < dim1; i++ ) + /*-------------------------------------------------------------------------* + * ivas_alloc_pppMem() + * + * Allocate memory for tripple pointer elements + *-------------------------------------------------------------------------*/ + static ivas_error ivas_alloc_pppMem_fx( + Word32 * ***pppMem, /*Qx*/ + const Word16 dim1, + const Word16 dim2, + const Word16 dim3, + const Word16 allocate_init_flag ) { - IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ) + Word16 i, j; + Word32 ***localMem = NULL; + + IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } - IF( allocate_init_flag == 0 ) + + for ( i = 0; i < dim1; i++ ) { - FOR( j = 0; j < dim2; j++ ) + IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + } + IF( allocate_init_flag == 0 ) { - IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) + FOR( j = 0; j < dim2; j++ ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + } } } } - } - *pppMem = localMem; + *pppMem = localMem; - return IVAS_ERR_OK; -} + return IVAS_ERR_OK; + } -/*-------------------------------------------------------------------------* - * ivas_allocate_binaural_hrtf() - * - * Allocate memory for HrtfFastConv structure elements - *-------------------------------------------------------------------------*/ -ivas_error ivas_allocate_binaural_hrtf_fx( - HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ - const AUDIO_CONFIG input_config, /* i : input audio configuration */ - const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ - const RENDERER_TYPE renderer_type, /* i : renderer type */ - const Word16 allocate_init_flag /* i : Memory allocation flag */ -) -{ - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) ) + /*-------------------------------------------------------------------------* + * ivas_allocate_binaural_hrtf() + * + * Allocate memory for HrtfFastConv structure elements + *-------------------------------------------------------------------------*/ + ivas_error ivas_allocate_binaural_hrtf_fx( + HRTFS_FASTCONV * HrtfFastConv, /* i/o: FASTCONV HRTF structure */ + const AUDIO_CONFIG input_config, /* i : input audio configuration */ + const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ + const RENDERER_TYPE renderer_type, /* i : renderer type */ + const Word16 allocate_init_flag /* i : Memory allocation flag */ + ) { test(); - test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA3_fx != NULL ) ) - { - return IVAS_ERR_OK; - } - ELSE + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA3" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA3" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + test(); + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA3_fx != NULL ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA3" ); + return IVAS_ERR_OK; } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + ELSE { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA3" ); + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA3" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA3" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA3" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA3" ); + } } } - } - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) ) - { - test(); test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA2_fx != NULL ) ) - { - return IVAS_ERR_OK; - } - ELSE + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA2" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA2" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + test(); + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA2_fx != NULL ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA2" ); + return IVAS_ERR_OK; } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + ELSE { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA2" ); + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA2" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA2" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA2" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA2" ); + } } } - } - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_FOA ) ) - { - test(); test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_FOA_fx != NULL ) ) - { - return IVAS_ERR_OK; - } - ELSE + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_FOA ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_FOA" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_FOA" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + test(); + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_FOA_fx != NULL ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_FOA" ); + return IVAS_ERR_OK; } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + ELSE { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_FOA" ); + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_FOA" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_FOA" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_FOA" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_FOA" ); + } } } - } - test(); - IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) - { - test(); test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_fx != NULL ) ) - { - return IVAS_ERR_OK; - } - ELSE + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + test(); + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_fx != NULL ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal" ); + return IVAS_ERR_OK; } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + ELSE { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag" ); + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag" ); + } } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + } + + test(); + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) + { + test(); + test(); + test(); + IF( ( HrtfFastConv->leftBRIRReal_fx != NULL ) && ( HrtfFastConv->leftBRIRImag_fx != NULL ) && ( HrtfFastConv->rightBRIRReal_fx != NULL ) && ( HrtfFastConv->rightBRIRImag_fx != NULL ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal" ); + return IVAS_ERR_OK; } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) + ELSE { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag" ); + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRReal" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRImag" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRReal" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRImag" ); + } } } + + return IVAS_ERR_OK; } - test(); - IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) + /*-------------------------------------------------------------------------* + * ivas_binaural_HRTF_open() + * + * + *-------------------------------------------------------------------------*/ + static ivas_error ivas_binaural_hrtf_open_fx( + HRTFS_FASTCONV_HANDLE * hHrtfFastConv, /* i : fastconv HRTF handle */ + const AUDIO_CONFIG input_config, /* i : output configuration */ + const RENDERER_TYPE renderer_type /* i : renderer type */ + ) { + Word16 i, j; + ivas_error error; + test(); - test(); - test(); - IF( ( HrtfFastConv->leftBRIRReal_fx != NULL ) && ( HrtfFastConv->leftBRIRImag_fx != NULL ) && ( HrtfFastConv->rightBRIRReal_fx != NULL ) && ( HrtfFastConv->rightBRIRImag_fx != NULL ) ) + IF( hHrtfFastConv != NULL && *hHrtfFastConv != NULL ) { + /* Tables already loaded from file */ return IVAS_ERR_OK; } ELSE { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + /* Initialise tables from ROM */ + HRTFS_FASTCONV *HrtfFastConv; + + IF( ( HrtfFastConv = (HRTFS_FASTCONV *) malloc( sizeof( HRTFS_FASTCONV ) ) ) == NULL ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRReal" ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for FastConv HRTF tables" ); } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + + ivas_init_binaural_hrtf_fx( HrtfFastConv ); + + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRImag" ); + HrtfFastConv->FASTCONV_HRIR_latency_s_fx = FASTCONV_HRIR_latency_s_fx; + move32(); } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRReal" ); + HrtfFastConv->FASTCONV_HOA2_latency_s_fx = FASTCONV_HOA2_latency_s_fx; + move32(); } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRImag" ); + HrtfFastConv->FASTCONV_HOA3_latency_s_fx = FASTCONV_HOA3_latency_s_fx; + move32(); + } + if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + HrtfFastConv->FASTCONV_FOA_latency_s_fx = FASTCONV_FOA_latency_s_fx; + move32(); + } + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + HrtfFastConv->FASTCONV_BRIR_latency_s_fx = FASTCONV_BRIR_latency_s_fx; + move32(); } - } - } - - return IVAS_ERR_OK; -} - -/*-------------------------------------------------------------------------* - * ivas_binaural_HRTF_open() - * - * - *-------------------------------------------------------------------------*/ -static ivas_error ivas_binaural_hrtf_open_fx( - HRTFS_FASTCONV_HANDLE *hHrtfFastConv, /* i : fastconv HRTF handle */ - const AUDIO_CONFIG input_config, /* i : output configuration */ - const RENDERER_TYPE renderer_type /* i : renderer type */ -) -{ - Word16 i, j; - ivas_error error; - - test(); - IF( hHrtfFastConv != NULL && *hHrtfFastConv != NULL ) - { - /* Tables already loaded from file */ - return IVAS_ERR_OK; - } - ELSE - { - /* Initialise tables from ROM */ - HRTFS_FASTCONV *HrtfFastConv; - - IF( ( HrtfFastConv = (HRTFS_FASTCONV *) malloc( sizeof( HRTFS_FASTCONV ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for FastConv HRTF tables" ); - } - - ivas_init_binaural_hrtf_fx( HrtfFastConv ); - - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) - { - HrtfFastConv->FASTCONV_HRIR_latency_s_fx = FASTCONV_HRIR_latency_s_fx; - move32(); - } - if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) - { - HrtfFastConv->FASTCONV_HOA2_latency_s_fx = FASTCONV_HOA2_latency_s_fx; - move32(); - } - if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - HrtfFastConv->FASTCONV_HOA3_latency_s_fx = FASTCONV_HOA3_latency_s_fx; - move32(); - } - if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) - { - HrtfFastConv->FASTCONV_FOA_latency_s_fx = FASTCONV_FOA_latency_s_fx; - move32(); - } - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - HrtfFastConv->FASTCONV_BRIR_latency_s_fx = FASTCONV_BRIR_latency_s_fx; - move32(); - } - HrtfFastConv->allocate_init_flag = 1; - move16(); + HrtfFastConv->allocate_init_flag = 1; + move16(); - IF( NE_32( ( error = ivas_allocate_binaural_hrtf_fx( HrtfFastConv, input_config, BINAURAL_INPUT_AUDIO_CONFIG_INVALID, renderer_type, HrtfFastConv->allocate_init_flag ) ), IVAS_ERR_OK ) ) - { - return error; - } - FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) - { - IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) + IF( NE_32( ( error = ivas_allocate_binaural_hrtf_fx( HrtfFastConv, input_config, BINAURAL_INPUT_AUDIO_CONFIG_INVALID, renderer_type, HrtfFastConv->allocate_init_flag ) ), IVAS_ERR_OK ) ) { - FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - HrtfFastConv->leftHRIRReal_fx[i][j] = leftHRIRReal_fx[i][j]; - HrtfFastConv->leftHRIRImag_fx[i][j] = leftHRIRImag_fx[i][j]; - HrtfFastConv->rightHRIRReal_fx[i][j] = rightHRIRReal_fx[i][j]; - HrtfFastConv->rightHRIRImag_fx[i][j] = rightHRIRImag_fx[i][j]; - } + return error; } - ELSE IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { - HrtfFastConv->leftBRIRReal_fx[i][j] = leftBRIRReal_fx[i][j]; - HrtfFastConv->leftBRIRImag_fx[i][j] = leftBRIRImag_fx[i][j]; - HrtfFastConv->rightBRIRReal_fx[i][j] = rightBRIRReal_fx[i][j]; - HrtfFastConv->rightBRIRImag_fx[i][j] = rightBRIRImag_fx[i][j]; + FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) + { + HrtfFastConv->leftHRIRReal_fx[i][j] = leftHRIRReal_fx[i][j]; + HrtfFastConv->leftHRIRImag_fx[i][j] = leftHRIRImag_fx[i][j]; + HrtfFastConv->rightHRIRReal_fx[i][j] = rightHRIRReal_fx[i][j]; + HrtfFastConv->rightHRIRImag_fx[i][j] = rightHRIRImag_fx[i][j]; + } } - } - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - FOR( j = 0; j < HOA3_CHANNELS; j++ ) + ELSE IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - HrtfFastConv->leftHRIRReal_HOA3_fx[i][j] = leftHRIRReal_HOA3_fx[i][j]; - HrtfFastConv->leftHRIRImag_HOA3_fx[i][j] = leftHRIRImag_HOA3_fx[i][j]; - HrtfFastConv->rightHRIRReal_HOA3_fx[i][j] = rightHRIRReal_HOA3_fx[i][j]; - HrtfFastConv->rightHRIRImag_HOA3_fx[i][j] = rightHRIRImag_HOA3_fx[i][j]; + FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) + { + HrtfFastConv->leftBRIRReal_fx[i][j] = leftBRIRReal_fx[i][j]; + HrtfFastConv->leftBRIRImag_fx[i][j] = leftBRIRImag_fx[i][j]; + HrtfFastConv->rightBRIRReal_fx[i][j] = rightBRIRReal_fx[i][j]; + HrtfFastConv->rightBRIRImag_fx[i][j] = rightBRIRImag_fx[i][j]; + } } - } - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) - { - FOR( j = 0; j < HOA2_CHANNELS; j++ ) + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) { - HrtfFastConv->leftHRIRReal_HOA2_fx[i][j] = leftHRIRReal_HOA2_fx[i][j]; - HrtfFastConv->leftHRIRImag_HOA2_fx[i][j] = leftHRIRImag_HOA2_fx[i][j]; - HrtfFastConv->rightHRIRReal_HOA2_fx[i][j] = rightHRIRReal_HOA2_fx[i][j]; - HrtfFastConv->rightHRIRImag_HOA2_fx[i][j] = rightHRIRImag_HOA2_fx[i][j]; + FOR( j = 0; j < HOA3_CHANNELS; j++ ) + { + HrtfFastConv->leftHRIRReal_HOA3_fx[i][j] = leftHRIRReal_HOA3_fx[i][j]; + HrtfFastConv->leftHRIRImag_HOA3_fx[i][j] = leftHRIRImag_HOA3_fx[i][j]; + HrtfFastConv->rightHRIRReal_HOA3_fx[i][j] = rightHRIRReal_HOA3_fx[i][j]; + HrtfFastConv->rightHRIRImag_HOA3_fx[i][j] = rightHRIRImag_HOA3_fx[i][j]; + } } - } - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) - { - FOR( j = 0; j < FOA_CHANNELS; j++ ) + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + { + FOR( j = 0; j < HOA2_CHANNELS; j++ ) + { + HrtfFastConv->leftHRIRReal_HOA2_fx[i][j] = leftHRIRReal_HOA2_fx[i][j]; + HrtfFastConv->leftHRIRImag_HOA2_fx[i][j] = leftHRIRImag_HOA2_fx[i][j]; + HrtfFastConv->rightHRIRReal_HOA2_fx[i][j] = rightHRIRReal_HOA2_fx[i][j]; + HrtfFastConv->rightHRIRImag_HOA2_fx[i][j] = rightHRIRImag_HOA2_fx[i][j]; + } + } + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) { - HrtfFastConv->leftHRIRReal_FOA_fx[i][j] = leftHRIRReal_FOA_fx[i][j]; - HrtfFastConv->leftHRIRImag_FOA_fx[i][j] = leftHRIRImag_FOA_fx[i][j]; - HrtfFastConv->rightHRIRReal_FOA_fx[i][j] = rightHRIRReal_FOA_fx[i][j]; - HrtfFastConv->rightHRIRImag_FOA_fx[i][j] = rightHRIRImag_FOA_fx[i][j]; + FOR( j = 0; j < FOA_CHANNELS; j++ ) + { + HrtfFastConv->leftHRIRReal_FOA_fx[i][j] = leftHRIRReal_FOA_fx[i][j]; + HrtfFastConv->leftHRIRImag_FOA_fx[i][j] = leftHRIRImag_FOA_fx[i][j]; + HrtfFastConv->rightHRIRReal_FOA_fx[i][j] = rightHRIRReal_FOA_fx[i][j]; + HrtfFastConv->rightHRIRImag_FOA_fx[i][j] = rightHRIRImag_FOA_fx[i][j]; + } } } + Copy32( fastconvReverberationTimes_fx, HrtfFastConv->fastconvReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); + Copy32( fastconvReverberationEneCorrections_fx, HrtfFastConv->fastconvReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); + + *hHrtfFastConv = HrtfFastConv; } - Copy32( fastconvReverberationTimes_fx, HrtfFastConv->fastconvReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); - Copy32( fastconvReverberationEneCorrections_fx, HrtfFastConv->fastconvReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); - *hHrtfFastConv = HrtfFastConv; + return IVAS_ERR_OK; } + /*-------------------------------------------------------------------------* + * ivas_binaural_obtain_DMX_fx() + * + * + *-------------------------------------------------------------------------*/ - return IVAS_ERR_OK; -} -/*-------------------------------------------------------------------------* - * ivas_binaural_obtain_DMX_fx() - * - * - *-------------------------------------------------------------------------*/ - -static void ivas_binaural_obtain_DMX_fx( - const Word16 numTimeSlots, - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ - Word32 RealBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ - Word32 ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ - Word32 realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q_in-1*/ - Word32 imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] ) /*Q_in-1*/ -{ - Word16 chIdx, bandIdx, k; - - test(); - IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) + static void ivas_binaural_obtain_DMX_fx( + const Word16 numTimeSlots, + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ + Word32 RealBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ + Word32 ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ + Word32 realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q_in-1*/ + Word32 imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] ) /*Q_in-1*/ { - /* Obtain the downmix */ - Word32 P_in_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 P_out_fx, factEQ_fx; - Word16 chOutIdx; - Word32 temp1_fx, temp2_fx; + Word16 chIdx, bandIdx, k; - FOR( k = 0; k < numTimeSlots; k++ ) + test(); + IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) { - FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) + /* Obtain the downmix */ + Word32 P_in_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 P_out_fx, factEQ_fx; + Word16 chOutIdx; + Word32 temp1_fx, temp2_fx; + + FOR( k = 0; k < numTimeSlots; k++ ) { - set32_fx( realDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) + { + set32_fx( realDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( imagDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } } - } - - FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) - { - set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) { - Word32 dmxConst = hBinRenderer->hReverb->dmxmtx_fx[chOutIdx][chIdx]; - move32(); + set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { - temp1_fx = Mpy_32_32( RealBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in - temp2_fx = Mpy_32_32( ImagBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in - realDMX[chOutIdx][k][bandIdx] = L_add( realDMX[chOutIdx][k][bandIdx], temp1_fx ); // Q_in - move32(); - imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in - move32(); + Word32 dmxConst = hBinRenderer->hReverb->dmxmtx_fx[chOutIdx][chIdx]; + move32(); - P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in - move32(); + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) + { + temp1_fx = Mpy_32_32( RealBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in + temp2_fx = Mpy_32_32( ImagBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in + realDMX[chOutIdx][k][bandIdx] = L_add( realDMX[chOutIdx][k][bandIdx], temp1_fx ); // Q_in + move32(); + imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in + move32(); + + P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in + move32(); + } } } - } - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - P_out_fx = 0; - move32(); - FOR( k = 0; k < numTimeSlots; k++ ) - { - temp1_fx = realDMX[chOutIdx][k][bandIdx]; - move32(); - temp2_fx = imagDMX[chOutIdx][k][bandIdx]; - move32(); - P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in - } - test(); - IF( ( P_in_fx[bandIdx] <= 0 ) || ( P_out_fx <= 0 ) ) - { - factEQ_fx = 0x40000000; // 1.0f in Q30 - move32(); - } - ELSE - { - Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); - Word16 exp = norm_l( div ); - factEQ_fx = Sqrt32( L_shl( div, Q16 ), &exp ); - factEQ_fx = L_shl( factEQ_fx, sub( exp, 1 ) ); // Q30 - } - if ( factEQ_fx <= 0 ) + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - factEQ_fx = 0x40000000; // 1.0f in Q30 + P_out_fx = 0; move32(); - } + FOR( k = 0; k < numTimeSlots; k++ ) + { + temp1_fx = realDMX[chOutIdx][k][bandIdx]; + move32(); + temp2_fx = imagDMX[chOutIdx][k][bandIdx]; + move32(); + P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in + } + test(); + IF( ( P_in_fx[bandIdx] <= 0 ) || ( P_out_fx <= 0 ) ) + { + factEQ_fx = 0x40000000; // 1.0f in Q30 + move32(); + } + ELSE + { + Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); + Word16 exp = norm_l( div ); + factEQ_fx = Sqrt32( L_shl( div, Q16 ), &exp ); + factEQ_fx = L_shl( factEQ_fx, sub( exp, 1 ) ); // Q30 + } + if ( factEQ_fx <= 0 ) + { + factEQ_fx = 0x40000000; // 1.0f in Q30 + move32(); + } - factEQ_fx = L_max( L_min( factEQ_fx, 0x7fffffff ), 0x20000000 ); // Q30 , 0x7fffffff -> (1.0f in Q31)-1, 0x20000000 ->1.0f in Q29 - FOR( k = 0; k < numTimeSlots; k++ ) - { - realDMX[chOutIdx][k][bandIdx] = Mpy_32_32( realDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 - move32(); - imagDMX[chOutIdx][k][bandIdx] = Mpy_32_32( imagDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 - move32(); + factEQ_fx = L_max( L_min( factEQ_fx, 0x7fffffff ), 0x20000000 ); // Q30 , 0x7fffffff -> (1.0f in Q31)-1, 0x20000000 ->1.0f in Q29 + FOR( k = 0; k < numTimeSlots; k++ ) + { + realDMX[chOutIdx][k][bandIdx] = Mpy_32_32( realDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 + move32(); + imagDMX[chOutIdx][k][bandIdx] = Mpy_32_32( imagDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 + move32(); + } } } } - } - ELSE IF( EQ_32( hBinRenderer->ivas_format, SBA_FORMAT ) || EQ_32( hBinRenderer->ivas_format, MASA_FORMAT ) ) - { - Word32 *outRealLeftPtr_fx, *outImagLeftPtr_fx, *outRealRightPtr_fx, *outImagRightPtr_fx; - Word32 *inRealPtr_fx, *inImagPtr_fx; - - /*compute DMX */ - FOR( k = 0; k < numTimeSlots; k++ ) + ELSE IF( EQ_32( hBinRenderer->ivas_format, SBA_FORMAT ) || EQ_32( hBinRenderer->ivas_format, MASA_FORMAT ) ) { - outRealLeftPtr_fx = realDMX[0][k]; - outImagLeftPtr_fx = imagDMX[0][k]; - outRealRightPtr_fx = realDMX[1][k]; - outImagRightPtr_fx = imagDMX[1][k]; - set32_fx( outRealLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outImagLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outRealRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outImagRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + Word32 *outRealLeftPtr_fx, *outImagLeftPtr_fx, *outRealRightPtr_fx, *outImagRightPtr_fx; + Word32 *inRealPtr_fx, *inImagPtr_fx; - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + /*compute DMX */ + FOR( k = 0; k < numTimeSlots; k++ ) { - Word32 foa_const_fx = L_shl( hBinRenderer->hReverb->foa_enc_fx[chIdx][1], 1 ); // Q30 - - inRealPtr_fx = (Word32 *) &( RealBuffer[chIdx][k][0] ); - inImagPtr_fx = (Word32 *) &( ImagBuffer[chIdx][k][0] ); + outRealLeftPtr_fx = realDMX[0][k]; + outImagLeftPtr_fx = imagDMX[0][k]; + outRealRightPtr_fx = realDMX[1][k]; + outImagRightPtr_fx = imagDMX[1][k]; + set32_fx( outRealLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outImagLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outRealRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outImagRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - outRealLeftPtr_fx[bandIdx] = L_add( outRealLeftPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); - outImagLeftPtr_fx[bandIdx] = L_add( outImagLeftPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); + Word32 foa_const_fx = L_shl( hBinRenderer->hReverb->foa_enc_fx[chIdx][1], 1 ); // Q30 - outRealRightPtr_fx[bandIdx] = L_add( outRealRightPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); - outImagRightPtr_fx[bandIdx] = L_add( outImagRightPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); + inRealPtr_fx = (Word32 *) &( RealBuffer[chIdx][k][0] ); + inImagPtr_fx = (Word32 *) &( ImagBuffer[chIdx][k][0] ); + + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + outRealLeftPtr_fx[bandIdx] = L_add( outRealLeftPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); + outImagLeftPtr_fx[bandIdx] = L_add( outImagLeftPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); + + outRealRightPtr_fx[bandIdx] = L_add( outRealRightPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); + outImagRightPtr_fx[bandIdx] = L_add( outImagRightPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); + } } } } - } - return; -} + return; + } #ifdef SPLIT_REND_WITH_HEAD_ROT -/*------------------------------------------------------------------------- - * ivas_rend_openCldfbRend() - * - * Allocate and initialize CLDFB fast conv renderer handle - *------------------------------------------------------------------------*/ - -ivas_error ivas_rend_openCldfbRend( - CLDFB_REND_WRAPPER *pCldfbRend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const Word32 output_Fs ) -{ - BINAURAL_RENDERER_HANDLE hBinRenderer; - Word16 convBand; - ivas_error error; - - error = IVAS_ERR_OK; + /*------------------------------------------------------------------------- + * ivas_rend_openCldfbRend() + * + * Allocate and initialize CLDFB fast conv renderer handle + *------------------------------------------------------------------------*/ - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ - - if ( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + ivas_error ivas_rend_openCldfbRend( + CLDFB_REND_WRAPPER * pCldfbRend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word32 output_Fs ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); - } + BINAURAL_RENDERER_HANDLE hBinRenderer; + Word16 convBand; + ivas_error error; - if ( ( hBinRenderer->hInputSetup = (IVAS_OUTPUT_SETUP_HANDLE) malloc( sizeof( IVAS_OUTPUT_SETUP ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output setup Binaural Renderer\n" ) ); - } + error = IVAS_ERR_OK; - hBinRenderer->rotInCldfb = 1; - hBinRenderer->ivas_format = SBA_FORMAT; + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ - hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); - move16(); + if ( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); + } - convBand = hBinRenderer->max_band; - move16(); + if ( ( hBinRenderer->hInputSetup = (IVAS_OUTPUT_SETUP_HANDLE) malloc( sizeof( IVAS_OUTPUT_SETUP ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output setup Binaural Renderer\n" ) ); + } - hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ - move16(); + hBinRenderer->rotInCldfb = 1; + hBinRenderer->ivas_format = SBA_FORMAT; - IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) - { - hBinRenderer->conv_band = BINAURAL_CONVBANDS; - move16(); - } - ELSE - { - hBinRenderer->conv_band = convBand; + hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); move16(); - } - hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; - hBinRenderer->hInputSetup->output_config = inConfig; - IF( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) - { - return error; - } + convBand = hBinRenderer->max_band; + move16(); - IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - hBinRenderer->numPoses = pMultiBinPoseData->num_poses; + hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ move16(); - } - ELSE - { - hBinRenderer->numPoses = 1; + + IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) + { + hBinRenderer->conv_band = BINAURAL_CONVBANDS; + move16(); + } + ELSE + { + hBinRenderer->conv_band = convBand; + move16(); + } + + hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; + hBinRenderer->hInputSetup->output_config = inConfig; + IF( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) + { + return error; + } + + IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + hBinRenderer->numPoses = pMultiBinPoseData->num_poses; + move16(); + } + ELSE + { + hBinRenderer->numPoses = 1; + move16(); + } + + /*LFE rendering switched off by default*/ + hBinRenderer->render_lfe = 0; move16(); - } - /*LFE rendering switched off by default*/ - hBinRenderer->render_lfe = 0; - move16(); + /* Load HRTF tables */ + IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &pCldfbRend->hHrtfFastConv, hBinRenderer->hInputSetup->output_config, RENDERER_BINAURAL_FASTCONV ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* Load HRTF tables */ - IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &pCldfbRend->hHrtfFastConv, hBinRenderer->hInputSetup->output_config, RENDERER_BINAURAL_FASTCONV ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* Allocate memories and buffers needed for convolutional module in CICP19 */ + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, RENDERER_BINAURAL_FASTCONV, hBinRenderer->hInputSetup->is_loudspeaker_setup, inConfig, pCldfbRend->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { + return error; + } + + pCldfbRend->binaural_latency_ns = (Word32) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx * 1000000000 ); + move32(); + hBinRenderer->hReverb = NULL; + move32(); + hBinRenderer->hEFAPdata = NULL; + move32(); + pCldfbRend->hCldfbRend = hBinRenderer; + move32(); - /* Allocate memories and buffers needed for convolutional module in CICP19 */ - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, RENDERER_BINAURAL_FASTCONV, hBinRenderer->hInputSetup->is_loudspeaker_setup, inConfig, pCldfbRend->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) - { return error; } - - pCldfbRend->binaural_latency_ns = (Word32) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx * 1000000000 ); - move32(); - hBinRenderer->hReverb = NULL; - move32(); - hBinRenderer->hEFAPdata = NULL; - move32(); - pCldfbRend->hCldfbRend = hBinRenderer; - move32(); - - return error; -} #endif -/*------------------------------------------------------------------------- - * ivas_binRenderer_open() - * - * Open fastconv binaural renderer handle - *-------------------------------------------------------------------------*/ -ivas_error ivas_binRenderer_open_fx( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -) -{ - BINAURAL_RENDERER_HANDLE hBinRenderer; - Word16 convBand, chIdx, k; - ivas_error error; + /*------------------------------------------------------------------------- + * ivas_binRenderer_open() + * + * Open fastconv binaural renderer handle + *-------------------------------------------------------------------------*/ + ivas_error ivas_binRenderer_open_fx( + Decoder_Struct * st_ivas /* i/o: IVAS decoder structure */ + ) + { + BINAURAL_RENDERER_HANDLE hBinRenderer; + Word16 convBand, chIdx, k; + ivas_error error; - error = IVAS_ERR_OK; - move32(); + error = IVAS_ERR_OK; + move32(); - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ - IF( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); - } + IF( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); + } - hBinRenderer->hInputSetup = &st_ivas->hIntSetup; + hBinRenderer->hInputSetup = &st_ivas->hIntSetup; - /* Define of head rotation has to be done in binRendeder in CLDFB*/ - hBinRenderer->rotInCldfb = 0; - move16(); - test(); - if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) - { - hBinRenderer->rotInCldfb = 1; + /* Define of head rotation has to be done in binRendeder in CLDFB*/ + hBinRenderer->rotInCldfb = 0; move16(); - } + test(); + if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) + { + hBinRenderer->rotInCldfb = 1; + move16(); + } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - hBinRenderer->numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; - move16(); - } - else - { - hBinRenderer->numPoses = 1; - move16(); - } + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + hBinRenderer->numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); + } + else + { + hBinRenderer->numPoses = 1; + move16(); + } #endif - /* Declare some common variables needed for renderer */ - /* Which format used for binaural rendering (needed for late reverb) ? MC or SBA */ - IF( st_ivas->hIntSetup.is_loudspeaker_setup ) - { - hBinRenderer->ivas_format = MC_FORMAT; - move32(); - } - ELSE - { - hBinRenderer->ivas_format = SBA_FORMAT; - move32(); - } - hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( st_ivas->hDecoderConfig->output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); - move16(); - - convBand = hBinRenderer->max_band; - move16(); - - hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ - move16(); + /* Declare some common variables needed for renderer */ + /* Which format used for binaural rendering (needed for late reverb) ? MC or SBA */ + IF( st_ivas->hIntSetup.is_loudspeaker_setup ) + { + hBinRenderer->ivas_format = MC_FORMAT; + move32(); + } + ELSE + { + hBinRenderer->ivas_format = SBA_FORMAT; + move32(); + } + hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( st_ivas->hDecoderConfig->output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); + move16(); - IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) - { - hBinRenderer->conv_band = BINAURAL_CONVBANDS; + convBand = hBinRenderer->max_band; move16(); - } - ELSE - { - hBinRenderer->conv_band = convBand; + + hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ move16(); - } - /*LFE rendering switched off by default*/ - hBinRenderer->render_lfe = 0; - move16(); + IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) + { + hBinRenderer->conv_band = BINAURAL_CONVBANDS; + move16(); + } + ELSE + { + hBinRenderer->conv_band = convBand; + move16(); + } - test(); - if ( NE_32( st_ivas->ivas_format, ISM_FORMAT ) && st_ivas->hIntSetup.is_loudspeaker_setup ) - { - hBinRenderer->render_lfe = 1; + /*LFE rendering switched off by default*/ + hBinRenderer->render_lfe = 0; move16(); - } - /* Load HRTF tables */ - IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &st_ivas->hHrtfFastConv, st_ivas->hIntSetup.output_config, st_ivas->renderer_type ) ), IVAS_ERR_OK ) ) - { - return error; - } - - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hIntSetup.is_loudspeaker_setup == 0 ) ) - { - IVAS_OUTPUT_SETUP out_setup; + test(); + if ( NE_32( st_ivas->ivas_format, ISM_FORMAT ) && st_ivas->hIntSetup.is_loudspeaker_setup ) + { + hBinRenderer->render_lfe = 1; + move16(); + } - /* Allocate memories and buffers needed for convolutional module in CICP19 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + /* Load HRTF tables */ + IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &st_ivas->hHrtfFastConv, st_ivas->hIntSetup.output_config, st_ivas->renderer_type ) ), IVAS_ERR_OK ) ) { return error; } + + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hIntSetup.is_loudspeaker_setup == 0 ) ) + { + IVAS_OUTPUT_SETUP out_setup; + + /* Allocate memories and buffers needed for convolutional module in CICP19 */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { + return error; + } #else IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) { return error; } #endif - ivas_output_init( &out_setup, IVAS_AUDIO_CONFIG_7_1_4 ); + ivas_output_init( &out_setup, IVAS_AUDIO_CONFIG_7_1_4 ); - IF( st_ivas->hoa_dec_mtx == NULL ) - { - IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) ) + IF( st_ivas->hoa_dec_mtx == NULL ) { - return error; + IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) ) + { + return error; + } } - } - hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx; - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; - move32(); - } - ELSE - { - /* Allocate memories and buffers needed for convolutional module */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) - { - return error; + hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx; + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; + move32(); } + ELSE + { + /* Allocate memories and buffers needed for convolutional module */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { + return error; + } #else IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) { @@ -1455,196 +1473,196 @@ ivas_error ivas_binRenderer_open_fx( } #endif - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) - { - IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HRIR_latency_s_fx; - move32(); - } - ELSE - { - IF( EQ_16( hBinRenderer->nInChannels, 16 ) ) - { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx; - move32(); - } - ELSE IF( EQ_16( hBinRenderer->nInChannels, 9 ) ) - { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA2_latency_s_fx; - move32(); - } - ELSE IF( EQ_16( hBinRenderer->nInChannels, 4 ) ) + IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_FOA_latency_s_fx; + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HRIR_latency_s_fx; move32(); } ELSE { - return IVAS_ERR_INVALID_INPUT_FORMAT; + IF( EQ_16( hBinRenderer->nInChannels, 16 ) ) + { + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx; + move32(); + } + ELSE IF( EQ_16( hBinRenderer->nInChannels, 9 ) ) + { + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA2_latency_s_fx; + move32(); + } + ELSE IF( EQ_16( hBinRenderer->nInChannels, 4 ) ) + { + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_FOA_latency_s_fx; + move32(); + } + ELSE + { + return IVAS_ERR_INVALID_INPUT_FORMAT; + } } } - } - ELSE - { - /* same value for MC or HOA both use MC BRIR*/ - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; - move32(); - } - } - - /* Allocate memories needed for reverb module */ - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) - { - IF( NE_32( ( error = ivas_binaural_reverb_open_fastconv_fx( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* initialize the dmx matrix */ - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < hBinRenderer->nInChannels; k++ ) + ELSE { - hBinRenderer->hReverb->dmxmtx_fx[chIdx][k] = dmxmtx_table_fx[chIdx][k]; + /* same value for MC or HOA both use MC BRIR*/ + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; move32(); } } - } - ELSE - { - hBinRenderer->hReverb = NULL; - } - hBinRenderer->hEFAPdata = NULL; - - IF( hBinRenderer->hReverb != NULL ) - { + /* Allocate memories needed for reverb module */ test(); - test(); - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - FOR( k = 0; k < 11; k++ ) + IF( NE_32( ( error = ivas_binaural_reverb_open_fastconv_fx( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) { - ivas_dirac_dec_get_response_fx( extract_l( L_shr_r( ls_azimuth_CICP19_fx[k], 22 ) ), extract_l( L_shr_r( ls_elevation_CICP19_fx[k], 22 ) ), hBinRenderer->hReverb->foa_enc_fx[k], 1, Q29 ); - // Q29: hBinRenderer->hReverb->foa_enc_fx[k] + return error; } + + /* initialize the dmx matrix */ + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < hBinRenderer->nInChannels; k++ ) + { + hBinRenderer->hReverb->dmxmtx_fx[chIdx][k] = dmxmtx_table_fx[chIdx][k]; + move32(); + } + } + } + ELSE + { + hBinRenderer->hReverb = NULL; } - ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + + hBinRenderer->hEFAPdata = NULL; + + IF( hBinRenderer->hReverb != NULL ) { - IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) + test(); + test(); + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) { - return error; + FOR( k = 0; k < 11; k++ ) + { + ivas_dirac_dec_get_response_fx( extract_l( L_shr_r( ls_azimuth_CICP19_fx[k], 22 ) ), extract_l( L_shr_r( ls_elevation_CICP19_fx[k], 22 ) ), hBinRenderer->hReverb->foa_enc_fx[k], 1, Q29 ); + // Q29: hBinRenderer->hReverb->foa_enc_fx[k] + } } + ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + { + IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* Copy handles to bin renderer handle*/ - hBinRenderer->hEFAPdata = st_ivas->hEFAPdata; + /* Copy handles to bin renderer handle*/ + hBinRenderer->hEFAPdata = st_ivas->hEFAPdata; + } } - } - /* Copy the handles to main handle */ - st_ivas->hBinRenderer = hBinRenderer; + /* Copy the handles to main handle */ + st_ivas->hBinRenderer = hBinRenderer; - return error; -} + return error; + } -/*------------------------------------------------------------------------- - * ivas_binRenderer_convModuleClose() - * - * Close convolution module handle of fastconv binaural renderer - *------------------------------------------------------------------------*/ -static void ivas_binRenderer_convModuleClose_fx( + /*------------------------------------------------------------------------- + * ivas_binRenderer_convModuleClose() + * + * Close convolution module handle of fastconv binaural renderer + *------------------------------------------------------------------------*/ + static void ivas_binRenderer_convModuleClose_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT - BINAURAL_RENDERER_HANDLE *hBinRenderer, /* i/o: fastconv binaural renderer handle */ - const Word16 num_poses /* i : number of poses */ + BINAURAL_RENDERER_HANDLE * hBinRenderer, /* i/o: fastconv binaural renderer handle */ + const Word16 num_poses /* i : number of poses */ #else BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ #endif -) -{ - Word16 bandIdx, chIdx; + ) + { + Word16 bandIdx, chIdx; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 posIdx; + Word16 posIdx; #endif - BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; - hBinRenConvModule = ( *hBinRenderer )->hBinRenConvModule; + hBinRenConvModule = ( *hBinRenderer )->hBinRenConvModule; - IF( hBinRenConvModule == NULL ) - { - return; - } + IF( hBinRenConvModule == NULL ) + { + return; + } - FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) - { - free( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] ); - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = NULL; + FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) + { + free( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] ); + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = NULL; - free( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] ); - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = NULL; + free( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] ); + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = NULL; - free( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] ); - hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = NULL; + free( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] ); + hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = NULL; - free( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] ); - hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = NULL; - } + free( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] ); + hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = NULL; + } - free( hBinRenConvModule->filterTapsLeftReal_fx ); - hBinRenConvModule->filterTapsLeftReal_fx = NULL; + free( hBinRenConvModule->filterTapsLeftReal_fx ); + hBinRenConvModule->filterTapsLeftReal_fx = NULL; - free( hBinRenConvModule->filterTapsLeftImag_fx ); - hBinRenConvModule->filterTapsLeftImag_fx = NULL; + free( hBinRenConvModule->filterTapsLeftImag_fx ); + hBinRenConvModule->filterTapsLeftImag_fx = NULL; - free( hBinRenConvModule->filterTapsRightReal_fx ); - hBinRenConvModule->filterTapsRightReal_fx = NULL; + free( hBinRenConvModule->filterTapsRightReal_fx ); + hBinRenConvModule->filterTapsRightReal_fx = NULL; - free( hBinRenConvModule->filterTapsRightImag_fx ); - hBinRenConvModule->filterTapsRightImag_fx = NULL; + free( hBinRenConvModule->filterTapsRightImag_fx ); + hBinRenConvModule->filterTapsRightImag_fx = NULL; #ifdef SPLIT_REND_WITH_HEAD_ROT - FOR( posIdx = 0; posIdx < num_poses; posIdx++ ) - { - FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) + FOR( posIdx = 0; posIdx < num_poses; posIdx++ ) { - FOR( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) + FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) { - free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] = NULL; + FOR( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) + { + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] = NULL; + free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] = NULL; #endif /* OPT_BASOP_ADD_v1 */ - } + } - free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] = NULL; + free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] = NULL; #endif /* OPT_BASOP_ADD_v1 */ - } - free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[posIdx] = NULL; + } + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx] = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[posIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx] = NULL; + free( hBinRenConvModule->Q_filterStatesLeft[posIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx] = NULL; #endif /* OPT_BASOP_ADD_v1 */ - } + } #else FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) { @@ -1674,281 +1692,281 @@ static void ivas_binRenderer_convModuleClose_fx( #endif /* OPT_BASOP_ADD_v1 */ } #endif - free( hBinRenConvModule->filterStatesLeftReal_fx ); - hBinRenConvModule->filterStatesLeftReal_fx = NULL; + free( hBinRenConvModule->filterStatesLeftReal_fx ); + hBinRenConvModule->filterStatesLeftReal_fx = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx ); - hBinRenConvModule->filterStatesLeftImag_fx = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx ); + hBinRenConvModule->filterStatesLeftImag_fx = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft ); - hBinRenConvModule->Q_filterStatesLeft = NULL; + free( hBinRenConvModule->Q_filterStatesLeft ); + hBinRenConvModule->Q_filterStatesLeft = NULL; #endif /* OPT_BASOP_ADD_v1 */ - free( ( *hBinRenderer )->hBinRenConvModule ); - ( *hBinRenderer )->hBinRenConvModule = NULL; - - return; -} + free( ( *hBinRenderer )->hBinRenConvModule ); + ( *hBinRenderer )->hBinRenConvModule = NULL; -/*------------------------------------------------------------------------- - * ivas_binRenderer_close() - * - * Close fastconv binaural renderer memories - *------------------------------------------------------------------------*/ -void ivas_binRenderer_close_fx( - BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ -) -{ - test(); - IF( hBinRenderer == NULL || *hBinRenderer == NULL ) - { return; } - IF( ( *hBinRenderer )->hBinRenConvModule != NULL ) + /*------------------------------------------------------------------------- + * ivas_binRenderer_close() + * + * Close fastconv binaural renderer memories + *------------------------------------------------------------------------*/ + void ivas_binRenderer_close_fx( + BINAURAL_RENDERER_HANDLE * hBinRenderer /* i/o: fastconv binaural renderer handle */ + ) { + test(); + IF( hBinRenderer == NULL || *hBinRenderer == NULL ) + { + return; + } + + IF( ( *hBinRenderer )->hBinRenConvModule != NULL ) + { #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_binRenderer_convModuleClose_fx( hBinRenderer, ( *hBinRenderer )->numPoses ); + ivas_binRenderer_convModuleClose_fx( hBinRenderer, ( *hBinRenderer )->numPoses ); #else ivas_binRenderer_convModuleClose_fx( hBinRenderer ); #endif - } - - IF( ( *hBinRenderer )->hReverb != NULL ) - { - ivas_binaural_reverb_close_fx( &( ( *hBinRenderer )->hReverb ) ); - } + } - free( *hBinRenderer ); - *hBinRenderer = NULL; + IF( ( *hBinRenderer )->hReverb != NULL ) + { + ivas_binaural_reverb_close_fx( &( ( *hBinRenderer )->hReverb ) ); + } - return; -} + free( *hBinRenderer ); + *hBinRenderer = NULL; -/*------------------------------------------------------------------------- - * ivas_free_pppHrtfMem() - * - * Free fastconv binaural renderer hrtf memories - *------------------------------------------------------------------------*/ -static void ivas_free_pppHrtfMem_fx( - Word32 ****ppppHRIR, /*Qx*/ - const Word16 dim, - const Word16 alloc_init ) -{ - Word16 i, j; + return; + } - IF( *ppppHRIR != NULL ) + /*------------------------------------------------------------------------- + * ivas_free_pppHrtfMem() + * + * Free fastconv binaural renderer hrtf memories + *------------------------------------------------------------------------*/ + static void ivas_free_pppHrtfMem_fx( + Word32 * ***ppppHRIR, /*Qx*/ + const Word16 dim, + const Word16 alloc_init ) { - FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) + Word16 i, j; + + IF( *ppppHRIR != NULL ) { - IF( alloc_init == 0 ) + FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - FOR( j = 0; j < dim; j++ ) + IF( alloc_init == 0 ) { - free( ( *ppppHRIR )[i][j] ); - ( *ppppHRIR )[i][j] = NULL; + FOR( j = 0; j < dim; j++ ) + { + free( ( *ppppHRIR )[i][j] ); + ( *ppppHRIR )[i][j] = NULL; + } } + free( ( *ppppHRIR )[i] ); + ( *ppppHRIR )[i] = NULL; } - free( ( *ppppHRIR )[i] ); - ( *ppppHRIR )[i] = NULL; + free( *ppppHRIR ); + *ppppHRIR = NULL; } - free( *ppppHRIR ); - *ppppHRIR = NULL; - } - - return; -} - -/*------------------------------------------------------------------------- - * ivas_binaural_hrtf_close() - * - * Close fastconv binaural renderer hrtf memories - *------------------------------------------------------------------------*/ -void ivas_binaural_hrtf_close( - HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i : fastconv HRTF handle */ -) -{ - Word16 allocate_init_flag; - test(); - IF( hHrtfFastConv == NULL || *hHrtfFastConv == NULL ) - { return; } - allocate_init_flag = ( *hHrtfFastConv )->allocate_init_flag; - move16(); + /*------------------------------------------------------------------------- + * ivas_binaural_hrtf_close() + * + * Close fastconv binaural renderer hrtf memories + *------------------------------------------------------------------------*/ + void ivas_binaural_hrtf_close( + HRTFS_FASTCONV_HANDLE * hHrtfFastConv /* i : fastconv HRTF handle */ + ) + { + Word16 allocate_init_flag; - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + test(); + IF( hHrtfFastConv == NULL || *hHrtfFastConv == NULL ) + { + return; + } - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + allocate_init_flag = ( *hHrtfFastConv )->allocate_init_flag; + move16(); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - return; -} + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); -/*-------------------------------------------------------------------------* - * ivas_binaural_add_LFE() - * - * The functions adds the LFE to the left and right channels after binaural rendering - *-------------------------------------------------------------------------*/ -void ivas_binaural_add_LFE_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Word16 output_frame, /* i : length of input frame */ - Word32 *input_fx[], /* i : transport channels Q11*/ - Word32 *output_fx[] /* o : synthesized core-coder transport channels/DirAC output Q11*/ -) -{ - Word16 render_lfe, idx_lfe, gain_fx; - Word32 lfe_tc[L_FRAME48k]; + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - IF( st_ivas->hBinRenderer != NULL ) - { - render_lfe = st_ivas->hBinRenderer->render_lfe; - move16(); - } - ELSE - { - render_lfe = TRUE; - move16(); + return; } - - IF( render_lfe ) + /*-------------------------------------------------------------------------* + * ivas_binaural_add_LFE() + * + * The functions adds the LFE to the left and right channels after binaural rendering + *-------------------------------------------------------------------------*/ + void ivas_binaural_add_LFE_fx( + Decoder_Struct * st_ivas, /* i/o: IVAS decoder structure */ + Word16 output_frame, /* i : length of input frame */ + Word32 * input_fx[], /* i : transport channels Q11*/ + Word32 * output_fx[] /* o : synthesized core-coder transport channels/DirAC output Q11*/ + ) { - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) + Word16 render_lfe, idx_lfe, gain_fx; + Word32 lfe_tc[L_FRAME48k]; + + IF( st_ivas->hBinRenderer != NULL ) { - gain_fx = GAIN_LFE_FX; + render_lfe = st_ivas->hBinRenderer->render_lfe; move16(); } ELSE { - test(); - IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) + render_lfe = TRUE; + move16(); + } + + + IF( render_lfe ) + { + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { - gain_fx = st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx; + gain_fx = GAIN_LFE_FX; move16(); } ELSE { - gain_fx = GAIN_LFE_FX; - move16(); + test(); + IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) + { + gain_fx = st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx; + move16(); + } + ELSE + { + gain_fx = GAIN_LFE_FX; + move16(); + } } - } - FOR( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) - { - v_multc_fixed_16( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain_fx, lfe_tc, output_frame ); // q_input_fx - 1 - /* copy LFE to left and right channels */ - FOR( int idx = 0; idx < output_frame; idx++ ) + FOR( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) { - lfe_tc[idx] = L_shl_sat( lfe_tc[idx], 1 ); // saturating to keep same q - move32(); - output_fx[0][idx] = L_add_sat( output_fx[0][idx], lfe_tc[idx] ); - move32(); - output_fx[1][idx] = L_add_sat( output_fx[1][idx], lfe_tc[idx] ); - move32(); + v_multc_fixed_16( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain_fx, lfe_tc, output_frame ); // q_input_fx - 1 + /* copy LFE to left and right channels */ + FOR( int idx = 0; idx < output_frame; idx++ ) + { + lfe_tc[idx] = L_shl_sat( lfe_tc[idx], 1 ); // saturating to keep same q + move32(); + output_fx[0][idx] = L_add_sat( output_fx[0][idx], lfe_tc[idx] ); + move32(); + output_fx[1][idx] = L_add_sat( output_fx[1][idx], lfe_tc[idx] ); + move32(); + } } } - } - return; -} + return; + } -/*------------------------------------------------------------------------- - * ivas_binRenderer_fx() - * - * Fastconv binaural renderer main function - *-------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------- + * ivas_binRenderer_fx() + * + * Fastconv binaural renderer main function + *-------------------------------------------------------------------------*/ -void ivas_binRenderer_fx( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ + void ivas_binRenderer_fx( + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, #endif - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - const Word16 numTimeSlots, /* i : number of time slots to render */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ + const Word16 numTimeSlots, /* i : number of time slots to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT - Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ - Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ #else Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ #endif - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word16 *Q_in /* i : LS signals exp */ -) -{ - Word16 chIdx, i, j, k; + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word16 *Q_in /* i : LS signals exp */ + ) + { + Word16 chIdx, i, j, k; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 pos_idx, num_poses; - Word32 RealBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 ImagBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word16 pos_idx, num_poses; + Word32 RealBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 ImagBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; #endif - // to be checked: feasibility with 32 bit buffers - Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + // to be checked: feasibility with 32 bit buffers + Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - push_wmops( "fastconv_binaural_rendering" ); + push_wmops( "fastconv_binaural_rendering" ); #ifdef SPLIT_REND_WITH_HEAD_ROT - num_poses = hBinRenderer->numPoses; + num_poses = hBinRenderer->numPoses; #endif - /* Compute Convolution */ - /* memory reset for the binaural output */ + /* Compute Convolution */ + /* memory reset for the binaural output */ #ifdef SPLIT_REND_WITH_HEAD_ROT - FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - set32_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + FOR( k = 0; k < numTimeSlots; k++ ) + { + set32_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } } } - } - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + FOR( k = 0; k < numTimeSlots; k++ ) + { + set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } } - } - FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) { - Copy32( RealBuffer_fx[chIdx][k], RealBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - Copy32( ImagBuffer_fx[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + FOR( k = 0; k < numTimeSlots; k++ ) + { + Copy32( RealBuffer_fx[chIdx][k], RealBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + Copy32( ImagBuffer_fx[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + } } - } #else FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { @@ -1962,301 +1980,301 @@ void ivas_binRenderer_fx( } #endif - /* Head rotation in HOA3 or CICPx */ - test(); - test(); - IF( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] && hBinRenderer->rotInCldfb ) - { - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + /* Head rotation in HOA3 or CICPx */ + test(); + test(); + IF( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] && hBinRenderer->rotInCldfb ) { - /* Rotation in SHD (HOA3) */ - IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, -1 ) ) + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); - *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) - move16(); + /* Rotation in SHD (HOA3) */ + IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, -1 ) ) + { + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) + move16(); + } + ELSE IF( hCombinedOrientationData->shd_rot_max_order > 0 ) + { + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); + *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) + move16(); + } } - ELSE IF( hCombinedOrientationData->shd_rot_max_order > 0 ) + ELSE { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); - *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) - move16(); + /* Rotation in SD (CICPx) */ + rotateFrame_sd_cldfb_fixed( hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], RealBuffer_fx, ImagBuffer_fx, + hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); } } - ELSE + + /* HOA decoding to CICP19 if needed*/ + test(); + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && NE_16( hBinRenderer->nInChannels, 16 ) ) { - /* Rotation in SD (CICPx) */ - rotateFrame_sd_cldfb_fixed( hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], RealBuffer_fx, ImagBuffer_fx, - hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx, + hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); } - } - - /* HOA decoding to CICP19 if needed*/ - test(); - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && NE_16( hBinRenderer->nInChannels, 16 ) ) - { - ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx, - hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); - } #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, 0, *Q_in ); + ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, 0, *Q_in ); #else ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in ); #endif - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { - FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { + FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + { #ifdef SPLIT_REND_WITH_HEAD_ROT - Cldfb_RealBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 - move32(); - Cldfb_ImagBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 - move32(); + Cldfb_RealBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + move32(); + Cldfb_ImagBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + move32(); #else Cldfb_RealBuffer_Binaural_fx[i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 move32(); Cldfb_ImagBuffer_Binaural_fx[i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 move32(); #endif + } } } - } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( pMultiBinPoseData != NULL ) - { - IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) + IF( pMultiBinPoseData != NULL ) { - IVAS_QUATERNION Quaternions_abs, Quaternions_ref, Quaternions_ref2; - Word32 Rmat_local[3][3]; - Word16 q_fact_orig, extra_shift = 0; - - IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) + IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) { - Quaternions_ref = hCombinedOrientationData->Quaternions[0]; - q_fact_orig = Quaternions_ref.q_fact; - - modify_Quat_q_fx( &Quaternions_ref, &Quaternions_ref, Q22 ); + IVAS_QUATERNION Quaternions_abs, Quaternions_ref, Quaternions_ref2; + Word32 Rmat_local[3][3]; + Word16 q_fact_orig, extra_shift = 0; - Quaternions_ref2.w_fx = L_negate( 12582912 ); // Q22 - IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, 0 ) ) + IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) { - /*HOA signal already rotated by DirAC*/ - Quaternions_ref2.x_fx = 0; - Quaternions_ref2.y_fx = 0; - Quaternions_ref2.z_fx = 0; - extra_shift = 1; - } - ELSE - { - /*euler*/ - Quat2EulerDegree_fx( Quaternions_ref, &Quaternions_ref2.z_fx, &Quaternions_ref2.y_fx, &Quaternions_ref2.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ - } + Quaternions_ref = hCombinedOrientationData->Quaternions[0]; + q_fact_orig = Quaternions_ref.q_fact; - FOR( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) - { - FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) + modify_Quat_q_fx( &Quaternions_ref, &Quaternions_ref, Q22 ); + + Quaternions_ref2.w_fx = L_negate( 12582912 ); // Q22 + IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, 0 ) ) { - FOR( k = 0; k < numTimeSlots; k++ ) + /*HOA signal already rotated by DirAC*/ + Quaternions_ref2.x_fx = 0; + Quaternions_ref2.y_fx = 0; + Quaternions_ref2.z_fx = 0; + extra_shift = 1; + } + ELSE + { + /*euler*/ + Quat2EulerDegree_fx( Quaternions_ref, &Quaternions_ref2.z_fx, &Quaternions_ref2.y_fx, &Quaternions_ref2.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ + } + + FOR( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) { - Copy32( RealBuffer_local[chIdx][k], RealBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - Copy32( ImagBuffer_local[chIdx][k], ImagBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + FOR( k = 0; k < numTimeSlots; k++ ) + { + Copy32( RealBuffer_local[chIdx][k], RealBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + Copy32( ImagBuffer_local[chIdx][k], ImagBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + } } - } - Quaternions_abs.x_fx = L_add( Quaternions_ref2.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); - Quaternions_abs.y_fx = L_add( Quaternions_ref2.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); - Quaternions_abs.z_fx = L_add( Quaternions_ref2.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); - Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 + Quaternions_abs.x_fx = L_add( Quaternions_ref2.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + Quaternions_abs.y_fx = L_add( Quaternions_ref2.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + Quaternions_abs.z_fx = L_add( Quaternions_ref2.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 - Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), deg2rad_fx( Quaternions_abs.y_fx ), deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); + Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), deg2rad_fx( Quaternions_abs.y_fx ), deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); - modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); + modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); - QuatToRotMat_fx( Quaternions_abs, Rmat_local ); + QuatToRotMat_fx( Quaternions_abs, Rmat_local ); - modify_Rmat_q_fx( Rmat_local, Rmat_local, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); + modify_Rmat_q_fx( Rmat_local, Rmat_local, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); - if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) - { - rotateFrame_sd_cldfb_fixed( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); - } - else - { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); - } + if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) + { + rotateFrame_sd_cldfb_fixed( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + } + else + { + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + } - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + FOR( k = 0; k < numTimeSlots; k++ ) + { + set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } } - } - ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); + ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { - FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - Cldfb_RealBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 - move32(); - Cldfb_ImagBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 - move32(); + FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + { + Cldfb_RealBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 + move32(); + Cldfb_ImagBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 + move32(); + } } } } } } } - } #endif - /* Obtain the binaural dmx and compute the reverb */ - IF( hBinRenderer->hReverb != NULL ) - { - Word32 reverbRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 inRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + /* Obtain the binaural dmx and compute the reverb */ + IF( hBinRenderer->hReverb != NULL ) + { + Word32 reverbRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 inRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx ); + ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx ); - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - set32_fx( reverbRe_fx[chIdx][k], 0, hBinRenderer->max_band ); - set32_fx( reverbIm_fx[chIdx][k], 0, hBinRenderer->max_band ); + FOR( k = 0; k < numTimeSlots; k++ ) + { + set32_fx( reverbRe_fx[chIdx][k], 0, hBinRenderer->max_band ); + set32_fx( reverbIm_fx[chIdx][k], 0, hBinRenderer->max_band ); + } } - } - ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); + ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( j = 0; j < numTimeSlots; j++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { - FOR( k = 0; k < hBinRenderer->hReverb->numBins; k++ ) + FOR( j = 0; j < numTimeSlots; j++ ) { - reverbRe_fx[i][j][k] = L_shl( reverbRe_fx[i][j][k], 1 ); //*Q_in - move32(); - reverbIm_fx[i][j][k] = L_shl( reverbIm_fx[i][j][k], 1 ); //*Q_in - move32(); + FOR( k = 0; k < hBinRenderer->hReverb->numBins; k++ ) + { + reverbRe_fx[i][j][k] = L_shl( reverbRe_fx[i][j][k], 1 ); //*Q_in + move32(); + reverbIm_fx[i][j][k] = L_shl( reverbIm_fx[i][j][k], 1 ); //*Q_in + move32(); + } } } - } - /* Add the conv module and reverb module output */ - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) + /* Add the conv module and reverb module output */ + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + FOR( k = 0; k < numTimeSlots; k++ ) { - /* Combine first and second parts to generate binaural output signal with room effect */ - v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in - v_add_32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in - } +#ifdef SPLIT_REND_WITH_HEAD_ROT + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + /* Combine first and second parts to generate binaural output signal with room effect */ + v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in + v_add_32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in + } #else /* Combine first and second parts to generate binaural output signal with room effect */ v_add_32( Cldfb_RealBuffer_Binaural_fx[chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[chIdx][k], hBinRenderer->conv_band ); // Q_in v_add_32( Cldfb_ImagBuffer_Binaural_fx[chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[chIdx][k], hBinRenderer->conv_band ); // Q_in #endif + } } } + pop_wmops(); + return; } - pop_wmops(); - return; -} #ifdef SPLIT_REND_WITH_HEAD_ROT -/*------------------------------------------------------------------------- - * ivas_rend_CldfbMultiBinRendProcess() - * - * - *-------------------------------------------------------------------------*/ - -void ivas_rend_CldfbMultiBinRendProcess( - const BINAURAL_RENDERER_HANDLE hCldfbRend, - const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData, - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_Out_Real[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const Word16 low_res_pre_rend_rot, - const Word16 num_subframes, - const Word16 Q_in /* i : LS signals exp */ -) -{ - int16_t slot_idx, ch_idx, idx, pose_idx, i, j; - int16_t sf_idx; - Word32 Cldfb_RealBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word16 Q_in_orig; - - FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) - { - Q_in_orig = Q_in; - move16(); - FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) - { - idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; - FOR( ch_idx = 0; ch_idx < hCldfbRend->nInChannels; ch_idx++ ) + /*------------------------------------------------------------------------- + * ivas_rend_CldfbMultiBinRendProcess() + * + * + *-------------------------------------------------------------------------*/ + + void ivas_rend_CldfbMultiBinRendProcess( + const BINAURAL_RENDERER_HANDLE hCldfbRend, + const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_Out_Real[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ + Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 low_res_pre_rend_rot, + const Word16 num_subframes, + const Word16 Q_in /* i : LS signals exp */ + ) + { + int16_t slot_idx, ch_idx, idx, pose_idx, i, j; + int16_t sf_idx; + Word32 Cldfb_RealBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word16 Q_in_orig; + + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + Q_in_orig = Q_in; + move16(); + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { - Copy32( &Cldfb_In_Real[ch_idx][idx][0], &Cldfb_RealBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); - Copy32( &Cldfb_In_Imag[ch_idx][idx][0], &Cldfb_ImagBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); + idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; + FOR( ch_idx = 0; ch_idx < hCldfbRend->nInChannels; ch_idx++ ) + { + Copy32( &Cldfb_In_Real[ch_idx][idx][0], &Cldfb_RealBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); + Copy32( &Cldfb_In_Imag[ch_idx][idx][0], &Cldfb_ImagBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); + } } - } - IF( ( *pCombinedOrientationData ) != NULL ) - { - IF( ( low_res_pre_rend_rot ) && ( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) ) + IF( ( *pCombinedOrientationData ) != NULL ) { - Copy_Quat_fx( &( *pCombinedOrientationData )->Quaternions[0], &( *pCombinedOrientationData )->Quaternions[sf_idx] ); - - FOR( i = 0; i < 3; i++ ) + IF( ( low_res_pre_rend_rot ) && ( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) ) { - FOR( j = 0; j < 3; j++ ) + Copy_Quat_fx( &( *pCombinedOrientationData )->Quaternions[0], &( *pCombinedOrientationData )->Quaternions[sf_idx] ); + + FOR( i = 0; i < 3; i++ ) { - ( *pCombinedOrientationData )->Rmat_fx[sf_idx][i][j] = ( *pCombinedOrientationData )->Rmat_fx[0][i][j]; - move32(); + FOR( j = 0; j < 3; j++ ) + { + ( *pCombinedOrientationData )->Rmat_fx[sf_idx][i][j] = ( *pCombinedOrientationData )->Rmat_fx[0][i][j]; + move32(); + } } } + ( *pCombinedOrientationData )->shd_rot_max_order = -1; + move16(); } - ( *pCombinedOrientationData )->shd_rot_max_order = -1; - move16(); - } - ivas_binRenderer_fx( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn, &Q_in_orig ); + ivas_binRenderer_fx( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn, &Q_in_orig ); - FOR( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) - { - FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + FOR( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) { - idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; - FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { - Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); - Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); - Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig - Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig + idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; + FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) + { + Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); + Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); + Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig + Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig + } } } } - } - return; -} + return; + } #endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 993ad40b2..028afd9d7 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -668,7 +668,7 @@ typedef struct ivas_binaural_rendering_conv_module_struct_fx Word32 ****filterStatesLeftReal_fx; Word32 ****filterStatesLeftImag_fx; #ifdef OPT_BASOP_ADD_v1 - Word16 Q_filterStatesLeft; + Word16 *Q_filterStates; #else Word16 ****Q_filterStatesLeft; #endif -- GitLab From 4cc0b0dda1afad6c2cc9373fc5eab7c3d86352a3 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 11 Mar 2025 12:45:04 +1100 Subject: [PATCH 61/97] clang formatting fix --- lib_dec/ivas_binRenderer_internal_fx.c | 2848 ++++++++++++------------ 1 file changed, 1424 insertions(+), 1424 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index c561ea3df..fa7db4593 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -178,279 +178,279 @@ static void ivas_binRenderer_filterModule_fx( } #endif /* OPT_BASOP_ADD_v1 */ - filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; - move32(); - filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; - move32(); + filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; + move32(); + filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; + move32(); #ifndef OPT_BASOP_ADD_v1 - Q_filterStates[0] = Q_curr; - move16(); + Q_filterStates[0] = Q_curr; + move16(); #endif /* OPT_BASOP_ADD_v1 */ - /* Left Real and Imag */ - // Q29 + Q_curr + /* Left Real and Imag */ + // Q29 + Q_curr - Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); - Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); + Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); + Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( temp2 ), filterTapsLeftImagPtr_fx[0] ); - out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], outRealLeft_fx ); // Q29 - move64(); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( temp2 ), filterTapsLeftImagPtr_fx[0] ); + out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], outRealLeft_fx ); // Q29 + move64(); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); - out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], outImagLeft_fx ); // Q29 - move64(); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); + out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], outImagLeft_fx ); // Q29 + move64(); - /* Right Real and Imag */ - outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); - outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( temp2 ), filterTapsRightImagPtr_fx[0] ); - out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], outRealRight_fx ); // Q29 - move64(); + /* Right Real and Imag */ + outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); + outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( temp2 ), filterTapsRightImagPtr_fx[0] ); + out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], outRealRight_fx ); // Q29 + move64(); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); - out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], outImagRight_fx ); // Q29 - move64(); - } + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); + out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], outImagRight_fx ); // Q29 + move64(); } } - - return; } - /*------------------------------------------------------------------------- - * ivas_binRenderer_convModuleOpen() - * - * Open convolution module handle of fastconv binaural renderer - *-------------------------------------------------------------------------*/ - static ivas_error ivas_binRenderer_convModuleOpen( - BINAURAL_RENDERER_HANDLE hBinRenderer, - const Word16 renderer_type, - const Word16 isLoudspeaker, - const AUDIO_CONFIG input_config, + return; +} + +/*------------------------------------------------------------------------- + * ivas_binRenderer_convModuleOpen() + * + * Open convolution module handle of fastconv binaural renderer + *-------------------------------------------------------------------------*/ +static ivas_error ivas_binRenderer_convModuleOpen( + BINAURAL_RENDERER_HANDLE hBinRenderer, + const Word16 renderer_type, + const Word16 isLoudspeaker, + const AUDIO_CONFIG input_config, #ifdef SPLIT_REND_WITH_HEAD_ROT - const HRTFS_FASTCONV_HANDLE hHrtf, - const Word16 num_poses + const HRTFS_FASTCONV_HANDLE hHrtf, + const Word16 num_poses #else const HRTFS_FASTCONV_HANDLE hHrtf #endif - ) - { - Word16 bandIdx, chIdx; +) +{ + Word16 bandIdx, chIdx; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 pos_idx; + Word16 pos_idx; #endif - BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ + + IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( !isLoudspeaker ) + { + hBinRenderer->nInChannels = audioCfg2channels( input_config ); + move16(); + } + ELSE + { + /* Note: needs to be revisited if multiple LFE support is required */ + hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); + move16(); + } - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; + move16(); - IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) + /* Use variable order filtering */ + bandIdx = 0; + move16(); + FOR( ; bandIdx < 5; bandIdx++ ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); } - - IF( !isLoudspeaker ) + FOR( ; bandIdx < 10; bandIdx++ ) { - hBinRenderer->nInChannels = audioCfg2channels( input_config ); + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; move16(); } - ELSE + FOR( ; bandIdx < 20; bandIdx++ ) { - /* Note: needs to be revisited if multiple LFE support is required */ - hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; move16(); } - - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + FOR( ; bandIdx < 30; bandIdx++ ) { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; move16(); - - /* Use variable order filtering */ - bandIdx = 0; + } + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; + move16(); + } + } + ELSE + { + IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; move16(); - FOR( ; bandIdx < 5; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; - move16(); - } - FOR( ; bandIdx < 10; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; - move16(); - } - FOR( ; bandIdx < 20; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; - move16(); - } - FOR( ; bandIdx < 30; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; - move16(); - } - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; - move16(); - } } ELSE { - IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; - move16(); - } - ELSE - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS; - move16(); - } - - /* Use fixed order filtering */ - bandIdx = 0; + hBinRenConvModule->numTaps = BINAURAL_NTAPS; move16(); - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; - move16(); - } } - /* allocate memory for filter states */ - IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + /* Use fixed order filtering */ + bandIdx = 0; + move16(); + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); } + } + + /* allocate memory for filter states */ + IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { - IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + } - IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + if ( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - } +#ifdef OPT_BASOP_ADD_v1 + IF( ( hBinRenConvModule->Q_filterStates = (Word16 *) malloc( num_poses * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } +#else + IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ****) malloc( num_poses * sizeof( Word16 *** ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } +#endif /* OPT_BASOP_ADD_v1 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } -#ifdef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStates = (Word16 *) malloc( num_poses * sizeof( Word16 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#else - IF( ( hBinRenConvModule->Q_filterStatesLeft = (Word16 ****) malloc( num_poses * sizeof( Word16 *** ) ) ) == NULL ) +#ifndef OPT_BASOP_ADD_v1 + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx] = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #endif /* OPT_BASOP_ADD_v1 */ - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx] = (Word16 ***) malloc( hBinRenderer->conv_band * sizeof( Word16 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #endif /* OPT_BASOP_ADD_v1 */ - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx] = (Word16 **) malloc( hBinRenderer->nInChannels * sizeof( Word16 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } #endif /* OPT_BASOP_ADD_v1 */ - - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - -#ifndef OPT_BASOP_ADD_v1 - IF( ( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx] = (Word16 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word16 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } -#endif /* OPT_BASOP_ADD_v1 */ - } } } + } #else IF( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) @@ -510,962 +510,962 @@ static void ivas_binRenderer_filterModule_fx( } } #endif - /* set memories */ - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + /* set memories */ + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - Word16 tmp = 0; - move16(); + Word16 tmp = 0; + move16(); - IF( isLoudspeaker ) + IF( isLoudspeaker ) + { + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) - { - tmp = channelIndex_CICP6[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) - { - tmp = channelIndex_CICP12[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) - { - tmp = channelIndex_CICP14[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) - { - tmp = channelIndex_CICP16[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) - { - tmp = channelIndex_CICP19[chIdx]; - move16(); - } + tmp = channelIndex_CICP6[chIdx]; + move16(); } - - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) { - /* set the memories to zero */ + tmp = channelIndex_CICP12[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) + { + tmp = channelIndex_CICP14[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) + { + tmp = channelIndex_CICP16[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) + { + tmp = channelIndex_CICP19[chIdx]; + move16(); + } + } + + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + /* set the memories to zero */ #ifndef SPLIT_REND_WITH_HEAD_ROT - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); #else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); #endif /* OPT_BASOP_ADD_v1 */ #endif /* !SPLIT_REND_WITH_HEAD_ROT */ - IF( isLoudspeaker ) - { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; - } - } - ELSE + IF( isLoudspeaker ) { + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; + } + } + ELSE + { #ifndef SPLIT_REND_WITH_HEAD_ROT - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); #else /* OPT_BASOP_ADD_v1 */ - set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); #endif /* OPT_BASOP_ADD_v1 */ #endif /* SPLIT_REND_WITH_HEAD_ROT */ - IF( isLoudspeaker ) + IF( isLoudspeaker ) + { + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; + } + ELSE + { + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + /* HOA3 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + { + /* HOA2 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; + /* FOA filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; } ELSE { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - /* HOA3 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) - { - /* HOA2 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) - { - /* FOA filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; - } - ELSE - { - return IVAS_ERR_INVALID_INPUT_FORMAT; - } + return IVAS_ERR_INVALID_INPUT_FORMAT; } } } } + } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStates[pos_idx] = 31; - move16(); + hBinRenConvModule->Q_filterStates[pos_idx] = 31; + move16(); #endif - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); #ifndef OPT_BASOP_ADD_v1 - set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTapsArray[bandIdx] ); #endif /* OPT_BASOP_ADD_v1 */ - } } } } - ELSE + } + ELSE + { + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { #ifdef OPT_BASOP_ADD_v1 - hBinRenConvModule->Q_filterStates[pos_idx] = 31; - move16(); + hBinRenConvModule->Q_filterStates[pos_idx] = 31; + move16(); #endif - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); #ifndef OPT_BASOP_ADD_v1 - set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); + set16_fx( hBinRenConvModule->Q_filterStatesLeft[pos_idx][bandIdx][chIdx], 31, hBinRenConvModule->numTaps ); #endif /* OPT_BASOP_ADD_v1 */ - } } } } + } #endif - hBinRenderer->hBinRenConvModule = hBinRenConvModule; + hBinRenderer->hBinRenConvModule = hBinRenConvModule; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*-------------------------------------------------------------------------* - * ivas_init_binaural_hrtf() - * - * initialize memory for HrtfFastConv structure elements - *-------------------------------------------------------------------------*/ - void ivas_init_binaural_hrtf_fx( - HRTFS_FASTCONV * HrtfFastConv /* i/o: FASTCONV HRTF structure */ - ) - { - Word16 i; +/*-------------------------------------------------------------------------* + * ivas_init_binaural_hrtf() + * + * initialize memory for HrtfFastConv structure elements + *-------------------------------------------------------------------------*/ +void ivas_init_binaural_hrtf_fx( + HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ +) +{ + Word16 i; + + HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; + HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; + move32(); + + HrtfFastConv->leftHRIRReal_fx = NULL; + HrtfFastConv->leftHRIRImag_fx = NULL; + HrtfFastConv->rightHRIRReal_fx = NULL; + HrtfFastConv->rightHRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; + move32(); + + HrtfFastConv->leftBRIRReal_fx = NULL; + HrtfFastConv->leftBRIRImag_fx = NULL; + HrtfFastConv->rightBRIRReal_fx = NULL; + HrtfFastConv->rightBRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; + move32(); + + HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; + HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; + move32(); + + HrtfFastConv->leftHRIRReal_FOA_fx = NULL; + HrtfFastConv->leftHRIRImag_FOA_fx = NULL; + HrtfFastConv->rightHRIRReal_FOA_fx = NULL; + HrtfFastConv->rightHRIRImag_FOA_fx = NULL; + HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; + move32(); + + HrtfFastConv->allocate_init_flag = 0; + move16(); - HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; - HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; + FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; move32(); - - HrtfFastConv->leftHRIRReal_fx = NULL; - HrtfFastConv->leftHRIRImag_fx = NULL; - HrtfFastConv->rightHRIRReal_fx = NULL; - HrtfFastConv->rightHRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; + HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; move32(); + } - HrtfFastConv->leftBRIRReal_fx = NULL; - HrtfFastConv->leftBRIRImag_fx = NULL; - HrtfFastConv->rightBRIRReal_fx = NULL; - HrtfFastConv->rightBRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; - move32(); - - HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; - HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; - move32(); - - HrtfFastConv->leftHRIRReal_FOA_fx = NULL; - HrtfFastConv->leftHRIRImag_FOA_fx = NULL; - HrtfFastConv->rightHRIRReal_FOA_fx = NULL; - HrtfFastConv->rightHRIRImag_FOA_fx = NULL; - HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; - move32(); - - HrtfFastConv->allocate_init_flag = 0; - move16(); + return; +} - FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; - move32(); - HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; - move32(); - } +/*-------------------------------------------------------------------------* + * ivas_alloc_pppMem() + * + * Allocate memory for tripple pointer elements + *-------------------------------------------------------------------------*/ +static ivas_error ivas_alloc_pppMem_fx( + Word32 ****pppMem, /*Qx*/ + const Word16 dim1, + const Word16 dim2, + const Word16 dim3, + const Word16 allocate_init_flag ) +{ + Word16 i, j; + Word32 ***localMem = NULL; - return; + IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } - /*-------------------------------------------------------------------------* - * ivas_alloc_pppMem() - * - * Allocate memory for tripple pointer elements - *-------------------------------------------------------------------------*/ - static ivas_error ivas_alloc_pppMem_fx( - Word32 * ***pppMem, /*Qx*/ - const Word16 dim1, - const Word16 dim2, - const Word16 dim3, - const Word16 allocate_init_flag ) + for ( i = 0; i < dim1; i++ ) { - Word16 i, j; - Word32 ***localMem = NULL; - - IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } - - for ( i = 0; i < dim1; i++ ) + IF( allocate_init_flag == 0 ) { - IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); - } - IF( allocate_init_flag == 0 ) + FOR( j = 0; j < dim2; j++ ) { - FOR( j = 0; j < dim2; j++ ) + IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) { - IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } } } + } - *pppMem = localMem; + *pppMem = localMem; - return IVAS_ERR_OK; - } + return IVAS_ERR_OK; +} - /*-------------------------------------------------------------------------* - * ivas_allocate_binaural_hrtf() - * - * Allocate memory for HrtfFastConv structure elements - *-------------------------------------------------------------------------*/ - ivas_error ivas_allocate_binaural_hrtf_fx( - HRTFS_FASTCONV * HrtfFastConv, /* i/o: FASTCONV HRTF structure */ - const AUDIO_CONFIG input_config, /* i : input audio configuration */ - const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ - const RENDERER_TYPE renderer_type, /* i : renderer type */ - const Word16 allocate_init_flag /* i : Memory allocation flag */ - ) +/*-------------------------------------------------------------------------* + * ivas_allocate_binaural_hrtf() + * + * Allocate memory for HrtfFastConv structure elements + *-------------------------------------------------------------------------*/ +ivas_error ivas_allocate_binaural_hrtf_fx( + HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ + const AUDIO_CONFIG input_config, /* i : input audio configuration */ + const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ + const RENDERER_TYPE renderer_type, /* i : renderer type */ + const Word16 allocate_init_flag /* i : Memory allocation flag */ +) +{ + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) ) { test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) ) + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA3_fx != NULL ) ) { - test(); - test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA3_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA3_fx != NULL ) ) + return IVAS_ERR_OK; + } + ELSE + { + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - return IVAS_ERR_OK; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA3" ); } - ELSE + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA3" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA3" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA3" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA3" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA3" ); } - } - - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) ) - { - test(); - test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA2_fx != NULL ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - return IVAS_ERR_OK; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA3" ); } - ELSE + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA3_fx, BINAURAL_CONVBANDS, HOA3_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA2" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA2" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA2" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA2" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA3" ); } } + } + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) ) + { test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_FOA ) ) + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA2_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA2_fx != NULL ) ) { - test(); - test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_FOA_fx != NULL ) ) + return IVAS_ERR_OK; + } + ELSE + { + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - return IVAS_ERR_OK; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_HOA2" ); } - ELSE + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_FOA" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_FOA" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_FOA" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_FOA" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_HOA2" ); } - } - - test(); - IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) - { - test(); - test(); - test(); - IF( ( HrtfFastConv->leftHRIRReal_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_fx != NULL ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - return IVAS_ERR_OK; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_HOA2" ); } - ELSE + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_HOA2_fx, BINAURAL_CONVBANDS, HOA2_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_HOA2" ); } } + } + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_FOA ) ) + { test(); - IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_FOA_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_FOA_fx != NULL ) ) { - test(); - test(); - test(); - IF( ( HrtfFastConv->leftBRIRReal_fx != NULL ) && ( HrtfFastConv->leftBRIRImag_fx != NULL ) && ( HrtfFastConv->rightBRIRReal_fx != NULL ) && ( HrtfFastConv->rightBRIRImag_fx != NULL ) ) + return IVAS_ERR_OK; + } + ELSE + { + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - return IVAS_ERR_OK; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal_FOA" ); } - ELSE + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) { - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRReal" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRImag" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRReal" ); - } - IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRImag" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag_FOA" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal_FOA" ); + } + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_FOA_fx, BINAURAL_CONVBANDS, FOA_CHANNELS, BINAURAL_NTAPS_SBA, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag_FOA" ); } } - - return IVAS_ERR_OK; } - /*-------------------------------------------------------------------------* - * ivas_binaural_HRTF_open() - * - * - *-------------------------------------------------------------------------*/ - static ivas_error ivas_binaural_hrtf_open_fx( - HRTFS_FASTCONV_HANDLE * hHrtfFastConv, /* i : fastconv HRTF handle */ - const AUDIO_CONFIG input_config, /* i : output configuration */ - const RENDERER_TYPE renderer_type /* i : renderer type */ - ) + test(); + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) { - Word16 i, j; - ivas_error error; - test(); - IF( hHrtfFastConv != NULL && *hHrtfFastConv != NULL ) + test(); + test(); + IF( ( HrtfFastConv->leftHRIRReal_fx != NULL ) && ( HrtfFastConv->leftHRIRImag_fx != NULL ) && ( HrtfFastConv->rightHRIRReal_fx != NULL ) && ( HrtfFastConv->rightHRIRImag_fx != NULL ) ) { - /* Tables already loaded from file */ return IVAS_ERR_OK; } ELSE { - /* Initialise tables from ROM */ - HRTFS_FASTCONV *HrtfFastConv; - - IF( ( HrtfFastConv = (HRTFS_FASTCONV *) malloc( sizeof( HRTFS_FASTCONV ) ) ) == NULL ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for FastConv HRTF tables" ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRReal" ); } - - ivas_init_binaural_hrtf_fx( HrtfFastConv ); - - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) { - HrtfFastConv->FASTCONV_HRIR_latency_s_fx = FASTCONV_HRIR_latency_s_fx; - move32(); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftHRIRImag" ); } - if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) { - HrtfFastConv->FASTCONV_HOA2_latency_s_fx = FASTCONV_HOA2_latency_s_fx; - move32(); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRReal" ); } - if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightHRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS, allocate_init_flag ) ) ) { - HrtfFastConv->FASTCONV_HOA3_latency_s_fx = FASTCONV_HOA3_latency_s_fx; - move32(); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightHRIRImag" ); + } + } + } + + test(); + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( bin_input_config, BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) + { + test(); + test(); + test(); + IF( ( HrtfFastConv->leftBRIRReal_fx != NULL ) && ( HrtfFastConv->leftBRIRImag_fx != NULL ) && ( HrtfFastConv->rightBRIRReal_fx != NULL ) && ( HrtfFastConv->rightBRIRImag_fx != NULL ) ) + { + return IVAS_ERR_OK; + } + ELSE + { + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRReal" ); } - if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->leftBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) { - HrtfFastConv->FASTCONV_FOA_latency_s_fx = FASTCONV_FOA_latency_s_fx; - move32(); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for leftBRIRImag" ); } - test(); - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRReal_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) { - HrtfFastConv->FASTCONV_BRIR_latency_s_fx = FASTCONV_BRIR_latency_s_fx; - move32(); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRReal" ); } - - HrtfFastConv->allocate_init_flag = 1; - move16(); - - IF( NE_32( ( error = ivas_allocate_binaural_hrtf_fx( HrtfFastConv, input_config, BINAURAL_INPUT_AUDIO_CONFIG_INVALID, renderer_type, HrtfFastConv->allocate_init_flag ) ), IVAS_ERR_OK ) ) + IF( NE_32( IVAS_ERR_OK, ivas_alloc_pppMem_fx( &HrtfFastConv->rightBRIRImag_fx, BINAURAL_CONVBANDS, HRTF_LS_CHANNELS, BINAURAL_NTAPS_MAX, allocate_init_flag ) ) ) { - return error; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for rightBRIRImag" ); } - FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) + } + } + + return IVAS_ERR_OK; +} + +/*-------------------------------------------------------------------------* + * ivas_binaural_HRTF_open() + * + * + *-------------------------------------------------------------------------*/ +static ivas_error ivas_binaural_hrtf_open_fx( + HRTFS_FASTCONV_HANDLE *hHrtfFastConv, /* i : fastconv HRTF handle */ + const AUDIO_CONFIG input_config, /* i : output configuration */ + const RENDERER_TYPE renderer_type /* i : renderer type */ +) +{ + Word16 i, j; + ivas_error error; + + test(); + IF( hHrtfFastConv != NULL && *hHrtfFastConv != NULL ) + { + /* Tables already loaded from file */ + return IVAS_ERR_OK; + } + ELSE + { + /* Initialise tables from ROM */ + HRTFS_FASTCONV *HrtfFastConv; + + IF( ( HrtfFastConv = (HRTFS_FASTCONV *) malloc( sizeof( HRTFS_FASTCONV ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for FastConv HRTF tables" ); + } + + ivas_init_binaural_hrtf_fx( HrtfFastConv ); + + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) + { + HrtfFastConv->FASTCONV_HRIR_latency_s_fx = FASTCONV_HRIR_latency_s_fx; + move32(); + } + if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + { + HrtfFastConv->FASTCONV_HOA2_latency_s_fx = FASTCONV_HOA2_latency_s_fx; + move32(); + } + if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + HrtfFastConv->FASTCONV_HOA3_latency_s_fx = FASTCONV_HOA3_latency_s_fx; + move32(); + } + if ( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + HrtfFastConv->FASTCONV_FOA_latency_s_fx = FASTCONV_FOA_latency_s_fx; + move32(); + } + test(); + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + HrtfFastConv->FASTCONV_BRIR_latency_s_fx = FASTCONV_BRIR_latency_s_fx; + move32(); + } + + HrtfFastConv->allocate_init_flag = 1; + move16(); + + IF( NE_32( ( error = ivas_allocate_binaural_hrtf_fx( HrtfFastConv, input_config, BINAURAL_INPUT_AUDIO_CONFIG_INVALID, renderer_type, HrtfFastConv->allocate_init_flag ) ), IVAS_ERR_OK ) ) + { + return error; + } + FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) + { + IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { - IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV ) ) + FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) { - FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - HrtfFastConv->leftHRIRReal_fx[i][j] = leftHRIRReal_fx[i][j]; - HrtfFastConv->leftHRIRImag_fx[i][j] = leftHRIRImag_fx[i][j]; - HrtfFastConv->rightHRIRReal_fx[i][j] = rightHRIRReal_fx[i][j]; - HrtfFastConv->rightHRIRImag_fx[i][j] = rightHRIRImag_fx[i][j]; - } + HrtfFastConv->leftHRIRReal_fx[i][j] = leftHRIRReal_fx[i][j]; + HrtfFastConv->leftHRIRImag_fx[i][j] = leftHRIRImag_fx[i][j]; + HrtfFastConv->rightHRIRReal_fx[i][j] = rightHRIRReal_fx[i][j]; + HrtfFastConv->rightHRIRImag_fx[i][j] = rightHRIRImag_fx[i][j]; } - ELSE IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + } + ELSE IF( EQ_32( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) { - FOR( j = 0; j < HRTF_LS_CHANNELS; j++ ) - { - HrtfFastConv->leftBRIRReal_fx[i][j] = leftBRIRReal_fx[i][j]; - HrtfFastConv->leftBRIRImag_fx[i][j] = leftBRIRImag_fx[i][j]; - HrtfFastConv->rightBRIRReal_fx[i][j] = rightBRIRReal_fx[i][j]; - HrtfFastConv->rightBRIRImag_fx[i][j] = rightBRIRImag_fx[i][j]; - } + HrtfFastConv->leftBRIRReal_fx[i][j] = leftBRIRReal_fx[i][j]; + HrtfFastConv->leftBRIRImag_fx[i][j] = leftBRIRImag_fx[i][j]; + HrtfFastConv->rightBRIRReal_fx[i][j] = rightBRIRReal_fx[i][j]; + HrtfFastConv->rightBRIRImag_fx[i][j] = rightBRIRImag_fx[i][j]; } - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + } + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + FOR( j = 0; j < HOA3_CHANNELS; j++ ) { - FOR( j = 0; j < HOA3_CHANNELS; j++ ) - { - HrtfFastConv->leftHRIRReal_HOA3_fx[i][j] = leftHRIRReal_HOA3_fx[i][j]; - HrtfFastConv->leftHRIRImag_HOA3_fx[i][j] = leftHRIRImag_HOA3_fx[i][j]; - HrtfFastConv->rightHRIRReal_HOA3_fx[i][j] = rightHRIRReal_HOA3_fx[i][j]; - HrtfFastConv->rightHRIRImag_HOA3_fx[i][j] = rightHRIRImag_HOA3_fx[i][j]; - } + HrtfFastConv->leftHRIRReal_HOA3_fx[i][j] = leftHRIRReal_HOA3_fx[i][j]; + HrtfFastConv->leftHRIRImag_HOA3_fx[i][j] = leftHRIRImag_HOA3_fx[i][j]; + HrtfFastConv->rightHRIRReal_HOA3_fx[i][j] = rightHRIRReal_HOA3_fx[i][j]; + HrtfFastConv->rightHRIRImag_HOA3_fx[i][j] = rightHRIRImag_HOA3_fx[i][j]; } - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + } + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + { + FOR( j = 0; j < HOA2_CHANNELS; j++ ) { - FOR( j = 0; j < HOA2_CHANNELS; j++ ) - { - HrtfFastConv->leftHRIRReal_HOA2_fx[i][j] = leftHRIRReal_HOA2_fx[i][j]; - HrtfFastConv->leftHRIRImag_HOA2_fx[i][j] = leftHRIRImag_HOA2_fx[i][j]; - HrtfFastConv->rightHRIRReal_HOA2_fx[i][j] = rightHRIRReal_HOA2_fx[i][j]; - HrtfFastConv->rightHRIRImag_HOA2_fx[i][j] = rightHRIRImag_HOA2_fx[i][j]; - } + HrtfFastConv->leftHRIRReal_HOA2_fx[i][j] = leftHRIRReal_HOA2_fx[i][j]; + HrtfFastConv->leftHRIRImag_HOA2_fx[i][j] = leftHRIRImag_HOA2_fx[i][j]; + HrtfFastConv->rightHRIRReal_HOA2_fx[i][j] = rightHRIRReal_HOA2_fx[i][j]; + HrtfFastConv->rightHRIRImag_HOA2_fx[i][j] = rightHRIRImag_HOA2_fx[i][j]; } - IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + } + IF( EQ_32( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + FOR( j = 0; j < FOA_CHANNELS; j++ ) { - FOR( j = 0; j < FOA_CHANNELS; j++ ) - { - HrtfFastConv->leftHRIRReal_FOA_fx[i][j] = leftHRIRReal_FOA_fx[i][j]; - HrtfFastConv->leftHRIRImag_FOA_fx[i][j] = leftHRIRImag_FOA_fx[i][j]; - HrtfFastConv->rightHRIRReal_FOA_fx[i][j] = rightHRIRReal_FOA_fx[i][j]; - HrtfFastConv->rightHRIRImag_FOA_fx[i][j] = rightHRIRImag_FOA_fx[i][j]; - } + HrtfFastConv->leftHRIRReal_FOA_fx[i][j] = leftHRIRReal_FOA_fx[i][j]; + HrtfFastConv->leftHRIRImag_FOA_fx[i][j] = leftHRIRImag_FOA_fx[i][j]; + HrtfFastConv->rightHRIRReal_FOA_fx[i][j] = rightHRIRReal_FOA_fx[i][j]; + HrtfFastConv->rightHRIRImag_FOA_fx[i][j] = rightHRIRImag_FOA_fx[i][j]; } } - Copy32( fastconvReverberationTimes_fx, HrtfFastConv->fastconvReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); - Copy32( fastconvReverberationEneCorrections_fx, HrtfFastConv->fastconvReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); - - *hHrtfFastConv = HrtfFastConv; } + Copy32( fastconvReverberationTimes_fx, HrtfFastConv->fastconvReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); + Copy32( fastconvReverberationEneCorrections_fx, HrtfFastConv->fastconvReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); - return IVAS_ERR_OK; + *hHrtfFastConv = HrtfFastConv; } - /*-------------------------------------------------------------------------* - * ivas_binaural_obtain_DMX_fx() - * - * - *-------------------------------------------------------------------------*/ - static void ivas_binaural_obtain_DMX_fx( - const Word16 numTimeSlots, - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ - Word32 RealBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ - Word32 ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ - Word32 realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q_in-1*/ - Word32 imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] ) /*Q_in-1*/ - { - Word16 chIdx, bandIdx, k; + return IVAS_ERR_OK; +} +/*-------------------------------------------------------------------------* + * ivas_binaural_obtain_DMX_fx() + * + * + *-------------------------------------------------------------------------*/ - test(); - IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) - { - /* Obtain the downmix */ - Word32 P_in_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 P_out_fx, factEQ_fx; - Word16 chOutIdx; - Word32 temp1_fx, temp2_fx; +static void ivas_binaural_obtain_DMX_fx( + const Word16 numTimeSlots, + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ + Word32 RealBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ + Word32 ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Contains the LS signals Q_in */ + Word32 realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*Q_in-1*/ + Word32 imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] ) /*Q_in-1*/ +{ + Word16 chIdx, bandIdx, k; - FOR( k = 0; k < numTimeSlots; k++ ) - { - FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) - { - set32_fx( realDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - } - } + test(); + IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) + { + /* Obtain the downmix */ + Word32 P_in_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 P_out_fx, factEQ_fx; + Word16 chOutIdx; + Word32 temp1_fx, temp2_fx; + FOR( k = 0; k < numTimeSlots; k++ ) + { FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) { - set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); + set32_fx( realDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( imagDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } + } - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - Word32 dmxConst = hBinRenderer->hReverb->dmxmtx_fx[chOutIdx][chIdx]; - move32(); + FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) + { + set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) - { - temp1_fx = Mpy_32_32( RealBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in - temp2_fx = Mpy_32_32( ImagBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in - realDMX[chOutIdx][k][bandIdx] = L_add( realDMX[chOutIdx][k][bandIdx], temp1_fx ); // Q_in - move32(); - imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in - move32(); - - P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in - move32(); - } - } - } + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + Word32 dmxConst = hBinRenderer->hReverb->dmxmtx_fx[chOutIdx][chIdx]; + move32(); FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - P_out_fx = 0; - move32(); FOR( k = 0; k < numTimeSlots; k++ ) { - temp1_fx = realDMX[chOutIdx][k][bandIdx]; - move32(); - temp2_fx = imagDMX[chOutIdx][k][bandIdx]; + temp1_fx = Mpy_32_32( RealBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in + temp2_fx = Mpy_32_32( ImagBuffer[chIdx][k][bandIdx], dmxConst ); // Q_in + realDMX[chOutIdx][k][bandIdx] = L_add( realDMX[chOutIdx][k][bandIdx], temp1_fx ); // Q_in move32(); - P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in - } - test(); - IF( ( P_in_fx[bandIdx] <= 0 ) || ( P_out_fx <= 0 ) ) - { - factEQ_fx = 0x40000000; // 1.0f in Q30 + imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in move32(); - } - ELSE - { - Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); - Word16 exp = norm_l( div ); - factEQ_fx = Sqrt32( L_shl( div, Q16 ), &exp ); - factEQ_fx = L_shl( factEQ_fx, sub( exp, 1 ) ); // Q30 - } - if ( factEQ_fx <= 0 ) - { - factEQ_fx = 0x40000000; // 1.0f in Q30 + + P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in move32(); } + } + } - factEQ_fx = L_max( L_min( factEQ_fx, 0x7fffffff ), 0x20000000 ); // Q30 , 0x7fffffff -> (1.0f in Q31)-1, 0x20000000 ->1.0f in Q29 - FOR( k = 0; k < numTimeSlots; k++ ) - { - realDMX[chOutIdx][k][bandIdx] = Mpy_32_32( realDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 - move32(); - imagDMX[chOutIdx][k][bandIdx] = Mpy_32_32( imagDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 - move32(); - } + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + P_out_fx = 0; + move32(); + FOR( k = 0; k < numTimeSlots; k++ ) + { + temp1_fx = realDMX[chOutIdx][k][bandIdx]; + move32(); + temp2_fx = imagDMX[chOutIdx][k][bandIdx]; + move32(); + P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in + } + test(); + IF( ( P_in_fx[bandIdx] <= 0 ) || ( P_out_fx <= 0 ) ) + { + factEQ_fx = 0x40000000; // 1.0f in Q30 + move32(); + } + ELSE + { + Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); + Word16 exp = norm_l( div ); + factEQ_fx = Sqrt32( L_shl( div, Q16 ), &exp ); + factEQ_fx = L_shl( factEQ_fx, sub( exp, 1 ) ); // Q30 + } + if ( factEQ_fx <= 0 ) + { + factEQ_fx = 0x40000000; // 1.0f in Q30 + move32(); + } + + factEQ_fx = L_max( L_min( factEQ_fx, 0x7fffffff ), 0x20000000 ); // Q30 , 0x7fffffff -> (1.0f in Q31)-1, 0x20000000 ->1.0f in Q29 + FOR( k = 0; k < numTimeSlots; k++ ) + { + realDMX[chOutIdx][k][bandIdx] = Mpy_32_32( realDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 + move32(); + imagDMX[chOutIdx][k][bandIdx] = Mpy_32_32( imagDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1 + move32(); } } } - ELSE IF( EQ_32( hBinRenderer->ivas_format, SBA_FORMAT ) || EQ_32( hBinRenderer->ivas_format, MASA_FORMAT ) ) + } + ELSE IF( EQ_32( hBinRenderer->ivas_format, SBA_FORMAT ) || EQ_32( hBinRenderer->ivas_format, MASA_FORMAT ) ) + { + Word32 *outRealLeftPtr_fx, *outImagLeftPtr_fx, *outRealRightPtr_fx, *outImagRightPtr_fx; + Word32 *inRealPtr_fx, *inImagPtr_fx; + + /*compute DMX */ + FOR( k = 0; k < numTimeSlots; k++ ) { - Word32 *outRealLeftPtr_fx, *outImagLeftPtr_fx, *outRealRightPtr_fx, *outImagRightPtr_fx; - Word32 *inRealPtr_fx, *inImagPtr_fx; + outRealLeftPtr_fx = realDMX[0][k]; + outImagLeftPtr_fx = imagDMX[0][k]; + outRealRightPtr_fx = realDMX[1][k]; + outImagRightPtr_fx = imagDMX[1][k]; + set32_fx( outRealLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outImagLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outRealRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( outImagRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - /*compute DMX */ - FOR( k = 0; k < numTimeSlots; k++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - outRealLeftPtr_fx = realDMX[0][k]; - outImagLeftPtr_fx = imagDMX[0][k]; - outRealRightPtr_fx = realDMX[1][k]; - outImagRightPtr_fx = imagDMX[1][k]; - set32_fx( outRealLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outImagLeftPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outRealRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( outImagRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - Word32 foa_const_fx = L_shl( hBinRenderer->hReverb->foa_enc_fx[chIdx][1], 1 ); // Q30 + Word32 foa_const_fx = L_shl( hBinRenderer->hReverb->foa_enc_fx[chIdx][1], 1 ); // Q30 - inRealPtr_fx = (Word32 *) &( RealBuffer[chIdx][k][0] ); - inImagPtr_fx = (Word32 *) &( ImagBuffer[chIdx][k][0] ); + inRealPtr_fx = (Word32 *) &( RealBuffer[chIdx][k][0] ); + inImagPtr_fx = (Word32 *) &( ImagBuffer[chIdx][k][0] ); - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - outRealLeftPtr_fx[bandIdx] = L_add( outRealLeftPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); - outImagLeftPtr_fx[bandIdx] = L_add( outImagLeftPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + outRealLeftPtr_fx[bandIdx] = L_add( outRealLeftPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); + outImagLeftPtr_fx[bandIdx] = L_add( outImagLeftPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_add( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); - outRealRightPtr_fx[bandIdx] = L_add( outRealRightPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); - outImagRightPtr_fx[bandIdx] = L_add( outImagRightPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 - move32(); - } + outRealRightPtr_fx[bandIdx] = L_add( outRealRightPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); + outImagRightPtr_fx[bandIdx] = L_add( outImagRightPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], L_sub( ONE_IN_Q30, foa_const_fx ) ) ); // Q_in - 1 + move32(); } } } - - return; } + return; +} + #ifdef SPLIT_REND_WITH_HEAD_ROT - /*------------------------------------------------------------------------- - * ivas_rend_openCldfbRend() - * - * Allocate and initialize CLDFB fast conv renderer handle - *------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * ivas_rend_openCldfbRend() + * + * Allocate and initialize CLDFB fast conv renderer handle + *------------------------------------------------------------------------*/ + +ivas_error ivas_rend_openCldfbRend( + CLDFB_REND_WRAPPER *pCldfbRend, + const AUDIO_CONFIG inConfig, + const AUDIO_CONFIG outConfig, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const Word32 output_Fs ) +{ + BINAURAL_RENDERER_HANDLE hBinRenderer; + Word16 convBand; + ivas_error error; - ivas_error ivas_rend_openCldfbRend( - CLDFB_REND_WRAPPER * pCldfbRend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const Word32 output_Fs ) - { - BINAURAL_RENDERER_HANDLE hBinRenderer; - Word16 convBand; - ivas_error error; + error = IVAS_ERR_OK; - error = IVAS_ERR_OK; + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ + if ( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); + } - if ( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); - } + if ( ( hBinRenderer->hInputSetup = (IVAS_OUTPUT_SETUP_HANDLE) malloc( sizeof( IVAS_OUTPUT_SETUP ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output setup Binaural Renderer\n" ) ); + } - if ( ( hBinRenderer->hInputSetup = (IVAS_OUTPUT_SETUP_HANDLE) malloc( sizeof( IVAS_OUTPUT_SETUP ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output setup Binaural Renderer\n" ) ); - } + hBinRenderer->rotInCldfb = 1; + hBinRenderer->ivas_format = SBA_FORMAT; - hBinRenderer->rotInCldfb = 1; - hBinRenderer->ivas_format = SBA_FORMAT; + hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); + move16(); - hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); - move16(); + convBand = hBinRenderer->max_band; + move16(); - convBand = hBinRenderer->max_band; - move16(); + hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ + move16(); - hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ + IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) + { + hBinRenderer->conv_band = BINAURAL_CONVBANDS; move16(); + } + ELSE + { + hBinRenderer->conv_band = convBand; + move16(); + } - IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) - { - hBinRenderer->conv_band = BINAURAL_CONVBANDS; - move16(); - } - ELSE - { - hBinRenderer->conv_band = convBand; - move16(); - } - - hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; - hBinRenderer->hInputSetup->output_config = inConfig; - IF( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - hBinRenderer->numPoses = pMultiBinPoseData->num_poses; - move16(); - } - ELSE - { - hBinRenderer->numPoses = 1; - move16(); - } + hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; + hBinRenderer->hInputSetup->output_config = inConfig; + IF( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) + { + return error; + } - /*LFE rendering switched off by default*/ - hBinRenderer->render_lfe = 0; + IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + hBinRenderer->numPoses = pMultiBinPoseData->num_poses; move16(); + } + ELSE + { + hBinRenderer->numPoses = 1; + move16(); + } + /*LFE rendering switched off by default*/ + hBinRenderer->render_lfe = 0; + move16(); - /* Load HRTF tables */ - IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &pCldfbRend->hHrtfFastConv, hBinRenderer->hInputSetup->output_config, RENDERER_BINAURAL_FASTCONV ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* Allocate memories and buffers needed for convolutional module in CICP19 */ - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, RENDERER_BINAURAL_FASTCONV, hBinRenderer->hInputSetup->is_loudspeaker_setup, inConfig, pCldfbRend->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) - { - return error; - } - pCldfbRend->binaural_latency_ns = (Word32) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx * 1000000000 ); - move32(); - hBinRenderer->hReverb = NULL; - move32(); - hBinRenderer->hEFAPdata = NULL; - move32(); - pCldfbRend->hCldfbRend = hBinRenderer; - move32(); + /* Load HRTF tables */ + IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &pCldfbRend->hHrtfFastConv, hBinRenderer->hInputSetup->output_config, RENDERER_BINAURAL_FASTCONV ) ), IVAS_ERR_OK ) ) + { + return error; + } + /* Allocate memories and buffers needed for convolutional module in CICP19 */ + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, RENDERER_BINAURAL_FASTCONV, hBinRenderer->hInputSetup->is_loudspeaker_setup, inConfig, pCldfbRend->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { return error; } + + pCldfbRend->binaural_latency_ns = (Word32) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx * 1000000000 ); + move32(); + hBinRenderer->hReverb = NULL; + move32(); + hBinRenderer->hEFAPdata = NULL; + move32(); + pCldfbRend->hCldfbRend = hBinRenderer; + move32(); + + return error; +} #endif - /*------------------------------------------------------------------------- - * ivas_binRenderer_open() - * - * Open fastconv binaural renderer handle - *-------------------------------------------------------------------------*/ - ivas_error ivas_binRenderer_open_fx( - Decoder_Struct * st_ivas /* i/o: IVAS decoder structure */ - ) - { - BINAURAL_RENDERER_HANDLE hBinRenderer; - Word16 convBand, chIdx, k; - ivas_error error; +/*------------------------------------------------------------------------- + * ivas_binRenderer_open() + * + * Open fastconv binaural renderer handle + *-------------------------------------------------------------------------*/ +ivas_error ivas_binRenderer_open_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + BINAURAL_RENDERER_HANDLE hBinRenderer; + Word16 convBand, chIdx, k; + ivas_error error; - error = IVAS_ERR_OK; - move32(); + error = IVAS_ERR_OK; + move32(); - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ - IF( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); - } + IF( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); + } - hBinRenderer->hInputSetup = &st_ivas->hIntSetup; + hBinRenderer->hInputSetup = &st_ivas->hIntSetup; - /* Define of head rotation has to be done in binRendeder in CLDFB*/ - hBinRenderer->rotInCldfb = 0; + /* Define of head rotation has to be done in binRendeder in CLDFB*/ + hBinRenderer->rotInCldfb = 0; + move16(); + test(); + if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) + { + hBinRenderer->rotInCldfb = 1; move16(); - test(); - if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) - { - hBinRenderer->rotInCldfb = 1; - move16(); - } + } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) - { - hBinRenderer->numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; - move16(); - } - else - { - hBinRenderer->numPoses = 1; - move16(); - } + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + { + hBinRenderer->numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); + } + else + { + hBinRenderer->numPoses = 1; + move16(); + } #endif - /* Declare some common variables needed for renderer */ - /* Which format used for binaural rendering (needed for late reverb) ? MC or SBA */ - IF( st_ivas->hIntSetup.is_loudspeaker_setup ) - { - hBinRenderer->ivas_format = MC_FORMAT; - move32(); - } - ELSE - { - hBinRenderer->ivas_format = SBA_FORMAT; - move32(); - } - hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( st_ivas->hDecoderConfig->output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); - move16(); + /* Declare some common variables needed for renderer */ + /* Which format used for binaural rendering (needed for late reverb) ? MC or SBA */ + IF( st_ivas->hIntSetup.is_loudspeaker_setup ) + { + hBinRenderer->ivas_format = MC_FORMAT; + move32(); + } + ELSE + { + hBinRenderer->ivas_format = SBA_FORMAT; + move32(); + } + hBinRenderer->max_band = extract_l( Mpy_32_32( Mpy_32_32( BINAURAL_MAXBANDS_Q25, L_shl( st_ivas->hDecoderConfig->output_Fs, Q6 ) ), ONE_BY_48000_Q31 ) ); + move16(); - convBand = hBinRenderer->max_band; - move16(); + convBand = hBinRenderer->max_band; + move16(); - hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ + hBinRenderer->timeSlots = MAX_PARAM_SPATIAL_SUBFRAMES; /* Corresponds to 5 msec sound to motion latency */ + move16(); + + IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) + { + hBinRenderer->conv_band = BINAURAL_CONVBANDS; move16(); + } + ELSE + { + hBinRenderer->conv_band = convBand; + move16(); + } - IF( GT_16( convBand, BINAURAL_CONVBANDS ) ) - { - hBinRenderer->conv_band = BINAURAL_CONVBANDS; - move16(); - } - ELSE - { - hBinRenderer->conv_band = convBand; - move16(); - } + /*LFE rendering switched off by default*/ + hBinRenderer->render_lfe = 0; + move16(); - /*LFE rendering switched off by default*/ - hBinRenderer->render_lfe = 0; + test(); + if ( NE_32( st_ivas->ivas_format, ISM_FORMAT ) && st_ivas->hIntSetup.is_loudspeaker_setup ) + { + hBinRenderer->render_lfe = 1; move16(); + } - test(); - if ( NE_32( st_ivas->ivas_format, ISM_FORMAT ) && st_ivas->hIntSetup.is_loudspeaker_setup ) - { - hBinRenderer->render_lfe = 1; - move16(); - } + /* Load HRTF tables */ + IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &st_ivas->hHrtfFastConv, st_ivas->hIntSetup.output_config, st_ivas->renderer_type ) ), IVAS_ERR_OK ) ) + { + return error; + } + + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hIntSetup.is_loudspeaker_setup == 0 ) ) + { + IVAS_OUTPUT_SETUP out_setup; - /* Load HRTF tables */ - IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &st_ivas->hHrtfFastConv, st_ivas->hIntSetup.output_config, st_ivas->renderer_type ) ), IVAS_ERR_OK ) ) + /* Allocate memories and buffers needed for convolutional module in CICP19 */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) { return error; } - - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hIntSetup.is_loudspeaker_setup == 0 ) ) - { - IVAS_OUTPUT_SETUP out_setup; - - /* Allocate memories and buffers needed for convolutional module in CICP19 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) - { - return error; - } #else IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) { return error; } #endif - ivas_output_init( &out_setup, IVAS_AUDIO_CONFIG_7_1_4 ); + ivas_output_init( &out_setup, IVAS_AUDIO_CONFIG_7_1_4 ); - IF( st_ivas->hoa_dec_mtx == NULL ) - { - IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - - hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx; - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; - move32(); - } - ELSE + IF( st_ivas->hoa_dec_mtx == NULL ) { - /* Allocate memories and buffers needed for convolutional module */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_sba_get_hoa_dec_matrix_fx( out_setup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ), IVAS_ERR_OK ) ) { return error; } + } + + hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx; + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; + move32(); + } + ELSE + { + /* Allocate memories and buffers needed for convolutional module */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) + { + return error; + } #else IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) { @@ -1473,196 +1473,196 @@ static void ivas_binRenderer_filterModule_fx( } #endif - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) + { + IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) + { + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HRIR_latency_s_fx; + move32(); + } + ELSE { - IF( EQ_32( hBinRenderer->ivas_format, MC_FORMAT ) ) + IF( EQ_16( hBinRenderer->nInChannels, 16 ) ) { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HRIR_latency_s_fx; + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx; move32(); } - ELSE + ELSE IF( EQ_16( hBinRenderer->nInChannels, 9 ) ) { - IF( EQ_16( hBinRenderer->nInChannels, 16 ) ) - { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA3_latency_s_fx; - move32(); - } - ELSE IF( EQ_16( hBinRenderer->nInChannels, 9 ) ) - { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA2_latency_s_fx; - move32(); - } - ELSE IF( EQ_16( hBinRenderer->nInChannels, 4 ) ) - { - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_FOA_latency_s_fx; - move32(); - } - ELSE - { - return IVAS_ERR_INVALID_INPUT_FORMAT; - } + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_HOA2_latency_s_fx; + move32(); } - } - ELSE - { - /* same value for MC or HOA both use MC BRIR*/ - st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; - move32(); - } - } - - /* Allocate memories needed for reverb module */ - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) - { - IF( NE_32( ( error = ivas_binaural_reverb_open_fastconv_fx( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* initialize the dmx matrix */ - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < hBinRenderer->nInChannels; k++ ) + ELSE IF( EQ_16( hBinRenderer->nInChannels, 4 ) ) { - hBinRenderer->hReverb->dmxmtx_fx[chIdx][k] = dmxmtx_table_fx[chIdx][k]; + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_FOA_latency_s_fx; move32(); } + ELSE + { + return IVAS_ERR_INVALID_INPUT_FORMAT; + } } } ELSE { - hBinRenderer->hReverb = NULL; + /* same value for MC or HOA both use MC BRIR*/ + st_ivas->binaural_latency_ns = st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx; + move32(); } + } - hBinRenderer->hEFAPdata = NULL; + /* Allocate memories needed for reverb module */ + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + IF( NE_32( ( error = ivas_binaural_reverb_open_fastconv_fx( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) + { + return error; + } - IF( hBinRenderer->hReverb != NULL ) + /* initialize the dmx matrix */ + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - test(); - test(); - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + FOR( k = 0; k < hBinRenderer->nInChannels; k++ ) { - FOR( k = 0; k < 11; k++ ) - { - ivas_dirac_dec_get_response_fx( extract_l( L_shr_r( ls_azimuth_CICP19_fx[k], 22 ) ), extract_l( L_shr_r( ls_elevation_CICP19_fx[k], 22 ) ), hBinRenderer->hReverb->foa_enc_fx[k], 1, Q29 ); - // Q29: hBinRenderer->hReverb->foa_enc_fx[k] - } + hBinRenderer->hReverb->dmxmtx_fx[chIdx][k] = dmxmtx_table_fx[chIdx][k]; + move32(); } - ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) - { - IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) - { - return error; - } + } + } + ELSE + { + hBinRenderer->hReverb = NULL; + } + + hBinRenderer->hEFAPdata = NULL; - /* Copy handles to bin renderer handle*/ - hBinRenderer->hEFAPdata = st_ivas->hEFAPdata; + IF( hBinRenderer->hReverb != NULL ) + { + test(); + test(); + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + { + FOR( k = 0; k < 11; k++ ) + { + ivas_dirac_dec_get_response_fx( extract_l( L_shr_r( ls_azimuth_CICP19_fx[k], 22 ) ), extract_l( L_shr_r( ls_elevation_CICP19_fx[k], 22 ) ), hBinRenderer->hReverb->foa_enc_fx[k], 1, Q29 ); + // Q29: hBinRenderer->hReverb->foa_enc_fx[k] } } + ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + { + IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* Copy the handles to main handle */ - st_ivas->hBinRenderer = hBinRenderer; - - return error; + /* Copy handles to bin renderer handle*/ + hBinRenderer->hEFAPdata = st_ivas->hEFAPdata; + } } - /*------------------------------------------------------------------------- - * ivas_binRenderer_convModuleClose() - * - * Close convolution module handle of fastconv binaural renderer - *------------------------------------------------------------------------*/ - static void ivas_binRenderer_convModuleClose_fx( + /* Copy the handles to main handle */ + st_ivas->hBinRenderer = hBinRenderer; + + return error; +} + +/*------------------------------------------------------------------------- + * ivas_binRenderer_convModuleClose() + * + * Close convolution module handle of fastconv binaural renderer + *------------------------------------------------------------------------*/ +static void ivas_binRenderer_convModuleClose_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT - BINAURAL_RENDERER_HANDLE * hBinRenderer, /* i/o: fastconv binaural renderer handle */ - const Word16 num_poses /* i : number of poses */ + BINAURAL_RENDERER_HANDLE *hBinRenderer, /* i/o: fastconv binaural renderer handle */ + const Word16 num_poses /* i : number of poses */ #else BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ #endif - ) - { - Word16 bandIdx, chIdx; +) +{ + Word16 bandIdx, chIdx; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 posIdx; + Word16 posIdx; #endif - BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; - hBinRenConvModule = ( *hBinRenderer )->hBinRenConvModule; + hBinRenConvModule = ( *hBinRenderer )->hBinRenConvModule; - IF( hBinRenConvModule == NULL ) - { - return; - } + IF( hBinRenConvModule == NULL ) + { + return; + } - FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) - { - free( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] ); - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = NULL; + FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) + { + free( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] ); + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = NULL; - free( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] ); - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = NULL; + free( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] ); + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = NULL; - free( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] ); - hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = NULL; + free( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] ); + hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = NULL; - free( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] ); - hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = NULL; - } + free( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] ); + hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = NULL; + } - free( hBinRenConvModule->filterTapsLeftReal_fx ); - hBinRenConvModule->filterTapsLeftReal_fx = NULL; + free( hBinRenConvModule->filterTapsLeftReal_fx ); + hBinRenConvModule->filterTapsLeftReal_fx = NULL; - free( hBinRenConvModule->filterTapsLeftImag_fx ); - hBinRenConvModule->filterTapsLeftImag_fx = NULL; + free( hBinRenConvModule->filterTapsLeftImag_fx ); + hBinRenConvModule->filterTapsLeftImag_fx = NULL; - free( hBinRenConvModule->filterTapsRightReal_fx ); - hBinRenConvModule->filterTapsRightReal_fx = NULL; + free( hBinRenConvModule->filterTapsRightReal_fx ); + hBinRenConvModule->filterTapsRightReal_fx = NULL; - free( hBinRenConvModule->filterTapsRightImag_fx ); - hBinRenConvModule->filterTapsRightImag_fx = NULL; + free( hBinRenConvModule->filterTapsRightImag_fx ); + hBinRenConvModule->filterTapsRightImag_fx = NULL; #ifdef SPLIT_REND_WITH_HEAD_ROT - FOR( posIdx = 0; posIdx < num_poses; posIdx++ ) + FOR( posIdx = 0; posIdx < num_poses; posIdx++ ) + { + FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) { - FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) + FOR( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) { - FOR( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) - { - free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx][chIdx] = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx][chIdx] = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] = NULL; + free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx][chIdx] = NULL; #endif /* OPT_BASOP_ADD_v1 */ - } + } - free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx][bandIdx] = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx][bandIdx] = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] = NULL; + free( hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx][bandIdx] = NULL; #endif /* OPT_BASOP_ADD_v1 */ - } - free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[posIdx] = NULL; + } + free( hBinRenConvModule->filterStatesLeftReal_fx[posIdx] ); + hBinRenConvModule->filterStatesLeftReal_fx[posIdx] = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); + hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft[posIdx] ); - hBinRenConvModule->Q_filterStatesLeft[posIdx] = NULL; + free( hBinRenConvModule->Q_filterStatesLeft[posIdx] ); + hBinRenConvModule->Q_filterStatesLeft[posIdx] = NULL; #endif /* OPT_BASOP_ADD_v1 */ - } + } #else FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) { @@ -1692,281 +1692,281 @@ static void ivas_binRenderer_filterModule_fx( #endif /* OPT_BASOP_ADD_v1 */ } #endif - free( hBinRenConvModule->filterStatesLeftReal_fx ); - hBinRenConvModule->filterStatesLeftReal_fx = NULL; + free( hBinRenConvModule->filterStatesLeftReal_fx ); + hBinRenConvModule->filterStatesLeftReal_fx = NULL; - free( hBinRenConvModule->filterStatesLeftImag_fx ); - hBinRenConvModule->filterStatesLeftImag_fx = NULL; + free( hBinRenConvModule->filterStatesLeftImag_fx ); + hBinRenConvModule->filterStatesLeftImag_fx = NULL; #ifndef OPT_BASOP_ADD_v1 - free( hBinRenConvModule->Q_filterStatesLeft ); - hBinRenConvModule->Q_filterStatesLeft = NULL; + free( hBinRenConvModule->Q_filterStatesLeft ); + hBinRenConvModule->Q_filterStatesLeft = NULL; #endif /* OPT_BASOP_ADD_v1 */ - free( ( *hBinRenderer )->hBinRenConvModule ); - ( *hBinRenderer )->hBinRenConvModule = NULL; + free( ( *hBinRenderer )->hBinRenConvModule ); + ( *hBinRenderer )->hBinRenConvModule = NULL; + + return; +} +/*------------------------------------------------------------------------- + * ivas_binRenderer_close() + * + * Close fastconv binaural renderer memories + *------------------------------------------------------------------------*/ +void ivas_binRenderer_close_fx( + BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ +) +{ + test(); + IF( hBinRenderer == NULL || *hBinRenderer == NULL ) + { return; } - /*------------------------------------------------------------------------- - * ivas_binRenderer_close() - * - * Close fastconv binaural renderer memories - *------------------------------------------------------------------------*/ - void ivas_binRenderer_close_fx( - BINAURAL_RENDERER_HANDLE * hBinRenderer /* i/o: fastconv binaural renderer handle */ - ) + IF( ( *hBinRenderer )->hBinRenConvModule != NULL ) { - test(); - IF( hBinRenderer == NULL || *hBinRenderer == NULL ) - { - return; - } - - IF( ( *hBinRenderer )->hBinRenConvModule != NULL ) - { #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_binRenderer_convModuleClose_fx( hBinRenderer, ( *hBinRenderer )->numPoses ); + ivas_binRenderer_convModuleClose_fx( hBinRenderer, ( *hBinRenderer )->numPoses ); #else ivas_binRenderer_convModuleClose_fx( hBinRenderer ); #endif - } + } - IF( ( *hBinRenderer )->hReverb != NULL ) - { - ivas_binaural_reverb_close_fx( &( ( *hBinRenderer )->hReverb ) ); - } + IF( ( *hBinRenderer )->hReverb != NULL ) + { + ivas_binaural_reverb_close_fx( &( ( *hBinRenderer )->hReverb ) ); + } - free( *hBinRenderer ); - *hBinRenderer = NULL; + free( *hBinRenderer ); + *hBinRenderer = NULL; - return; - } + return; +} - /*------------------------------------------------------------------------- - * ivas_free_pppHrtfMem() - * - * Free fastconv binaural renderer hrtf memories - *------------------------------------------------------------------------*/ - static void ivas_free_pppHrtfMem_fx( - Word32 * ***ppppHRIR, /*Qx*/ - const Word16 dim, - const Word16 alloc_init ) - { - Word16 i, j; +/*------------------------------------------------------------------------- + * ivas_free_pppHrtfMem() + * + * Free fastconv binaural renderer hrtf memories + *------------------------------------------------------------------------*/ +static void ivas_free_pppHrtfMem_fx( + Word32 ****ppppHRIR, /*Qx*/ + const Word16 dim, + const Word16 alloc_init ) +{ + Word16 i, j; - IF( *ppppHRIR != NULL ) + IF( *ppppHRIR != NULL ) + { + FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) { - FOR( i = 0; i < BINAURAL_CONVBANDS; i++ ) + IF( alloc_init == 0 ) { - IF( alloc_init == 0 ) + FOR( j = 0; j < dim; j++ ) { - FOR( j = 0; j < dim; j++ ) - { - free( ( *ppppHRIR )[i][j] ); - ( *ppppHRIR )[i][j] = NULL; - } + free( ( *ppppHRIR )[i][j] ); + ( *ppppHRIR )[i][j] = NULL; } - free( ( *ppppHRIR )[i] ); - ( *ppppHRIR )[i] = NULL; } - free( *ppppHRIR ); - *ppppHRIR = NULL; + free( ( *ppppHRIR )[i] ); + ( *ppppHRIR )[i] = NULL; } + free( *ppppHRIR ); + *ppppHRIR = NULL; + } + + return; +} + +/*------------------------------------------------------------------------- + * ivas_binaural_hrtf_close() + * + * Close fastconv binaural renderer hrtf memories + *------------------------------------------------------------------------*/ +void ivas_binaural_hrtf_close( + HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i : fastconv HRTF handle */ +) +{ + Word16 allocate_init_flag; + test(); + IF( hHrtfFastConv == NULL || *hHrtfFastConv == NULL ) + { return; } - /*------------------------------------------------------------------------- - * ivas_binaural_hrtf_close() - * - * Close fastconv binaural renderer hrtf memories - *------------------------------------------------------------------------*/ - void ivas_binaural_hrtf_close( - HRTFS_FASTCONV_HANDLE * hHrtfFastConv /* i : fastconv HRTF handle */ - ) - { - Word16 allocate_init_flag; + allocate_init_flag = ( *hHrtfFastConv )->allocate_init_flag; + move16(); - test(); - IF( hHrtfFastConv == NULL || *hHrtfFastConv == NULL ) - { - return; - } + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - allocate_init_flag = ( *hHrtfFastConv )->allocate_init_flag; - move16(); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRReal_fx, HRTF_LS_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightBRIRImag_fx, HRTF_LS_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA3_fx, HOA3_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); + ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_HOA2_fx, HOA2_CHANNELS, allocate_init_flag ); + return; +} - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->leftHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRReal_FOA_fx, FOA_CHANNELS, allocate_init_flag ); - ivas_free_pppHrtfMem_fx( &( *hHrtfFastConv )->rightHRIRImag_FOA_fx, FOA_CHANNELS, allocate_init_flag ); +/*-------------------------------------------------------------------------* + * ivas_binaural_add_LFE() + * + * The functions adds the LFE to the left and right channels after binaural rendering + *-------------------------------------------------------------------------*/ +void ivas_binaural_add_LFE_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Word16 output_frame, /* i : length of input frame */ + Word32 *input_fx[], /* i : transport channels Q11*/ + Word32 *output_fx[] /* o : synthesized core-coder transport channels/DirAC output Q11*/ +) +{ + Word16 render_lfe, idx_lfe, gain_fx; + Word32 lfe_tc[L_FRAME48k]; - return; + IF( st_ivas->hBinRenderer != NULL ) + { + render_lfe = st_ivas->hBinRenderer->render_lfe; + move16(); } - - /*-------------------------------------------------------------------------* - * ivas_binaural_add_LFE() - * - * The functions adds the LFE to the left and right channels after binaural rendering - *-------------------------------------------------------------------------*/ - void ivas_binaural_add_LFE_fx( - Decoder_Struct * st_ivas, /* i/o: IVAS decoder structure */ - Word16 output_frame, /* i : length of input frame */ - Word32 * input_fx[], /* i : transport channels Q11*/ - Word32 * output_fx[] /* o : synthesized core-coder transport channels/DirAC output Q11*/ - ) + ELSE { - Word16 render_lfe, idx_lfe, gain_fx; - Word32 lfe_tc[L_FRAME48k]; + render_lfe = TRUE; + move16(); + } + - IF( st_ivas->hBinRenderer != NULL ) + IF( render_lfe ) + { + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { - render_lfe = st_ivas->hBinRenderer->render_lfe; + gain_fx = GAIN_LFE_FX; move16(); } ELSE { - render_lfe = TRUE; - move16(); - } - - - IF( render_lfe ) - { - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) + test(); + IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) { - gain_fx = GAIN_LFE_FX; + gain_fx = st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx; move16(); } ELSE { - test(); - IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hHrtfCrend != NULL ) ) - { - gain_fx = st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx; - move16(); - } - ELSE - { - gain_fx = GAIN_LFE_FX; - move16(); - } + gain_fx = GAIN_LFE_FX; + move16(); } - FOR( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) + } + FOR( idx_lfe = 0; idx_lfe < st_ivas->hIntSetup.num_lfe; idx_lfe++ ) + { + v_multc_fixed_16( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain_fx, lfe_tc, output_frame ); // q_input_fx - 1 + /* copy LFE to left and right channels */ + FOR( int idx = 0; idx < output_frame; idx++ ) { - v_multc_fixed_16( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain_fx, lfe_tc, output_frame ); // q_input_fx - 1 - /* copy LFE to left and right channels */ - FOR( int idx = 0; idx < output_frame; idx++ ) - { - lfe_tc[idx] = L_shl_sat( lfe_tc[idx], 1 ); // saturating to keep same q - move32(); - output_fx[0][idx] = L_add_sat( output_fx[0][idx], lfe_tc[idx] ); - move32(); - output_fx[1][idx] = L_add_sat( output_fx[1][idx], lfe_tc[idx] ); - move32(); - } + lfe_tc[idx] = L_shl_sat( lfe_tc[idx], 1 ); // saturating to keep same q + move32(); + output_fx[0][idx] = L_add_sat( output_fx[0][idx], lfe_tc[idx] ); + move32(); + output_fx[1][idx] = L_add_sat( output_fx[1][idx], lfe_tc[idx] ); + move32(); } } - - return; } - /*------------------------------------------------------------------------- - * ivas_binRenderer_fx() - * - * Fastconv binaural renderer main function - *-------------------------------------------------------------------------*/ + return; +} - void ivas_binRenderer_fx( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ +/*------------------------------------------------------------------------- + * ivas_binRenderer_fx() + * + * Fastconv binaural renderer main function + *-------------------------------------------------------------------------*/ + +void ivas_binRenderer_fx( + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, #endif - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - const Word16 numTimeSlots, /* i : number of time slots to render */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ + const Word16 numTimeSlots, /* i : number of time slots to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT - Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ - Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ + Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ #else Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ #endif - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word16 *Q_in /* i : LS signals exp */ - ) - { - Word16 chIdx, i, j, k; + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word16 *Q_in /* i : LS signals exp */ +) +{ + Word16 chIdx, i, j, k; #ifdef SPLIT_REND_WITH_HEAD_ROT - Word16 pos_idx, num_poses; - Word32 RealBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 ImagBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word16 pos_idx, num_poses; + Word32 RealBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 ImagBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; #endif - // to be checked: feasibility with 32 bit buffers - Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + // to be checked: feasibility with 32 bit buffers + Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - push_wmops( "fastconv_binaural_rendering" ); + push_wmops( "fastconv_binaural_rendering" ); #ifdef SPLIT_REND_WITH_HEAD_ROT - num_poses = hBinRenderer->numPoses; + num_poses = hBinRenderer->numPoses; #endif - /* Compute Convolution */ - /* memory reset for the binaural output */ + /* Compute Convolution */ + /* memory reset for the binaural output */ #ifdef SPLIT_REND_WITH_HEAD_ROT - FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) - { - set32_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - } - } - } + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { FOR( k = 0; k < numTimeSlots; k++ ) { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); } } + } + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) + { + set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + } + } - FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) + FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { - Copy32( RealBuffer_fx[chIdx][k], RealBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - Copy32( ImagBuffer_fx[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - } + Copy32( RealBuffer_fx[chIdx][k], RealBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + Copy32( ImagBuffer_fx[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); } + } #else FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { @@ -1980,301 +1980,301 @@ static void ivas_binRenderer_filterModule_fx( } #endif - /* Head rotation in HOA3 or CICPx */ - test(); - test(); - IF( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] && hBinRenderer->rotInCldfb ) + /* Head rotation in HOA3 or CICPx */ + test(); + test(); + IF( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] && hBinRenderer->rotInCldfb ) + { + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) { - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) + /* Rotation in SHD (HOA3) */ + IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, -1 ) ) { - /* Rotation in SHD (HOA3) */ - IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, -1 ) ) - { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); - *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) - move16(); - } - ELSE IF( hCombinedOrientationData->shd_rot_max_order > 0 ) - { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); - *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) - move16(); - } + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) + move16(); } - ELSE + ELSE IF( hCombinedOrientationData->shd_rot_max_order > 0 ) { - /* Rotation in SD (CICPx) */ - rotateFrame_sd_cldfb_fixed( hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], RealBuffer_fx, ImagBuffer_fx, - hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); + *Q_in = sub( *Q_in, 1 ); //( Q_in + 14 - 15 ) + move16(); } } - - /* HOA decoding to CICP19 if needed*/ - test(); - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && NE_16( hBinRenderer->nInChannels, 16 ) ) + ELSE { - ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx, - hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); + /* Rotation in SD (CICPx) */ + rotateFrame_sd_cldfb_fixed( hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], RealBuffer_fx, ImagBuffer_fx, + hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); } + } + + /* HOA decoding to CICP19 if needed*/ + test(); + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && NE_16( hBinRenderer->nInChannels, 16 ) ) + { + ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx, + hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); + } #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, 0, *Q_in ); + ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, 0, *Q_in ); #else ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in ); #endif - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) { - FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) - { #ifdef SPLIT_REND_WITH_HEAD_ROT - Cldfb_RealBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 - move32(); - Cldfb_ImagBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 - move32(); + Cldfb_RealBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + move32(); + Cldfb_ImagBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 + move32(); #else Cldfb_RealBuffer_Binaural_fx[i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 move32(); Cldfb_ImagBuffer_Binaural_fx[i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 move32(); #endif - } } } + } #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( pMultiBinPoseData != NULL ) + IF( pMultiBinPoseData != NULL ) + { + IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) { - IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) - { - IVAS_QUATERNION Quaternions_abs, Quaternions_ref, Quaternions_ref2; - Word32 Rmat_local[3][3]; - Word16 q_fact_orig, extra_shift = 0; + IVAS_QUATERNION Quaternions_abs, Quaternions_ref, Quaternions_ref2; + Word32 Rmat_local[3][3]; + Word16 q_fact_orig, extra_shift = 0; - IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) - { - Quaternions_ref = hCombinedOrientationData->Quaternions[0]; - q_fact_orig = Quaternions_ref.q_fact; + IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) + { + Quaternions_ref = hCombinedOrientationData->Quaternions[0]; + q_fact_orig = Quaternions_ref.q_fact; - modify_Quat_q_fx( &Quaternions_ref, &Quaternions_ref, Q22 ); + modify_Quat_q_fx( &Quaternions_ref, &Quaternions_ref, Q22 ); - Quaternions_ref2.w_fx = L_negate( 12582912 ); // Q22 - IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, 0 ) ) - { - /*HOA signal already rotated by DirAC*/ - Quaternions_ref2.x_fx = 0; - Quaternions_ref2.y_fx = 0; - Quaternions_ref2.z_fx = 0; - extra_shift = 1; - } - ELSE - { - /*euler*/ - Quat2EulerDegree_fx( Quaternions_ref, &Quaternions_ref2.z_fx, &Quaternions_ref2.y_fx, &Quaternions_ref2.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ - } + Quaternions_ref2.w_fx = L_negate( 12582912 ); // Q22 + IF( EQ_16( hCombinedOrientationData->shd_rot_max_order, 0 ) ) + { + /*HOA signal already rotated by DirAC*/ + Quaternions_ref2.x_fx = 0; + Quaternions_ref2.y_fx = 0; + Quaternions_ref2.z_fx = 0; + extra_shift = 1; + } + ELSE + { + /*euler*/ + Quat2EulerDegree_fx( Quaternions_ref, &Quaternions_ref2.z_fx, &Quaternions_ref2.y_fx, &Quaternions_ref2.x_fx ); /*order in Quat2Euler seems to be reversed ?*/ + } - FOR( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + FOR( pos_idx = 1; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) { - FOR( chIdx = 0; chIdx < hBinRenderer->hInputSetup->nchan_out_woLFE; chIdx++ ) + FOR( k = 0; k < numTimeSlots; k++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { - Copy32( RealBuffer_local[chIdx][k], RealBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - Copy32( ImagBuffer_local[chIdx][k], ImagBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); - } + Copy32( RealBuffer_local[chIdx][k], RealBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); + Copy32( ImagBuffer_local[chIdx][k], ImagBuffer_fx[chIdx][k], CLDFB_NO_CHANNELS_MAX ); } + } - Quaternions_abs.x_fx = L_add( Quaternions_ref2.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); - Quaternions_abs.y_fx = L_add( Quaternions_ref2.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); - Quaternions_abs.z_fx = L_add( Quaternions_ref2.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); - Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 + Quaternions_abs.x_fx = L_add( Quaternions_ref2.x_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][0] ); + Quaternions_abs.y_fx = L_add( Quaternions_ref2.y_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][1] ); + Quaternions_abs.z_fx = L_add( Quaternions_ref2.z_fx, pMultiBinPoseData->relative_head_poses_fx[pos_idx][2] ); + Quaternions_abs.w_fx = L_negate( 12582912 ); // Q22 - Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), deg2rad_fx( Quaternions_abs.y_fx ), deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); + Euler2Quat_fx( deg2rad_fx( Quaternions_abs.x_fx ), deg2rad_fx( Quaternions_abs.y_fx ), deg2rad_fx( Quaternions_abs.z_fx ), &Quaternions_abs ); - modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); + modify_Quat_q_fx( &Quaternions_abs, &Quaternions_abs, q_fact_orig ); - QuatToRotMat_fx( Quaternions_abs, Rmat_local ); + QuatToRotMat_fx( Quaternions_abs, Rmat_local ); - modify_Rmat_q_fx( Rmat_local, Rmat_local, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); + modify_Rmat_q_fx( Rmat_local, Rmat_local, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); - if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) - { - rotateFrame_sd_cldfb_fixed( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); - } - else - { - rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); - } + if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) + { + rotateFrame_sd_cldfb_fixed( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + } + else + { + rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + } - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - } + set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); } - ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); + } + ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) { - FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) - { - Cldfb_RealBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 - move32(); - Cldfb_ImagBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 - move32(); - } + Cldfb_RealBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 + move32(); + Cldfb_ImagBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 + move32(); } } } } } } + } #endif - /* Obtain the binaural dmx and compute the reverb */ - IF( hBinRenderer->hReverb != NULL ) - { - Word32 reverbRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 inRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + /* Obtain the binaural dmx and compute the reverb */ + IF( hBinRenderer->hReverb != NULL ) + { + Word32 reverbRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 inRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx ); + ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx ); - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { - set32_fx( reverbRe_fx[chIdx][k], 0, hBinRenderer->max_band ); - set32_fx( reverbIm_fx[chIdx][k], 0, hBinRenderer->max_band ); - } + set32_fx( reverbRe_fx[chIdx][k], 0, hBinRenderer->max_band ); + set32_fx( reverbIm_fx[chIdx][k], 0, hBinRenderer->max_band ); } + } - ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); + ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + FOR( j = 0; j < numTimeSlots; j++ ) { - FOR( j = 0; j < numTimeSlots; j++ ) + FOR( k = 0; k < hBinRenderer->hReverb->numBins; k++ ) { - FOR( k = 0; k < hBinRenderer->hReverb->numBins; k++ ) - { - reverbRe_fx[i][j][k] = L_shl( reverbRe_fx[i][j][k], 1 ); //*Q_in - move32(); - reverbIm_fx[i][j][k] = L_shl( reverbIm_fx[i][j][k], 1 ); //*Q_in - move32(); - } + reverbRe_fx[i][j][k] = L_shl( reverbRe_fx[i][j][k], 1 ); //*Q_in + move32(); + reverbIm_fx[i][j][k] = L_shl( reverbIm_fx[i][j][k], 1 ); //*Q_in + move32(); } } + } - /* Add the conv module and reverb module output */ - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + /* Add the conv module and reverb module output */ + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + FOR( k = 0; k < numTimeSlots; k++ ) { - FOR( k = 0; k < numTimeSlots; k++ ) - { #ifdef SPLIT_REND_WITH_HEAD_ROT - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { - /* Combine first and second parts to generate binaural output signal with room effect */ - v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in - v_add_32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in - } + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + /* Combine first and second parts to generate binaural output signal with room effect */ + v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in + v_add_32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in + } #else /* Combine first and second parts to generate binaural output signal with room effect */ v_add_32( Cldfb_RealBuffer_Binaural_fx[chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[chIdx][k], hBinRenderer->conv_band ); // Q_in v_add_32( Cldfb_ImagBuffer_Binaural_fx[chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[chIdx][k], hBinRenderer->conv_band ); // Q_in #endif - } } } - pop_wmops(); - return; } + pop_wmops(); + return; +} #ifdef SPLIT_REND_WITH_HEAD_ROT - /*------------------------------------------------------------------------- - * ivas_rend_CldfbMultiBinRendProcess() - * - * - *-------------------------------------------------------------------------*/ - - void ivas_rend_CldfbMultiBinRendProcess( - const BINAURAL_RENDERER_HANDLE hCldfbRend, - const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData, - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_Out_Real[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const Word16 low_res_pre_rend_rot, - const Word16 num_subframes, - const Word16 Q_in /* i : LS signals exp */ - ) - { - int16_t slot_idx, ch_idx, idx, pose_idx, i, j; - int16_t sf_idx; - Word32 Cldfb_RealBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word16 Q_in_orig; - - FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) - { - Q_in_orig = Q_in; - move16(); - FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) +/*------------------------------------------------------------------------- + * ivas_rend_CldfbMultiBinRendProcess() + * + * + *-------------------------------------------------------------------------*/ + +void ivas_rend_CldfbMultiBinRendProcess( + const BINAURAL_RENDERER_HANDLE hCldfbRend, + const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + Word32 Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_Out_Real[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ + Word32 Cldfb_Out_Imag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const Word16 low_res_pre_rend_rot, + const Word16 num_subframes, + const Word16 Q_in /* i : LS signals exp */ +) +{ + int16_t slot_idx, ch_idx, idx, pose_idx, i, j; + int16_t sf_idx; + Word32 Cldfb_RealBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word16 Q_in_orig; + + FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) + { + Q_in_orig = Q_in; + move16(); + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + { + idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; + FOR( ch_idx = 0; ch_idx < hCldfbRend->nInChannels; ch_idx++ ) { - idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; - FOR( ch_idx = 0; ch_idx < hCldfbRend->nInChannels; ch_idx++ ) - { - Copy32( &Cldfb_In_Real[ch_idx][idx][0], &Cldfb_RealBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); - Copy32( &Cldfb_In_Imag[ch_idx][idx][0], &Cldfb_ImagBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); - } + Copy32( &Cldfb_In_Real[ch_idx][idx][0], &Cldfb_RealBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); + Copy32( &Cldfb_In_Imag[ch_idx][idx][0], &Cldfb_ImagBuffer_sfIn[ch_idx][slot_idx][0], hCldfbRend->max_band ); } + } - IF( ( *pCombinedOrientationData ) != NULL ) + IF( ( *pCombinedOrientationData ) != NULL ) + { + IF( ( low_res_pre_rend_rot ) && ( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) ) { - IF( ( low_res_pre_rend_rot ) && ( EQ_32( pMultiBinPoseData->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) ) - { - Copy_Quat_fx( &( *pCombinedOrientationData )->Quaternions[0], &( *pCombinedOrientationData )->Quaternions[sf_idx] ); + Copy_Quat_fx( &( *pCombinedOrientationData )->Quaternions[0], &( *pCombinedOrientationData )->Quaternions[sf_idx] ); - FOR( i = 0; i < 3; i++ ) + FOR( i = 0; i < 3; i++ ) + { + FOR( j = 0; j < 3; j++ ) { - FOR( j = 0; j < 3; j++ ) - { - ( *pCombinedOrientationData )->Rmat_fx[sf_idx][i][j] = ( *pCombinedOrientationData )->Rmat_fx[0][i][j]; - move32(); - } + ( *pCombinedOrientationData )->Rmat_fx[sf_idx][i][j] = ( *pCombinedOrientationData )->Rmat_fx[0][i][j]; + move32(); } } - ( *pCombinedOrientationData )->shd_rot_max_order = -1; - move16(); } + ( *pCombinedOrientationData )->shd_rot_max_order = -1; + move16(); + } - ivas_binRenderer_fx( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn, &Q_in_orig ); + ivas_binRenderer_fx( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn, &Q_in_orig ); - FOR( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) + FOR( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) + { + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { - FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; + FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { - idx = sf_idx * MAX_PARAM_SPATIAL_SUBFRAMES + slot_idx; - FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) - { - Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); - Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); - Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig - Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig - } + Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); + Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); + Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig + Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig } } } - - return; } + + return; +} #endif -- GitLab From e5668dda7f0ab8d18636164edf0451e1a6c9f798 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 09:30:57 +0530 Subject: [PATCH 62/97] Fix for 3GPP issue 1345: Decoder crash for Stereo at 32kbps in stereo_dft_dec_res_fx() Link #1345 --- lib_dec/ivas_stereo_dft_dec_fx.c | 41 +++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 8dcc7ada9..fb54476fa 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -1368,23 +1368,23 @@ void stereo_dft_dec_res_fx( /*Inverse MDCT*/ TCX_MDCT_Inverse( res_buf, q_res, win, STEREO_DFT_OVL_8k, L_FRAME8k - STEREO_DFT_OVL_8k, STEREO_DFT_OVL_8k, IVAS_CPE_DFT ); + scale_sig( win, L_FRAME8k + STEREO_DFT_OVL_8k, -1 ); + + Word16 q_shift = sub( hCPE->hStereoDft->q_res_cod_mem_fx, Q16 ); IF( !prev_bfi ) { /*OLA*/ /*overlapping parts*/ - Word16 q_shift = sub( hCPE->hStereoDft->q_res_cod_mem_fx, Q16 ); + FOR( i = 0; i < STEREO_DFT_OVL_8k; i++ ) { - win[i] = extract_h( L_add( hCPE->hStereoDft->res_cod_mem_fx[i], L_shl( L_mult( win[i], hCPE->hStereoDft->win_8k_fx[i] ), q_shift ) ) ); /* q_res_cod_mem_fx */ + win[i] = extract_h( L_add( L_shr( hCPE->hStereoDft->res_cod_mem_fx[i], 1 ), L_shl( L_mult( win[i], hCPE->hStereoDft->win_8k_fx[i] ), q_shift ) ) ); /* q_res_cod_mem_fx -17 (q_shift -1)*/ move16(); - hCPE->hStereoDft->res_cod_mem_fx[i] = L_mult( win[L_FRAME8k + i], hCPE->hStereoDft->win_8k_fx[STEREO_DFT_OVL_8k - 1 - i] ); /* q_res_cod_mem_fx */ + hCPE->hStereoDft->res_cod_mem_fx[i] = L_shl( L_mult( win[L_FRAME8k + i], hCPE->hStereoDft->win_8k_fx[STEREO_DFT_OVL_8k - 1 - i] ), 1 ); /* -1 +15 +1 +1 */ move32(); } - IF( q_shift != 0 ) - { - v_shr_16( &win[STEREO_DFT_OVL_8k], negate( q_shift ), &win[STEREO_DFT_OVL_8k], L_FRAME8k ); - } - hCPE->hStereoDft->q_res_cod_mem_fx = Q16; + + move16(); } ELSE @@ -1396,23 +1396,30 @@ void stereo_dft_dec_res_fx( move16(); FOR( i = 0; i < STEREO_DFT_OVL_8k; i++ ) { - win[i] = extract_h( Madd_32_16( Mpy_32_16_1( hCPE->hStereoDft->res_cod_mem_fx[i], sub( MAX_16, mult( fac, fac ) ) ), - L_mult( hCPE->hStereoDft->win_8k_fx[i], win[i] ), - sub( MAX_16, mult( sub( MAX_16, fac ), sub( MAX_16, fac ) ) ) ) ); /* Q0 */ + win[i] = extract_h( Madd_32_16( Mpy_32_16_1( L_shr( hCPE->hStereoDft->res_cod_mem_fx[i], 1 ), sub( MAX_16, mult( fac, fac ) ) ), + L_shl( L_mult( hCPE->hStereoDft->win_8k_fx[i], win[i] ), q_shift ), + sub( MAX_16, mult( sub( MAX_16, fac ), sub( MAX_16, fac ) ) ) ) ); /* Q(q_shift -1) */ move16(); - hCPE->hStereoDft->res_cod_mem_fx[i] = L_mult( win[L_FRAME8k + i], hCPE->hStereoDft->win_8k_fx[STEREO_DFT_OVL_8k - 1 - i] ); /* Q16 */ + hCPE->hStereoDft->res_cod_mem_fx[i] = L_shl( L_mult( win[L_FRAME8k + i], hCPE->hStereoDft->win_8k_fx[STEREO_DFT_OVL_8k - 1 - i] ), 1 ); /* Q16 */ move32(); fac = add( fac, step ); } } - Copy( win, out_16, L_FRAME8k ); /* Q0 */ + IF( q_shift != 0 ) + { + v_shr_16( &win[STEREO_DFT_OVL_8k], negate( q_shift ), &win[STEREO_DFT_OVL_8k], L_FRAME8k ); + } + + hCPE->hStereoDft->q_res_cod_mem_fx = Q16; + + Copy( win, out_16, L_FRAME8k ); /* Q(q_shift -1 ) */ IF( hCPE->hCoreCoder[0]->core == ACELP_CORE ) { /* bass post-filter */ bass_psfilter_fx( hCPE->hStereoDft->hBpf, hCPE->hCoreCoder[0]->Opt_AMR_WB, out_16, L_FRAME8k, hCPE->hCoreCoder[0]->old_pitch_buf_16_fx + ( L_FRAME8k / STEREO_DFT_L_SUBFR_8k ), hCPE->hCoreCoder[0]->bpf_off, - hCPE->hCoreCoder[0]->stab_fac_fx, &hCPE->hStereoDft->stab_fac_smooth_res_fx, hCPE->hCoreCoder[0]->last_coder_type, 0, bpf_error_signal_8k_16 ); + hCPE->hCoreCoder[0]->stab_fac_fx, &hCPE->hStereoDft->stab_fac_smooth_res_fx, hCPE->hCoreCoder[0]->last_coder_type, sub( q_shift, 1 ), bpf_error_signal_8k_16 ); Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_8k_16, bpf_error_signal_8k, L_FRAME8k, Q15 ); /* Q15 */ res_bpf_flag = res_bpf_adapt_ivas_fx( hCPE->hStereoDft, bpf_error_signal_8k, res_buf, q_res ); @@ -1430,7 +1437,7 @@ void stereo_dft_dec_res_fx( } } #ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, 15 ); /* Q15 */ + Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, sub( 15, sub( q_shift, 1 ) ) ); /* Q15 */ #else Copy_Scale_sig_16_32_DEPREC( out_16, output, L_FRAME8k, 16 ); /* Q16 */ #endif @@ -1445,7 +1452,7 @@ void stereo_dft_dec_res_fx( hCPE->hStereoDft->hBpf->pst_mem_deemp_err_fx = 0; move16(); #ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, 15 ); /* Q15 */ + Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, sub( 15, sub( q_shift, 1 ) ) ); /* Q15 */ #else Copy_Scale_sig_16_32_DEPREC( out_16, output, L_FRAME8k, 16 ); /* Q16 */ #endif @@ -1454,7 +1461,7 @@ void stereo_dft_dec_res_fx( { /* This step is needed to ensure output is properly populated with scaled values in all cases*/ #ifdef FIX_ISSUE_1237 - Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, 15 ); /* Q15 */ + Copy_Scale_sig_16_32_no_sat( out_16, output, L_FRAME8k, sub( 15, sub( q_shift, 1 ) ) ); /* Q15 */ #else Copy_Scale_sig_16_32_DEPREC( out_16, output, L_FRAME8k, 16 ); /* Q16 */ #endif -- GitLab From f934b4d2d794ed257ff77f5cffff9ec1e6ebd66e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 09:48:48 +0530 Subject: [PATCH 63/97] Fix for 3GPP issue 1037: Wrong variable type used in the fixed-point code - 1 Link #1037 --- lib_com/cng_exc_fx.c | 2 +- lib_com/cnst.h | 6 +- lib_com/common_api_types.h | 50 +- lib_com/fft_evs.c | 2 +- lib_com/ivas_cnst.h | 10 +- lib_com/ivas_rom_com_fx.c | 24 +- lib_com/ivas_spar_com_fx.c | 8 +- lib_com/ivas_stat_com.h | 250 +++---- lib_com/ivas_tools_fx.c | 6 +- lib_com/longarith.c | 44 +- lib_com/lsf_dec_bfi_fx.c | 2 +- lib_com/mslvq_com.c | 6 +- lib_com/parameter_bitmaping_fx.c | 26 +- lib_com/prot_fx.h | 6 +- lib_com/rom_basop_util.c | 2 +- lib_com/rom_com.h | 2 +- lib_com/stat_com.h | 13 +- lib_dec/FEC_clas_estim_fx.c | 2 +- lib_dec/acelp_core_switch_dec_fx.c | 1 - lib_dec/core_switching_dec_fx.c | 2 +- lib_dec/dec_uv_fx.c | 22 +- lib_dec/er_dec_acelp_fx.c | 2 +- lib_dec/ivas_binRenderer_internal_fx.c | 4 +- lib_dec/ivas_dirac_dec_fx.c | 2 +- lib_dec/ivas_ism_param_dec_fx.c | 6 +- lib_dec/ivas_jbm_dec_fx.c | 26 +- lib_dec/ivas_mc_param_dec_fx.c | 10 +- lib_dec/ivas_rom_dec.c | 44 +- lib_dec/ivas_rom_dec.h | 16 +- lib_dec/ivas_spar_md_dec_fx.c | 10 +- lib_dec/ivas_stat_dec.h | 524 +++++++-------- lib_dec/ivas_stereo_switching_dec_fx.c | 8 +- lib_dec/ivas_svd_dec_fx.c | 1 - lib_dec/jbm_jb4sb.h | 2 +- lib_dec/jbm_pcmdsp_apa.h | 8 +- lib_dec/jbm_pcmdsp_window.h | 2 +- lib_enc/amr_wb_enc_fx.c | 2 +- lib_enc/avq_cod_fx.c | 12 +- lib_enc/core_enc_init_fx.c | 8 +- lib_enc/core_enc_reconf_fx.c | 2 +- lib_enc/enc_acelp_fx.c | 4 +- lib_enc/ivas_ism_metadata_enc_fx.c | 2 +- lib_enc/ivas_mcmasa_enc_fx.c | 2 +- lib_enc/ivas_mct_enc_fx.c | 2 +- lib_enc/ivas_mdct_core_enc_fx.c | 2 +- lib_enc/ivas_qmetadata_enc_fx.c | 6 +- lib_enc/ivas_sns_enc_fx.c | 10 +- lib_enc/ivas_spar_md_enc_fx.c | 2 +- lib_enc/ivas_stereo_dft_enc_fx.c | 6 +- lib_enc/ivas_stereo_td_enc_fx.c | 3 +- lib_enc/lib_enc.c | 64 +- lib_enc/lib_enc.h | 64 +- lib_enc/lsf_enc_fx.c | 4 +- lib_enc/lsf_msvq_ma_enc.c | 2 +- lib_enc/prot_fx_enc.h | 24 +- lib_enc/stat_enc.h | 624 +++++++++--------- lib_enc/swb_bwe_enc_fx.c | 2 +- lib_enc/swb_pre_proc_fx.c | 2 +- lib_enc/tcx_utils_enc_fx.c | 6 +- lib_enc/transient_detection_fx.c | 6 +- .../ivas_dirac_dec_binaural_functions_fx.c | 22 +- lib_rend/ivas_dirac_decorr_dec_fx.c | 4 +- lib_rend/ivas_reverb_fx.c | 32 +- lib_rend/ivas_rom_binaural_crend_head.h | 180 ++--- lib_rend/ivas_rom_binaural_crend_head_fx.c | 180 ++--- lib_rend/ivas_rom_rend_fx.c | 20 +- lib_rend/lib_rend.h | 2 +- 67 files changed, 1215 insertions(+), 1237 deletions(-) diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index 3eab0b1f5..4153afa32 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -47,7 +47,7 @@ void CNG_exc_fx( Word16 *cng_ener_seed1, Word16 exc3[], /*Q_exc*/ Word16 Opt_AMR_WB, - const int16_t element_mode /* i : IVAS Element mode */ + const Word16 element_mode /* i : IVAS Element mode */ ) { Word16 i, tmp, tmp2, exp, exp2, Q_ener; diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 87aafb11a..7c93498af 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -239,7 +239,7 @@ enum{ #define L_FRAME48k_EXT 1200 /* Extended MDCT frame size in samples at 48kHz */ /* Conversion of ns to samples for a given sampling frequency */ -#define NS2SA( fs, x ) ( int16_t )( ( ( ( int32_t )( fs ) / 100L ) * ( ( x ) / 100L ) ) / 100000L ) +#define NS2SA( fs, x ) ( Word16 )( ( ( ( Word32 )( fs ) / 100L ) * ( ( x ) / 100L ) ) / 100000L ) #define NRG_CHANGE_E 8 #define AVG_FLAT_E 8 #define ACTIVE_FRAME 0xFF @@ -1172,7 +1172,6 @@ enum #define NBITS_NOISE_FILL_LEVEL 3 /* Number of bits used for coding noise filling level for each range */ #define NF_GAIN_BITS ( NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ) #define MIN_NOISE_FILLING_HOLE 8 -#define HOLE_SIZE_FROM_LTP_FLT( gain ) ( 4 + ( int16_t )( 2.0f * gain * ( 4.0f / 0.625f ) ) ) #define HOLE_SIZE_FROM_LTP( gain ) (add(4, extract_h(L_shr(L_mult0(gain, 0x6666), 10)))) /* gain (Q15), 0x6666 = 2.0*(4.0/0.625) (4Q11) */ #define HOLE_SIZE_FROM_LTP32( gain ) (add(4, extract_h(L_shr(Mpy_32_32(gain, 0x66666667), 11)))) /* gain (Q31), 0x66666667 = 2.0*(4.0/0.625) (4Q27) */ @@ -1469,7 +1468,7 @@ enum #define cbitsnew 16 #define stat_bitsnew 14 -#define ari_q4new ( ( (int32_t) 1 << cbitsnew ) - 1 ) +#define ari_q4new ( ( (Word32) 1 << cbitsnew ) - 1 ) #define ari_q1new ( ari_q4new / 4 + 1 ) #define ari_q2new ( 2 * ari_q1new ) #define ari_q3new ( 3 * ari_q1new ) @@ -1951,7 +1950,6 @@ typedef enum _DCTTYPE #define N_SMC_MIXTURES 6 /* number of mixtures */ #define N_PCA_COEF 12 /* number of PCA components */ #define HALF_N_PCA_COEF_LOG_P12_Q18 2890731 //Q18 of (0.5f * N_PCA_COEF *logf( PI2 )) -#define SMC_ST_MEAN_FACT 0.5 /* forgetting factor of short-term IIR mean filter */ #define SMC_ST_MEAN_RSHIFT_FACT_FX 1 /* SMC_ST_MEAN_FACT equivalent right shift factor */ #define M_LSP_SPMUS 6 /* number of LSPs used in speech/music classifier */ diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 553a34f56..bc6fd4f1a 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -108,9 +108,9 @@ typedef enum _IVAS_ENC_FEC_INDICATOR typedef struct _IVAS_ENC_CHANNEL_AWARE_CONFIG { - int16_t channelAwareModeEnabled; + Word16 channelAwareModeEnabled; IVAS_ENC_FEC_INDICATOR fec_indicator; - int16_t fec_offset; + Word16 fec_offset; } IVAS_ENC_CHANNEL_AWARE_CONFIG; @@ -130,7 +130,7 @@ typedef struct _IVAS_ISM_METADATA float gainFactor; float yaw; float pitch; - int16_t non_diegetic_flag; + Word16 non_diegetic_flag; } IVAS_ISM_METADATA; @@ -183,29 +183,29 @@ typedef struct ivas_LS_setup_custom IVAS_LSSETUP_CUSTOM_STRUCT; typedef struct _IVAS_LS_CUSTOM_LAYOUT { - int16_t num_spk; + Word16 num_spk; float azimuth[IVAS_MAX_OUTPUT_CHANNELS]; float elevation[IVAS_MAX_OUTPUT_CHANNELS]; Word32 azimuth_fx[IVAS_MAX_OUTPUT_CHANNELS]; // Q22 Word32 elevation_fx[IVAS_MAX_OUTPUT_CHANNELS]; // Q22 - int16_t num_lfe; - int16_t lfe_idx[IVAS_MAX_OUTPUT_CHANNELS]; + Word16 num_lfe; + Word16 lfe_idx[IVAS_MAX_OUTPUT_CHANNELS]; } IVAS_CUSTOM_LS_DATA; typedef struct _IVAS_JBM_TRACE_DATA { - uint32_t systemTimestamp_ms; - uint16_t extBufferedSamples; - uint16_t lastDecodedWasActive; - int32_t output_Fs; - int16_t dataUnit_flag; - uint16_t sequenceNumber; - uint32_t timeStamp; - uint32_t rcvTime; - - int16_t partial_frame; - int16_t partialCopyOffset; + UWord32 systemTimestamp_ms; + UWord16 extBufferedSamples; + UWord16 lastDecodedWasActive; + Word32 output_Fs; + Word16 dataUnit_flag; + UWord16 sequenceNumber; + UWord32 timeStamp; + UWord32 rcvTime; + + Word16 partial_frame; + Word16 partialCopyOffset; } IVAS_JBM_TRACE_DATA; @@ -217,8 +217,8 @@ typedef struct _IVAS_JBM_TRACE_DATA typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG { - int16_t override; - int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ + Word16 override; + Word16 nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ float pAcoustic_rt60[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ float pAcoustic_dsr[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ @@ -231,12 +231,12 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG Word32 inputPreDelay_fx; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ /* Assumed Q-27*/ /* early reflections */ - int16_t use_er; /* ER activation flag */ - int32_t lowComplexity; /* Low complexity ER flag */ - IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ - float AbsCoeff[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */ - IVAS_VECTOR3 ListenerOrigin; /* Listener origin */ - int32_t AbsCoeff_fx[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */ + Word16 use_er; /* ER activation flag */ + Word32 lowComplexity; /* Low complexity ER flag */ + IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ + float AbsCoeff[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */ + IVAS_VECTOR3 ListenerOrigin; /* Listener origin */ + Word32 AbsCoeff_fx[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs */ } IVAS_ROOM_ACOUSTICS_CONFIG_DATA; diff --git a/lib_com/fft_evs.c b/lib_com/fft_evs.c index e53404f0b..94c2dea8f 100644 --- a/lib_com/fft_evs.c +++ b/lib_com/fft_evs.c @@ -505,7 +505,7 @@ static void fft15_with_cmplx_data( cmplx *inp_data /*Qx*/ ) */ void fft16( Word32 *re, Word32 *im, Word16 s, Word16 bScale ) { - int i; + Word16 i; if ( s == 2 ) { fft16_with_cmplx_data( (cmplx *) re, bScale ); diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 6612fac1f..2abb790f1 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1440,12 +1440,12 @@ typedef enum _COV_SMOOTHING_TYPE } COV_SMOOTHING_TYPE; typedef struct { - const int32_t *value; - const uint16_t *length; + const Word32 *value; + const UWord16 *length; } HUFF_TAB; typedef struct { - int32_t value[81]; + Word32 value[81]; unsigned short length[81]; } HUFF_ELEMENTS; @@ -1467,8 +1467,8 @@ typedef struct { typedef struct { - const int16_t (*alpha)[2]; - const int16_t (*beta)[2]; + const Word16 (*alpha)[2]; + const Word16 (*beta)[2]; } HUFF_NODE_TABLE; /*----------------------------------------------------------------------------------* diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index 8ea2b91e4..a7a8bdcbf 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -1617,23 +1617,23 @@ const Word32 coherence_cb1_masa_fx[MASA_NO_CV_COH1 * MASA_MAXIMUM_CODING_SUBBAND }; /* Multi-channel input and output setups */ -const int16_t ls_azimuth_CICP2_idx[2] = { 1, 2 }; -const int16_t ls_elevation_CICP2_idx[2] = { 0, 0 }; +const Word16 ls_azimuth_CICP2_idx[2] = { 1, 2 }; +const Word16 ls_elevation_CICP2_idx[2] = { 0, 0 }; -const int16_t ls_azimuth_CICP6_idx[5] = { 1, 2, 0, 7, 8 }; -const int16_t ls_elevation_CICP6_idx[5] = { 0, 0, 0, 0, 0 }; +const Word16 ls_azimuth_CICP6_idx[5] = { 1, 2, 0, 7, 8 }; +const Word16 ls_elevation_CICP6_idx[5] = { 0, 0, 0, 0, 0 }; -const int16_t ls_azimuth_CICP12_idx[7] = { 1, 2, 0, 7, 8, 9, 10 }; -const int16_t ls_elevation_CICP12_idx[7] = { 0, 0, 0, 0, 0, 0, 0 }; +const Word16 ls_azimuth_CICP12_idx[7] = { 1, 2, 0, 7, 8, 9, 10 }; +const Word16 ls_elevation_CICP12_idx[7] = { 0, 0, 0, 0, 0, 0, 0 }; -const int16_t ls_azimuth_CICP14_idx[7] = { 1, 2, 0, 7, 8, 1, 2 }; -const int16_t ls_elevation_CICP14_idx[7] = { 0, 0, 0, 0, 0, 3, 4 }; +const Word16 ls_azimuth_CICP14_idx[7] = { 1, 2, 0, 7, 8, 1, 2 }; +const Word16 ls_elevation_CICP14_idx[7] = { 0, 0, 0, 0, 0, 3, 4 }; -const int16_t ls_azimuth_CICP16_idx[9] = { 1, 2, 0, 7, 8, 1, 2, 7, 8 }; -const int16_t ls_elevation_CICP16_idx[9] = { 0, 0, 0, 0, 0, 3, 3, 3, 3 }; +const Word16 ls_azimuth_CICP16_idx[9] = { 1, 2, 0, 7, 8, 1, 2, 7, 8 }; +const Word16 ls_elevation_CICP16_idx[9] = { 0, 0, 0, 0, 0, 3, 3, 3, 3 }; -const int16_t ls_azimuth_CICP19_idx[11] = { 1, 2, 0, 9, 10, 5, 6, 1, 2, 9, 10 }; -const int16_t ls_elevation_CICP19_idx[11] = { 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3 }; +const Word16 ls_azimuth_CICP19_idx[11] = { 1, 2, 0, 9, 10, 5, 6, 1, 2, 9, 10 }; +const Word16 ls_elevation_CICP19_idx[11] = { 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3 }; const Word32 shoebox_sin_cos_tbl_fx[11][2] = { { 0, 1073741824 }, // 0 { 536870912, 929887680 }, diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 6c80c1898..96df64aa5 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -3807,7 +3807,7 @@ void ivas_compute_spar_params_fx( { Word32 pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS]; - Word16 b, i, ndm; + Word16 b, i, ndm, j; Word16 q_pred_coeffs; ivas_get_pred_coeffs_fx( cov_real, pred_coeffs_re, dm_fv_re, num_ch, start_band, end_band, active_w, active_w_vlbr, dtx_vad, from_dirac, dyn_active_w_flag, hSparMd->res_ind, &q_pred_coeffs, q_dm_fv_re ); @@ -3869,7 +3869,7 @@ void ivas_compute_spar_params_fx( #ifdef MSAN_FIX FOR( i = 0; i < ( num_ch - ndm ); i++ ) { - FOR( Word16 j = 0; j < sub( ndm, 1 ); j++ ) + FOR( j = 0; j < sub( ndm, 1 ); j++ ) { hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].C_re_fx[i][j] = L_shr( hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].C_re_fx[i][j], sub( q_tmp, 22 ) ); // q22 move32(); @@ -3878,7 +3878,7 @@ void ivas_compute_spar_params_fx( #else for ( i = 0; i < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; i++ ) { - for ( int j = 0; j < IVAS_SPAR_MAX_DMX_CHS - 1; j++ ) + for ( j = 0; j < IVAS_SPAR_MAX_DMX_CHS - 1; j++ ) { hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re_fx[i][j] = L_shr( hSparMd->band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re_fx[i][j], sub( q_tmp, 22 ) ); } @@ -3891,7 +3891,7 @@ void ivas_compute_spar_params_fx( q_tmp = hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].q_P_re_fx; move16(); - FOR( Word16 j = 0; j < sub( IVAS_SPAR_MAX_CH, 1 ); j++ ) + FOR( j = 0; j < sub( IVAS_SPAR_MAX_CH, 1 ); j++ ) { hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].P_re_fx[j] = L_shr( hSparMd->band_coeffs[b + ( i_ts * IVAS_MAX_NUM_BANDS )].P_re_fx[j], sub( q_tmp, 22 ) ); // q22 move32(); diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 249d1e963..fb11d3934 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -46,18 +46,18 @@ typedef struct { - int16_t last_angle1_idx; /* last frame index of coded azimuth/yaw */ - int16_t angle1_diff_cnt; /* FEC counter of consecutive differentially azimuth/yaw coded frames */ - int16_t last_angle2_idx; /* last frame index of coded elevation/pitch */ - int16_t angle2_diff_cnt; /* FEC counter of consecutive differentially elevation/pitch coded frames */ + Word16 last_angle1_idx; /* last frame index of coded azimuth/yaw */ + Word16 angle1_diff_cnt; /* FEC counter of consecutive differentially azimuth/yaw coded frames */ + Word16 last_angle2_idx; /* last frame index of coded elevation/pitch */ + Word16 angle2_diff_cnt; /* FEC counter of consecutive differentially elevation/pitch coded frames */ } ISM_METADATA_ANGLE, *ISM_METADATA_ANGLE_HANDLE; /* ISM metadata handle (storage for one frame of read ISM metadata) */ typedef struct { - int16_t ism_metadata_flag; /* flag whether metadata are coded in particular frame of particular object */ - int16_t last_ism_metadata_flag; /* last frame ism_metadata_flag */ + Word16 ism_metadata_flag; /* flag whether metadata are coded in particular frame of particular object */ + Word16 last_ism_metadata_flag; /* last frame ism_metadata_flag */ Word32 azimuth_fx; /* azimuth value read from the input metadata file */ /* Q22 */ Word32 elevation_fx; /* elevation value read from the input metadata file */ /* Q22 */ @@ -65,25 +65,25 @@ typedef struct Word32 yaw_fx; /* yaw value read from the input metadata file */ /* Q22 */ Word32 pitch_fx; /* pitch value read from the input metadata file */ /* Q22 */ - int16_t non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ + Word16 non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ ISM_METADATA_ANGLE position_angle; /* Angle structs for azimuth and elevation */ ISM_METADATA_ANGLE orientation_angle; /* Angle structs for yaw and pitch */ - int16_t last_radius_idx; /* last frame index of coded radius */ - int16_t radius_diff_cnt; /* FEC counter of consecutive differentially radius coded frames */ + Word16 last_radius_idx; /* last frame index of coded radius */ + Word16 radius_diff_cnt; /* FEC counter of consecutive differentially radius coded frames */ Word32 last_azimuth_fx; /* MD smoothing in DTX- last Q azimuth value */ /* Q22 */ Word32 last_elevation_fx; /* MD smoothing in DTX - last Q elevation value */ /* Q22 */ Word32 last_true_azimuth_fx; /* MD smoothing in DTX- last true Q azimuth value */ /* Q22 */ Word32 last_true_elevation_fx; /* MD smoothing in DTX- last true Q elevation value */ /* Q22 */ - int16_t ism_md_fec_cnt_enc; /* counter of continuous frames where MD are not transmitted */ - int16_t ism_md_inc_diff_cnt; /* counter of continuous frames where MD are transmitted in inactive segments when MD significantly changes */ - Word16 last_true_radius_fx; /* last true Q radius value */ + Word16 ism_md_fec_cnt_enc; /* counter of continuous frames where MD are not transmitted */ + Word16 ism_md_inc_diff_cnt; /* counter of continuous frames where MD are transmitted in inactive segments when MD significantly changes */ + Word16 last_true_radius_fx; /* last true Q radius value */ - int16_t ism_imp; /* ISM importance flag */ - int16_t ism_md_null_flag; - int16_t ism_md_lowrate_flag; + Word16 ism_imp; /* ISM importance flag */ + Word16 ism_md_null_flag; + Word16 ism_md_lowrate_flag; Word32 q_azimuth_old_fx; Word32 q_elevation_old_fx; @@ -96,15 +96,15 @@ typedef struct typedef struct stereo_dft_config_data_struct { - int16_t dmx_active; - int16_t band_res; - int16_t prm_res; /* Send prm every # DFT frames */ - int16_t res_pred_mode; /* mode : from 0 (off) to 1 (on) */ - int16_t res_cod_mode; /* mode : from 0 (off) to 3 */ - int16_t hybrid_itd_flag; - int16_t ada_wb_res_cod_mode; /* res_cod_mode for adaptive wide band residual coding */ + Word16 dmx_active; + Word16 band_res; + Word16 prm_res; /* Send prm every # DFT frames */ + Word16 res_pred_mode; /* mode : from 0 (off) to 1 (on) */ + Word16 res_cod_mode; /* mode : from 0 (off) to 3 */ + Word16 hybrid_itd_flag; + Word16 ada_wb_res_cod_mode; /* res_cod_mode for adaptive wide band residual coding */ - int16_t force_mono_transmission; + Word16 force_mono_transmission; } STEREO_DFT_CONFIG_DATA, *STEREO_DFT_CONFIG_DATA_HANDLE; @@ -115,20 +115,20 @@ typedef struct stereo_dft_config_data_struct typedef struct { - uint8_t const bandLengthsTCX20[SMDCT_MAX_STEREO_BANDS_TCX20]; /* Length of a band in number of bins. Range is 4..160 */ - const int16_t bdnCnt_TCX20[4]; /* uppermost band for FB,SWB,WB,NB */ - uint8_t const bandLengthsTCX10[SMDCT_MAX_STEREO_BANDS_TCX10]; /* Length of a band in number of bins. Range is 2..80, always divisible by 2 */ - const int16_t bndCnt_TCX10[4]; /* uppermost band for FB,SWB,WB,NB */ + UWord8 const bandLengthsTCX20[SMDCT_MAX_STEREO_BANDS_TCX20]; /* Length of a band in number of bins. Range is 4..160 */ + const Word16 bdnCnt_TCX20[4]; /* uppermost band for FB,SWB,WB,NB */ + UWord8 const bandLengthsTCX10[SMDCT_MAX_STEREO_BANDS_TCX10]; /* Length of a band in number of bins. Range is 2..80, always divisible by 2 */ + const Word16 bndCnt_TCX10[4]; /* uppermost band for FB,SWB,WB,NB */ } MDCTStereoBands_config; /* MDCT stereo frequency band structure */ typedef struct stereo_mdct_dec_band_parameters_struct { - int16_t sfbOffset[MAX_SFB + 1]; /* stereo frequency band start offsets */ - int16_t sfbCnt; /* number of stereo frequency bands */ - int16_t nBandsStereoCore; /* number of stereo frequency bands in the core */ - int16_t sfbIgfStart; /*index for first IGF band*/ + Word16 sfbOffset[MAX_SFB + 1]; /* stereo frequency band start offsets */ + Word16 sfbCnt; /* number of stereo frequency bands */ + Word16 nBandsStereoCore; /* number of stereo frequency bands in the core */ + Word16 sfbIgfStart; /*index for first IGF band*/ } STEREO_MDCT_BAND_PARAMETERS; @@ -139,9 +139,9 @@ typedef struct stereo_mdct_dec_band_parameters_struct typedef struct { - int16_t config_index; - int16_t encoding_active; /* internal state specifying if actual encoding is active or only length evaluation is active */ - int32_t bit_count_estimate; /* uses 22Q10 fixed-point representation */ + Word16 config_index; + Word16 encoding_active; /* internal state specifying if actual encoding is active or only length evaluation is active */ + Word32 bit_count_estimate; /* uses 22Q10 fixed-point representation */ void *ac_handle; } ECSQ_instance; @@ -153,9 +153,9 @@ typedef struct typedef struct ivas_dirac_config_data_struct { - int16_t enc_param_start_band; - int16_t dec_param_estim; - int16_t nbands; + Word16 enc_param_start_band; + Word16 dec_param_estim; + Word16 nbands; } DIRAC_CONFIG_DATA, *DIRAC_CONFIG_DATA_HANDLE; @@ -180,9 +180,9 @@ typedef struct ivas_band_coeffs_t typedef struct ivas_band_coeffs_ind_t { - int16_t pred_index_re[IVAS_SPAR_MAX_CH - 1]; - int16_t drct_index_re[IVAS_SPAR_MAX_C_COEFF]; - int16_t decd_index_re[IVAS_SPAR_MAX_CH - 1]; + Word16 pred_index_re[IVAS_SPAR_MAX_CH - 1]; + Word16 drct_index_re[IVAS_SPAR_MAX_C_COEFF]; + Word16 decd_index_re[IVAS_SPAR_MAX_CH - 1]; } ivas_band_coeffs_ind_t; @@ -192,7 +192,7 @@ typedef struct ivas_spar_md_t ivas_band_coeffs_ind_t band_coeffs_idx[IVAS_MAX_NUM_BANDS]; Word16 num_bands; Word32 min_max_fx[2]; /*q28*/ - int16_t dtx_vad; + Word16 dtx_vad; Word32 en_ratio_slow_fx[IVAS_MAX_NUM_BANDS]; Word32 ref_pow_slow_fx[IVAS_MAX_NUM_BANDS]; Word16 res_ind; @@ -210,7 +210,7 @@ typedef struct ivas_quant_coeffs_t { Word32 min_fx; /* Q28 */ Word32 max_fx; /* Q28 */ - int16_t q_levels[2]; + Word16 q_levels[2]; } ivas_quant_coeffs_t; typedef struct ivas_quant_strat_t @@ -224,23 +224,23 @@ typedef struct ivas_quant_strat_t typedef struct ivas_spar_md_com_cfg { - int16_t max_freq_per_chan[IVAS_SPAR_MAX_CH]; - int16_t num_dmx_chans_per_band[IVAS_MAX_NUM_BANDS]; - int16_t num_decorr_per_band[IVAS_MAX_NUM_BANDS]; - int16_t active_w; - int16_t remix_unmix_order; + Word16 max_freq_per_chan[IVAS_SPAR_MAX_CH]; + Word16 num_dmx_chans_per_band[IVAS_MAX_NUM_BANDS]; + Word16 num_decorr_per_band[IVAS_MAX_NUM_BANDS]; + Word16 active_w; + Word16 remix_unmix_order; ivas_quant_strat_t quant_strat[MAX_QUANT_STRATS]; - int16_t quant_strat_bits; - int16_t nchan_transport; - int16_t num_quant_strats; - int16_t prior_strat; - int16_t tgt_bits_per_blk; - int16_t max_bits_per_blk; - int16_t prev_quant_idx; - int16_t agc_bits_ch_idx; - int16_t planarCP; - int16_t num_umx_chs; - int16_t max_md_bits_spar; + Word16 quant_strat_bits; + Word16 nchan_transport; + Word16 num_quant_strats; + Word16 prior_strat; + Word16 tgt_bits_per_blk; + Word16 max_bits_per_blk; + Word16 prev_quant_idx; + Word16 agc_bits_ch_idx; + Word16 planarCP; + Word16 num_umx_chs; + Word16 max_md_bits_spar; } ivas_spar_md_com_cfg; @@ -248,26 +248,26 @@ typedef struct ivas_spar_md_com_cfg /* arithmetic coder structures */ typedef struct ivas_cell_dim_t { - int16_t dim1; - int16_t dim2; + Word16 dim1; + Word16 dim2; } ivas_cell_dim_t; typedef struct ivas_freq_models_t { - int16_t freq_model[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; - int16_t diff_freq_model[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; - int16_t vals[IVAS_MAX_QUANT_LEVELS]; - int16_t diff_vals[IVAS_MAX_QUANT_LEVELS]; - int16_t num_models; - int16_t diff_num_models; + Word16 freq_model[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; + Word16 diff_freq_model[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; + Word16 vals[IVAS_MAX_QUANT_LEVELS]; + Word16 diff_vals[IVAS_MAX_QUANT_LEVELS]; + Word16 num_models; + Word16 diff_num_models; } ivas_freq_models_t; typedef struct ivas_huff_models_t { - int16_t code_book[IVAS_MAX_QUANT_LEVELS][3]; - int16_t diff_code_book[IVAS_MAX_QUANT_LEVELS][3]; + Word16 code_book[IVAS_MAX_QUANT_LEVELS][3]; + Word16 diff_code_book[IVAS_MAX_QUANT_LEVELS][3]; } ivas_huff_models_t; @@ -275,22 +275,22 @@ typedef struct ivas_huff_models_t /* Entropy coder structures */ typedef struct ivas_huffman_cfg_t { - const int16_t *codebook; - int16_t min_len; - int16_t max_len; - int16_t sym_len; + const Word16 *codebook; + Word16 min_len; + Word16 max_len; + Word16 sym_len; } ivas_huffman_cfg_t; typedef struct ivas_arith_t { - int16_t dyn_model_bits; - const int16_t *pFreq_model; - const int16_t *pAlt_freq_models[IVAS_NUM_PROB_MODELS]; - const int16_t *vals; - int16_t cum_freq[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; - int16_t range; - int16_t num_models; + Word16 dyn_model_bits; + const Word16 *pFreq_model; + const Word16 *pAlt_freq_models[IVAS_NUM_PROB_MODELS]; + const Word16 *vals; + Word16 cum_freq[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; + Word16 range; + Word16 num_models; Word32 saved_dist_arr[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; /* Q15 */ } ivas_arith_t; @@ -338,18 +338,18 @@ typedef struct ivas_cov_smooth_state_t Word32 *pPrior_cov_real_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 *q_cov_real_per_band[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 *q_prior_cov_real_per_band[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; - int16_t prior_bank_idx; + Word16 prior_bank_idx; Word32 *pSmoothing_factor_fx; /* Q31 */ - int16_t num_bins; + Word16 num_bins; } ivas_cov_smooth_state_t; typedef struct ivas_cov_smooth_cfg_t { Word32 max_update_rate_fx; /* Q31 */ - int16_t min_pool_size; - int16_t max_bands; - int16_t num_bins; + Word16 min_pool_size; + Word16 max_bands; + Word16 num_bins; } ivas_cov_smooth_cfg_t; @@ -357,20 +357,20 @@ typedef struct ivas_cov_smooth_cfg_t /* SPAR bitrate constant table structure */ typedef struct ivas_spar_br_table_t { - int32_t ivas_total_brate; - int16_t isPlanar; - int16_t sba_order; - int16_t bwidth; - int16_t fpcs; - int16_t nchan_transport; + Word32 ivas_total_brate; + Word16 isPlanar; + Word16 sba_order; + Word16 bwidth; + Word16 fpcs; + Word16 nchan_transport; ivas_spar_pmx_strings_t dmx_str; - int16_t active_w; - int16_t tmode; - int32_t core_brs[FOA_CHANNELS][3]; - int16_t q_lvls[MAX_QUANT_STRATS][NUM_MD_Q_COEFS_SET]; - int16_t td_ducking; - int16_t agc_bits_ch_idx; /* 0-3, Indicates core-coder channel index from which AGC bits have been taken from*/ - int16_t usePlanarCoeff; + Word16 active_w; + Word16 tmode; + Word32 core_brs[FOA_CHANNELS][3]; + Word16 q_lvls[MAX_QUANT_STRATS][NUM_MD_Q_COEFS_SET]; + Word16 td_ducking; + Word16 agc_bits_ch_idx; /* 0-3, Indicates core-coder channel index from which AGC bits have been taken from*/ + Word16 usePlanarCoeff; } ivas_spar_br_table_t; @@ -419,7 +419,7 @@ typedef struct ivas_masa_common_spatial_meta_struct typedef struct ivas_omasa_meta_struct { - uint8_t num_dirs; + UWord8 num_dirs; MASA_DIRECTIONAL_SPATIAL_META directional_meta[MASA_MAXIMUM_DIRECTIONS]; MASA_COMMON_SPATIAL_META common_meta; @@ -435,16 +435,16 @@ typedef struct ivas_masa_metadata_frame_struct typedef struct ivas_masa_config_struct { - uint16_t max_metadata_bits; - int16_t block_grouping[5]; - int16_t band_grouping[MASA_FREQUENCY_BANDS + 1]; - uint8_t numCodingBands; - uint8_t numTwoDirBands; - uint8_t numberOfDirections; - uint8_t joinedSubframes; - uint8_t useCoherence; - uint8_t coherencePresent; - uint8_t mergeRatiosOverSubframes; + UWord16 max_metadata_bits; + Word16 block_grouping[5]; + Word16 band_grouping[MASA_FREQUENCY_BANDS + 1]; + UWord8 numCodingBands; + UWord8 numTwoDirBands; + UWord8 numberOfDirections; + UWord8 joinedSubframes; + UWord8 useCoherence; + UWord8 coherencePresent; + UWord8 mergeRatiosOverSubframes; IVAS_FORMAT input_ivas_format; } MASA_CODEC_CONFIG; @@ -456,11 +456,11 @@ typedef struct ivas_masa_config_struct typedef struct { - int16_t nbands; - int16_t nblocks; - int16_t start_band; - uint8_t inactiveBands; - int16_t search_effort; + Word16 nbands; + Word16 nblocks; + Word16 start_band; + UWord8 inactiveBands; + Word16 search_effort; MC_LS_SETUP mc_ls_setup; } IVAS_METADATA_CONFIG; @@ -615,10 +615,10 @@ typedef struct ivas_parametric_mc_metadata_struct typedef struct ivas_lfe_window { - int16_t dct_len; - int16_t fade_len; - int16_t zero_pad_len; - int16_t full_len; + Word16 dct_len; + Word16 fade_len; + Word16 zero_pad_len; + Word16 full_len; const Word32 *pWindow_coeffs_fx; @@ -626,14 +626,14 @@ typedef struct ivas_lfe_window typedef struct ivas_lfe_freq_models { - uint16_t entropy_coder_model_fine_sg1[65]; - uint16_t entropy_coder_model_fine_sg2[33]; - uint16_t entropy_coder_model_fine_sg3[9]; - uint16_t entropy_coder_model_fine_sg4[3]; - uint16_t entropy_coder_model_coarse_sg1[33]; - uint16_t entropy_coder_model_coarse_sg2[17]; - uint16_t entropy_coder_model_coarse_sg3[5]; - uint16_t entropy_coder_model_coarse_sg4; + UWord16 entropy_coder_model_fine_sg1[65]; + UWord16 entropy_coder_model_fine_sg2[33]; + UWord16 entropy_coder_model_fine_sg3[9]; + UWord16 entropy_coder_model_fine_sg4[3]; + UWord16 entropy_coder_model_coarse_sg1[33]; + UWord16 entropy_coder_model_coarse_sg2[17]; + UWord16 entropy_coder_model_coarse_sg3[5]; + UWord16 entropy_coder_model_coarse_sg4; } ivas_lfe_freq_models; diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index e460637f7..e15db9a15 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -2970,7 +2970,7 @@ Word64 var_32_fx( Word16 q /* q : q-factor for the array */ ) { - + Word16 i; Word64 mean, var; mean = 0; @@ -2978,14 +2978,14 @@ Word64 var_32_fx( var = 0; move64(); - FOR( int i = 0; i < len; i++ ) + FOR( i = 0; i < len; i++ ) { mean = W_add( mean, x[i] ); /*q*/ } mean = mean / len; /* NOTE: No BASOP for 64 bit division q*/ - FOR( int i = 0; i < len; i++ ) + FOR( i = 0; i < len; i++ ) { var = W_add( var, Mpy_32_32( L_sub( x[i], W_extract_l( mean ) ), L_sub( x[i], W_extract_l( mean ) ) ) ); /*q + q - 31*/ } diff --git a/lib_com/longarith.c b/lib_com/longarith.c index 8946e41aa..72a763de3 100644 --- a/lib_com/longarith.c +++ b/lib_com/longarith.c @@ -52,27 +52,27 @@ *--------------------------------------------------------------------*/ void longadd( - uint16_t a[], /* i/o: vector of the length lena */ - const uint16_t b[], /* i/o: vector of the length lenb */ - const int16_t lena, /* i/o: length of vector a[] */ - const int16_t lenb /* i/o: length of vector b[] */ + UWord16 a[], /* i/o: vector of the length lena */ + const UWord16 b[], /* i/o: vector of the length lenb */ + const Word16 lena, /* i/o: length of vector a[] */ + const Word16 lenb /* i/o: length of vector b[] */ ) { - int16_t h; - int32_t carry = 0; + Word16 h; + Word32 carry = 0; assert( lena >= lenb ); for ( h = 0; h < lenb; h++ ) { carry += ( (uint32_t) a[h] ) + ( (uint32_t) b[h] ); - a[h] = (uint16_t) carry; + a[h] = (UWord16) carry; carry = carry >> 16; } for ( ; h < lena; h++ ) { carry = ( (uint32_t) a[h] ) + carry; - a[h] = (uint16_t) carry; + a[h] = (UWord16) carry; carry = carry >> 16; } @@ -91,14 +91,14 @@ void longadd( *--------------------------------------------------------------------*/ void longshiftright( - uint16_t a[], /* i : vector of the length lena */ - const int16_t b, /* i : number of bit positions to shift right */ - uint16_t d[], /* o : vector of the length lend */ - int16_t lena, /* i : length of vector a[] */ - const int16_t lend /* i : length of vector d[] */ + UWord16 a[], /* i : vector of the length lena */ + const Word16 b, /* i : number of bit positions to shift right */ + UWord16 d[], /* o : vector of the length lend */ + Word16 lena, /* i : length of vector a[] */ + const Word16 lend /* i : length of vector d[] */ ) { - int16_t intb, fracb, fracb_u, k; + Word16 intb, fracb, fracb_u, k; intb = b >> 4; @@ -164,16 +164,16 @@ void longshr( *--------------------------------------------------------------------*/ void longshiftleft( - const uint16_t a[], /* i : vector of the length len */ - const int16_t b, /* i : number of bit positions to shift left */ - uint16_t d[], /* o : vector of the length len */ - const int16_t len /* i : length of vector a[] and d[] */ + const UWord16 a[], /* i : vector of the length len */ + const Word16 b, /* i : number of bit positions to shift left */ + UWord16 d[], /* o : vector of the length len */ + const Word16 len /* i : length of vector a[] and d[] */ ) { - int16_t intb; /* integer part of b */ - int16_t fracb; /* shift left value for all upper words a[k] */ - int16_t fracb_l; /* shift right value for all lower words a[k-1] */ - int16_t k = len - 1; + Word16 intb; /* integer part of b */ + Word16 fracb; /* shift left value for all upper words a[k] */ + Word16 fracb_l; /* shift right value for all lower words a[k-1] */ + Word16 k = len - 1; intb = b >> 4; fracb = b & 0xF; diff --git a/lib_com/lsf_dec_bfi_fx.c b/lib_com/lsf_dec_bfi_fx.c index 6292630af..33de5d9ac 100644 --- a/lib_com/lsf_dec_bfi_fx.c +++ b/lib_com/lsf_dec_bfi_fx.c @@ -36,7 +36,7 @@ void lsf_dec_bfi( const Word16 Last_GSC_pit_band_idx, const Word16 Opt_AMR_WB, /* i : IO flag */ const Word8 tcxonly, - const short bwidth /* i: coded bandwidth */ + const Word16 bwidth /* i: coded bandwidth */ ) { Word16 i; diff --git a/lib_com/mslvq_com.c b/lib_com/mslvq_com.c index a15b11611..6bd8026c4 100644 --- a/lib_com/mslvq_com.c +++ b/lib_com/mslvq_com.c @@ -75,10 +75,10 @@ static void make_offset_scale( void create_offset( UWord32 *offset_scale1, UWord32 *offset_scale2, - const int16_t mode, - const int16_t prediction_flag ) + const Word16 mode, + const Word16 prediction_flag ) { - int16_t tmp, tmp1; + Word16 tmp, tmp1; if ( prediction_flag == 0 ) { diff --git a/lib_com/parameter_bitmaping_fx.c b/lib_com/parameter_bitmaping_fx.c index 180275d8f..0846c618b 100644 --- a/lib_com/parameter_bitmaping_fx.c +++ b/lib_com/parameter_bitmaping_fx.c @@ -58,15 +58,15 @@ static Word16 FixedWidthEncoding( Word16 value, Word16 index ) void GetParameters( ParamsBitMap const *paramsBitMap, - const int16_t nArrayLength, + const Word16 nArrayLength, void const *pParameter, - int16_t **pStream, - int16_t *pnSize, - int16_t *pnBits ) + Word16 **pStream, + Word16 *pnSize, + Word16 *pnBits ) { - int16_t index; - int16_t iParam, nParams; - int16_t value; + Word16 index; + Word16 iParam, nParams; + Word16 value; void const *pSubStruct; assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pParameter != NULL ) && ( pStream != NULL ) && ( pnSize != NULL ) && ( pnBits != NULL ) ); @@ -168,14 +168,14 @@ void GetParameters_fx( void SetParameters( ParamsBitMap const *paramsBitMap, - const int16_t nArrayLength, + const Word16 nArrayLength, void *pParameter, - const int16_t **pStream, - int16_t *pnSize ) + const Word16 **pStream, + Word16 *pnSize ) { - int16_t index; - int16_t iParam, nParams; - int16_t value; + Word16 index; + Word16 iParam, nParams; + Word16 value; void *pSubStruct; assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pParameter != NULL ) && ( pStream != NULL ) && ( pnSize != NULL ) ); diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9b596ca42..d0f0efb72 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -72,10 +72,6 @@ #define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) #endif -#ifndef TRUNC -#define TRUNC( x ) ( (int16_t) ( ( ( x ) >= 32767. ? 32767 : ( ( x ) <= -32768. ? -32768 : ( x ) ) ) + 0.5 ) ) -#endif - #define log_base_2( x ) ( (double) log( (double) ( x ) ) * 1.4426950408889634074f ) #define round_f( x ) ( ( ( x ) > 0 ) ? (int32_t) ( ( x ) + 0.5f ) : ( -(int32_t) ( ( -x ) + 0.5f ) ) ) @@ -11101,7 +11097,7 @@ void init_coder_ace_plus_ivas_fx( void core_coder_reconfig_ivas_fx( Encoder_State *st, - const int32_t last_total_brate ); + const Word32 last_total_brate ); void core_coder_mode_switch_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ diff --git a/lib_com/rom_basop_util.c b/lib_com/rom_basop_util.c index c3bfc6eef..eb79cc026 100644 --- a/lib_com/rom_basop_util.c +++ b/lib_com/rom_basop_util.c @@ -1449,7 +1449,7 @@ void BASOP_getTables( const PWord16 **ptwiddle /*Q15*/, const PWord16 **sin_twid ld2_length = sub( 16 - 1 - 1, norm_s( length ) ); /* Extract sort of "eigenvalue" (the 5 left most bits) of length. */ - SWITCH( (unsigned short) L_shl( length, sub( 15, ld2_length ) ) ) + SWITCH( (UWord16) L_shl( length, sub( 15, ld2_length ) ) ) { case 0xa000: /* 640 */ move16(); diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 274a33a18..33661fb58 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -66,7 +66,7 @@ typedef struct Word16 filt_len; /* number of filter coeff. */ Word16 filt_len_fx; /* number of filter coeff. Q0 */ - uint16_t flags; /* flags from config. table */ + UWord16 flags; /* flags from config. table */ UWord16 flags_fx; /* flags from config. table Q0 */ // UNS_Word16 flags_fx; /* flags from config. table Q0 */ diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 9edc28c03..c96dcc884 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -74,7 +74,7 @@ typedef struct typedef struct { Word16 lead_sign_ind; - uint32_t index, size; + UWord32 index, size; Word16 dim, k_val; } PvqEntry; @@ -313,7 +313,7 @@ typedef struct { Word32 low; Word32 high; - uint32_t value; + UWord32 value; Word32 bits_to_follow; } Tastat; typedef struct @@ -490,15 +490,6 @@ typedef Word16 ( *TEncodeValue )( Word16 value, Word16 index ); */ typedef Word16 ( *TDecodeValue )( struct Decoder_State *st, Word16 index, Word16 *pValue ); -/** Linear prediction analysis/synthesis filter definition. - * @param order filter order. - * @param parCoeff filter (PARCOR) coefficients. - * @param state state of the filter. Must be at least of 'order' size. - * @param x the current input value. - * @return the output of the filter. - */ -typedef float ( *TLinearPredictionFilter_flt )( const int16_t order, const float parCoeff[], float *state, float x ); - /** Structure that defines mapping between a parameter and a bitstream. */ typedef struct ParamBitMap { diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c index 9b58084e3..e56a77be1 100644 --- a/lib_dec/FEC_clas_estim_fx.c +++ b/lib_dec/FEC_clas_estim_fx.c @@ -82,7 +82,7 @@ void FEC_clas_estim_fx( Word16 bfi, /* i : bad frame indicator */ /*B*/ Word32 last_core_brate, /* i : bitrate of previous frame */ - const int16_t FEC_mode /* i : ACELP FEC mode */ + const Word16 FEC_mode /* i : ACELP FEC mode */ ) { Word16 i, j, pos; diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index fc8aba043..b2cc593b3 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -847,7 +847,6 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( move16(); Copy_Scale_sig_16_32_DEPREC( synth_out, synth32, L_FRAME48k, 5 ); /*11-5-1*/ - // cldfbSynthesis_ivas_fx(realBuffer, imagBuffer, synth_out, (int16_t)(st_fx->output_Fs * 0.01f), st_fx->cldfbSyn); cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ), st_fx->cldfbSyn ); Scale_sig32( st_fx->cldfbSyn->cldfb_state_fx, st_fx->cldfbSyn->cldfb_state_length, -1 ); // Q_cldfb_state-1 st_fx->cldfbSyn->Q_cldfb_state = sub( st_fx->cldfbSyn->Q_cldfb_state, 1 ); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 17b3f9fbc..0f361e658 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1290,7 +1290,7 @@ ivas_error core_switching_post_dec_ivas_fx( FD_BWE_DEC_HANDLE hBWE_FD; HQ_DEC_HANDLE hHQ_core; ivas_error error; - int16_t offset; + Word16 offset; L_tmp = 0; move32(); diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index aa898956a..42f3250fb 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -114,17 +114,17 @@ void decod_unvoiced_fx( *-------------------------------------------------------------------*/ void decod_unvoiced_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */ - const Word16 coder_type, /* Q0 i : coding type */ - Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ - Word16 *voice_factors_fx, /* Q15 o : voicing factors */ - Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ - Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ + const Word16 coder_type, /* Q0 i : coding type */ + Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ + Word16 *voice_factors_fx, /* Q15 o : voicing factors */ + Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ + Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ Word16 *gain_buf ) { Word16 gain_pit_fx; /* Quantized pitch gain */ diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index 7c3ecaa0a..e30553d38 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -446,7 +446,7 @@ void con_acelp_fx( ELSE { /* No harmonic part */ - assert( (int) ( sizeof( buf ) / sizeof( buf[0] ) ) - M - L_EXC_MEM_DEC >= st->L_frame + st->L_frame / 2 ); + assert( (Word32) ( sizeof( buf ) / sizeof( buf[0] ) ) - M - L_EXC_MEM_DEC >= st->L_frame + st->L_frame / 2 ); set16_fx( &exc[0], 0, add( st->L_frame, shr( st->L_frame, 1 ) ) ); FOR( i = 0; i < st->nb_subfr; i++ ) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 3fe40c1f3..3c234c098 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1484,7 +1484,7 @@ void ivas_binaural_add_LFE_fx( Word32 *output_fx[] /* o : synthesized core-coder transport channels/DirAC output Q11*/ ) { - Word16 render_lfe, idx_lfe, gain_fx; + Word16 render_lfe, idx_lfe, gain_fx, idx; IF( st_ivas->hBinRenderer != NULL ) { @@ -1523,7 +1523,7 @@ void ivas_binaural_add_LFE_fx( { v_multc_fixed_16( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], gain_fx, input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]], output_frame ); // q_input_fx - 1 /* copy LFE to left and right channels */ - FOR( int idx = 0; idx < output_frame; idx++ ) + FOR( idx = 0; idx < output_frame; idx++ ) { input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]][idx] = L_shl_sat( input_fx[st_ivas->hIntSetup.index_lfe[idx_lfe]][idx], 1 ); // saturating to keep same q move32(); diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 7dd7371fd..59d9c9e38 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2216,7 +2216,7 @@ void ivas_dirac_dec_render_sf_fx( DIRAC_DEC_STACK_MEM DirAC_mem; Word32 *p_onset_filter_fx = NULL; - uint16_t coherence_flag; + UWord16 coherence_flag; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; Word16 scale = 0; move16(); diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 9040a8a71..eae0e9069 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1428,9 +1428,9 @@ void ivas_ism_param_dec_tc_gain_ajust_fx( static void ivas_ism_param_dec_render_sf_fx( Decoder_Struct *st_ivas, IVAS_OUTPUT_SETUP hSetup, - const int16_t nchan_transport, - const int16_t nchan_out, - const int16_t nchan_out_woLFE, + const Word16 nchan_transport, + const Word16 nchan_out, + const Word16 nchan_out_woLFE, Word32 *output_f_fx[], /*Q_output*/ Word16 Q_output[] ) { diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index f632d86c8..428c817ef 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -83,7 +83,7 @@ ivas_error ivas_jbm_dec_tc_fx( Word32 *data_fx /*Q11*/ ) { - Word16 n, output_frame, nchan_out, i; + Word16 n, output_frame, nchan_out, i, ii; Decoder_State *st; /* used for bitstream handling */ Word32 *p_output_fx[MAX_TRANSPORT_CHANNELS]; /* buffer for output synthesis */ Word16 nchan_remapped; @@ -512,14 +512,14 @@ ivas_error ivas_jbm_dec_tc_fx( hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; move16(); } - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; move16(); } #ifdef MSAN_FIX - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx } @@ -534,7 +534,7 @@ ivas_error ivas_jbm_dec_tc_fx( Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); } #ifdef MSAN_FIX - FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { Scale_sig32( &hCPE->prev_synth_fx[ii][0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 } @@ -614,7 +614,7 @@ ivas_error ivas_jbm_dec_tc_fx( st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; move16(); - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 hCPE->q_output_mem_fx[ii] = Q11; @@ -999,7 +999,7 @@ ivas_error ivas_jbm_dec_tc_fx( hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; move16(); } - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; @@ -1045,7 +1045,7 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); } - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 hCPE->q_output_mem_fx[ii] = Q11; @@ -1464,7 +1464,7 @@ ivas_error ivas_jbm_dec_tc_fx( hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; move16(); } - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->q_output_mem_fx[ii] ) ); // q_dft hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; @@ -1509,7 +1509,7 @@ ivas_error ivas_jbm_dec_tc_fx( } IF( st_ivas->hSpar != NULL ) { - FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 hCPE->q_output_mem_fx[ii] = Q11; @@ -1787,7 +1787,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { - ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_mc_paramupmix_dec_digest_tc( st_ivas, (UWord8) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { @@ -1882,7 +1882,7 @@ ivas_error ivas_jbm_dec_render_fx( ivas_error error; Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; Word32 *p_tc_fx[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; - Word16 subframe_len, gd_bits, exp, nchan_in, i, j; + Word16 subframe_len, gd_bits, exp, nchan_in, i, j, ch; const Word16 output_q_factor = Q11; move16(); SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -2448,7 +2448,7 @@ ivas_error ivas_jbm_dec_render_fx( move16(); } /* CLDFB synthesis */ - FOR( Word16 ch = 0; ch < nchan_out_cldfb; ch++ ) + FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) { IF( st_ivas->cldfbSynDec[ch] ) { @@ -2476,7 +2476,7 @@ ivas_error ivas_jbm_dec_render_fx( ivas_param_mc_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, channel_active_fx ); - FOR( int ch = 0; ch < nchan_out_cldfb; ch++ ) + FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) { IF( st_ivas->cldfbSynDec[ch] ) { diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 897fd4433..be2363469 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -107,7 +107,7 @@ static ivas_error param_mc_get_diff_proto_info_fx( const Word32 *proto_mtx, cons static void param_mc_update_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, Word32 *mixing_matrix[], Word16 *mixing_matrix_fx, Word32 *mixing_matrix_res[], Word16 *mixing_matrix_res_exp, const UWord16 nX, const UWord16 nY ); -static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const int16_t num_freq_bands /*, Word16 RealBuffer_fx_e, Word16 ImagBuffer_fx_e, Word16 *common_e*/ ); +static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const Word16 num_freq_bands /*, Word16 RealBuffer_fx_e, Word16 ImagBuffer_fx_e, Word16 *common_e*/ ); /*------------------------------------------------------------------------- * ivas_param_mc_dec_open() @@ -1509,8 +1509,8 @@ void ivas_param_mc_dec_read_BS_fx( *------------------------------------------------------------------------*/ void ivas_param_mc_dec_digest_tc_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ Word32 *transport_channels_f_fx[], Word16 transport_f_e ) { @@ -2361,7 +2361,7 @@ static void param_mc_protoSignalComputation_fx( Word32 *ImagBuffer_fx, /* i : CLDFB samples of the transport channels (imaginary part) */ Word32 *proto_frame_f_fx, /* o : interleaved complex prototype CLDFB samples */ const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, /* i : prototype generation information */ - const int16_t num_freq_bands /* i : number of frequency bands for the prototypes */ + const Word16 num_freq_bands /* i : number of frequency bands for the prototypes */ ) { Word16 band; @@ -2680,7 +2680,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( Word16 nY_band; Word16 num_lfe_bands; Word16 brange[2]; - uint16_t i; + UWord16 i; Word16 ch_idx1, ch_idx2, lfe_idx1, lfe_idx2; Word16 remove_lfe; Word16 lfe_indices[PARAM_MC_LOCAL_SZ_LFE_MAP]; diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 812d9957f..6f75230c9 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -100,7 +100,7 @@ const Word32 dft_ap_gains_fx[5][3] = { 644245094, -644245120, 1073741824 } }; -const int16_t dft_ap_delays[3][3] = +const Word16 dft_ap_delays[3][3] = { { 2, 47, 61}, {29, 41, 73}, @@ -196,7 +196,7 @@ const Word16 dft_win_8k_fx[70] = * stereo CNA tables *------------------------------------------------------------------------*/ -const int16_t cna_init_bands[CNA_INIT_NBANDS + 1] = +const Word16 cna_init_bands[CNA_INIT_NBANDS + 1] = { 1, 4, 14, 33, 67, 171, 320 }; @@ -235,7 +235,7 @@ const Word16 min_smooth_gains2_fx[SBA_DIRAC_STEREO_NUM_BANDS] = /* all the "probability" tables for the actual AC are in the reversed cumulative counts table format; for example, given the counts table [c0 | c1 | c2 | c3] with c0 + c1 + c2 + c3 = 2 ^ 14, the reversed cumulative counts table is [2 ^ 14 | 2 ^ 14 - c0 | 2 ^ 14 - c0 - c1 | 2 ^ 14 - c0 - c1 - c2 | 2 ^ 14 - c0 - c1 - c2 - c3] */ -const uint16_t cum_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT] = +const UWord16 cum_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT] = { {0,1024,2048,3072,4096,5120,6144,7168,8192,9216,10240,11264,12288,13312,14336,15360,16384 }, {0,9294,16019,16213,16311,16346,16363,16371,16375,16377,16378,16379,16380,16381,16382,16383,16384 }, @@ -246,7 +246,7 @@ const uint16_t cum_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT] {0,5836,14448,15610,16267,16343,16374,16375,16376,16377,16378,16379,16380,16381,16382,16383,16384 } }; -const uint16_t sym_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][ECSQ_PARAM_COUNT] = +const UWord16 sym_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][ECSQ_PARAM_COUNT] = { {1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024 }, {9294,6725,194,98,35,17,8,4,2,1,1,1,1,1,1,1 }, @@ -257,7 +257,7 @@ const uint16_t sym_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][ECSQ_PARAM_COUNT] = {5836,8612,1162,657,76,31,1,1,1,1,1,1,1,1,1,1 } }; -const uint16_t cum_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE] = +const UWord16 cum_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE] = { {0,6445,12725,15035,15885,16198,16313,16355,16370,16376,16378,16379,16380,16381,16382,16383,16384 }, {0,3624,8645,11690,13537,14657,15336,15748,15998,16150,16242,16298,16332,16352,16364,16372,16384 }, @@ -276,7 +276,7 @@ const uint16_t cum_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SI {0,3623,6446,8644,10356,11689,12727,13536,14166,14657,15039,15337,15569,15749,15890,15999,16384 }, }; -const uint16_t sym_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][ECSQ_TAB_VALS_SIZE] = +const UWord16 sym_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][ECSQ_TAB_VALS_SIZE] = { {6445,6280,2310,850,313,115,42,15,6,2,1,1,1,1,1,1 }, {3624,5021,3045,1847,1120,679,412,250,152,92,56,34,20,12,8,12 }, @@ -295,59 +295,59 @@ const uint16_t sym_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][ECSQ_TAB_VALS_SIZE] {3623,2823,2198,1712,1333,1038,809,630,491,382,298,232,180,141,109,385 }, }; -const uint16_t cum_freq_ECSQ_tab_abs_1bit[1 + 2] = +const UWord16 cum_freq_ECSQ_tab_abs_1bit[1 + 2] = { 0, 5462, 16384 }; /* table for uniform coding of absolute values in {0, +-1, +-2, +-3} */ -const uint16_t cum_freq_ECSQ_tab_abs_2bit[1 + 4] = +const UWord16 cum_freq_ECSQ_tab_abs_2bit[1 + 4] = { 0, 2338, 7020, 11702, 16384 }; /* table for uniform coding of absolute values in {0, +-1, ..., +-7} */ -const uint16_t cum_freq_ECSQ_tab_abs_3bit[1 + 8] = +const UWord16 cum_freq_ECSQ_tab_abs_3bit[1 + 8] = { 0, 1096, 3280, 5464, 7648, 9832, 12016, 14200, 16384 }; /* table for uniform coding of absolute values in {0, +-1, ..., +-15} */ -const uint16_t cum_freq_ECSQ_tab_abs_4bit[1 + 16] = +const UWord16 cum_freq_ECSQ_tab_abs_4bit[1 + 16] = { 0, 514, 1572, 2630, 3688, 4746, 5804, 6862, 7920, 8978, 10036, 11094, 12152, 13210, 14268, 15326, 16384 }; -const uint16_t sym_freq_ECSQ_tab_abs_1bit[2] = +const UWord16 sym_freq_ECSQ_tab_abs_1bit[2] = { 5462, 10922 }; /* table for uniform coding of absolute values in {0, +-1, +-2, +-3} */ -const uint16_t sym_freq_ECSQ_tab_abs_2bit[4] = +const UWord16 sym_freq_ECSQ_tab_abs_2bit[4] = { 2338, 4682, 4682, 4682 }; /* table for uniform coding of absolute values in {0, +-1, ..., +-7} */ -const uint16_t sym_freq_ECSQ_tab_abs_3bit[8] = +const UWord16 sym_freq_ECSQ_tab_abs_3bit[8] = { 1096, 2184, 2184, 2184, 2184, 2184, 2184, 2184 }; /* table for uniform coding of absolute values in {0, +-1, ..., +-15} */ -const uint16_t sym_freq_ECSQ_tab_abs_4bit[16] = +const UWord16 sym_freq_ECSQ_tab_abs_4bit[16] = { 514, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058, 1058 }; /* array of tables for uniform coding of absolute values */ -const uint16_t * const cum_freq_ECSQ_tab_abs_lsbs[1 + 4] = +const UWord16 * const cum_freq_ECSQ_tab_abs_lsbs[1 + 4] = { NULL, cum_freq_ECSQ_tab_abs_1bit, cum_freq_ECSQ_tab_abs_2bit, cum_freq_ECSQ_tab_abs_3bit, cum_freq_ECSQ_tab_abs_4bit }; -const uint16_t * const sym_freq_ECSQ_tab_abs_lsbs[1 + 4] = +const UWord16 * const sym_freq_ECSQ_tab_abs_lsbs[1 + 4] = { NULL, sym_freq_ECSQ_tab_abs_1bit, sym_freq_ECSQ_tab_abs_2bit, sym_freq_ECSQ_tab_abs_3bit, sym_freq_ECSQ_tab_abs_4bit }; @@ -391,7 +391,7 @@ const Word32 dmxmtx_table_fx[BINAURAL_CHANNELS][11] = *-----------------------------------------------------------------------*/ /* Alpha Fine Huffman table df0 */ -static const int16_t huff_nodes_first_band_alpha[32][2] = +static const Word16 huff_nodes_first_band_alpha[32][2] = { { -17, 1 }, { 3, 2 }, @@ -428,7 +428,7 @@ static const int16_t huff_nodes_first_band_alpha[32][2] = }; /* Alpha Fine Huffman table df */ -static const int16_t huff_nodes_alpha_1D_DF[64][2] = +static const Word16 huff_nodes_alpha_1D_DF[64][2] = { { -33, 1 }, { 3, 2 }, @@ -497,7 +497,7 @@ static const int16_t huff_nodes_alpha_1D_DF[64][2] = }; /* Alpha Fine Huffman table dt */ -static const int16_t huff_nodes_alpha_1D_DT[64][2] = +static const Word16 huff_nodes_alpha_1D_DT[64][2] = { { -33, 1 }, { -34, 2 }, @@ -566,19 +566,19 @@ static const int16_t huff_nodes_alpha_1D_DT[64][2] = }; /* Beta Fine Huffman table df0 */ -static const int16_t huff_nodes_first_band_beta[8][2] = +static const Word16 huff_nodes_first_band_beta[8][2] = { { -1, 1 }, { -2, 2 }, { -3, 3 }, { -4, 4 }, { -5, 5 }, { -6, 6 }, { -7, 7 }, { -8, -9 } }; /* Beta Fine Huffman table df */ -static const int16_t huff_nodes_beta_1D_DF[16][2] = +static const Word16 huff_nodes_beta_1D_DF[16][2] = { { -9, 1 }, { -10, 2 }, { -8, 3 }, { -11, 4 }, { -7, 5 }, { 7, 6 }, { -6, -12 }, { 9, 8 }, { -5, -13 }, { 11, 10 }, { -4, -14 }, { -15, 12 }, { -3, 13 }, { -16, 14 }, { -2, 15 }, { -1, -17 } }; /* Beta Fine Huffman table dt */ -static const int16_t huff_nodes_beta_1D_DT[16][2] = +static const Word16 huff_nodes_beta_1D_DT[16][2] = { { -9, 1 }, { -10, 2 }, { -8, 3 }, { -11, 4 }, { -7, 5 }, { 7, 6 }, { -6, -12 }, { -13, 8 }, { -5, 9 }, { -14, 10 }, { -4, 11 }, { -15, 12 }, { -3, 13 }, { -16, 14 }, { -2, 15 }, { -1, -17 } }; diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index 11752380d..84c1a94a0 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -53,7 +53,7 @@ extern const Word16 dft_alpha_s2_b2_fx[STEREO_DFT_BAND_MAX]; extern const Word32 dft_bpf_weights_fx[]; extern const Word32 dft_ap_gains_fx[5][3]; -extern const int16_t dft_ap_delays[3][3]; +extern const Word16 dft_ap_delays[3][3]; extern const Word16 dft_win232ms_8k_fx[75]; extern const Word16 dft_win232ms_12k8_fx[120]; extern const Word16 dft_win232ms_16k_fx[150]; @@ -62,7 +62,7 @@ extern const Word16 dft_win232ms_48k_fx[450]; extern const Word16 dft_res_pred_weights_fx[][STEREO_DFT_BAND_MAX]; extern const Word16 dft_win_8k_fx[70]; -extern const int16_t cna_init_bands[CNA_INIT_NBANDS + 1]; +extern const Word16 cna_init_bands[CNA_INIT_NBANDS + 1]; extern const Word16 min_smooth_gains1_fx[SBA_DIRAC_STEREO_NUM_BANDS]; @@ -74,12 +74,12 @@ extern const Word16 max_smooth_gains2_fx[SBA_DIRAC_STEREO_NUM_BANDS]; * ECLVQ Stereo ROM tables *----------------------------------------------------------------------------------*/ -extern const uint16_t cum_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT]; -extern const uint16_t sym_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][ECSQ_PARAM_COUNT]; -extern const uint16_t cum_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE]; -extern const uint16_t sym_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][ECSQ_TAB_VALS_SIZE]; -extern const uint16_t *const cum_freq_ECSQ_tab_abs_lsbs[1 + 4]; -extern const uint16_t *const sym_freq_ECSQ_tab_abs_lsbs[1 + 4]; +extern const UWord16 cum_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][1 + ECSQ_PARAM_COUNT]; +extern const UWord16 sym_freq_ECSQ_tab_param[ECSQ_CONFIG_COUNT][ECSQ_PARAM_COUNT]; +extern const UWord16 cum_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][1 + ECSQ_TAB_VALS_SIZE]; +extern const UWord16 sym_freq_ECSQ_tab_vals[ECSQ_PARAM_COUNT - 1][ECSQ_TAB_VALS_SIZE]; +extern const UWord16 *const cum_freq_ECSQ_tab_abs_lsbs[1 + 4]; +extern const UWord16 *const sym_freq_ECSQ_tab_abs_lsbs[1 + 4]; /*----------------------------------------------------------------------------------* diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index d1efbbd2c..bb79b956c 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -49,11 +49,11 @@ #define IVAS_DEFAULT_DTX_CNG_RAMP ( 8 ) /* PLC constants */ -static const int16_t ivas_spar_dec_plc_num_frames_keep = 9; -// static const int16_t ivas_spar_dec_plc_num_frames_fade_out = 9; -static const int16_t ivas_spar_dec_plc_per_frame_ramp_down_gain_dB = 3; -static const int16_t ivas_spar_dec_plc_max_num_frames_ramp_down = 33; -static const int16_t ivas_spar_dec_plc_spatial_target[IVAS_SPAR_MAX_CH] = { 1, 0, 0, 0, 0, 0, 0, 0 }; +static const Word16 ivas_spar_dec_plc_num_frames_keep = 9; +// static const Word16 ivas_spar_dec_plc_num_frames_fade_out = 9; +static const Word16 ivas_spar_dec_plc_per_frame_ramp_down_gain_dB = 3; +static const Word16 ivas_spar_dec_plc_max_num_frames_ramp_down = 33; +static const Word16 ivas_spar_dec_plc_spatial_target[IVAS_SPAR_MAX_CH] = { 1, 0, 0, 0, 0, 0, 0, 0 }; /*------------------------------------------------------------------------------------------* diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index b1522be36..5704f4f60 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -49,14 +49,14 @@ /* State of the range decoder */ typedef struct { - uint32_t rc_low; - uint32_t rc_range; + UWord32 rc_low; + UWord32 rc_range; - uint16_t *bit_buffer; - int16_t bit_count; - int16_t max_allowable_bit_count; + UWord16 *bit_buffer; + Word16 bit_count; + Word16 max_allowable_bit_count; - int16_t bit_error_detected; + Word16 bit_error_detected; } RangeUniDecState; @@ -78,11 +78,11 @@ typedef struct stereo_dft_dec_data_struct STEREO_DFT_CONFIG_DATA_HANDLE hConfig; /*Sizes*/ - int16_t N; /* Size of DFT hop size */ - int16_t NFFT; /* Size of DFT */ + Word16 N; /* Size of DFT hop size */ + Word16 NFFT; /* Size of DFT */ /*FFT*/ - int16_t dft_trigo_step; + Word16 dft_trigo_step; const Word16 *dft_trigo_fx; /* Q15 */ const Word16 *dft_trigo_12k8_fx; /* Q15 */ @@ -90,13 +90,13 @@ typedef struct stereo_dft_dec_data_struct const Word16 *dft_trigo_8k_fx; /* Q15 */ - int16_t dft32ms_ovl; /* Overlap size */ + Word16 dft32ms_ovl; /* Overlap size */ const Word16 *win32ms_fx; /* DFT window */ /* Q15 */ const Word16 *win32ms_12k8_fx; /* DFT window */ /* Q15 */ const Word16 *win32ms_16k_fx; /* DFT window */ /* Q15 */ const Word16 *win32ms_8k_fx; /* DFT window */ /* Q15 */ - int16_t dft32ms_ovl2; /* Overlap2 size */ + Word16 dft32ms_ovl2; /* Overlap2 size */ const Word16 *win232ms_fx; /* DFT window */ /* Q15 */ const Word16 *win232ms_12k8_fx; /* DFT window */ /* Q15 */ const Word16 *win232ms_16k_fx; /* DFT window */ /* Q15 */ @@ -105,31 +105,31 @@ typedef struct stereo_dft_dec_data_struct /*Bands*/ - int16_t band_res[STEREO_DFT_DEC_DFT_NB]; - int16_t band_limits[STEREO_DFT_BAND_MAX + 1]; - int16_t nbands; + Word16 band_res[STEREO_DFT_DEC_DFT_NB]; + Word16 band_limits[STEREO_DFT_BAND_MAX + 1]; + Word16 nbands; /*Configuration*/ - int16_t prm_res[STEREO_DFT_DEC_DFT_NB]; + Word16 prm_res[STEREO_DFT_DEC_DFT_NB]; /*Stereo parameters*/ Word32 side_gain_fx[STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX]; /* Q31 */ - int16_t side_gain_flag_1; - int16_t side_gain_flag_2; - int16_t side_gain_index_previous[STEREO_DFT_BAND_MAX]; - int16_t side_gain_index[STEREO_DFT_BAND_MAX]; + Word16 side_gain_flag_1; + Word16 side_gain_flag_2; + Word16 side_gain_index_previous[STEREO_DFT_BAND_MAX]; + Word16 side_gain_index[STEREO_DFT_BAND_MAX]; Word32 gipd_fx[STEREO_DFT_DEC_DFT_NB]; /* Q27 */ - int16_t no_ipd_flag; /* flag to indicate when no IPD gets used */ + Word16 no_ipd_flag; /* flag to indicate when no IPD gets used */ - int16_t itd_xfade_counter; - int32_t last_active_element_brate; - int16_t ipd_xfade_counter; + Word16 itd_xfade_counter; + Word32 last_active_element_brate; + Word16 ipd_xfade_counter; /*residual prediction*/ - int16_t res_pred_mode[STEREO_DFT_DEC_DFT_NB]; /* residual prediction mode: 0(off), 1(stereo filling only), 2(enhanced stereo filling) */ - Word32 itd_fx[STEREO_DFT_DEC_DFT_NB]; /* Q15 */ + Word16 res_pred_mode[STEREO_DFT_DEC_DFT_NB]; /* residual prediction mode: 0(off), 1(stereo filling only), 2(enhanced stereo filling) */ + Word32 itd_fx[STEREO_DFT_DEC_DFT_NB]; /* Q15 */ Word32 itd_xfade_step_fx; /* Q15 */ Word32 itd_xfade_target_fx; /* Q15 */ @@ -139,19 +139,19 @@ typedef struct stereo_dft_dec_data_struct Word32 ipd_xfade_step_fx; /* Q27 */ Word32 ipd_xfade_prev_fx; /* Q27 */ Word32 res_pred_gain_fx[STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX]; /* prediction gain for the residual HFs */ /* Q31 */ - int16_t res_pred_band_min; /* Band min for prediction of residual */ - int16_t past_DMX_pos; - int16_t res_pred_flag_0; - int16_t res_pred_flag_1; - int16_t res_pred_index_previous[STEREO_DFT_BAND_MAX]; + Word16 res_pred_band_min; /* Band min for prediction of residual */ + Word16 past_DMX_pos; + Word16 res_pred_flag_0; + Word16 res_pred_flag_1; + Word16 res_pred_index_previous[STEREO_DFT_BAND_MAX]; - int16_t reverb_flag; - int16_t nbands_respred; + Word16 reverb_flag; + Word16 nbands_respred; /*residual coding*/ - int16_t res_cod_mode[STEREO_DFT_DEC_DFT_NB]; /* mode from 0 (off) to 3 */ - int16_t res_cod_band_max; /* Band max for coding of residual */ - int16_t res_cod_line_max; + Word16 res_cod_mode[STEREO_DFT_DEC_DFT_NB]; /* mode from 0 (off) to 3 */ + Word16 res_cod_band_max; /* Band max for coding of residual */ + Word16 res_cod_line_max; Word32 DFT_past_DMX_fx[STEREO_DFT_PAST_MAX][STEREO_DFT32MS_N_32k]; /* Past DMX for residual prediction */ /* Q(q_DFT_past_DMX_fx) */ Word32 past_res_pred_gain_fx[STEREO_DFT_PAST_MAX][STEREO_DFT_BAND_MAX]; /* Q31 */ Word32 res_gains_ind_fx[2][2 * STEREO_DFT_BAND_MAX]; /* Q26 */ @@ -171,9 +171,9 @@ typedef struct stereo_dft_dec_data_struct BPF_DEC_HANDLE hBpf; TCX_LTP_DEC_HANDLE hTcxLtpDec; - int16_t trans; - int16_t attackPresent; - int16_t wasTransient; + Word16 trans; + Word16 attackPresent; + Word16 wasTransient; basic_allpass_t ap1, ap2, ap3; @@ -188,9 +188,9 @@ typedef struct stereo_dft_dec_data_struct Word32 ap_fade_mem_fx[STEREO_DFT_ALLPASS_FADELEN_16k]; /* Q(q_ap_fade_mem_fx) */ Word16 q_ap_fade_mem_fx; - int16_t ap_wasTransient; - int16_t core_hist[STEREO_DFT_CORE_HIST_MAX]; - int16_t hb_stefi_delay; + Word16 ap_wasTransient; + Word16 core_hist[STEREO_DFT_CORE_HIST_MAX]; + Word16 hb_stefi_delay; Word32 smooth_dmx_nrg_fx[STEREO_DFT_BAND_MAX]; /* Q(q_smoothed_nrg) */ Word32 smooth_res_nrg_fx[STEREO_DFT_BAND_MAX]; /* Q(q_smoothed_nrg) */ Word32 td_gain_fx[STEREO_DFT_CORE_HIST_MAX]; /* Q(q_td_gain) */ @@ -206,16 +206,16 @@ typedef struct stereo_dft_dec_data_struct /* stereo DTX */ Word16 g_state_fx[STEREO_DFT_BAND_MAX]; /* Q15 */ - int16_t frame_sid_nodata; - int16_t frame_nodata; - int16_t frame_sid; + Word16 frame_sid_nodata; + Word16 frame_nodata; + Word16 frame_sid; Word16 scale_fx; /* Q15 */ /* PLC on residual signal */ - int16_t time_offs; - int16_t sg_mem_corrupt; - int16_t recovery_flg; + Word16 time_offs; + Word16 sg_mem_corrupt; + Word16 recovery_flg; /* PLC on residual signal */ Word32 sg_mean_fx; /* Q31 */ @@ -228,7 +228,7 @@ typedef struct stereo_dft_dec_data_struct Word16 q_hb_nrg_subr; Word16 q_res_mem; - int16_t first_frame; + Word16 first_frame; Word32 mixer_mat_smooth_fx[2][4][2 * IVAS_MAX_NUM_BANDS]; /* Q31 */ Word32 g_L_prev_fx; /* Q31 */ Word32 g_R_prev_fx; /* Q31 */ @@ -257,26 +257,26 @@ typedef struct stereo_dec_cng { Word16 cm_fx[STEREO_DFT_BAND_MAX]; /* cm */ /* Q15 */ Word16 coh_fx[STEREO_DFT_BAND_MAX + 1]; /* coherence */ /* Q15 */ - int16_t first_SID; /* first SID indicator */ - int16_t first_SID_after_TD; /* first SID after TD-stereo indicator */ - int16_t prev_sid_nodata; /* previous frame SID/FRAME_NO_DATA indicator */ - int16_t last_tdm_idx; /* last tdm index */ + Word16 first_SID; /* first SID indicator */ + Word16 first_SID_after_TD; /* first SID after TD-stereo indicator */ + Word16 prev_sid_nodata; /* previous frame SID/FRAME_NO_DATA indicator */ + Word16 last_tdm_idx; /* last tdm index */ Word32 c_LR_LT_fx; /* left right cross correlation */ /* Q31 */ - int16_t active_frame_counter; /* counter for active frames */ - int16_t xfade_frame_counter; /* xfade counter */ - int16_t xfade_length; /* number of frames to perform xfade */ - int16_t nr_dft_frames; /* dft frame counter */ - int16_t nr_corr_frames; /* correlation frame counter */ - int16_t nr_sid_frames; /* SID frame counter */ - int16_t last_act_element_mode; /* Element mode of last active frame */ + Word16 active_frame_counter; /* counter for active frames */ + Word16 xfade_frame_counter; /* xfade counter */ + Word16 xfade_length; /* number of frames to perform xfade */ + Word16 nr_dft_frames; /* dft frame counter */ + Word16 nr_corr_frames; /* correlation frame counter */ + Word16 nr_sid_frames; /* SID frame counter */ + Word16 last_act_element_mode; /* Element mode of last active frame */ Word16 olapBufferSynth22_fx[FFTLEN]; /* overlap buffer for secondary channel CNA */ Word32 olapBufferSynth22_32fx[FFTLEN]; /* overlap buffer for secondary channel CNA */ - int16_t flag_cna_fade; /* flag enabling CNA fade out */ + Word16 flag_cna_fade; /* flag enabling CNA fade out */ Word16 maskingNoiseS_fx[L_FRAME16k]; /* masking noise (CNA) for secondary channel */ - int16_t enableSecCNA; /* flag enabling secondary channel CNA */ + Word16 enableSecCNA; /* flag enabling secondary channel CNA */ Word16 c_PS_LT_fx; /* long term cross-correlation between primary and secondary channel */ // Assumed Q15 for initialization. Can be modified later if reqd. - const int16_t *frameSize; /* Frame size in samples */ - const int16_t *fftlen; /* FFT length used for the decomposition */ + const Word16 *frameSize; /* Frame size in samples */ + const Word16 *fftlen; /* FFT length used for the decomposition */ } STEREO_CNG_DEC, *STEREO_CNG_DEC_HANDLE; @@ -287,18 +287,18 @@ typedef struct stereo_dec_cng typedef struct stereo_td_dec_data_structure { - int16_t tdm_last_ratio_idx; /* last TDM ratio index */ - int16_t tdm_last_SM_flag; /* last channel combination scheme flag */ - int16_t tdm_prev_last_SM_flag; /* channel combination scheme flag before last frame */ - int16_t tdm_SM_flag; /* current channel combination scheme flag */ - int16_t tdm_use_IAWB_Ave_lpc; /* Flag to indicate the usage of mean inactive LP coefficients */ - - int16_t tdm_lp_reuse_flag; /* Flag that indicate if it is possible to reuse the LP coefficient from the primary channel or not */ - int16_t tdm_low_rate_mode; /* secondary channel low rate mode flag */ + Word16 tdm_last_ratio_idx; /* last TDM ratio index */ + Word16 tdm_last_SM_flag; /* last channel combination scheme flag */ + Word16 tdm_prev_last_SM_flag; /* channel combination scheme flag before last frame */ + Word16 tdm_SM_flag; /* current channel combination scheme flag */ + Word16 tdm_use_IAWB_Ave_lpc; /* Flag to indicate the usage of mean inactive LP coefficients */ + + Word16 tdm_lp_reuse_flag; /* Flag that indicate if it is possible to reuse the LP coefficient from the primary channel or not */ + Word16 tdm_low_rate_mode; /* secondary channel low rate mode flag */ Word16 tdm_Pri_pitch_buf_fx[NB_SUBFR]; - int16_t tdm_Pitch_reuse_flag; - int16_t tdm_LRTD_flag; - int16_t flag_skip_DMX; /* flag that indicates whether the TD downmixing is skipped */ + Word16 tdm_Pitch_reuse_flag; + Word16 tdm_LRTD_flag; + Word16 flag_skip_DMX; /* flag that indicates whether the TD downmixing is skipped */ Word32 TCX_old_syn_Overl_fx[L_FRAME16k / 2]; /* past ovrl buffer for possible switching from TD stereo ACELP to MDCT stereo TCX frame */ /* Q11 */ Word16 prevSP_ratio_fx; /* previous SP ratio */ @@ -320,24 +320,24 @@ typedef struct stereo_mdct_dec_data_structure STEREO_MDCT_BAND_PARAMETERS stbParamsTCX20afterACELP; /* stereo frequency band parameters for transition frame */ /* only intraframe */ - int16_t mdct_stereo_mode[2]; /* mdct stereo mode: LR, MS, band-wise MS */ - int16_t global_ild[2]; /* Quantized ILD for the whole spectrum */ - int16_t split_ratio; /* Ratio of bitrate (1 to 7), split_ratio = 8 * 1st chn bitrate / (1st + 2nd chn bitrate) */ + Word16 mdct_stereo_mode[2]; /* mdct stereo mode: LR, MS, band-wise MS */ + Word16 global_ild[2]; /* Quantized ILD for the whole spectrum */ + Word16 split_ratio; /* Ratio of bitrate (1 to 7), split_ratio = 8 * 1st chn bitrate / (1st + 2nd chn bitrate) */ - int16_t IGFStereoMode[2]; /* MDCT stereo mode for IGF */ + Word16 IGFStereoMode[2]; /* MDCT stereo mode for IGF */ - int16_t use_itd; - int16_t itd_mode; /*0/1*/ - Word32 itd_fx; /* Q15 */ + Word16 use_itd; + Word16 itd_mode; /*0/1*/ + Word32 itd_fx; /* Q15 */ - int16_t reverse_dmx; + Word16 reverse_dmx; Word32 smooth_ratio_fx; /* Q26 */ - int16_t prev_ms_mask[NB_DIV][MAX_SFB]; + Word16 prev_ms_mask[NB_DIV][MAX_SFB]; Word16 lastCoh_fx; /* Q14 */ - int16_t noise_seeds_channels[CPE_CHANNELS]; - int16_t noise_seed_common; - int16_t isSBAStereoMode; + Word16 noise_seeds_channels[CPE_CHANNELS]; + Word16 noise_seed_common; + Word16 isSBAStereoMode; } STEREO_MDCT_DEC_DATA, *STEREO_MDCT_DEC_DATA_HANDLE; @@ -348,18 +348,18 @@ typedef struct stereo_mdct_dec_data_structure typedef struct stereo_tca_dec_data_structure { - int16_t refChanIndx; /* reference channel index in current frame */ - int16_t prevRefChanIndx; /* reference channel index in previous frame */ - int16_t indx_ica_NCShift; /* ICA target channel inter-channel corrstats */ - int16_t indx_ica_gD; /* ICA target gain */ + Word16 refChanIndx; /* reference channel index in current frame */ + Word16 prevRefChanIndx; /* reference channel index in previous frame */ + Word16 indx_ica_NCShift; /* ICA target channel inter-channel corrstats */ + Word16 indx_ica_gD; /* ICA target gain */ Word32 targetGain_fx; /* gain norm applied on target (or right) channel in current frame */ // Q29 Word32 prevTargetGain_fx; /* gain norm applied on target (or right) channel in previous frame */ // Q29 - int16_t corrLagStats; /* corr lag stats in current frame */ - int16_t prevCorrLagStats; /* corr lag stats in previous frame */ + Word16 corrLagStats; /* corr lag stats in current frame */ + Word16 prevCorrLagStats; /* corr lag stats in previous frame */ - int16_t interp_dec_prevNCShift; /* NC Shift in previous frame */ - int16_t interp_dec_switch_to_zero_diff; /* switch flag for interpolation */ + Word16 interp_dec_prevNCShift; /* NC Shift in previous frame */ + Word16 interp_dec_switch_to_zero_diff; /* switch flag for interpolation */ Word32 memChanL_fx[L_DEC_MEM_LEN_ICA]; /* left channel input to correct at the cross-over for Fixed */ @@ -428,10 +428,10 @@ typedef struct stereo_icbwe_dec_data_structure typedef struct { - int16_t dtx_flag; - int16_t sce_id_dtx; + Word16 dtx_flag; + Word16 sce_id_dtx; - int16_t ism_dtx_hangover_cnt; /* hangover counter for ISM DTX decoder */ + Word16 ism_dtx_hangover_cnt; /* hangover counter for ISM DTX decoder */ } ISM_DTX_DATA_DEC; @@ -478,9 +478,9 @@ typedef struct ivas_dirac_dec_data_structure { DIRAC_CONFIG_DATA_HANDLE hConfig; - int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; - int16_t dithering_seed; - int16_t spar_to_dirac_write_idx; + Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1]; + Word16 dithering_seed; + Word16 spar_to_dirac_write_idx; IVAS_FB_MIXER_HANDLE hFbMdft; @@ -521,10 +521,10 @@ typedef struct dirac_output_synthesis_cov_state_structure typedef struct ivas_param_mc_diff_proto_info_structure { - int16_t num_protos_diff; - int16_t *proto_index_diff; - int16_t *num_source_chan_diff; - int16_t **source_chan_idx; + Word16 num_protos_diff; + Word16 *proto_index_diff; + Word16 *num_source_chan_diff; + Word16 **source_chan_idx; Word32 **proto_fac_fx; } PARAM_MC_DIFF_PROTO_INFO; @@ -532,42 +532,42 @@ typedef struct ivas_param_mc_diff_proto_info_structure typedef struct ivas_param_mc_dec_data_structure { - int16_t slot_size; + Word16 slot_size; Word32 *Cldfb_RealBuffer_tc_fx; // Q12 Word16 Cldfb_RealBuffer_tc_e; Word32 *Cldfb_ImagBuffer_tc_fx; // Q12 Word16 Cldfb_ImagBuffer_tc_e; Word16 sz; - int16_t subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; - int16_t nb_subframes; - int16_t subframes_rendered; - int16_t slots_rendered; - int16_t num_slots; - int16_t num_freq_bands; - int16_t num_param_bands_synth; + Word16 subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; + Word16 nb_subframes; + Word16 subframes_rendered; + Word16 slots_rendered; + Word16 num_slots; + Word16 num_freq_bands; + Word16 num_param_bands_synth; - int16_t band_grouping[PARAM_MC_MAX_PARAMETER_BANDS + 1]; + Word16 band_grouping[PARAM_MC_MAX_PARAMETER_BANDS + 1]; /*Decoder parameters */ /*Prototypes*/ - int16_t num_outputs_diff; + Word16 num_outputs_diff; PARAM_MC_DIFF_PROTO_INFO *diff_proto_info; PARAM_MC_SYNTHESIS_CONF synthesis_conf; /*Options*/ /* Decorrelator options */ - int16_t max_band_decorr; + Word16 max_band_decorr; /*Decoder states=memories*/ Word32 *proto_frame_f_fx; /* Q11 */ Word32 *proto_frame_dec_f_fx; /* Q11 */ DIRAC_OUTPUT_SYNTHESIS_COV_STATE h_output_synthesis_cov_state; DIRAC_OUTPUT_SYNTHESIS_PARAMS h_output_synthesis_params; - int16_t max_band_energy_compensation; + Word16 max_band_energy_compensation; HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC; Word16 *icc_q_fx; /* ICC parameters*/ /* Q15 */ Word16 *icld_q_fx; /* Q8 */ - int16_t max_param_band_abs_cov; + Word16 max_param_band_abs_cov; Word16 q_proto_frame_f; Word32 *ls_conv_dmx_matrix_fx; /* Q30 */ Word32 *proto_matrix_int_fx; @@ -588,12 +588,12 @@ typedef struct ivas_param_mc_dec_data_structure typedef struct ivas_mc_paramupmix_dec_data_structure { - int16_t num_freq_bands; + Word16 num_freq_bands; ivas_td_decorr_state_t *hTdDecorr[MC_PARAMUPMIX_COMBINATIONS]; - int32_t alpha_quant[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; - int32_t beta_quant[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; - int16_t first_frame; - int16_t free_param_interpolator; + Word32 alpha_quant[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; + Word32 beta_quant[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; + Word16 first_frame; + Word16 free_param_interpolator; Word32 alphas_fx[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS]; // Q28 @@ -627,30 +627,30 @@ typedef struct ivas_spar_md_dec_state_t ivas_spar_dec_matrices_t spar_coeffs; ivas_spar_dec_matrices_t spar_coeffs_prev; ivas_spar_dec_matrices_t spar_coeffs_tar; - int16_t dtx_md_smoothing_cntr; - int16_t valid_bands[IVAS_MAX_NUM_BANDS]; - int16_t base_band_age[IVAS_MAX_NUM_BANDS]; - int16_t spar_plc_num_lost_frames; - int16_t num_decorr; - int16_t td_decorr_flag; - int16_t spar_plc_enable_fadeout_flag; + Word16 dtx_md_smoothing_cntr; + Word16 valid_bands[IVAS_MAX_NUM_BANDS]; + Word16 base_band_age[IVAS_MAX_NUM_BANDS]; + Word16 spar_plc_num_lost_frames; + Word16 num_decorr; + Word16 td_decorr_flag; + Word16 spar_plc_enable_fadeout_flag; Word32 ***mixer_mat_fx; /* Q(Q_mixer_mat) */ Word32 mixer_mat_prev_fx[MAX_PARAM_SPATIAL_SUBFRAMES + 1][IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH][IVAS_MAX_NUM_BANDS]; /* Q(Q_mixer_mat) */ Word16 Q_mixer_mat; ivas_spar_md_com_cfg spar_md_cfg; ivas_arith_coeffs_t arith_coeffs; ivas_huff_coeffs_t huff_coeffs; - int16_t table_idx; - int16_t dtx_vad; - int16_t spar_hoa_md_flag; - int16_t spar_hoa_dirac2spar_md_flag; - int16_t HOA_md_ind[IVAS_SPAR_MAX_CH]; + Word16 table_idx; + Word16 dtx_vad; + Word16 spar_hoa_md_flag; + Word16 spar_hoa_dirac2spar_md_flag; + Word16 HOA_md_ind[IVAS_SPAR_MAX_CH]; Word32 smooth_buf_fx[IVAS_MAX_NUM_BANDS][2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1]; /* Q0 */ Word16 smooth_fac_fx[IVAS_MAX_NUM_BANDS]; /* Q15 */ Word32 mixer_mat_prev2_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; /* Q(Q_mixer_mat) */ - int16_t first_valid_frame; + Word16 first_valid_frame; ivas_band_coeffs_t *band_coeffs_prev; - int16_t base_band_coeffs_age[IVAS_MAX_NUM_BANDS]; + Word16 base_band_coeffs_age[IVAS_MAX_NUM_BANDS]; } ivas_spar_md_dec_state_t; @@ -676,11 +676,11 @@ typedef struct { Word16 prev_ql_fx[IVAS_PCA_INTERP]; Word16 prev_qr_fx[IVAS_PCA_INTERP]; - int16_t prev_pca_bypass; + Word16 prev_pca_bypass; Word16 mem_eigVec_interp_fx[IVAS_PCA_LEN_INTERP_EIG_DEC]; /* parser output: */ - int16_t pca_bypass; - int32_t index[2]; + Word16 pca_bypass; + Word32 index[2]; } PCA_DEC_STATE; @@ -690,20 +690,20 @@ typedef struct ivas_spar_dec_lib_t ivas_td_decorr_state_t *hTdDecorr; ivas_spar_md_dec_state_t *hMdDec; IVAS_FB_MIXER_HANDLE hFbMixer; - int16_t AGC_flag; + Word16 AGC_flag; ivas_agc_dec_state_t *hAgcDec; PCA_DEC_STATE *hPCA; - int16_t dirac_to_spar_md_bands[DIRAC_MAX_NBANDS]; - int16_t enc_param_start_band; - int32_t core_nominal_brate; /* Nominal bitrate for core coding */ - int16_t i_subframe; - - int16_t subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; - int16_t render_to_md_map[MAX_JBM_CLDFB_TIMESLOTS]; - int16_t nb_subframes; - int16_t subframes_rendered; - int16_t slots_rendered; - int16_t num_slots; + Word16 dirac_to_spar_md_bands[DIRAC_MAX_NBANDS]; + Word16 enc_param_start_band; + Word32 core_nominal_brate; /* Nominal bitrate for core coding */ + Word16 i_subframe; + + Word16 subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; + Word16 render_to_md_map[MAX_JBM_CLDFB_TIMESLOTS]; + Word16 nb_subframes; + Word16 subframes_rendered; + Word16 slots_rendered; + Word16 num_slots; } SPAR_DEC_DATA, *SPAR_DEC_HANDLE; @@ -712,8 +712,8 @@ typedef struct ivas_spar_dec_lib_t typedef struct ivas_osba_data { Word32 **delayBuffer_fx; - int16_t delayBuffer_size; - int16_t delayBuffer_nchan; + Word16 delayBuffer_size; + Word16 delayBuffer_nchan; } SBA_ISM_DATA, *SBA_ISM_DATA_HANDLE; @@ -724,9 +724,9 @@ typedef struct ivas_osba_data typedef struct sce_dec_data_structure { - int16_t sce_id; /* SCE # identifier */ - int32_t element_brate; /* SCE total bitrate in bps */ - int32_t last_element_brate; /* SCE last total bitrate in bps */ + Word16 sce_id; /* SCE # identifier */ + Word32 element_brate; /* SCE total bitrate in bps */ + Word32 last_element_brate; /* SCE last total bitrate in bps */ /* core coder handle */ DEC_CORE_HANDLE hCoreCoder[1]; @@ -747,15 +747,15 @@ typedef struct sce_dec_data_structure typedef struct cpe_dec_data_structure { - int16_t cpe_id; /* CPE # identifier */ - int32_t element_brate; /* CPE element total bitrate in bps */ - int32_t last_element_brate; /* last CPE element total bitrate in bps */ + Word16 cpe_id; /* CPE # identifier */ + Word32 element_brate; /* CPE element total bitrate in bps */ + Word32 last_element_brate; /* last CPE element total bitrate in bps */ - int16_t element_mode; /* element mode, in CPE it can be IVAS_CPE_DFT, IVAS_CPE_TD or IVAS_CPE_MDCT */ - int16_t last_element_mode; /* last element mode */ + Word16 element_mode; /* element mode, in CPE it can be IVAS_CPE_DFT, IVAS_CPE_TD or IVAS_CPE_MDCT */ + Word16 last_element_mode; /* last element mode */ - int16_t stereo_switching_counter; - int16_t NbFrameMod; + Word16 stereo_switching_counter; + Word16 NbFrameMod; /* core coder handle */ DEC_CORE_HANDLE hCoreCoder[CPE_CHANNELS]; @@ -768,7 +768,7 @@ typedef struct cpe_dec_data_structure STEREO_ICBWE_DEC_HANDLE hStereoICBWE; /* Stereo inter-channel BWE data handle */ STEREO_CNG_DEC_HANDLE hStereoCng; /* Stereo CNG data structure */ - int16_t nchan_out; /* number of output channels (1: mono dmx, 2: default stereo) */ + Word16 nchan_out; /* number of output channels (1: mono dmx, 2: default stereo) */ /* DFT stereo I/O channel buffer memories that need to be updated for TD->DFT stereo switching */ @@ -792,7 +792,7 @@ typedef struct cpe_dec_data_structure /* buffers used for fading between MDCT and DFT Stereo */ - int32_t brate_surplus; /* bitrate surplus for bitrate adaptation in combined format coding */ + Word32 brate_surplus; /* bitrate surplus for bitrate adaptation in combined format coding */ } CPE_DEC_DATA, *CPE_DEC_HANDLE; @@ -803,8 +803,8 @@ typedef struct cpe_dec_data_structure typedef struct mct_dec_block_data_struct { - int16_t ch1, ch2; - int16_t mask[2][MAX_SFB]; + Word16 ch1, ch2; + Word16 mask[2][MAX_SFB]; STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct; /* MDCT stereo data handle */ } MCT_DEC_BLOCK_DATA, *MCT_DEC_BLOCK_DATA_HANDLE; @@ -812,14 +812,14 @@ typedef struct mct_dec_block_data_struct typedef struct mct_dec_data_structure { - int16_t nchan_out_woLFE; /* number of active channels within multi-channel configuration */ - int16_t currBlockDataCnt; - int16_t bitsChannelPairIndex; /* bits needed to code channel pair index, depends on number of active channels */ + Word16 nchan_out_woLFE; /* number of active channels within multi-channel configuration */ + Word16 currBlockDataCnt; + Word16 bitsChannelPairIndex; /* bits needed to code channel pair index, depends on number of active channels */ MCT_DEC_BLOCK_DATA_HANDLE hBlockData[MCT_MAX_BLOCKS]; - int16_t chBitRatios[MCT_MAX_CHANNELS]; - int16_t lowE_ch[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ - uint16_t mc_global_ild[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ + Word16 chBitRatios[MCT_MAX_CHANNELS]; + Word16 lowE_ch[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ + UWord16 mc_global_ild[MCT_MAX_CHANNELS]; /* note: pointer to local parameter */ } MCT_DEC_DATA, *MCT_DEC_HANDLE; @@ -866,12 +866,12 @@ typedef struct ivas_binaural_rendering_struct IVAS_OUTPUT_SETUP_HANDLE hInputSetup; /* pointer to input spatial format for binaural renderer*/ EFAP_HANDLE hEFAPdata; /* EFAP structure*/ Word32 *hoa_dec_mtx; /* pointer to HOA decoder mtx */ /*Q29*/ - int8_t rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/ - int16_t max_band; /* band upto which rendering is performed */ - int16_t conv_band; /* band upto which convolution in cldfb domain is performed */ - int16_t timeSlots; /* number of time slots of binaural renderer */ - int16_t nInChannels; /* number input channels */ - int8_t render_lfe; /* Flag to render LFE in binaural rendering*/ + Word8 rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/ + Word16 max_band; /* band upto which rendering is performed */ + Word16 conv_band; /* band upto which convolution in cldfb domain is performed */ + Word16 timeSlots; /* number of time slots of binaural renderer */ + Word16 nInChannels; /* number input channels */ + Word8 render_lfe; /* Flag to render LFE in binaural rendering*/ IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */ /* Convolution module structure */ @@ -892,18 +892,18 @@ typedef struct ivas_masa_decoder_ext_out_meta_struct { MASA_DECRIPTIVE_META descriptiveMeta; - uint16_t directionIndex[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - uint8_t directToTotalRatio[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - uint8_t spreadCoherence[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + UWord16 directionIndex[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + UWord8 directToTotalRatio[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + UWord8 spreadCoherence[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - uint8_t surroundCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - uint8_t diffuseToTotalRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + UWord8 surroundCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + UWord8 diffuseToTotalRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; } MASA_DECODER_EXT_OUT_META; typedef struct ivas_masa_decoder_data_struct { - int16_t band_mapping[MASA_FREQUENCY_BANDS + 1]; + Word16 band_mapping[MASA_FREQUENCY_BANDS + 1]; SPHERICAL_GRID_DATA *sph_grid16; MASA_DECODER_EXT_OUT_META *extOutMeta; @@ -922,32 +922,32 @@ typedef struct ivas_masa_decoder_struct /* Data structure for MASA_ISM rendering */ typedef struct ivas_masa_ism_data_structure { - int16_t azimuth_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; - int16_t elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + Word16 azimuth_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + Word16 elevation_ism[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; Word32 energy_ratio_ism_fx[MAX_NUM_OBJECTS][MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; /* Q30 */ Word32 masa_to_total_energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q30 */ - int16_t azimuth_ism_edited[MAX_NUM_OBJECTS]; - int16_t elevation_ism_edited[MAX_NUM_OBJECTS]; - uint8_t ism_is_edited[MAX_NUM_OBJECTS]; + Word16 azimuth_ism_edited[MAX_NUM_OBJECTS]; + Word16 elevation_ism_edited[MAX_NUM_OBJECTS]; + UWord8 ism_is_edited[MAX_NUM_OBJECTS]; - int16_t idx_separated_ism; - int16_t azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; - int16_t elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + Word16 idx_separated_ism; + Word16 azimuth_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; + Word16 elevation_separated_ism[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR]; Word32 q_azimuth_old_fx[MAX_NUM_OBJECTS]; /* Q22 */ Word32 q_elevation_old_fx[MAX_NUM_OBJECTS]; /* Q22 */ Word16 ismPreprocMatrix_fx[2][2][CLDFB_NO_CHANNELS_MAX]; /* Q15 */ - uint8_t objectsMoved; + UWord8 objectsMoved; Word32 eneMoveIIR_fx[2][CLDFB_NO_CHANNELS_MAX]; /*Q-22*/ Word32 enePreserveIIR_fx[2][CLDFB_NO_CHANNELS_MAX]; /*Q-22*/ Word32 preprocEneTarget_fx[CLDFB_NO_CHANNELS_MAX]; /*Q-19*/ Word32 preprocEneRealized_fx[CLDFB_NO_CHANNELS_MAX]; /*Q-19*/ Word32 **delayBuffer_fx; /* Q11 */ - int16_t delayBuffer_size; - int16_t delayBuffer_nchan; + Word16 delayBuffer_size; + Word16 delayBuffer_nchan; } MASA_ISM_DATA, *MASA_ISM_DATA_HANDLE; @@ -965,41 +965,41 @@ typedef struct decoder_tc_buffer_structure Word16 no_channels; /*Stores no of channels in tc_fx with values*/ #endif Word16 q_tc_fx; - TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ - int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ - int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ - int16_t nchan_buffer_full; /* number of channels to be fully buffered */ - int16_t n_samples_available; /* samples still available for rendering in the current frame */ - int16_t n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ - int16_t n_samples_rendered; /* samples already rendered in the current frame */ - int16_t n_samples_granularity; /* render granularity */ - int16_t n_samples_flushed; - int16_t subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; - int16_t nb_subframes; - int16_t subframes_rendered; - int16_t slots_rendered; - int16_t num_slots; - int16_t n_samples_discard; /* number of samples to discard from the beginning of the output */ + TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ + Word16 nchan_transport_jbm; /* number of TCs after TC decoding */ + Word16 nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ + Word16 nchan_buffer_full; /* number of channels to be fully buffered */ + Word16 n_samples_available; /* samples still available for rendering in the current frame */ + Word16 n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ + Word16 n_samples_rendered; /* samples already rendered in the current frame */ + Word16 n_samples_granularity; /* render granularity */ + Word16 n_samples_flushed; + Word16 subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; + Word16 nb_subframes; + Word16 subframes_rendered; + Word16 slots_rendered; + Word16 num_slots; + Word16 n_samples_discard; /* number of samples to discard from the beginning of the output */ } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; typedef struct jbm_metadata_structure { - int16_t sf_write_idx; - int16_t sf_md_buffer_length; + Word16 sf_write_idx; + Word16 sf_md_buffer_length; - uint16_t directionIndexBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; - uint8_t directToTotalRatioBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; - uint8_t spreadCoherenceBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; - uint8_t surroundCoherenceBuffer[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; - uint8_t diffuseToTotalRatioBuffer[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; - uint8_t numberOfDirections[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES]; /* Descriptive metadata, value is 0 or 1 */ + UWord16 directionIndexBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + UWord8 directToTotalRatioBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + UWord8 spreadCoherenceBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + UWord8 surroundCoherenceBuffer[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + UWord8 diffuseToTotalRatioBuffer[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + UWord8 numberOfDirections[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES]; /* Descriptive metadata, value is 0 or 1 */ - int16_t slot_read_idx; - int16_t slot_write_idx; - int16_t slot_md_buffer_length; + Word16 slot_read_idx; + Word16 slot_write_idx; + Word16 slot_md_buffer_length; - int16_t sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME * MASA_JBM_RINGBUFFER_FRAMES]; + Word16 sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME * MASA_JBM_RINGBUFFER_FRAMES]; } JBM_METADATA, *JBM_METADATA_HANDLE; @@ -1010,25 +1010,25 @@ typedef struct jbm_metadata_structure typedef struct decoder_config_structure { - int32_t ivas_total_brate; /* IVAS total bitrate in bps */ - int32_t last_ivas_total_brate; /* last IVAS total bitrate in bps */ - int32_t output_Fs; /* output signal sampling frequency in Hz */ - int16_t nchan_out; /* number of output audio channels */ + Word32 ivas_total_brate; /* IVAS total bitrate in bps */ + Word32 last_ivas_total_brate; /* last IVAS total bitrate in bps */ + Word32 output_Fs; /* output signal sampling frequency in Hz */ + Word16 nchan_out; /* number of output audio channels */ AUDIO_CONFIG output_config; /* output audio configuration */ - int16_t Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ - int16_t Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ - int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ - int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ + Word16 Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ + Word16 Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ + Word16 Opt_Headrotation; /* indicates whether head-rotation is used */ + Word16 Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ - int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ + Word16 Opt_non_diegetic_pan; /* indicates diegetic or not */ Word16 non_diegetic_pan_gain_fx; /* non diegetic panning gain*/ /* Q15 */ - int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - int16_t Opt_ExternalOrientation; /* indiates whether external orientations are used */ - int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ - int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ - int16_t Opt_tsm; /* indicates whether time scaling modification is activated */ + Word16 Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ + Word16 Opt_ExternalOrientation; /* indiates whether external orientations are used */ + Word16 Opt_dpid_on; /* indicates whether Directivity pattern option is used */ + Word16 Opt_aeid_on; /* indicates whether Acoustic environment option is used */ + Word16 Opt_tsm; /* indicates whether time scaling modification is activated */ IVAS_RENDER_FRAMESIZE render_framesize; - int16_t Opt_delay_comp; /* flag indicating delay compensation active */ + Word16 Opt_delay_comp; /* flag indicating delay compensation active */ } DECODER_CONFIG, *DECODER_CONFIG_HANDLE; @@ -1047,8 +1047,8 @@ typedef struct Decoder_Struct IVAS_FORMAT ivas_format; /* IVAS format */ IVAS_FORMAT last_ivas_format; /* last frame IVAS format */ - int16_t sid_format; /* IVAS format indicator from SID frame */ - int16_t nchan_transport; /* number of transport channels */ + Word16 sid_format; /* IVAS format indicator from SID frame */ + Word16 nchan_transport; /* number of transport channels */ IVAS_OUTPUT_SETUP hOutSetup; /* output setup structure */ AUDIO_CONFIG intern_config; /* internal audio configuration */ IVAS_OUTPUT_SETUP hIntSetup; /* internal setup structure */ @@ -1056,24 +1056,24 @@ typedef struct Decoder_Struct AUDIO_CONFIG transport_config; /* transport audio configuration */ IVAS_OUTPUT_SETUP hTransSetup; /* transport setup structure */ - int16_t element_mode_init; /* element mode used at initialization */ - int16_t codec_mode; /* Mode 1 or 2 */ - int16_t ini_frame; /* initialization frames counter */ - int16_t ini_active_frame; /* initialization active frames counter */ + Word16 element_mode_init; /* element mode used at initialization */ + Word16 codec_mode; /* Mode 1 or 2 */ + Word16 ini_frame; /* initialization frames counter */ + Word16 ini_active_frame; /* initialization active frames counter */ - int16_t bfi; /* FEC - bad frame indicator */ - int16_t BER_detect; /* BER detect flag */ - int16_t num_bits; /* BER detect flag */ + Word16 bfi; /* FEC - bad frame indicator */ + Word16 BER_detect; /* BER detect flag */ + Word16 num_bits; /* BER detect flag */ - uint16_t *bit_stream; /* Pointer to bitstream buffer */ - int16_t writeFECoffset; /* parameter for debugging JBM stuff */ + UWord16 *bit_stream; /* Pointer to bitstream buffer */ + Word16 writeFECoffset; /* parameter for debugging JBM stuff */ IVAS_LIMITER_HANDLE hLimiter; /* Limiter handle */ /* core-decoder modules */ - int16_t nSCE; /* number of total SCEs */ - int16_t nCPE; /* number of total CPEs */ - int16_t nCPE_old; /* number of total CPEs available in the last frame before bitrate switching */ + Word16 nSCE; /* number of total SCEs */ + Word16 nCPE; /* number of total CPEs */ + Word16 nCPE_old; /* number of total CPEs available in the last frame before bitrate switching */ SCE_DEC_HANDLE hSCE[MAX_SCE]; /* SCE handles */ CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS]; /* CPE handles */ @@ -1092,12 +1092,12 @@ typedef struct Decoder_Struct LFE_DEC_HANDLE hLFE; /* LFE handle */ ISM_MODE ism_mode; /* ISM format mode */ - int16_t nchan_ism; /* number of ISM channels */ + Word16 nchan_ism; /* number of ISM channels */ MC_MODE mc_mode; /* MC format mode */ - int16_t sba_order; /* Ambisonic (SBA) order */ - int16_t sba_planar; /* Ambisonic (SBA) planar flag */ - int16_t sba_analysis_order; /* Ambisonic (SBA) order used for analysis and coding */ - int16_t sba_dirac_stereo_flag; /* flag indicating stereo output for SBA DirAC modes with 1 TC */ + Word16 sba_order; /* Ambisonic (SBA) order */ + Word16 sba_planar; /* Ambisonic (SBA) planar flag */ + Word16 sba_analysis_order; /* Ambisonic (SBA) order used for analysis and coding */ + Word16 sba_dirac_stereo_flag; /* flag indicating stereo output for SBA DirAC modes with 1 TC */ /* rendering modules */ RENDERER_TYPE renderer_type; /* renderer type */ @@ -1120,7 +1120,7 @@ typedef struct Decoder_Struct Word32 *hoa_dec_mtx; /* Pointer to decoder matrix for SBA */ HEAD_TRACK_DATA_HANDLE hHeadTrackData; /* Head tracking data structure */ RENDER_CONFIG_DATA *hRenderConfig; /* Renderer config pointer */ - int32_t binaural_latency_ns; /* Binauralization latency in ns */ + Word32 binaural_latency_ns; /* Binauralization latency in ns */ EXTERNAL_ORIENTATION_HANDLE hExtOrientationData; /* External orientation data structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData; /* Combined external and head orientation data structure */ DIRAC_REND_HANDLE hDirACRend; /* DirAC renderer handle */ @@ -1128,16 +1128,16 @@ typedef struct Decoder_Struct MASA_ISM_DATA_HANDLE hMasaIsmData; /* OMASA rendering handle */ SBA_ISM_DATA_HANDLE hSbaIsmData; /* OSBA rendering handle */ - int16_t flag_omasa_brate; + Word16 flag_omasa_brate; /* JBM module */ DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM structure */ JBM_METADATA_HANDLE hJbmMetadata; /* Structure for metadata buffering in JBM */ - int32_t last_active_ivas_total_brate; - int16_t ism_extmeta_active; /* Extended metadata active in decoder */ - int16_t ism_extmeta_cnt; /* Change frame counter for extended metadata */ + Word32 last_active_ivas_total_brate; + Word16 ism_extmeta_active; /* Extended metadata active in decoder */ + Word16 ism_extmeta_cnt; /* Change frame counter for extended metadata */ Word32 **mem_hp20_out_fx; Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* Word32-output audio buffers */ Word16 p_out_len;/*Stores the total no of channels for which memory is allocated to p_output_fx*/ diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 2dd2a30c3..e5e18083d 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -2078,7 +2078,7 @@ void stereo_td2dft_update_fx( ) { Word16 ovl, ovl_TCX, dft32ms_ovl, hq_delay_comp; - Word16 ns, nsLB; + Word16 ns, nsLB, i; Word16 old_out_len, old_outLB_len; Decoder_State **sts; @@ -2181,9 +2181,9 @@ void stereo_td2dft_update_fx( v_add_fx( sts[0]->hHQ_core->old_outLB_fx + nsLB, sts[1]->hHQ_core->old_outLB_fx + nsLB, hCPE->old_outLB_mdct_fx, old_outLB_len ); L_lerp_fx_q11( hCPE->old_outLB_mdct_fx, hCPE->old_outLB_mdct_fx, STEREO_MDCT2DFT_FADE_LEN_48k, old_outLB_len ); #ifndef MSAN_FIX - for ( int i = 0; i < STEREO_MDCT2DFT_FADE_LEN_48k; i++ ) + for ( i = 0; i < STEREO_MDCT2DFT_FADE_LEN_48k; i++ ) #else - FOR( Word32 i = 0; i < old_outLB_len; i++ ) + FOR( i = 0; i < old_outLB_len; i++ ) #endif { hCPE->old_outLB_mdct_fx[i] = L_shr( hCPE->old_outLB_mdct_fx[i], 1 ); /* Q11 */ @@ -2193,7 +2193,7 @@ void stereo_td2dft_update_fx( #ifndef MSAN_FIX for ( int i = 0; i < STEREO_MDCT2DFT_FADE_LEN_48k; i++ ) #else - FOR( Word32 i = 0; i < old_out_len; i++ ) + FOR( i = 0; i < old_out_len; i++ ) #endif { hCPE->old_out_mdct_fx[i] = L_shr( hCPE->old_out_mdct_fx[i], 1 ); /* q_old_out_mdct */ diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index bb73fe7f0..375dbdad0 100644 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -306,7 +306,6 @@ Word16 svd_fx( Word16 iCh, jCh; Word16 lengthSingularValues; Word16 errorMessage, condition; - // int16_t max_length = ((nChannelsL > nChannelsC) ? nChannelsL : nChannelsC); Word32 secDiag_fx[MAX_OUTPUT_CHANNELS]; #ifndef FIX_1010_OPT_SEC_SINGLE_RESCALE Word16 secDiag_fx_e = 0; diff --git a/lib_dec/jbm_jb4sb.h b/lib_dec/jbm_jb4sb.h index 939fad2cb..5b5ff16c5 100644 --- a/lib_dec/jbm_jb4sb.h +++ b/lib_dec/jbm_jb4sb.h @@ -67,7 +67,7 @@ struct JB4_DATAUNIT Word16 qBit; /** the binary encoded access unit */ - uint8_t *data; + UWord8 *data; /** the size of the binary encoded access unit [bits] */ UWord16 dataSize; diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index 1fe7481df..7955d0ea6 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -92,7 +92,7 @@ typedef struct apa_state_t *PCMDSP_APA_HANDLE; /*! Allocates memory for state struct and initializes elements. * @return 0 on success, 1 on failure */ ivas_error apa_init( apa_state_t **s, - const int32_t num_channels ); + const Word32 num_channels ); /*! Sets state variables to initial value. */ void apa_reset( apa_state_t *s ); @@ -106,7 +106,7 @@ void apa_reset( apa_state_t *s ); * @param[in] output_Fs sample rate [Hz] * @param[in] num_channels number of channels * @return 0 on success, 1 on failure */ -bool apa_set_rate( apa_state_t *ps, const int32_t output_Fs ); +bool apa_set_rate( apa_state_t *ps, const Word32 output_Fs ); /*! Set scaling. * The scale is given in % and will be valid until changed again. @@ -120,7 +120,7 @@ bool apa_set_renderer_residual_samples( apa_state_t *ps, UWord16 l_r_buf ); bool apa_set_evs_compat_mode( apa_state_t *ps, bool mode ); -uint8_t apa_reconfigure( apa_state_t *ps, uint16_t num_channels, uint16_t l_ts ); +UWord8 apa_reconfigure( apa_state_t *ps, UWord16 num_channels, UWord16 l_ts ); bool apa_set_complexity_options( apa_state_t *s, UWord16 wss, UWord16 css ); @@ -129,5 +129,5 @@ bool apa_set_quality( apa_state_t *s, Word32 quality, UWord16 qualityred, UWord1 bool apa_exit( apa_state_t **s ); UWord8 apa_exec_ivas_fx( apa_state_t *s, const Word32 a_in[], UWord16 l_in, UWord16 maxScaling, Word32 a_out[], UWord16 *l_out ); -uint8_t apa_exec_fx( apa_state_t *s, const Word16 a_in[], UWord16 l_in, UWord16 maxScaling, Word16 a_out[], UWord16 *l_out ); +UWord8 apa_exec_fx( apa_state_t *s, const Word16 a_in[], UWord16 l_in, UWord16 maxScaling, Word16 a_out[], UWord16 *l_out ); #endif /* JBM_PCMDSP_APA_H */ diff --git a/lib_dec/jbm_pcmdsp_window.h b/lib_dec/jbm_pcmdsp_window.h index 3551380de..1d193433e 100644 --- a/lib_dec/jbm_pcmdsp_window.h +++ b/lib_dec/jbm_pcmdsp_window.h @@ -52,7 +52,7 @@ * <------> * n */ -void hannWindow( uint16_t n, float *w ); +void hannWindow( UWord16 n, float *w ); /** Overlap/Add of two signal with a given window. */ /** @param[in] fadeOut signal to fade out diff --git a/lib_enc/amr_wb_enc_fx.c b/lib_enc/amr_wb_enc_fx.c index 5a3aec3f4..976826949 100644 --- a/lib_enc/amr_wb_enc_fx.c +++ b/lib_enc/amr_wb_enc_fx.c @@ -612,7 +612,7 @@ void amr_wb_enc_init_fx( AMRWB_IO_ENC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO encoder handle */ ) { - int16_t i; + Word16 i; /* HF (6-7kHz) BWE */ hAmrwb_IO->seed2_enc = RANDOM_INITSEED; diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 93a0146f3..962b715cd 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -519,7 +519,7 @@ void AVQ_encmux_fx( bit_tmp = add( unusedbitsFlag, unused_bits_idx ); /*nq_est = (int16_t)ceil(0.2f * (bits - 5 * (unusedbitsFlag + unused_bits_idx)));*/ nq_est = mult( 6554, sub( bits, add( shl( bit_tmp, 2 ), bit_tmp ) ) ); - assert( (int16_t) ceil( 0.2f * ( bits - 5 * ( unusedbitsFlag + unused_bits_idx ) ) ) == nq_est ); + assert( (Word16) ceil( 0.2f * ( bits - 5 * ( unusedbitsFlag + unused_bits_idx ) ) ) == nq_est ); if ( EQ_16( nq_est, 1 ) ) { @@ -946,7 +946,7 @@ void AVQ_encmux_ivas_fx( bit_tmp = add( unusedbitsFlag, unused_bits_idx ); /*nq_est = (int16_t)ceil(0.2f * (bits - 5 * (unusedbitsFlag + unused_bits_idx)));*/ nq_est = mult( 6554 /*.2 in Q15*/, sub( bits, add( shl( bit_tmp, 2 ), bit_tmp ) ) ); - assert( (int16_t) ceil( 0.2f * ( bits - 5 * ( unusedbitsFlag + unused_bits_idx ) ) ) == nq_est ); + assert( (Word16) ceil( 0.2f * ( bits - 5 * ( unusedbitsFlag + unused_bits_idx ) ) ) == nq_est ); if ( EQ_16( nq_est, 1 ) ) { @@ -1085,8 +1085,8 @@ static void wrte_cv( Word16 *nbits /* i/o: bits */ ) { - int16_t pos, j; - int16_t bits, nq4; + Word16 pos, j; + Word16 bits, nq4; bits = *nbits; move16(); @@ -1145,8 +1145,8 @@ static void wrte_cv_ivas_fx( Word16 *nbits /* i/o: bits */ ) { - int16_t pos, j; - int16_t bits, nq4; + Word16 pos, j; + Word16 bits, nq4; bits = *nbits; move16(); diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index a2995245d..1c60f2ecd 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -30,8 +30,8 @@ static void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, co static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag ); static void init_core_sig_ana_ivas_fx( Encoder_State *st ); static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate ); -static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ); -static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ); +static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const Word32 last_total_brate ); +static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const Word32 last_total_brate ); /*-----------------------------------------------------------------------* * init_coder_ace_plus_fx() @@ -1324,7 +1324,7 @@ static void init_tcx_ivas_fx( * Initialization of signal buffers *-----------------------------------------------------------------------*/ /*copy of evs function since it was static */ -static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const int32_t last_total_brate ) +static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const Word32 last_total_brate ) { LPD_state_HANDLE hLPDmem = st->hLPDmem; @@ -1542,7 +1542,7 @@ static void init_core_sig_ana_ivas_fx( Encoder_State *st ) * * *-----------------------------------------------------------------------*/ -static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const int32_t last_total_brate ) +static void init_acelp_ivas_fx( Encoder_State *st, Word16 L_frame_old, Word16 shift, const Word32 last_total_brate ) { Word16 mem_syn_r_size_old; Word16 mem_syn_r_size_new; diff --git a/lib_enc/core_enc_reconf_fx.c b/lib_enc/core_enc_reconf_fx.c index 3637dd53f..1ba496b0e 100644 --- a/lib_enc/core_enc_reconf_fx.c +++ b/lib_enc/core_enc_reconf_fx.c @@ -344,7 +344,7 @@ void core_coder_reconfig_fx( void core_coder_reconfig_ivas_fx( Encoder_State *st, - const int32_t last_total_brate ) + const Word32 last_total_brate ) { Word16 i, bwidth, index; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 7dd342318..a509a7cd7 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1761,7 +1761,7 @@ void E_ACELP_4t_fx( const Word16 last_L_frame, /*Q0*/ const Word32 total_brate, /*Q0*/ const Word16 i_subfr, /*Q0*/ - const int16_t cmpl_flag /*Q0*/ ) + const Word16 cmpl_flag /*Q0*/ ) { PulseConfig config; Word16 ind[NPMAXPT * 4]; @@ -1824,7 +1824,7 @@ void E_ACELP_4t_ivas_fx( const Word16 last_L_frame, /*Q0*/ const Word32 total_brate, /*Q0*/ const Word16 i_subfr, /*Q0*/ - const int16_t cmpl_flag, /*Q0*/ + const Word16 cmpl_flag, /*Q0*/ Word16 element_mode /*Q0*/ ) { PulseConfig config; diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index a36ee78e2..4305e5bca 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -216,7 +216,7 @@ ivas_error ivas_ism_metadata_enc_fx( move16(); Word32 valQ_fx; ISM_METADATA_HANDLE hIsmMetaData; - int32_t element_brate[MAX_NUM_OBJECTS], total_brate[MAX_NUM_OBJECTS]; + Word32 element_brate[MAX_NUM_OBJECTS], total_brate[MAX_NUM_OBJECTS]; Word16 ism_metadata_flag_global; Word16 non_diegetic_flag_global; Word16 ism_imp[MAX_NUM_OBJECTS]; diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index bb6ef0d01..c4d3908ca 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -574,7 +574,7 @@ ivas_error ivas_mcmasa_enc_reconfig_fx( void ivas_mcmasa_enc_close_fx( MCMASA_ENC_HANDLE *hMcMasa, /* i/o: encoder McMASA handle */ - const int32_t input_Fs /* i : input sampling rate */ + const Word32 input_Fs /* i : input sampling rate */ ) { Word16 i, j; diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index 55da30e73..d6bc4c7f0 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -421,7 +421,7 @@ ivas_error ivas_mct_enc_fx( } /* joint MCT encoding */ - ivas_mct_core_enc_fx( ivas_format, hMCT, st_ivas->hCPE, hMCT->nchan_out_woLFE, ivas_total_brate, switch_bw, ( ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) ? (int16_t) st_ivas->hLFE->lfe_bits : 0, st_ivas->hEncoderConfig->sba_order ); + ivas_mct_core_enc_fx( ivas_format, hMCT, st_ivas->hCPE, hMCT->nchan_out_woLFE, ivas_total_brate, switch_bw, ( ivas_format == MC_FORMAT && ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) ? (Word16) st_ivas->hLFE->lfe_bits : 0, st_ivas->hEncoderConfig->sba_order ); FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 403d379fa..70b2b0034 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -799,7 +799,7 @@ static void applyStereoPreProcessingCplx( * * encoder-side complex-valued stereo pre-processing (crosstalk) *---------------------------------------------------------------*/ -static uint16_t enc_ste_pre_mdct( +static UWord16 enc_ste_pre_mdct( Word32 *sigR0_fx, /* i/o: MDCT samples of the 1st (left) channel q_com*/ Word32 *sigR1_fx, /* i/o: MDCT samples of the 2nd (right) channel q_com*/ Word32 *sigI0_fx, /* i/o: MDST samples of the 1st (left) channel q_com*/ diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 3416ab279..b32c80404 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -160,7 +160,7 @@ static Word16 encode_coherence_indexesDCT1_fx( BSTR_ENC_HANDLE hMetaData /* i : metadata handle */ ); -static UWord64 create_combined_index_fx( uint16_t *idx_dct, const Word16 len, const Word16 *no_cb_vec ); +static UWord64 create_combined_index_fx( UWord16 *idx_dct, const Word16 len, const Word16 *no_cb_vec ); static Word16 encode_surround_coherence_fx( IVAS_QMETADATA *hQMetaData, /* i : quantized metadata */ @@ -184,7 +184,7 @@ static void ivas_diffuseness_huff_ec_prepare_fx( UWord16 *avr_idx, Word16 *diffuseness_bits_huff ); -static Word16 coherence_coding_length( const uint16_t *idx_sur_coh_shift, const UWord8 idx_shift_len, const Word16 coding_subbands, const Word16 *no_cv, uint16_t *mr_idx, Word16 *no_cv_shift, Word16 *p_min_idx, Word16 *GR_ord, Word16 *nbits_fr, Word16 *nbits_fr1 ); +static Word16 coherence_coding_length( const UWord16 *idx_sur_coh_shift, const UWord8 idx_shift_len, const Word16 coding_subbands, const Word16 *no_cv, UWord16 *mr_idx, Word16 *no_cv_shift, Word16 *p_min_idx, Word16 *GR_ord, Word16 *nbits_fr, Word16 *nbits_fr1 ); static Word16 write_2dir_info( BSTR_ENC_HANDLE hMetaData, UWord8 *twoDirBands, const Word16 n, const Word16 k ); @@ -2326,7 +2326,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx( move16(); UWord16 dist_elevation_indexes_best[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_MAXIMUM_CODING_SUBBANDS]; Word16 gr_param_azimuth_best, avg_azimuth_index_best; - uint16_t dist_azimuth_indexes_best[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_MAXIMUM_CODING_SUBBANDS]; + UWord16 dist_azimuth_indexes_best[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_MAXIMUM_CODING_SUBBANDS]; UWord16 idx, dist_count; Word16 direction_bits_ec; diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index e6038186e..e321f1c7c 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -60,7 +60,7 @@ static Word16 sns_1st_cod_fx( Word32 *snsq_fx /* o : quantized sns Q16 */ ) { - Word16 index; + Word16 index, i; const Word16 split_len = M / 2; move16(); const Word16 *means; @@ -85,7 +85,7 @@ static Word16 sns_1st_cod_fx( Word16 exp_snsq_buffer[M] = { 0 }, exp_snsq = 0; move16(); move16(); - FOR( Word16 i = 0; i < M; ++i ) + FOR( i = 0; i < M; ++i ) { Word32 tmp = L_mult( means[i], means_fix ); // Q16 exp_snsq_buffer[i] = 0; @@ -93,11 +93,11 @@ static Word16 sns_1st_cod_fx( snsq_fx[i] = BASOP_Util_Add_Mant32Exp( sns_fx[i], exp_sns, L_negate( tmp ), 15, &exp_snsq_buffer[i] ); move32(); } - FOR( int i = 0; i < M; i++ ) + FOR( i = 0; i < M; i++ ) { exp_snsq = s_max( exp_snsq_buffer[i], exp_snsq ); } - FOR( int i = 0; i < M; i++ ) + FOR( i = 0; i < M; i++ ) { snsq_fx[i] = L_shr( snsq_fx[i], exp_snsq - exp_snsq_buffer[i] ); move32(); @@ -121,7 +121,7 @@ static Word16 sns_1st_cod_fx( dist_min_fx = MAXVAL_WORD32; Word16 exp_dist_min = 31; index_split = 0; - FOR( Word16 i = 0; i < 32; ++i ) + FOR( i = 0; i < 32; ++i ) { Word32 dist_fx = 0; move32(); diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index 925f4e702..2ace35473 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -1665,7 +1665,7 @@ static void ivas_write_parameter_bitstream_dtx_fx( Word16 *num_dec, const Word16 num_bands ) { - int16_t i, j; + Word16 i, j; Word32 val; Word16 idx; Word32 pr_min_max[2]; diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index 3f7237ce5..ede3d3ad9 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -3302,8 +3302,8 @@ static void stereo_dft_enc_compute_prm_fx( Word32 *dot_prod_nrg_ratio_fx, // Q(31-dot_prod_nrg_ratio_fx_e[]) Word16 *dot_prod_nrg_ratio_fx_e ) { - int16_t b, i; - int16_t b2; + Word16 b, i; + Word16 b2; Word32 *pDFT_L, *pDFT_R; // Word16 DFT_L_e, DFT_R_e; Word32 sum_nrg_L, sum_nrg_R; @@ -3352,7 +3352,7 @@ static void stereo_dft_enc_compute_prm_fx( Word16 sum_past_dot_prod_abs_e, sum_past_dot_prod_abs2_e = 0; Word32 sum_past_nrg_dmx; Word16 sum_past_nrg_dmx_e; - int16_t pos; + Word16 pos; Word32 pIpd[STEREO_DFT_BAND_MAX]; // Q13 Word32 ipd_smooth[STEREO_DFT_BAND_MAX]; // Q13 Word32 ipd_mean_change; // Q13 diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index f8d600276..979978c03 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -1006,9 +1006,8 @@ void stereo_tdm_prep_dwnmx_fx( const Word16 input_q /* i : frame lenght */ ) { -#define USER_ENER Word32 mener; - int16_t i, sw_pos, enr_len; + Word16 i, sw_pos, enr_len; Encoder_State **sts; Word16 mener_e; sts = hCPE->hCoreCoder; diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 211c53f8c..9d4736368 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -59,8 +59,8 @@ struct IVAS_ENC bool cmd_stereo; #endif bool switchingActive; /* flag for configuration changes during encoding - currently only used with mono */ - int16_t Opt_RF_ON_loc; - int16_t rf_fec_offset_loc; + Word16 Opt_RF_ON_loc; + Word16 rf_fec_offset_loc; bool ismMetadataProvided[MAX_NUM_OBJECTS]; bool maxBandwidthUser; /* Was a specific max bandwith selected by the user? */ IVAS_ENC_BANDWIDTH newBandwidthApi; /* maximum encoded bandwidth, as set on API level */ @@ -77,14 +77,14 @@ static ivas_error setChannelAwareConfig_fx( IVAS_ENC_HANDLE hIvasEnc, const IVAS static ivas_error sanitizeBandwidth_fx( const IVAS_ENC_HANDLE hIvasEnc ); static ivas_error sanitizeBitrateISM_fx( const ENCODER_CONFIG_HANDLE hEncoderConfig, const bool extMetadataApi ); static Word16 getInputBufferSize_fx( const Encoder_Struct *st_ivas ); -static ivas_error configureEncoder( IVAS_ENC_HANDLE hIvasEnc, const int32_t inputFs, const int32_t initBitrate, const IVAS_ENC_BANDWIDTH initBandwidth, const IVAS_ENC_DTX_CONFIG dtxConfig, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ); -static ivas_error setBitrate( IVAS_ENC_HANDLE hIvasEnc, const int32_t totalBitrate ); +static ivas_error configureEncoder( IVAS_ENC_HANDLE hIvasEnc, const Word32 inputFs, const Word32 initBitrate, const IVAS_ENC_BANDWIDTH initBandwidth, const IVAS_ENC_DTX_CONFIG dtxConfig, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ); +static ivas_error setBitrate( IVAS_ENC_HANDLE hIvasEnc, const Word32 totalBitrate ); static ivas_error doCommonConfigureChecks( IVAS_ENC_HANDLE hIvasEnc ); static ivas_error doCommonSetterChecks( IVAS_ENC_HANDLE hIvasEnc ); static void init_encoder_config( ENCODER_CONFIG_HANDLE hEncoderConfig ); static void resetIsmMetadataProvidedFlags( IVAS_ENC_HANDLE hIvasEnc ); -static ivas_error bandwidthApiToInternal( const IVAS_ENC_BANDWIDTH maxBandwidth, int16_t *internalMaxBandwidth ); -static ivas_error fecIndicatorApiToInternal( const IVAS_ENC_FEC_INDICATOR fecIndicator, int16_t *fecIndicatorInternal ); +static ivas_error bandwidthApiToInternal( const IVAS_ENC_BANDWIDTH maxBandwidth, Word16 *internalMaxBandwidth ); +static ivas_error fecIndicatorApiToInternal( const IVAS_ENC_FEC_INDICATOR fecIndicator, Word16 *fecIndicatorInternal ); #ifdef DEBUGGING static ivas_error forcedModeApiToInternal( IVAS_ENC_FORCED_MODE forcedMode, int16_t *forcedModeInternal ); #endif @@ -276,8 +276,8 @@ void IVAS_ENC_Close( ivas_error IVAS_ENC_ConfigureForMono( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -296,7 +296,7 @@ ivas_error IVAS_ENC_ConfigureForMono( } hIvasEnc->st_ivas->hEncoderConfig->ivas_format = MONO_FORMAT; - hIvasEnc->st_ivas->hEncoderConfig->is_binaural = (int16_t) is_binaural; + hIvasEnc->st_ivas->hEncoderConfig->is_binaural = (Word16) is_binaural; if ( downmixFromStereo ) { @@ -318,8 +318,8 @@ ivas_error IVAS_ENC_ConfigureForMono( ivas_error IVAS_ENC_ConfigureForStereo( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -344,7 +344,7 @@ ivas_error IVAS_ENC_ConfigureForStereo( hEncoderConfig = st_ivas->hEncoderConfig; hEncoderConfig->nchan_inp = 2; hEncoderConfig->ivas_format = STEREO_FORMAT; - hEncoderConfig->is_binaural = (int16_t) is_binaural; + hEncoderConfig->is_binaural = (Word16) is_binaural; #ifdef DEBUGGING switch ( stereoMode ) @@ -458,12 +458,12 @@ ivas_error IVAS_ENC_ConfigureForMASAObjects( ivas_error IVAS_ENC_ConfigureForObjects( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects, /* i : number of objects to be encoded */ + const UWord16 numObjects, /* i : number of objects to be encoded */ const bool ism_extended_metadata /* i : Extended metadata used (true/false), where extended metadata includes radius and orientation */ ) { @@ -503,7 +503,7 @@ ivas_error IVAS_ENC_ConfigureForObjects( ivas_error IVAS_ENC_FeedObjectMetadata( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const uint16_t ismIndex, /* i : object index */ + const UWord16 ismIndex, /* i : object index */ const IVAS_ISM_METADATA metadata /* i : object metadata handle for current frame */ ) { @@ -551,8 +551,8 @@ ivas_error IVAS_ENC_FeedObjectMetadata( ivas_error IVAS_ENC_ConfigureForAmbisonics( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -580,7 +580,7 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( hEncoderConfig->nchan_inp = ivas_sba_get_nchan_fx( hEncoderConfig->sba_order, 0 ); /*planar input arg. deliberately set to zero since input always in ACN/SN3D*/ - hEncoderConfig->Opt_PCA_ON = (int16_t) Opt_PCA_ON; + hEncoderConfig->Opt_PCA_ON = (Word16) Opt_PCA_ON; hIvasEnc->maxBandwidthUser = max_bwidth_user; @@ -780,8 +780,8 @@ ivas_error IVAS_ENC_FeedMasaMetadata( ivas_error IVAS_ENC_ConfigureForMultichannel( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -841,8 +841,8 @@ ivas_error IVAS_ENC_ConfigureForMultichannel( static ivas_error configureEncoder( IVAS_ENC_HANDLE hIvasEnc, - const int32_t inputFs, - const int32_t initBitrate, + const Word32 inputFs, + const Word32 initBitrate, const IVAS_ENC_BANDWIDTH initBandwidth, const IVAS_ENC_DTX_CONFIG dtxConfig, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ) @@ -850,7 +850,7 @@ static ivas_error configureEncoder( Encoder_Struct *st_ivas; ENCODER_CONFIG_HANDLE hEncoderConfig; ivas_error error; - int32_t cpe_brate; + Word32 cpe_brate; error = IVAS_ERR_OK; @@ -1476,7 +1476,7 @@ static Word16 getInputBufferSize_fx( *---------------------------------------------------------------------*/ ivas_error IVAS_ENC_GetNumInChannels( const IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - int16_t *numInChannels /* o : total number of samples expected in the input buffer for current encoder configuration */ + Word16 *numInChannels /* o : total number of samples expected in the input buffer for current encoder configuration */ ) { if ( hIvasEnc == NULL || numInChannels == NULL ) @@ -1824,8 +1824,8 @@ ivas_error IVAS_ENC_SetBandwidth( *---------------------------------------------------------------------*/ ivas_error IVAS_ENC_SetBitrate( - IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t totalBitrate /* i : requested bitrate of the output bitstream */ + IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ + const Word32 totalBitrate /* i : requested bitrate of the output bitstream */ ) { ivas_error error; @@ -2003,11 +2003,11 @@ const char *IVAS_ENC_GetErrorMessage( static ivas_error printConfigInfo_enc( IVAS_ENC_HANDLE hIvasEnc, - const int16_t channelAwareModeEnabled ) + const Word16 channelAwareModeEnabled ) { Encoder_Struct *st_ivas; ENCODER_CONFIG_HANDLE hEncoderConfig; - int16_t newBandwidthApi; + Word16 newBandwidthApi; ivas_error error; st_ivas = hIvasEnc->st_ivas; @@ -2237,7 +2237,7 @@ static ivas_error printConfigInfo_enc( static ivas_error setBitrate( IVAS_ENC_HANDLE hIvasEnc, - const int32_t totalBitrate ) + const Word32 totalBitrate ) { Encoder_Struct *st_ivas; ENCODER_CONFIG_HANDLE hEncoderConfig; @@ -2753,8 +2753,8 @@ static ivas_error forcedModeApiToInternal( *---------------------------------------------------------------------*/ ivas_error IVAS_ENC_PrintConfig( - const IVAS_ENC_HANDLE hIvasEnc, /* i : IVAS encoder handle */ - const int16_t channelAwareModeEnabled /* i : channel-aware mode enabled flag */ + const IVAS_ENC_HANDLE hIvasEnc, /* i : IVAS encoder handle */ + const Word16 channelAwareModeEnabled /* i : channel-aware mode enabled flag */ ) { return printConfigInfo_enc( hIvasEnc, channelAwareModeEnabled ); diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 4911711d7..ab6c39c23 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -68,7 +68,7 @@ typedef struct _IVAS_ENC_DTX_CONFIG { bool enabled; bool variable_SID_rate; - int16_t SID_interval; + Word16 SID_interval; } IVAS_ENC_DTX_CONFIG; typedef enum _IVAS_ENC_SBA_ORDER @@ -169,8 +169,8 @@ ivas_error IVAS_ENC_Open_fx( /*! r: error code */ ivas_error IVAS_ENC_ConfigureForMono( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -182,8 +182,8 @@ ivas_error IVAS_ENC_ConfigureForMono( /*! r: error code */ ivas_error IVAS_ENC_ConfigureForStereo( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -197,34 +197,34 @@ ivas_error IVAS_ENC_ConfigureForStereo( /*! r: error code */ ivas_error IVAS_ENC_ConfigureForObjects( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects, /* i : number of objects to be encoded */ + const UWord16 numObjects, /* i : number of objects to be encoded */ const bool ism_extended_metadata /* i : Extended metadata used (true/false), where extended metadata includes radius and orientation */ ); /*! r: encoder error code */ ivas_error IVAS_ENC_ConfigureForMASAObjects( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the ouput bitstream */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects, /* i : number of objects to be encoded */ - const int16_t masaVariant /* i : index specifying the number of MASA transport channels */ + const UWord16 numObjects, /* i : number of objects to be encoded */ + const Word16 masaVariant /* i : index specifying the number of MASA transport channels */ ); /*! r: encoder error code */ ivas_error IVAS_ENC_ConfigureForSBAObjects( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the ouput bitstream */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects, /* i : number of objects to be encoded */ + const UWord16 numObjects, /* i : number of objects to be encoded */ const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ const bool Opt_PCA_ON /* i : PCA option flag */ @@ -233,8 +233,8 @@ ivas_error IVAS_ENC_ConfigureForSBAObjects( /*! r: error code */ ivas_error IVAS_ENC_ConfigureForAmbisonics( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -245,8 +245,8 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( ivas_error IVAS_ENC_ConfigureForAmbisonics_fx( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -257,8 +257,8 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics_fx( /*! r: error code */ ivas_error IVAS_ENC_ConfigureForMasa( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -268,8 +268,8 @@ ivas_error IVAS_ENC_ConfigureForMasa( /*! r: encoder error code */ ivas_error IVAS_ENC_ConfigureForMultichannel( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the output bitstream */ + const Word32 inputFs, /* i : input sampling frequency */ + const Word32 bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ @@ -285,7 +285,7 @@ void IVAS_ENC_Close( /*! r: error code */ ivas_error IVAS_ENC_FeedObjectMetadata( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const uint16_t ismIndex, /* i : object index */ + const UWord16 ismIndex, /* i : object index */ const IVAS_ISM_METADATA metadata /* i : object metadata handle for current frame */ ); @@ -307,10 +307,10 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( /*! r: error code */ ivas_error IVAS_ENC_EncodeFrameToCompact( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - int16_t *inputBuffer, /* i : PCM input */ - const int16_t inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */ - uint8_t *outputBitStream, /* o : pointer to compact output bitstream. The array must already be allocated. */ - uint16_t *numOutBits /* o : number of bits written to output bitstream */ + Word16 *inputBuffer, /* i : PCM input */ + const Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */ + UWord8 *outputBitStream, /* o : pointer to compact output bitstream. The array must already be allocated. */ + UWord16 *numOutBits /* o : number of bits written to output bitstream */ ); /* Setter functions - apply changes to encoder configuration */ @@ -324,7 +324,7 @@ ivas_error IVAS_ENC_SetBandwidth( /*! r: error code */ ivas_error IVAS_ENC_SetBitrate( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t totalBitrate /* i : requested bitrate of the output bitstream */ + const Word32 totalBitrate /* i : requested bitrate of the output bitstream */ ); /*! r: error code */ @@ -355,13 +355,13 @@ ivas_error IVAS_ENC_GetDelay( /*! r: encoder error code */ ivas_error IVAS_ENC_GetNumInChannels( const IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - int16_t *numInChannels /* o : total number of samples expected in the input buffer for current encoder configuration */ + Word16 *numInChannels /* o : total number of samples expected in the input buffer for current encoder configuration */ ); /*! r: encoder error code */ ivas_error IVAS_ENC_GetInputBufferSize( const IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - int16_t *inputBufferSize /* o : total number of samples expected in the input buffer for current encoder configuration */ + Word16 *inputBufferSize /* o : total number of samples expected in the input buffer for current encoder configuration */ ); /* Utility functions */ @@ -388,7 +388,7 @@ const char *IVAS_ENC_GetErrorMessage( ivas_error IVAS_ENC_PrintConfig( const IVAS_ENC_HANDLE hIvasEnc, /* i : IVAS encoder handle */ - const int16_t channelAwareModeEnabled /* i : channel-aware mode enabled flag */ + const Word16 channelAwareModeEnabled /* i : channel-aware mode enabled flag */ ); void IVAS_ENC_PrintDisclaimer( diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index a61b2ebff..24179f375 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -31,9 +31,9 @@ static Word32 vq_lvq_lsf_enc( Word16 pred_flag, Word16 mode, Word16 u[], Word16 static Word32 vq_lvq_lsf_enc_ivas_fx( Word16 pred_flag, Word16 mode, Word16 u[], Word16 *levels, Word16 stages, Word16 w[], Word16 Idx[], const Word16 *lsf, const Word16 *pred, Word16 *resq, Word16 *lsfq ); -static void lsf_mid_enc_fx( BSTR_ENC_HANDLE hBstr, int16_t nb_bits, const Word16 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word32 Bin_Ener[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); +static void lsf_mid_enc_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word16 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word32 Bin_Ener[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); -static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, int16_t nb_bits, const Word32 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); +static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, Word16 nb_bits, const Word32 int_fs, const Word16 qlsp0[], const Word16 qlsp1[], Word16 lsp[], const Word16 coder_type, const Word16 bwidth, Word32 Bin_Ener_old[], Word16 Q_ener, Word16 ppp_mode, Word16 nelp_mode ); /*===========================================================================*/ /* FUNCTION : lsf_enc_fx() */ diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 7f58a9501..28e1a39de 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -366,7 +366,7 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ const Word32 *u_fx, /* i : target signal */ const Word16 u_e, /* i : exp for target signal */ - const int16_t maxC_st1, /* i : number of candidates in stage1 */ + const Word16 maxC_st1, /* i : number of candidates in stage1 */ Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 02f8344d1..10d020ee3 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -143,7 +143,7 @@ void bw_detect_fx( const Word32 *enerBuffer, /* i : CLDFB Energy Q31 */ const Word16 *cldfbBuf_Ener_Exp, /* i : CLDFB Energy Exponent */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t mct_on /* i : flag MCT mode */ + const Word16 mct_on /* i : flag MCT mode */ ); void core_switching_post_enc_fx( /*done */ @@ -627,7 +627,7 @@ void swb_bwe_enc_fx( void swb_bwe_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const int16_t last_element_mode, /* i : last element mode */ + const Word16 last_element_mode, /* i : last element mode */ Word16 *old_input_12k8_fx, /* i : input signal @12.8kHz for SWB BWE */ Word16 *old_input_16k_fx, /* i : input signal @16kHz for SWB BWE */ const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ @@ -1585,7 +1585,7 @@ void E_ACELP_4t_ivas_fx( const Word16 last_L_frame, const Word32 total_brate, const Word16 i_subfr, - const int16_t cmpl_flag, + const Word16 cmpl_flag, Word16 element_mode ); void E_ACELP_innovative_codebook_fx( @@ -3077,15 +3077,15 @@ void IGFEncApplyMono_ivas_fx( Encoder_State *st, /* i : Encoder state #ifdef MSAN_FIX Word16 powerSpectrum_len, /* i: length of pPowerSpectrum_fx*/ #endif - const int16_t igfGridIdx, /* i : IGF grid index */ - Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ - Word16 e_mdct, /* i : exponent of pMDCTspectrum */ - Word32 *pPowerSpectrum_fx, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *e_ps, /* i : exponent of pPowerSpectrum */ - const int16_t isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ - const int8_t isTNSActive, /* i : flag indicating if the TNS is active */ - const int16_t sp_aud_decision0, /* i : first stage switching decision */ - const int16_t vad_hover_flag /* i : VAD hangover flag */ + const Word16 igfGridIdx, /* i : IGF grid index */ + Word32 *pMDCTSpectrum_fx, /* i/o: MDCT spectrum */ + Word16 e_mdct, /* i : exponent of pMDCTspectrum */ + Word32 *pPowerSpectrum_fx, /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 *e_ps, /* i : exponent of pPowerSpectrum */ + const Word16 isTCX20, /* i : flag indicating if the input is TCX20 or TCX10/2xTCX5 */ + const Word8 isTNSActive, /* i : flag indicating if the TNS is active */ + const Word16 sp_aud_decision0, /* i : first stage switching decision */ + const Word16 vad_hover_flag /* i : VAD hangover flag */ ); void IGFEncConcatenateBitstream_ivas_fx( const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index ad572d2ba..41c6b0468 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -51,9 +51,9 @@ typedef struct { - int16_t id; /* id of the indice */ - uint16_t value; /* value of the quantized indice */ - int16_t nb_bits; /* number of bits used for the quantization of the indice */ + Word16 id; /* id of the indice */ + UWord16 value; /* value of the quantized indice */ + Word16 nb_bits; /* number of bits used for the quantization of the indice */ } Indice, *INDICE_HANDLE; typedef struct @@ -84,12 +84,12 @@ typedef struct typedef struct bitstream_enc_data_structure { - int16_t nb_ind_tot; /* total number of indices already written */ - int16_t nb_bits_tot; /* total number of bits already written */ - Indice *ind_list; /* list of indices */ - int16_t *ivas_max_num_indices; /* maximum total number of indices in the list */ - Indice **ivas_ind_list_zero; /* beginning of the buffer of indices */ - void *st_ivas; /* IVAS encoder structure */ + Word16 nb_ind_tot; /* total number of indices already written */ + Word16 nb_bits_tot; /* total number of bits already written */ + Indice *ind_list; /* list of indices */ + Word16 *ivas_max_num_indices; /* maximum total number of indices in the list */ + Indice **ivas_ind_list_zero; /* beginning of the buffer of indices */ + void *st_ivas; /* IVAS encoder structure */ // Word16 nb_bits_tot_fx; /* total number of bits already written */ // Indice *ind_list_fx; /* list of indices */ Word16 next_ind_fx; /* pointer to the next empty slot in the list of indices */ @@ -128,9 +128,9 @@ typedef struct signal_buffers_enc_data_structure /* Delay buffer: Used to buffer input samples and to define the subblock size of a transient detector. */ typedef struct { - int16_t nSubblockSize; /* Subblock size of a transient detector that uses this delay buffer. */ + Word16 nSubblockSize; /* Subblock size of a transient detector that uses this delay buffer. */ Word16 buffer[L_FRAME48k / NSUBBLOCKS]; - int16_t nDelay; /* Size of the delay buffer in use. Maximum delay from all users of this buffer. */ + Word16 nDelay; /* Size of the delay buffer in use. Maximum delay from all users of this buffer. */ } DelayBuffer; @@ -141,8 +141,8 @@ typedef struct Word32 subblockNrg[NSUBBLOCKS + MAX_TD_DELAY]; // IVAS Q(-1) Word32 accSubblockNrg[NSUBBLOCKS + MAX_TD_DELAY + 1]; // IVAS Q(-1) Word16 subblockNrgChange[NSUBBLOCKS + MAX_TD_DELAY]; /* EVS: Q7(15 - SUBBLOCK_NRG_CHANGE_E) */ /* IVAS: Q3 */ - int16_t nDelay; /* Size of the delay buffer in use, as number of subblocks. Maximum delay from all users of this buffer. */ - int16_t nPartialDelay; /* Delay of the input (modulo pDelayBuffer->nSubblockSize), nPartialDelay <= pDelayBuffer->nDelay. */ + Word16 nDelay; /* Size of the delay buffer in use, as number of subblocks. Maximum delay from all users of this buffer. */ + Word16 nPartialDelay; /* Delay of the input (modulo pDelayBuffer->nSubblockSize), nPartialDelay <= pDelayBuffer->nDelay. */ /* Decay factor for the recursive accumulation */ Word16 facAccSubblockNrg; @@ -152,27 +152,25 @@ typedef struct Word16 firState2; Word16 q_firState; - uint16_t ramp_up_flag; /* bit map flags to indicate a ramp up in beginning of TCX frame */ + UWord16 ramp_up_flag; /* bit map flags to indicate a ramp up in beginning of TCX frame */ } SubblockEnergies; /* Attack detection function. */ -typedef void ( *TCheckSubblocksForAttack )( const float *pSubblockNrg, const float *pAccSubblockNrg, int16_t nSubblocks, int16_t nPastSubblocks, float attackRatioThreshold, int16_t *pbIsAttackPresent, int16_t *pAttackIndex ); typedef void ( *TCheckSubblocksForAttack_fx )( Word32 const *pSubblockNrg, Word32 const *pAccSubblockNrg, Word16 nSubblocks, Word16 nPastSubblocks, Word16 attackRatioThreshold, Word16 *pbIsAttackPresent, Word16 *pAttackIndex ); /* Transient detector. */ typedef struct TransientDetector { SubblockEnergies *pSubblockEnergies; /* Subblock energies used in this transient detector. */ - int16_t nDelay; /* Delay of the transient detector in number of subblocks, nDelay <= pSubblockEnergies->nDelay. */ - int16_t nSubblocksToCheck; /* Number of subblocks to check for transients. */ - TCheckSubblocksForAttack CheckSubblocksForAttack; /* Function for checking a presence of an attack. */ + Word16 nDelay; /* Delay of the transient detector in number of subblocks, nDelay <= pSubblockEnergies->nDelay. */ + Word16 nSubblocksToCheck; /* Number of subblocks to check for transients. */ TCheckSubblocksForAttack_fx CheckSubblocksForAttack_fx; /* Function for checking a presence of an attack. */ Word16 attackRatioThreshold; /* Attack ratio threshold Q11 */ - int16_t bIsAttackPresent; /* True when an attack was detected. */ - int16_t prev_bIsAttackPresent; /* True if an attack was detected in the previous frame. */ - int16_t attackIndex; /* The index of an attack. */ + Word16 bIsAttackPresent; /* True when an attack was detected. */ + Word16 prev_bIsAttackPresent; /* True if an attack was detected in the previous frame. */ + Word16 attackIndex; /* The index of an attack. */ } TransientDetector; /* Transient detection: Holds all transient detectors and buffers used by them. */ @@ -191,25 +189,25 @@ typedef struct TransientDetection_structure typedef struct vad_structure { - int16_t nb_active_frames; - int16_t hangover_cnt; - int16_t nb_active_frames_he; - int16_t hangover_cnt_he; - int32_t vad_flag_reg_H; - int32_t vad_flag_reg_L; - int32_t vad_prim_reg; - - int16_t vad_flag_cnt_50; - int16_t vad_prim_cnt_16; - - int16_t hangover_cnt_dtx; - int16_t hangover_cnt_music; + Word16 nb_active_frames; + Word16 hangover_cnt; + Word16 nb_active_frames_he; + Word16 hangover_cnt_he; + Word32 vad_flag_reg_H; + Word32 vad_flag_reg_L; + Word32 vad_prim_reg; + + Word16 vad_flag_cnt_50; + Word16 vad_prim_cnt_16; + + Word16 hangover_cnt_dtx; + Word16 hangover_cnt_music; Word16 bcg_flux_fx; // Q4 - int16_t soft_hangover; - int16_t voiced_burst; - int16_t bcg_flux_init; - int16_t nb_active_frames_he1; - int16_t hangover_cnt_he1; + Word16 soft_hangover; + Word16 voiced_burst; + Word16 bcg_flux_init; + Word16 nb_active_frames_he1; + Word16 hangover_cnt_he1; Word16 prim_act_quick_fx; /*Q15 */ /* Noise estimator - primary activity quick */ Word16 prim_act_slow_fx; /*Q15 */ /* Noise estimator - primary activity slow */ Word16 prim_act_fx; /*Q15 */ /* Noise estimator - primary activity slow rise quick fall */ @@ -217,22 +215,22 @@ typedef struct vad_structure Word16 prim_act_slow_he_fx; /*Q15 */ /* Noise estimator - primary activity slow */ Word16 prim_act_he_fx; /*Q15 */ /* Q15 Noise estimator - primary activity slow rise quick fall */ - int16_t spectral_tilt_reset; - int16_t consec_inactive; + Word16 spectral_tilt_reset; + Word16 consec_inactive; Word16 ra_deltasum_fx; - int16_t trigger_SID; + Word16 trigger_SID; Word16 snr_sum_vad_fx; /*Q15 */ Word16 running_avg_fx; /*Q15 */ Word32 L_snr_sum_vad_fx; /*Q4*/ - int16_t hangover_terminate_flag; /* CNG and DTX - flag indicating whether to early terminate DTX hangover */ - int16_t vad_flag; /* VAD flag */ + Word16 hangover_terminate_flag; /* CNG and DTX - flag indicating whether to early terminate DTX hangover */ + Word16 vad_flag; /* VAD flag */ } VAD_DATA, *VAD_HANDLE; typedef struct cldfb_vad_structure { - int16_t bw_index; /* index of band width */ + Word16 bw_index; /* index of band width */ /* feature */ Word16 sp_center[SP_CENTER_NUM]; /* spectral center*/ @@ -248,8 +246,8 @@ typedef struct cldfb_vad_structure Word32 t_bg_energy; /* time background energy of several frames*/ Word16 scale_t_bg_energy; /* the Scaling of t_bg_energy*/ T_VAD_EXP t_bg_energy_sum; /* number of time background energy*/ - int16_t tbg_energy_count; /* sum of time background energy of several frames*/ - int16_t bg_update_count; /* time of background update*/ + Word16 tbg_energy_count; /* sum of time background energy of several frames*/ + Word16 bg_update_count; /* time of background update*/ Word32 frame_energy_smooth; /* smoothed energy of several frames*/ Word16 frame_energy_smooth_scale; /* the Scaling of frame_energy_smooth*/ @@ -268,14 +266,14 @@ typedef struct cldfb_vad_structure Word16 fg_energy_scale; /* the Scaling of fg_energy*/ Word32 bg_energy; /* background energy sum */ Word16 bg_energy_scale; /* the Scaling of bg_energy*/ - int16_t fg_energy_count; /* number of the foreground energy frame */ - int16_t bg_energy_count; /* number of the background energy frame */ + Word16 fg_energy_count; /* number of the foreground energy frame */ + Word16 bg_energy_count; /* number of the background energy frame */ Word32 fg_energy_est_start; /* flag by that indicate whether if estimate energy*/ - int16_t speech_flag; /* residual number of hangover 1 */ - int16_t continuous_noise_num; /* time of continuous noise frames*/ - int16_t continuous_speech_num; /* time of continuous speech frames*/ - int16_t continuous_speech_num2; /* time 2 of continuous speech frames*/ - int16_t frameloop; /* number of frame*/ + Word16 speech_flag; /* residual number of hangover 1 */ + Word16 continuous_noise_num; /* time of continuous noise frames*/ + Word16 continuous_speech_num; /* time of continuous speech frames*/ + Word16 continuous_speech_num2; /* time 2 of continuous speech frames*/ + Word16 frameloop; /* number of frame*/ Word16 tonality_rate3; /* tonality rate*/ Word16 music_background_rate; /* music background rate*/ Word32 lt_noise_sp_center_diff_sum; /* different sum of long time noise sp_center*/ @@ -283,10 +281,10 @@ typedef struct cldfb_vad_structure Word16 lt_noise_sp_center0; /* long time noise sp_center0*/ Word16 lt_noise_sp_center3; /* long time noise sp_center3*/ Word32 lt_bg_highf_eng; /* average of long time high frequency energy*/ - int16_t update_num_with_snr; /* the number of the background update with SNR*/ - int16_t update_count; - int16_t warm_hang_num; /* the number of hangover for warm up*/ - int16_t vad_flag_for_bk_update; + Word16 update_num_with_snr; /* the number of the background update with SNR*/ + Word16 update_count; + Word16 warm_hang_num; /* the number of hangover for warm up*/ + Word16 vad_flag_for_bk_update; } T_CldfbVadState, *VAD_CLDFB_HANDLE; @@ -326,7 +324,7 @@ typedef struct td_cng_enc_structure Word16 cng_buf_cnt; /* CNG and DTX - Counter of buffered CNG parameters */ Word16 cng_exc2_buf[HO_HIST_SIZE * L_FFT]; /* CNG and DTX - exc2 buffer for storing */ Word16 cng_Qexc_buf[HO_HIST_SIZE]; /* CNG and DTX - Q_exc buffer for storing */ - int32_t cng_brate_buf[HO_HIST_SIZE]; /* CNG and DTX - buffer for storing last_active_brate */ + Word32 cng_brate_buf[HO_HIST_SIZE]; /* CNG and DTX - buffer for storing last_active_brate */ Word16 CNG_att_fx; /* CNG and DTX - attenuation factor for CNG, in dB Q7 */ Word16 ho_16k_lsp[HO_HIST_SIZE]; /* CNG and DTX - 16k LSPs flags */ Word16 act_cnt2; /* CNG and DTX - counter of active frames for CNG_mode switching */ @@ -432,23 +430,23 @@ typedef struct dtx_enc_structure typedef struct igfscfenc_public_data_struct { - int16_t ptrBitIndex; - int16_t bitCount; - int16_t prev[64]; /* no more than 64 SCFs for the IGF energy envelope of one block */ - int16_t prevSave[64]; - int16_t scfCountLongBlock[IGF_NOF_GRIDS]; - int16_t t; - int16_t Tsave; - int16_t contex_saved; - const uint16_t *cf_se00; - const uint16_t *cf_se01; - int16_t cf_off_se01; - const uint16_t *cf_se02; - const int16_t *cf_off_se02; - const uint16_t *cf_se10; - int16_t cf_off_se10; - const uint16_t *cf_se11; - const int16_t *cf_off_se11; + Word16 ptrBitIndex; + Word16 bitCount; + Word16 prev[64]; /* no more than 64 SCFs for the IGF energy envelope of one block */ + Word16 prevSave[64]; + Word16 scfCountLongBlock[IGF_NOF_GRIDS]; + Word16 t; + Word16 Tsave; + Word16 contex_saved; + const UWord16 *cf_se00; + const UWord16 *cf_se01; + Word16 cf_off_se01; + const UWord16 *cf_se02; + const Word16 *cf_off_se02; + const UWord16 *cf_se10; + Word16 cf_off_se10; + const UWord16 *cf_se11; + const Word16 *cf_off_se11; Tastat acState; TastatEnc acState_fx; @@ -749,21 +747,21 @@ typedef struct acelp_cbkcorr_structure typedef struct gsc_enc_structure { - int16_t seed_tcx; /* AC mode (GSC) - seed for noise fill */ - int16_t cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ - int16_t mem_last_pit_band; /* AC mode (GSC) - memory of the last band where pitch contribution was significant */ + Word16 seed_tcx; /* AC mode (GSC) - seed for noise fill */ + Word16 cor_strong_limit; /* AC mode (GSC) - Indicator about high spectral correlation per band */ + Word16 mem_last_pit_band; /* AC mode (GSC) - memory of the last band where pitch contribution was significant */ Word16 mem_w0_tmp_fx; Word16 mem_syn_tmp_fx[M]; Word16 mid_dyn_fx; /* AC mode (GSC) - signal dynamic Q7 */ - int16_t noise_lev; /* AC mode (GSC) - noise level */ - int16_t past_dyn_dec; /* AC mode (GSC) - Past noise level decision */ + Word16 noise_lev; /* AC mode (GSC) - noise level */ + Word16 past_dyn_dec; /* AC mode (GSC) - Past noise level decision */ Word32 Last_frame_ener_fx; /* AC mode (GSC) - Last frame energy */ - int16_t pit_exc_hangover; /* AC mode (GSC) - Hangover for the time contribution switching */ + Word16 pit_exc_hangover; /* AC mode (GSC) - Hangover for the time contribution switching */ Word16 last_exc_dct_in_fx[L_FRAME16k]; /* AC mode (GSC) - previous exciation */ Word16 Q_last_exc_dct_in; - Word16 last_ener_fx; /* AC mode (GSC) - previous energy Q0 */ - int16_t last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ - Word16 lt_gpitch_fx; /* Q15 */ + Word16 last_ener_fx; /* AC mode (GSC) - previous energy Q0 */ + Word16 last_bitallocation_band[6]; /* AC mode (GSC) - previous bit allocation of each band */ + Word16 lt_gpitch_fx; /* Q15 */ } GSC_ENC_DATA, *GSC_ENC_HANDLE; @@ -804,14 +802,14 @@ typedef struct hq_enc_structure /* PVQ range coder state */ typedef struct pvq_enc_structure { - uint32_t rc_low; - uint32_t rc_range; - int16_t rc_cache; - int16_t rc_carry; - int16_t rc_carry_count; - int16_t rc_num_bits; - int16_t rc_tot_bits; - int16_t rc_offset; + UWord32 rc_low; + UWord32 rc_range; + Word16 rc_cache; + Word16 rc_carry; + Word16 rc_carry_count; + Word16 rc_num_bits; + Word16 rc_tot_bits; + Word16 rc_offset; } PVQ_ENC_DATA, *PVQ_ENC_HANDLE; @@ -838,33 +836,33 @@ typedef struct sc_vbr_enc_structure Word16 nelp_lp_fit_mem[NELP_LP_ORDER * 2]; /* Q(prev_Q_new) */ Word32 bp1_filt_mem_nb_fx[14]; /* Q(qprevGain_fx) */ - int16_t nelp_enc_seed; + Word16 nelp_enc_seed; Word16 nelp_gain_mem_fx; /* Q0 */ - int16_t last_nelp_mode; - int16_t nelp_mode; + Word16 last_nelp_mode; + Word16 nelp_mode; Word16 qprevIn_fx; Word16 qprevGain_fx; /* PPP variables */ - int16_t pppcountE; - int16_t bump_up; - int16_t last_ppp_mode; - int16_t last_last_ppp_mode; - int16_t ppp_mode; + Word16 pppcountE; + Word16 bump_up; + Word16 last_ppp_mode; + Word16 last_last_ppp_mode; + Word16 ppp_mode; Word16 prev_ppp_gain_pit_fx; /* Q14 */ Word16 prev_tilt_code_fx; /* Q15 */ /* voiced encoder variables */ - int16_t firstTime_voicedenc; + Word16 firstTime_voicedenc; /* DTFS variables */ Word16 dtfs_enc_a_fx[MAXLAG_WI]; /* Q(dtfs_enc_Q) */ Word16 dtfs_enc_b_fx[MAXLAG_WI]; /* Q(dtfs_enc_Q) */ - int16_t dtfs_enc_lag; - int16_t dtfs_enc_nH; - int16_t dtfs_enc_nH_4kHz; + Word16 dtfs_enc_lag; + Word16 dtfs_enc_nH; + Word16 dtfs_enc_nH_4kHz; Word16 dtfs_enc_upper_cut_off_freq_of_interest_fx; /* Q0 */ Word16 dtfs_enc_upper_cut_off_freq_fx; /* Q0 */ Word16 dtfs_enc_Q; @@ -876,23 +874,23 @@ typedef struct sc_vbr_enc_structure Word16 lasterbE_fx[NUM_ERB_WB]; /* Previous Amplitude spectrum (ERB) Q13 */ Word16 Q_prev_cw_en_fx; - int16_t mode_QQF; - int16_t rate_control; + Word16 mode_QQF; + Word16 rate_control; Word16 SNR_THLD_fx; /* Q8 */ - int16_t Q_to_F; - int16_t pattern_m; - int16_t patterncount; - int16_t Last_Resort; - int16_t numactive; /* keep the count of the frames inside current 600 frame block */ + Word16 Q_to_F; + Word16 pattern_m; + Word16 patterncount; + Word16 Last_Resort; + Word16 numactive; /* keep the count of the frames inside current 600 frame block */ Word32 sum_of_rates_fx; /*Q=13 sum of the rates of past 600 active frames*/ Word32 global_avr_rate_fx; /*Q=13 global rate upto current time. recorded a (rate in kbps) *6000*/ - int16_t global_frame_cnt; /* 600 active frame block count. Used to update the global rate */ - int16_t set_ppp_generic; - int16_t avoid_HQ_VBR_NB; + Word16 global_frame_cnt; /* 600 active frame block count. Used to update the global rate */ + Word16 set_ppp_generic; + Word16 avoid_HQ_VBR_NB; - int16_t vbr_generic_ho; - int16_t Local_VAD; - int16_t last_7k2_coder_type; + Word16 vbr_generic_ho; + Word16 Local_VAD; + Word16 last_7k2_coder_type; } SC_VBR_ENC_DATA, *SC_VBR_ENC_HANDLE; @@ -910,7 +908,7 @@ typedef struct amrwb_io_enc_structure Word16 mem_hp400_enc_fx[6]; Word16 mem_hf_enc_fx[L_FIR - 1]; Word16 mem_syn_hf_enc_fx[M]; - int16_t seed2_enc; + Word16 seed2_enc; } AMRWB_IO_ENC_DATA, *AMRWB_IO_ENC_HANDLE; @@ -944,7 +942,7 @@ typedef struct td_bwe_enc_structure Word16 state_syn_shbexc_fx[L_SHB_LAHEAD]; /* Q(prev_Q_bwe_exc - 16) */ Word16 state_lpc_syn_fx[LPC_SHB_ORDER]; /* Q(prev_Q_bwe_exc - 16) */ Word16 old_bwe_exc_fx[PIT16k_MAX * 2]; /*Q_exc*/ - int16_t bwe_seed[2]; + Word16 bwe_seed[2]; Word32 bwe_non_lin_prev_scale_fx; /* Q30 */ Word16 old_bwe_exc_extended_fx[NL_BUFF_OFFSET]; /* Q(prev_Q_bwe_exc - 16) */ Word16 syn_overlap_fx[L_SHB_LAHEAD]; /* overlap buffer used to Adjust SHB Frame Gain */ @@ -964,7 +962,7 @@ typedef struct td_bwe_enc_structure Word16 shb_inv_filt_mem_fx[LPC_SHB_ORDER]; /* Q(Q_shb_spch) */ Word16 lsp_shb_spacing_fx[3]; /* Q15 */ Word16 prev_swb_GainShape_fx; /* Q15 */ - int16_t prev_frGainAtten; + Word16 prev_frGainAtten; Word16 prev_wb_GainShape; /* Q15 */ Word16 swb_lsp_prev_interp_fx[LPC_SHB_ORDER]; /* Q15 */ @@ -973,25 +971,25 @@ typedef struct td_bwe_enc_structure Word16 fb_tbe_demph_fx; Word16 tilt_mem_fx; /* Q12 */ - int16_t prev_coder_type; + Word16 prev_coder_type; Word16 prev_lsf_diff_fx[LPC_SHB_ORDER - 2]; /* Q15 */ Word16 prev_tilt_para_fx; /* Q10 */ Word16 cur_sub_Aq_fx[M + 1]; /* Q12 */ /* quantized data */ - int16_t lsf_idx[NUM_Q_LSF]; - int16_t m_idx; - int16_t grid_idx; - int16_t idxSubGains; - int16_t idxFrameGain; - int16_t idx_shb_fr_gain; - int16_t idx_res_gs[NB_SUBFR16k]; - int16_t idx_mixFac; - - int16_t lsf_WB; - int16_t gFrame_WB; - - int16_t idxGain; + Word16 lsf_idx[NUM_Q_LSF]; + Word16 m_idx; + Word16 grid_idx; + Word16 idxSubGains; + Word16 idxFrameGain; + Word16 idx_shb_fr_gain; + Word16 idx_res_gs[NB_SUBFR16k]; + Word16 idx_mixFac; + + Word16 lsf_WB; + Word16 gFrame_WB; + + Word16 idxGain; Word16 dec_2_over_3_mem_fx[L_FILT_2OVER3]; Word16 dec_2_over_3_mem_lp_fx[6]; @@ -1041,9 +1039,9 @@ typedef struct fd_bwe_enc_structure typedef struct rf_enc_structure { - int16_t rf_frame_type; - int16_t rf_targetbits_buff[MAX_RF_FEC_OFFSET]; - int16_t rf_indx_frametype[MAX_RF_FEC_OFFSET]; + Word16 rf_frame_type; + Word16 rf_targetbits_buff[MAX_RF_FEC_OFFSET]; + Word16 rf_indx_frametype[MAX_RF_FEC_OFFSET]; ACELP_config acelp_cfg_rf; /* configuration for RF frame */ @@ -1054,31 +1052,31 @@ typedef struct rf_enc_structure struct dispMem_fx rf_dm_fx; Word32 rf_gc_threshold; - int16_t rf_target_bits; + Word16 rf_target_bits; Word16 rf_tilt_buf[NB_SUBFR16k]; - int16_t rf_indx_lsf[MAX_RF_FEC_OFFSET][3]; - int16_t rf_indx_pitch[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; - int16_t rf_indx_fcb[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; - int16_t rf_indx_gain[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; - int16_t rf_indx_EsPred[MAX_RF_FEC_OFFSET]; - int16_t rf_indx_ltfMode[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; + Word16 rf_indx_lsf[MAX_RF_FEC_OFFSET][3]; + Word16 rf_indx_pitch[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; + Word16 rf_indx_fcb[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; + Word16 rf_indx_gain[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; + Word16 rf_indx_EsPred[MAX_RF_FEC_OFFSET]; + Word16 rf_indx_ltfMode[MAX_RF_FEC_OFFSET][NB_SUBFR16k]; - int16_t rf_indx_nelp_fid[MAX_RF_FEC_OFFSET]; - int16_t rf_indx_nelp_iG1[MAX_RF_FEC_OFFSET]; - int16_t rf_indx_nelp_iG2[MAX_RF_FEC_OFFSET][2]; + Word16 rf_indx_nelp_fid[MAX_RF_FEC_OFFSET]; + Word16 rf_indx_nelp_iG1[MAX_RF_FEC_OFFSET]; + Word16 rf_indx_nelp_iG2[MAX_RF_FEC_OFFSET][2]; - int16_t rf_indx_tbeGainFr[MAX_RF_FEC_OFFSET]; + Word16 rf_indx_tbeGainFr[MAX_RF_FEC_OFFSET]; - int16_t rf_tcxltp_pitch_int_past; - int16_t rf_last_tns_active; - int16_t rf_second_last_tns_active; - int16_t rf_second_last_core; - int16_t rf_clas[MAX_RF_FEC_OFFSET]; - int16_t rf_gain_tcx[MAX_RF_FEC_OFFSET]; - int16_t rf_tcxltp_param[MAX_RF_FEC_OFFSET]; + Word16 rf_tcxltp_pitch_int_past; + Word16 rf_last_tns_active; + Word16 rf_second_last_tns_active; + Word16 rf_second_last_core; + Word16 rf_clas[MAX_RF_FEC_OFFSET]; + Word16 rf_gain_tcx[MAX_RF_FEC_OFFSET]; + Word16 rf_tcxltp_param[MAX_RF_FEC_OFFSET]; - int16_t RF_bwe_gainFr_ind; + Word16 RF_bwe_gainFr_ind; } RF_ENC_DATA, *RF_ENC_HANDLE; @@ -1088,17 +1086,17 @@ typedef struct rf_enc_structure typedef struct plc_enc_evs_structure { - int16_t nBits; /* number of bits */ + Word16 nBits; /* number of bits */ Word16 Q_new; Word16 Q_exp; - int16_t enableGplc; - int16_t T0_4th; - int16_t T0; - int16_t calcOnlylsf; - int16_t pit_min; - int16_t pit_max; + Word16 enableGplc; + Word16 T0_4th; + Word16 T0; + Word16 calcOnlylsf; + Word16 pit_min; + Word16 pit_max; Word16 mem_MA_14Q1[M]; Word16 mem_AR[M]; @@ -1131,8 +1129,8 @@ typedef struct tec_enc_structure Word16 loTempEnv[CLDFB_NO_COL_MAX]; /* Q7 */ Word16 loTempEnv_ns[CLDFB_NO_COL_MAX]; /* Q7 */ Word16 hiTempEnv[CLDFB_NO_COL_MAX + DELAY_TEMP_ENV_BUFF_TEC + EXT_DELAY_HI_TEMP_ENV]; /* Q7 */ - int16_t tranFlag; - int16_t corrFlag; + Word16 tranFlag; + Word16 corrFlag; } TEC_ENC_DATA, *TEC_ENC_HANDLE; @@ -1143,63 +1141,63 @@ typedef struct tec_enc_structure typedef struct tcx_enc_structure { - int16_t L_frameTCX; + Word16 L_frameTCX; - int16_t tcxMode; /* Chosen TCX mode for this frame */ - int16_t transform_type[2]; /* TCX20/10/5 mode in each subframe */ + Word16 tcxMode; /* Chosen TCX mode for this frame */ + Word16 transform_type[2]; /* TCX20/10/5 mode in each subframe */ /* Core Signal Analysis Outputs */ Word16 noiseTiltFactor; /* compensation for LPC tilt in noise filling Q15 */ - int16_t noiseLevelMemory_cnt; /* counter of consecutive low TCX noise levels */ + Word16 noiseLevelMemory_cnt; /* counter of consecutive low TCX noise levels */ Word16 ltpGainMemory_fx[N_LTP_GAIN_MEMS]; /* for smoothing noiseTransWidth Q15 */ STnsData tnsData[2]; - // int16_t fUseTns[2]; + // Word16 fUseTns[2]; Word8 fUseTns[2]; - int16_t bTnsOnWhithenedSpectra[2]; + Word16 bTnsOnWhithenedSpectra[2]; - // int16_t memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ + // Word16 memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ Word8 memQuantZeros[L_FRAME_PLUS]; /* Quantization deadzone flags */ Word16 *speech_TCX; Word16 *new_speech_TCX; // Word16 q_speech_TCX; - int16_t tcxltp; - int16_t tcxltp_pitch_int; - int16_t tcxltp_pitch_fr; + Word16 tcxltp; + Word16 tcxltp_pitch_int; + Word16 tcxltp_pitch_fr; Word16 tcxltp_gain; /* Q15 */ - int16_t tcxltp_pitch_int_past; - int16_t tcxltp_pitch_fr_past; + Word16 tcxltp_pitch_int_past; + Word16 tcxltp_pitch_fr_past; Word16 tcxltp_gain_past; /* Q15 */ Word16 tcxltp_norm_corr_past; /* Q15 */ Word16 tcxltp_norm_corr_mem; /* Q15 */ Word16 kernel_switch_corr_past; /* Q15 */ - uint16_t kernel_type[2]; /* transform kernel type in each subframe (MDCT or MDST) */ - uint16_t kernel_symmetry_past; /* last TDA symmetry (0 for MDCT, 1 for MDST type) */ - uint16_t enc_ste_pre_corr_past; + UWord16 kernel_type[2]; /* transform kernel type in each subframe (MDCT or MDST) */ + UWord16 kernel_symmetry_past; /* last TDA symmetry (0 for MDCT, 1 for MDST type) */ + UWord16 enc_ste_pre_corr_past; Word32 tfm_mem_fx; /* state of IIR filtered temporal flatness measure Q31 */ Word16 buf_speech_ltp[L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k]; Word16 exp_buf_speech_ltp; Word16 *speech_ltp; Word16 *new_speech_ltp; - int16_t tcxltp_filt_idx; - int16_t tcxltp_bits; - int16_t tcxltp_param[LTPSIZE]; - int16_t tcxltp_on_mem; + Word16 tcxltp_filt_idx; + Word16 tcxltp_bits; + Word16 tcxltp_param[LTPSIZE]; + Word16 tcxltp_on_mem; Word16 measuredBwRatio; /* measured bw; used for TCX noise-filling. 1Q14 */ - int16_t nmStartLine; /* Starting line for the noise measurement */ + Word16 nmStartLine; /* Starting line for the noise measurement */ - int16_t tcx_lpc_shaped_ari; + Word16 tcx_lpc_shaped_ari; Word16 old_out_fx[L_FRAME32k]; /* buffer for OLA; at the encoder, the maximum length is L_FRAME32k (corresponds to maximum internal L_frame length) */ Word16 Q_old_out; /* MDCT switching */ Word16 prev_hi_ener; /* Q8 */ - int16_t prev_hi_sparse; + Word16 prev_hi_sparse; Word16 clas_sec_old_fx; /* Q13 */ - int16_t clas_final_old; + Word16 clas_final_old; Word32 last_gain1; /* Q(31 - st->last_enerBuffer_exp) */ Word32 last_gain2; /* Q(31 - st->last_enerBuffer_exp) */ @@ -1209,7 +1207,7 @@ typedef struct tcx_enc_structure Word16 q_Txnq; Word16 tcx_target_bits_fac; /* Q14 */ - int16_t tns_ms_flag[2]; + Word16 tns_ms_flag[2]; Word32 *spectrum_fx[2]; /* MDCT output for a short block */ Word16 spectrum_e[2]; Word32 spectrum_long_fx[N_MAX]; /* MDCT output for a long block. Points to spectrum */ @@ -1241,9 +1239,9 @@ typedef struct enc_core_structure Word16 idchan; /* channel ID (audio channel number) */ Word16 id_element; /* element ID */ - int16_t element_mode; /* element mode */ + Word16 element_mode; /* element mode */ Word16 last_element_mode; /* element mode */ - int32_t element_brate; /* element bitrate */ + Word32 element_brate; /* element bitrate */ Word16 extl_orig; /* extension layer */ Word32 extl_brate_orig; /* extension layer bitrate */ Word16 codec_mode; /* Mode1 or Mode2 */ @@ -1257,40 +1255,40 @@ typedef struct enc_core_structure BSTR_ENC_HANDLE hBstr; /* encoder bitstream handle */ Word16 last_enerBuffer_exp; - int16_t bitstreamformat; /* Bitstream format flag (G.192/MIME) */ - Word16 next_bit_pos_fx; /* position of the next bit to be written in the bitstream */ - - int32_t input_Fs; /* input signal sampling frequency in Hz */ - int32_t total_brate; /* total bitrate in kbps of the codec */ - int32_t last_total_brate; /* last frame's total bitrate in kbps of the codec */ - int32_t last_total_brate_cng; /* last inactive frame's total bitrate in kbps of the codec */ - int16_t core; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ - int16_t last_core; /* previous frame core */ - int16_t coder_type; /* core coder type */ - int16_t flag_ACELP16k; /* flag indicating use of ACELP core at 16kHz internal sampling rate */ - int32_t core_brate; /* core bitrate */ - int32_t last_core_brate; /* previous frame core bitrate */ - int16_t extl; /* extension layer */ - int16_t last_extl; /* previous extension layer */ - int32_t extl_brate; /* extension layer bitrate */ - int16_t input_bwidth; /* input signal bandwidth */ - int16_t bwidth; /* encoded bandwidth NB, WB, SWB or FB */ - int16_t max_bwidth; /* maximum encoded bandwidth */ - int16_t last_input_bwidth; /* input signal bandwidth in the previous frame */ - int16_t last_bwidth; /* coded bandwidth in the previous frame */ - int16_t last_bwidth_cng; /* coded bandwidth in the previous inactive frame */ - int16_t bwidth_sw_cnt; /* bandwidth switching counter */ - int16_t L_frame; /* ACELP core internal frame length */ - int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - int16_t Opt_DTX_ON; /* flag indicating DTX operation */ - int16_t cng_type; /* flag indicating LP or CLDFB based SID/CNG */ - int16_t cng_sba_flag; /* flag indicating CNG/SID for SBA 2TC */ - int16_t Opt_SC_VBR; /* flag indicating SC-VBR mode */ - int16_t last_Opt_SC_VBR; /* flag indicating prev frame's SC-VBR mode */ - int16_t low_rate_mode; /* low-rate mode flag */ - int16_t inactive_coder_type_flag; /* inactive coder type flag (0 = AVQ / 1 = GSC) */ + Word16 bitstreamformat; /* Bitstream format flag (G.192/MIME) */ + Word16 next_bit_pos_fx; /* position of the next bit to be written in the bitstream */ + + Word32 input_Fs; /* input signal sampling frequency in Hz */ + Word32 total_brate; /* total bitrate in kbps of the codec */ + Word32 last_total_brate; /* last frame's total bitrate in kbps of the codec */ + Word32 last_total_brate_cng; /* last inactive frame's total bitrate in kbps of the codec */ + Word16 core; /* core (ACELP_CORE, TCX_20_CORE, TCX_10_CORE, HQ_CORE, AMR_WB_CORE) */ + Word16 last_core; /* previous frame core */ + Word16 coder_type; /* core coder type */ + Word16 flag_ACELP16k; /* flag indicating use of ACELP core at 16kHz internal sampling rate */ + Word32 core_brate; /* core bitrate */ + Word32 last_core_brate; /* previous frame core bitrate */ + Word16 extl; /* extension layer */ + Word16 last_extl; /* previous extension layer */ + Word32 extl_brate; /* extension layer bitrate */ + Word16 input_bwidth; /* input signal bandwidth */ + Word16 bwidth; /* encoded bandwidth NB, WB, SWB or FB */ + Word16 max_bwidth; /* maximum encoded bandwidth */ + Word16 last_input_bwidth; /* input signal bandwidth in the previous frame */ + Word16 last_bwidth; /* coded bandwidth in the previous frame */ + Word16 last_bwidth_cng; /* coded bandwidth in the previous inactive frame */ + Word16 bwidth_sw_cnt; /* bandwidth switching counter */ + Word16 L_frame; /* ACELP core internal frame length */ + Word16 Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ + Word16 Opt_DTX_ON; /* flag indicating DTX operation */ + Word16 cng_type; /* flag indicating LP or CLDFB based SID/CNG */ + Word16 cng_sba_flag; /* flag indicating CNG/SID for SBA 2TC */ + Word16 Opt_SC_VBR; /* flag indicating SC-VBR mode */ + Word16 last_Opt_SC_VBR; /* flag indicating prev frame's SC-VBR mode */ + Word16 low_rate_mode; /* low-rate mode flag */ + Word16 inactive_coder_type_flag; /* inactive coder type flag (0 = AVQ / 1 = GSC) */ #ifdef DEBUGGING - int16_t force; /* flag indicating specific signal type (0 = speech, 1 = music, -1 = N/A) */ + Word16 force; /* flag indicating specific signal type (0 = speech, 1 = music, -1 = N/A) */ #ifdef DEBUG_FORCE_DIR char *force_dir; /* directory containing external binary files for modes/parameters enforcement (empty string indicates no enforcement) */ #endif @@ -1328,13 +1326,13 @@ typedef struct enc_core_structure * ACELP core parameters *----------------------------------------------------------------------------------*/ - int16_t clas; /* current frame clas */ - int16_t last_clas; /* previous frame signal classification */ + Word16 clas; /* current frame clas */ + Word16 last_clas; /* previous frame signal classification */ Word16 prev_fmerit; /* previous signal classification score Q15 */ Word16 fmerit_dt; /* signal classification score difference Q15 */ - int16_t Nb_ACELP_frames; + Word16 Nb_ACELP_frames; - int16_t pitch[3]; /* open-loop pitch values @12.8 kHz for three half-frames */ + Word16 pitch[3]; /* open-loop pitch values @12.8 kHz for three half-frames */ // Word16 pitch_fx[3]; Word16 voicing_fx[3]; /* open-loop normalized correlation values for three half-frames Q15 */ @@ -1348,7 +1346,7 @@ typedef struct enc_core_structure Word16 lsf_old_fx[M]; /* old LSF vector at the end of the frame Qlog2(2.56) */ Word16 lsp_old16k_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ Word16 lspold_enc_fx[M]; /* old LSP vector at the end of the frame @16kHz Q15 */ - int16_t pstreaklen; /* LSF quantizer */ + Word16 pstreaklen; /* LSF quantizer */ Word16 streaklimit_fx; /* LSF quantizer Q15 */ Word16 stab_fac_fx; /* LSF stability factor Q15 */ Word16 clip_var_fx[6]; /* pitch gain clipping memory [2.56x,Q14,Q8,Q0,Q14,Q14] */ @@ -1375,42 +1373,42 @@ typedef struct enc_core_structure Word16 mem_deemph_fx; /* deemphasis filter memory */ Word32 mem_hp20_in_fx[5]; /* HP filter memory for AMR-WB IO */ Word16 mCb1_fx; /* LSF quantizer - counter of stationary frames after a transition frame */ - int16_t GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ - int16_t GSC_IVAS_mode; + Word16 GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ + Word16 GSC_IVAS_mode; GSC_ENC_HANDLE hGSCEnc; - int16_t Last_pulse_pos; /* FEC - last position of the first glottal pulse in the frame */ + Word16 Last_pulse_pos; /* FEC - last position of the first glottal pulse in the frame */ Word16 lsfoldbfi0_fx[M]; /* FEC - LSF vector of the previous frame Qlog2(2.56) */ Word16 lsfoldbfi1_fx[M]; /* FEC - LSF vector of the past previous frame Qlog2(2.56) */ Word16 lsf_adaptive_mean_fx[M]; /* FEC - adaptive mean LSF vector for FEC Qlog2(2.56) */ - int16_t next_force_safety_net; /* FEC - flag to force safety net in next frame */ + Word16 next_force_safety_net; /* FEC - flag to force safety net in next frame */ // Word16 next_force_safety_net_fx; /* FEC - flag to force safety net in next frame */ - int16_t uv_count; /* Stationary noise UV modification - unvoiced counter */ - int16_t act_count; /* Stationary noise UV modification - activation counter */ + Word16 uv_count; /* Stationary noise UV modification - unvoiced counter */ + Word16 act_count; /* Stationary noise UV modification - activation counter */ Word32 ge_sm_fx; /* Stationary noise UV modification - smoothed excitation gain Q(GE_SHIFT) */ Word16 lspold_s_fx[M]; /* Stationary noise UV modification - old LSP vector Q15 */ - int16_t noimix_seed; /* Stationary noise UV modification - mixture seed */ + Word16 noimix_seed; /* Stationary noise UV modification - mixture seed */ Word16 min_alpha_fx; /* Stationary noise UV modification - minimum alpha Q15 */ Word16 exc_pe_fx; /* Stationary noise UV modification - memory of the preemphasis filter */ - int16_t coder_type_raw; /* raw coder_type (before UNVOICED is lost) */ - int16_t last_coder_type_raw; /* raw last_coder_type (coming from the sigal classification) */ - int16_t last_coder_type; /* previous coding type */ + Word16 coder_type_raw; /* raw coder_type (before UNVOICED is lost) */ + Word16 last_coder_type_raw; /* raw last_coder_type (coming from the sigal classification) */ + Word16 last_coder_type; /* previous coding type */ Word16 old_thres_fx; /* normalized correlation weighting in open-loop pitch Q14 */ Word16 old_corr_fx; /* normalized correlation in previous frame (mean value) Q15 */ - int16_t old_pitch; /* previous pitch for open-loop pitch search */ - int16_t delta_pit; /* open-loop pitch extrapolation correction */ + Word16 old_pitch; /* previous pitch for open-loop pitch search */ + Word16 delta_pit; /* open-loop pitch extrapolation correction */ Word32 ee_old_fx; /* previous frame low/high frequency energy ratio Q6 */ - int16_t min_band; /* minimum critical band of useful bandwidth */ - int16_t max_band; /* maximum critical band of useful bandwidth */ - int16_t tc_cnt; /* TC frame counter */ - int16_t audio_frame_cnt; /* Counter of relative presence of audio frames */ + Word16 min_band; /* minimum critical band of useful bandwidth */ + Word16 max_band; /* maximum critical band of useful bandwidth */ + Word16 tc_cnt; /* TC frame counter */ + Word16 audio_frame_cnt; /* Counter of relative presence of audio frames */ Word32 old_dE1_fx; /* Maximum energy increase in previous frame Q13 */ - int16_t old_ind_deltaMax; /* Index of the sub-subframe of maximum energy in previous frame */ + Word16 old_ind_deltaMax; /* Index of the sub-subframe of maximum energy in previous frame */ Word32 old_enr_ssf_fx[2 * NB_SSF]; /* Maxima of energies per sub-subframes of previous frame */ - int16_t spike_hyst; /* Hysteresis to prevent UC after sharp energy spike */ - int16_t last_harm_flag_acelp; /* harmonicity flag for ACELP @32kbps rate */ + Word16 spike_hyst; /* Hysteresis to prevent UC after sharp energy spike */ + Word16 last_harm_flag_acelp; /* harmonicity flag for ACELP @32kbps rate */ Word16 old_Aq_12_8_fx[M + 1]; /* Q12 old Aq[] for core switching */ Word16 old_Es_pred_fx; /* old Es_pred for core switching Q8 */ Word16 music_hysteresis_fx; /* Counter of frames after AUDIO coding mode to prevent UC */ @@ -1433,7 +1431,7 @@ typedef struct enc_core_structure Word16 voicing0_sm_fx; Word16 voicing_sm_fx; Word16 LF_EnergyRatio_sm_fx; - int16_t predecision_flag; + Word16 predecision_flag; Word32 diff_sm_fx; /* Q7 */ Word32 energy_sm_fx; /* Q7 */ @@ -1492,9 +1490,9 @@ typedef struct enc_core_structure Word16 lgBin_E_fx[L_FFT / 2]; /* Q8 per bin energy of two frames */ - int16_t sp_aud_decision0; /* 1st stage speech/music decision flag */ - int16_t sp_aud_decision1; /* 1st stage speech/music classification flag */ - int16_t sp_aud_decision2; /* 2nd stage speech/music classification flag */ + Word16 sp_aud_decision0; /* 1st stage speech/music decision flag */ + Word16 sp_aud_decision1; /* 1st stage speech/music classification flag */ + Word16 sp_aud_decision2; /* 2nd stage speech/music classification flag */ /*----------------------------------------------------------------------------------* * VAD/DTX/CNG @@ -1505,9 +1503,9 @@ typedef struct enc_core_structure VAD_CLDFB_HANDLE hVAD_CLDFB; T_CldfbVadState vad_st; - int16_t vad_flag; /* i : VAD flag */ - int16_t sharpFlag; - int16_t localVAD; /* i : local VAD flag */ + Word16 vad_flag; /* i : VAD flag */ + Word16 sharpFlag; + Word16 localVAD; /* i : local VAD flag */ Word32 bckr_tilt_lt; /* Q16 */ Word16 lp_speech_fx; /* Q8 */ @@ -1517,7 +1515,7 @@ typedef struct enc_core_structure Word16 voicing_old_fx; Word16 var_SID_rate_flag_fx; /* CNG and DTX - flag for variable SID rate */ Word16 interval_SID_fx; - int16_t active_cnt; /* counter of active frames */ + Word16 active_cnt; /* counter of active frames */ TD_CNG_ENC_HANDLE hTdCngEnc; @@ -1544,10 +1542,10 @@ typedef struct enc_core_structure *----------------------------------------------------------------------------------*/ HANDLE_FD_CNG_ENC hFdCngEnc; - int16_t fd_cng_reset_flag; + Word16 fd_cng_reset_flag; Word16 last_totalNoise_fx; /* Q8 */ Word16 totalNoise_increase_hist_fx[TOTALNOISE_HIST_SIZE]; /* Q8 */ - int16_t totalNoise_increase_len; + Word16 totalNoise_increase_len; /*----------------------------------------------------------------------------------* * SC-VBR parameters @@ -1564,7 +1562,7 @@ typedef struct enc_core_structure Word16 old_hpfilt_out_fx; Word32 EnergyLT_fx; /* Q(EnergyLT_fx_exp) */ Word32 Energy_Old_fx; - int16_t TransientHangOver; + Word16 TransientHangOver; HQ_ENC_HANDLE hHQ_core; /* HQ core encoder handle */ @@ -1588,21 +1586,21 @@ typedef struct enc_core_structure Word16 lt_mean_NB_fx; /* Q11 */ Word16 lt_mean_WB_fx; /* Q11 */ Word16 lt_mean_SWB_fx; /* Q11 */ - int16_t count_WB; - int16_t count_SWB; - int16_t count_FB; + Word16 count_WB; + Word16 count_SWB; + Word16 count_FB; /*----------------------------------------------------------------------------------* * Channel-aware mode *----------------------------------------------------------------------------------*/ - int16_t rf_mode; /* flag to signal the RF mode */ - int16_t rf_mode_last; - int16_t last_rf_mode_cng; - int16_t Opt_RF_ON; - int16_t rf_fec_offset; - int16_t rf_target_bits_write; - int16_t rf_fec_indicator; + Word16 rf_mode; /* flag to signal the RF mode */ + Word16 rf_mode_last; + Word16 last_rf_mode_cng; + Word16 Opt_RF_ON; + Word16 rf_fec_offset; + Word16 rf_target_bits_write; + Word16 rf_fec_indicator; RF_ENC_HANDLE hRF; /* RF encoder handle */ @@ -1650,17 +1648,17 @@ typedef struct enc_core_structure Word16 *wspeech_enc; // exp_buf_wspeech_enc Word16 *synth; - int16_t enableTcxLpc; /* global toggle for the TCX LPC quantizer */ - int16_t envWeighted; /* are is{p,f}_old_q[] weighted or not? */ + Word16 enableTcxLpc; /* global toggle for the TCX LPC quantizer */ + Word16 envWeighted; /* are is{p,f}_old_q[] weighted or not? */ - int16_t acelpEnabled; /* Flag indicating if ACELP can be used */ - int16_t tcx10Enabled; /* Flag indicating if TCX 10 can be used */ - int16_t tcx20Enabled; /* Flag indicating if TCX 20 can be used */ + Word16 acelpEnabled; /* Flag indicating if ACELP can be used */ + Word16 tcx10Enabled; /* Flag indicating if TCX 10 can be used */ + Word16 tcx20Enabled; /* Flag indicating if TCX 20 can be used */ Word16 mem_wsp_enc; /* wsp vector memory */ - int16_t nb_bits_header_ace; /* number of bits for the header */ - int16_t nb_bits_header_tcx; /* number of bits for the header */ + Word16 nb_bits_header_ace; /* number of bits for the header */ + Word16 nb_bits_header_tcx; /* number of bits for the header */ Word16 preemph_fac; /*Preemphasis factor Q15*/ Word16 gamma; /* Q15 */ @@ -1669,7 +1667,7 @@ typedef struct enc_core_structure TRAN_DET_HANDLE hTranDet; TransientDetection transientDetection; Word16 transient_info[3]; - int16_t acelpFramesCount; + Word16 acelpFramesCount; Word16 prevTempFlatness_fx; /* exponent is AVG_FLAT_E Q7 in EVS */ /* Q4 in IVAS */ // float currEnergyLookAhead; @@ -1684,34 +1682,34 @@ typedef struct enc_core_structure Word16 parcorr[2]; Word16 parcorr_mid[2]; - int16_t lpcQuantization; + Word16 lpcQuantization; Word16 numlpc; - int16_t encoderLookahead_enc; - int16_t encoderPastSamples_enc; - int16_t encoderLookahead_FB; + Word16 encoderLookahead_enc; + Word16 encoderPastSamples_enc; + Word16 encoderLookahead_FB; /* pitch_ol for adaptive lag window */ - int16_t old_pitch_la; /* past open loop pitch lag from look-ahead before very short stable pitch detection */ + Word16 old_pitch_la; /* past open loop pitch lag from look-ahead before very short stable pitch detection */ Word16 old_voicing_la; /* past open loop pitch gain from look-ahead */ Word32 band_energies[2 * NB_BANDS]; /* energy in critical bands without minimum noise floor MODE2_E_MIN */ Word16 band_energies_exp; /* exponent for energy in critical bands without minimum noise floor MODE2_E_MIN */ - int16_t acelp_autocorr; /* Optimize acelp in 0 covariance or 1 correlation domain */ + Word16 acelp_autocorr; /* Optimize acelp in 0 covariance or 1 correlation domain */ - int16_t pit_min; - int16_t pit_fr1; - int16_t pit_fr1b; - int16_t pit_fr2; - int16_t pit_max; - int16_t pit_res_max; + Word16 pit_min; + Word16 pit_fr1; + Word16 pit_fr1b; + Word16 pit_fr2; + Word16 pit_max; + Word16 pit_res_max; /* for FAC */ - int16_t L_frame_past; + Word16 L_frame_past; /*Adaptive BPF*/ - int16_t bpf_gain_param; + Word16 bpf_gain_param; Word32 mem_bpf_fx1[2 * L_FILT16k]; Word32 mem_error_bpf_fx[2 * L_FILT16k]; Word16 bpf_T[NB_SUBFR16k]; @@ -1726,24 +1724,24 @@ typedef struct enc_core_structure Word16 noise_shift_old; } mem_bpf_fx; - int16_t glr; - int16_t glr_idx[2]; + Word16 glr; + Word16 glr_idx[2]; Word32 mean_gc[2]; /* Q15 */ Word16 prev_lsf4_mean; /* Qlog2(2.56) */ - int16_t glr_reset; - int32_t last_sr_core; + Word16 glr_reset; + Word32 last_sr_core; Word16 last_stab_fac; /* Q15 */ Word32 gain_code[NB_SUBFR16k]; /*for rate switching*/ - int16_t rate_switching_reset; /*Rate switching flag requiring a reset of memories at least partially */ - int16_t rate_switching_reset_16kHz; + Word16 rate_switching_reset; /*Rate switching flag requiring a reset of memories at least partially */ + Word16 rate_switching_reset_16kHz; - int16_t enablePlcWaveadjust; - int16_t Tonal_SideInfo; + Word16 enablePlcWaveadjust; + Word16 Tonal_SideInfo; - int16_t seed_acelp; + Word16 seed_acelp; PLC_ENC_EVS_HANDLE hPlcExt; @@ -1752,23 +1750,23 @@ typedef struct enc_core_structure *----------------------------------------------------------------------------------*/ IGF_ENC_INSTANCE_HANDLE hIGFEnc; /* IGF encoder handle */ - int16_t igf; + Word16 igf; /*----------------------------------------------------------------------------------* * TEC *----------------------------------------------------------------------------------*/ - int16_t tec_tfa; + Word16 tec_tfa; TEC_ENC_HANDLE hTECEnc; /* TEC encoder handle */ - int16_t tec_flag; - int16_t tfa_flag; + Word16 tec_flag; + Word16 tfa_flag; Word32 tfa_enr[N_TEC_TFA_SUBFR]; /*---------------------------------------------------------------* * IVAS parameters *---------------------------------------------------------------*/ - int16_t tdm_LRTD_flag; /* LRTD stereo mode flag */ + Word16 tdm_LRTD_flag; /* LRTD stereo mode flag */ Word16 cna_dirac_flag; /* CNA in DirAC flag */ /* stereo switching memories */ @@ -1813,24 +1811,24 @@ typedef struct enc_core_structure Word16 prev_lpc_wb_fx[LPC_SHB_ORDER_WB]; Word16 prev_lsp_wb_temp_fx[LPC_SHB_ORDER_WB]; - int16_t sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ + Word16 sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ } Encoder_State, *ENC_CORE_HANDLE; typedef struct GainItemStr { - int16_t gainIndex; + Word16 gainIndex; } GainItem; typedef struct context_rc_mem_struct { - int16_t nbits_old; - int16_t ctx; + Word16 nbits_old; + Word16 ctx; Word64 bit_estimate_fx; /* Q23 */ - int16_t rateFlag; - int16_t lastnz; - int16_t nt_half; + Word16 rateFlag; + Word16 lastnz; + Word16 nt_half; } RC_CONTEXT_MEM, *HANDLE_RC_CONTEXT_MEM; diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 2ca0b6d74..b1a3f2f20 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -282,7 +282,7 @@ void wb_bwe_enc_ivas_fx( *-------------------------------------------------------------------*/ void swb_bwe_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ - const int16_t last_element_mode, /* i : last element mode */ + const Word16 last_element_mode, /* i : last element mode */ Word16 *old_input_12k8_fx, /* i : input signal @12.8kHz for SWB BWE */ Word16 *old_input_16k_fx, /* i : input signal @16kHz for SWB BWE */ const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 3bad5fa7f..7bbc54780 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1390,7 +1390,7 @@ void swb_pre_proc_ivas_fx( } /* Dirty downsampling to match Nyquist to upper frequency limit of target */ - lerp( st->input_fx, new_swb_speech, L_resamp, (int16_t) Mpy_32_32( input_Fs, one_by_50_Q31 ) ); + lerp( st->input_fx, new_swb_speech, L_resamp, extract_l( Mpy_32_32( input_Fs, one_by_50_Q31 ) ) ); /* flip the spectrum */ Copy( new_swb_speech, spchTmp, L_resamp ); diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 2a6f040ac..7247b6446 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -48,14 +48,12 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, Word8 *noiseFlags, Word16 lowpassLine ) { - Word16 i, lastTone; + Word16 i, lastTone, j; Word32 s, c; Word16 tmp16; Word32 tmp1, tmp2 = 0; /* initialization only to avoid compiler warning, not counted */ move32(); - int j; - IF( resetMemory != 0 ) { FOR( i = 0; i < lowpassLine; i++ ) @@ -81,7 +79,7 @@ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, i = sub( startLine, 1 ); s = 0; move32(); - for ( j = -7; j < 8; j++ ) + FOR( j = -7; j < 8; j++ ) { s = L_add( s, L_shr( powerSpec[i + j], 4 ) ); } diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index 82d24ceba..3c88ca224 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -1288,7 +1288,7 @@ static void UpdateDelayBuffer( Word16 const *input, Word16 nSamplesAvailable, De move16(); nDelay = pDelayBuffer->nDelay; - assert( ( nDelay >= 0 ) && ( nDelay <= (int) sizeof( pDelayBuffer->buffer ) / (int) sizeof( pDelayBuffer->buffer[0] ) ) ); + assert( ( nDelay >= 0 ) && ( nDelay <= (Word32) sizeof( pDelayBuffer->buffer ) / (Word32) sizeof( pDelayBuffer->buffer[0] ) ) ); assert( nSamplesAvailable <= NSUBBLOCKS * pDelayBuffer->nSubblockSize ); /* If this is not the last frame */ IF( EQ_16( nSamplesAvailable, imult1616( NSUBBLOCKS, pDelayBuffer->nSubblockSize ) ) ) @@ -1307,7 +1307,7 @@ static void UpdateSubblockEnergies( Word16 const *input, Word16 nSamplesAvailabl Word16 i; - assert( ( pSubblockEnergies->nDelay >= 0 ) && ( pSubblockEnergies->nDelay + NSUBBLOCKS <= (int) sizeof( pSubblockEnergies->subblockNrg ) / (int) sizeof( pSubblockEnergies->subblockNrg[0] ) ) ); + assert( ( pSubblockEnergies->nDelay >= 0 ) && ( pSubblockEnergies->nDelay + NSUBBLOCKS <= (Word32) sizeof( pSubblockEnergies->subblockNrg ) / (Word32) sizeof( pSubblockEnergies->subblockNrg[0] ) ) ); assert( pSubblockEnergies->nPartialDelay <= pSubblockEnergies->pDelayBuffer->nDelay ); /* At least one block delay is required when subblock energy change is required */ assert( pSubblockEnergies->nDelay >= 1 ); @@ -1332,7 +1332,7 @@ static void UpdateSubblockEnergies_ivas_fx( Word16 const *input, Word16 nSamples Word16 i; - assert( ( pSubblockEnergies->nDelay >= 0 ) && ( pSubblockEnergies->nDelay + NSUBBLOCKS <= (int) sizeof( pSubblockEnergies->subblockNrg ) / (int) sizeof( pSubblockEnergies->subblockNrg[0] ) ) ); + assert( ( pSubblockEnergies->nDelay >= 0 ) && ( pSubblockEnergies->nDelay + NSUBBLOCKS <= (Word32) sizeof( pSubblockEnergies->subblockNrg ) / (Word32) sizeof( pSubblockEnergies->subblockNrg[0] ) ) ); assert( pSubblockEnergies->nPartialDelay <= pSubblockEnergies->pDelayBuffer->nDelay ); /* At least one block delay is required when subblock energy change is required */ assert( pSubblockEnergies->nDelay >= 1 ); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 7e41581f4..730705ffd 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -83,8 +83,8 @@ Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; typedef struct hrtfGainCache { - int16_t azi; - int16_t ele; + Word16 azi; + Word16 ele; Word32 shVec_fx[HRTF_SH_CHANNELS]; @@ -92,13 +92,13 @@ typedef struct hrtfGainCache typedef struct parambin_rend_config_data { - int16_t separateCenterChannelRendering; + Word16 separateCenterChannelRendering; IVAS_FORMAT ivas_format; MC_MODE mc_mode; - int32_t ivas_total_brate; - int16_t nchan_transport; + Word32 ivas_total_brate; + Word16 nchan_transport; Word32 qualityBasedSmFactor_fx; /* Q31 */ - int16_t processReverb; + Word16 processReverb; ISM_MODE ism_mode; } PARAMBIN_REND_CONFIG, *PARAMBIN_REND_CONFIG_HANDLE; @@ -113,7 +113,7 @@ static void ivas_dirac_dec_decorrelate_slot_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBi static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q*/, Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q*/, Word32 Rmat_fx[3][3] /*Q30*/, const Word16 subframe, const Word16 isHeadtracked, const MASA_ISM_DATA_HANDLE hMasaIsmData, Word16 q ); -static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const int16_t max_band_decorr, Word32 Rmat[3][3] /*Q30*/, const Word16 subframe, const Word16 isHeadtracked, const Word16 nchanSeparateChannels, const MASA_ISM_DATA_HANDLE hMasaIsmData ); +static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const Word16 max_band_decorr, Word32 Rmat[3][3] /*Q30*/, const Word16 subframe, const Word16 isHeadtracked, const Word16 nchanSeparateChannels, const MASA_ISM_DATA_HANDLE hMasaIsmData ); static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[] /*q_out*/, Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat ); @@ -137,8 +137,8 @@ static void matrixTransp2Mul_fx( Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, #ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx - int Ascale, - int Bscale, + Word32 Ascale, + Word32 Bscale, #endif Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, @@ -3810,8 +3810,8 @@ static void matrixTransp2Mul_fx( Word32 Bim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_B*/ Word16 *q_B, #ifdef FIX_1072_SPEEDUP_matrixTransp2Mul_fx - int Ascale, - int Bscale, + Word32 Ascale, + Word32 Bscale, #endif Word32 outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ Word32 outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], /*q_out*/ diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index 32803f6c3..e89414542 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -67,7 +67,7 @@ *------------------------------------------------------------------------*/ static void get_lattice_coeffs_fx( const Word16 band_index, const Word16 channel_index, Word16 *lattice_coeffs ); -static void lattice2allpass_fx( const int16_t filter_length, const Word16 *lattice_coeffs_fx, Word16 *filter_coeffs_num_real_fx, Word16 *filter_coeffs_den_real_fx ); +static void lattice2allpass_fx( const Word16 filter_length, const Word16 *lattice_coeffs_fx, Word16 *filter_coeffs_num_real_fx, Word16 *filter_coeffs_den_real_fx ); /*------------------------------------------------------------------------- * ivas_dirac_dec_decorr_open() @@ -1280,7 +1280,7 @@ static void get_lattice_coeffs_fx( /* convert lattice filter coeffs to all pass transfer function coeffs */ static void lattice2allpass_fx( - const int16_t filter_length, // Q0 + const Word16 filter_length, // Q0 const Word16 *lattice_coeffs_fx, // Q15 Word16 *filter_coeffs_num_real_fx, // Q12 Word16 *filter_coeffs_den_real_fx ) // Q12 diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 6b41815c4..c8e6aa12f 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -165,13 +165,13 @@ static ivas_error calc_jot_t60_coeffs_fx( Word16 *pH_dB_fx, Word16 pH_dB_exp, co * *------------------------------------------------------------------------*/ -static uint16_t binRend_rand( +static UWord16 binRend_rand( REVERB_STRUCT_HANDLE hReverb /* i/o: binaural reverb handle */ ) { hReverb->binRend_RandNext = hReverb->binRend_RandNext * 1103515245 + 12345; - return (uint16_t) ( hReverb->binRend_RandNext / 65536 ) % 32768; + return (UWord16) ( hReverb->binRend_RandNext / 65536 ) % 32768; } @@ -886,9 +886,9 @@ static ivas_error calc_jot_t60_coeffs_fx( Word32 L_tmp; Word16 f0_fx, tmp_fx, lf_target_gain_dB_fx, hf_target_gain_dB_fx, mid_crossing_gain_dB_fx; Word16 lin_gain_lf_fx, lin_gain_hf_fx, shift, expl, exph; - int16_t f_idx, e = pH_dB_exp; + Word16 f_idx, e = pH_dB_exp; move16(); - uint16_t n_points_lf, n_points_hf; + UWord16 n_points_lf, n_points_hf; lf_target_gain_dB_fx = 0; move16(); @@ -1471,7 +1471,7 @@ ivas_error ivas_reverb_open_fx( { ivas_error error; REVERB_HANDLE pState = NULL; - Word16 bin_idx, subframe_len, output_frame, predelay_bf_len, loop_idx; + Word16 bin_idx, subframe_len, output_frame, predelay_bf_len, loop_idx, i; ivas_reverb_params_t params; Word32 pColor_target_l_fx[RV_LENGTH_NR_FC]; Word32 pColor_target_r_fx[RV_LENGTH_NR_FC]; @@ -1559,7 +1559,7 @@ ivas_error ivas_reverb_open_fx( set_reverb_acoustic_data_fx( ¶ms, input_audio_config, hHrtf, &hRenderConfig->roomAcoustics, subframe_len, nr_fc_input, nr_fc_fft_filter ); Scale_sig32( params.pFc_fx, nr_fc_fft_filter, -2 ); - FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { params.pRt60_fx[i] = L_abs( params.pRt60_fx[i] ); move32(); @@ -1601,7 +1601,7 @@ ivas_error ivas_reverb_open_fx( Word32 *pT60_filter_coeff = (Word32 *) malloc( ( lenT60_filter_coeff ) * sizeof( Word32 * ) ); - FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { params.pDsr_fx[i] = L_shl( params.pDsr_fx[i], params.pDsr_e[i] ); move32(); @@ -1610,7 +1610,7 @@ ivas_error ivas_reverb_open_fx( pHrtf_avg_pwr_response_r_const[i] = L_shl( params.pHrtf_avg_pwr_response_r_const_fx[i], 5 ); /*Q23+5*/ move32(); } - FOR( Word16 i = 0; i < lenT60_filter_coeff; i++ ) + FOR( i = 0; i < lenT60_filter_coeff; i++ ) { pT60_filter_coeff[i] = L_shl_sat( params.pT60_filter_coeff_fx[i], 17 ); move32(); @@ -1648,20 +1648,20 @@ ivas_error ivas_reverb_open_fx( { /* Computing correlation filters on the basis of target IA coherence */ #ifdef MSAN_FIX - FOR( int i = 0; i < shl( sub( nr_fc_fft_filter, 1 ), 1 ); i++ ) + FOR( i = 0; i < shl( sub( nr_fc_fft_filter, 1 ), 1 ); i++ ) { pTime_window_fx[i] = L_shr( pTime_window_fx[i], 1 ); /*Scaling signal down to 30*/ move32(); } #else - FOR( int i = 0; i < RV_FILTER_MAX_FFT_SIZE; i++ ) + FOR( i = 0; i < RV_FILTER_MAX_FFT_SIZE; i++ ) { pTime_window_fx[i] = L_shr( pTime_window_fx[i], 1 ); /*Scaling signal down to 30*/ } #endif // MSAN_FIX Word32 *pHrtf_inter_aural_coherence_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 ) ); - FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { pHrtf_inter_aural_coherence_const[i] = L_shl( params.pHrtf_inter_aural_coherence_const_fx[i], 3 ); /*Scaling up to Q30*/ move32(); @@ -1670,14 +1670,14 @@ ivas_error ivas_reverb_open_fx( free( pHrtf_inter_aural_coherence_const ); - FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { pFft_wf_filter_ch0_fx[i][0] = L_shl( pFft_wf_filter_ch0_fx[i][0], sub( 31, q_pFft_wf_filter_ch0_fx ) ); move32(); pFft_wf_filter_ch0_fx[i][1] = L_shl( pFft_wf_filter_ch0_fx[i][1], sub( 31, q_pFft_wf_filter_ch0_fx ) ); move32(); } - FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { pFft_wf_filter_ch1_fx[i][0] = L_shl( pFft_wf_filter_ch1_fx[i][0], sub( 31, q_pFft_wf_filter_ch1_fx ) ); move32(); @@ -1699,14 +1699,14 @@ ivas_error ivas_reverb_open_fx( /* Computing coloration filters on the basis of target responses */ ivas_reverb_calc_color_filters_fx( pColor_target_l_fx, pColor_target_r_fx, pTime_window_fx, pState->fft_size, pFft_wf_filter_ch0_fx, pFft_wf_filter_ch1_fx, &q_pFft_wf_filter_ch0_fx, &q_pFft_wf_filter_ch1_fx ); - FOR( int i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { pFft_wf_filter_ch0_fx[i][0] = L_shl( pFft_wf_filter_ch0_fx[i][0], sub( 31, q_pFft_wf_filter_ch0_fx ) ); move32(); pFft_wf_filter_ch0_fx[i][1] = L_shl( pFft_wf_filter_ch0_fx[i][1], sub( 31, q_pFft_wf_filter_ch0_fx ) ); move32(); } - FOR( Word16 i = 0; i < nr_fc_fft_filter; i++ ) + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { pFft_wf_filter_ch1_fx[i][0] = L_shl( pFft_wf_filter_ch1_fx[i][0], sub( 31, q_pFft_wf_filter_ch1_fx ) ); move32(); @@ -2492,7 +2492,7 @@ ivas_error ivas_binaural_reverb_open_parambin( const Word16 numBins, /* i : number of CLDFB bins Q0 */ const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame Q0 */ IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const int32_t sampling_rate, /* i : sampling rate Q0 */ + const Word32 sampling_rate, /* i : sampling rate Q0 */ const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ ) { diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index bc0d3cd17..2b4c3e919 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -56,13 +56,13 @@ extern Word32 CRendBin_Combined_HRIR_latency_s_fx; /* Sample Rate = 48000 */ -extern int16_t CRendBin_Combined_HRIR_max_num_iterations_48kHz; -extern uint16_t CRendBin_Combined_HRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz; +extern Word16 CRendBin_Combined_HRIR_max_num_iterations_48kHz; +extern UWord16 CRendBin_Combined_HRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz; extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz_fx[15]; -extern uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_Combined_HRIR_coeff_re_48kHz_fx[15][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_Combined_HRIR_coeff_im_48kHz_fx[15][BINAURAL_CHANNELS][240]; extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; @@ -70,13 +70,13 @@ extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNEL /* Sample Rate = 32000 */ -extern int16_t CRendBin_Combined_HRIR_max_num_iterations_32kHz; -extern uint16_t CRendBin_Combined_HRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz; +extern Word16 CRendBin_Combined_HRIR_max_num_iterations_32kHz; +extern UWord16 CRendBin_Combined_HRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz; extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz_fx[15]; -extern uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_Combined_HRIR_coeff_re_32kHz_fx[15][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_Combined_HRIR_coeff_im_32kHz_fx[15][BINAURAL_CHANNELS][160]; extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; @@ -84,13 +84,13 @@ extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNEL /* Sample Rate = 16000 */ -extern int16_t CRendBin_Combined_HRIR_max_num_iterations_16kHz; -extern uint16_t CRendBin_Combined_HRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz; +extern Word16 CRendBin_Combined_HRIR_max_num_iterations_16kHz; +extern UWord16 CRendBin_Combined_HRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz; extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz_fx[15]; -extern uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_Combined_HRIR_coeff_re_16kHz_fx[15][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_Combined_HRIR_coeff_im_16kHz_fx[15][BINAURAL_CHANNELS][80]; extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; @@ -105,13 +105,13 @@ extern Word32 CRendBin_FOA_HRIR_latency_s_fx; /* Sample Rate = 48000 */ -extern int16_t CRendBin_FOA_HRIR_max_num_iterations_48kHz; -extern uint16_t CRendBin_FOA_HRIR_num_iterations_48kHz[4][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[4][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz; +extern Word16 CRendBin_FOA_HRIR_max_num_iterations_48kHz; +extern UWord16 CRendBin_FOA_HRIR_num_iterations_48kHz[4][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[4][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz; extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz_fx[4]; -extern uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_FOA_HRIR_coeff_re_48kHz_fx[4][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_FOA_HRIR_coeff_im_48kHz_fx[4][BINAURAL_CHANNELS][240]; extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; @@ -119,13 +119,13 @@ extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ -extern int16_t CRendBin_FOA_HRIR_max_num_iterations_32kHz; -extern uint16_t CRendBin_FOA_HRIR_num_iterations_32kHz[4][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[4][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz; +extern Word16 CRendBin_FOA_HRIR_max_num_iterations_32kHz; +extern UWord16 CRendBin_FOA_HRIR_num_iterations_32kHz[4][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[4][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz; extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz_fx[4]; -extern uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_FOA_HRIR_coeff_re_32kHz_fx[4][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_FOA_HRIR_coeff_im_32kHz_fx[4][BINAURAL_CHANNELS][160]; extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; @@ -133,13 +133,13 @@ extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 16000 */ -extern int16_t CRendBin_FOA_HRIR_max_num_iterations_16kHz; -extern uint16_t CRendBin_FOA_HRIR_num_iterations_16kHz[4][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[4][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz; +extern Word16 CRendBin_FOA_HRIR_max_num_iterations_16kHz; +extern UWord16 CRendBin_FOA_HRIR_num_iterations_16kHz[4][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[4][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz; extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz_fx[4]; -extern uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_FOA_HRIR_coeff_re_16kHz_fx[4][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_FOA_HRIR_coeff_im_16kHz_fx[4][BINAURAL_CHANNELS][80]; extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; @@ -153,13 +153,13 @@ extern Word32 CRendBin_HOA2_HRIR_latency_s_fx; /* Sample Rate = 48000 */ -extern int16_t CRendBin_HOA2_HRIR_max_num_iterations_48kHz; -extern uint16_t CRendBin_HOA2_HRIR_num_iterations_48kHz[9][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[9][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz; +extern Word16 CRendBin_HOA2_HRIR_max_num_iterations_48kHz; +extern UWord16 CRendBin_HOA2_HRIR_num_iterations_48kHz[9][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[9][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz; extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz_fx[9]; -extern uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA2_HRIR_coeff_re_48kHz_fx[9][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_HOA2_HRIR_coeff_im_48kHz_fx[9][BINAURAL_CHANNELS][240]; extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; @@ -167,13 +167,13 @@ extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ -extern int16_t CRendBin_HOA2_HRIR_max_num_iterations_32kHz; -extern uint16_t CRendBin_HOA2_HRIR_num_iterations_32kHz[9][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[9][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz; +extern Word16 CRendBin_HOA2_HRIR_max_num_iterations_32kHz; +extern UWord16 CRendBin_HOA2_HRIR_num_iterations_32kHz[9][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[9][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz; extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz_fx[9]; -extern uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA2_HRIR_coeff_re_32kHz_fx[9][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_HOA2_HRIR_coeff_im_32kHz_fx[9][BINAURAL_CHANNELS][160]; extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; @@ -181,13 +181,13 @@ extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 16000 */ -extern int16_t CRendBin_HOA2_HRIR_max_num_iterations_16kHz; -extern uint16_t CRendBin_HOA2_HRIR_num_iterations_16kHz[9][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[9][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz; +extern Word16 CRendBin_HOA2_HRIR_max_num_iterations_16kHz; +extern UWord16 CRendBin_HOA2_HRIR_num_iterations_16kHz[9][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[9][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz; extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz_fx[9]; -extern uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA2_HRIR_coeff_re_16kHz_fx[9][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_HOA2_HRIR_coeff_im_16kHz_fx[9][BINAURAL_CHANNELS][80]; extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; @@ -200,13 +200,13 @@ extern Word32 CRendBin_HOA3_HRIR_latency_s_fx; /* Sample Rate = 48000 */ -extern int16_t CRendBin_HOA3_HRIR_max_num_iterations_48kHz; -extern uint16_t CRendBin_HOA3_HRIR_num_iterations_48kHz[16][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[16][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz; +extern Word16 CRendBin_HOA3_HRIR_max_num_iterations_48kHz; +extern UWord16 CRendBin_HOA3_HRIR_num_iterations_48kHz[16][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[16][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz; extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz_fx[16]; -extern uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA3_HRIR_coeff_re_48kHz_fx[16][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_HOA3_HRIR_coeff_im_48kHz_fx[16][BINAURAL_CHANNELS][240]; extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; @@ -214,13 +214,13 @@ extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ -extern int16_t CRendBin_HOA3_HRIR_max_num_iterations_32kHz; -extern uint16_t CRendBin_HOA3_HRIR_num_iterations_32kHz[16][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[16][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz; +extern Word16 CRendBin_HOA3_HRIR_max_num_iterations_32kHz; +extern UWord16 CRendBin_HOA3_HRIR_num_iterations_32kHz[16][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[16][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz; extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz_fx[16]; -extern uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA3_HRIR_coeff_re_32kHz_fx[16][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_HOA3_HRIR_coeff_im_32kHz_fx[16][BINAURAL_CHANNELS][160]; extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; @@ -228,13 +228,13 @@ extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 16000 */ -extern int16_t CRendBin_HOA3_HRIR_max_num_iterations_16kHz; -extern uint16_t CRendBin_HOA3_HRIR_num_iterations_16kHz[16][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[16][BINAURAL_CHANNELS][1]; -extern uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz; +extern Word16 CRendBin_HOA3_HRIR_max_num_iterations_16kHz; +extern UWord16 CRendBin_HOA3_HRIR_num_iterations_16kHz[16][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[16][BINAURAL_CHANNELS][1]; +extern UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz; extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz_fx[16]; -extern uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA3_HRIR_coeff_re_16kHz_fx[16][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_HOA3_HRIR_coeff_im_16kHz_fx[16][BINAURAL_CHANNELS][80]; extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; @@ -248,13 +248,13 @@ extern Word32 CRendBin_Combined_BRIR_latency_s_fx; /* Sample Rate = 48000 */ -extern int16_t CRendBin_Combined_BRIR_max_num_iterations_48kHz; -extern uint16_t CRendBin_Combined_BRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][22]; -extern uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz; +extern Word16 CRendBin_Combined_BRIR_max_num_iterations_48kHz; +extern UWord16 CRendBin_Combined_BRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][22]; +extern UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz; extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz_fx[15]; -extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]; +extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]; extern Word32 CRendBin_Combined_BRIR_coeff_re_48kHz_fx[15][BINAURAL_CHANNELS][2955]; extern Word32 CRendBin_Combined_BRIR_coeff_im_48kHz_fx[15][BINAURAL_CHANNELS][2955]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS][2885]; @@ -262,13 +262,13 @@ extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS /* Sample Rate = 32000 */ -extern int16_t CRendBin_Combined_BRIR_max_num_iterations_32kHz; -extern uint16_t CRendBin_Combined_BRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][22]; -extern uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz; +extern Word16 CRendBin_Combined_BRIR_max_num_iterations_32kHz; +extern UWord16 CRendBin_Combined_BRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][22]; +extern UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz; extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz_fx[15]; -extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]; +extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]; extern Word32 CRendBin_Combined_BRIR_coeff_re_32kHz_fx[15][BINAURAL_CHANNELS][2819]; extern Word32 CRendBin_Combined_BRIR_coeff_im_32kHz_fx[15][BINAURAL_CHANNELS][2819]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS][2870]; @@ -276,13 +276,13 @@ extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS /* Sample Rate = 16000 */ -extern int16_t CRendBin_Combined_BRIR_max_num_iterations_16kHz; -extern uint16_t CRendBin_Combined_BRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; -extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][23]; -extern uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz; +extern Word16 CRendBin_Combined_BRIR_max_num_iterations_16kHz; +extern UWord16 CRendBin_Combined_BRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; +extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][23]; +extern UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz; extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz_fx[15]; -extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]; +extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]; extern Word32 CRendBin_Combined_BRIR_coeff_re_16kHz_fx[15][BINAURAL_CHANNELS][1774]; extern Word32 CRendBin_Combined_BRIR_coeff_im_16kHz_fx[15][BINAURAL_CHANNELS][1774]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS][2522]; diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c index 068ce0927..be015058b 100644 --- a/lib_rend/ivas_rom_binaural_crend_head_fx.c +++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c @@ -56,35 +56,35 @@ const Word32 CRendBin_Combined_HRIR_latency_s_fx = 44741;/*Q-31*/ /* Sample Rate = 48000 */ -const int16_t CRendBin_Combined_HRIR_max_num_iterations_48kHz = 1; -const uint16_t CRendBin_Combined_HRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; -const uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz = 0; +const Word16 CRendBin_Combined_HRIR_max_num_iterations_48kHz = 1; +const UWord16 CRendBin_Combined_HRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; +const UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz = 0; const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz_fx[15]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; -const uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 32000 */ -const int16_t CRendBin_Combined_HRIR_max_num_iterations_32kHz = 1; -const uint16_t CRendBin_Combined_HRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; -const uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz = 0; +const Word16 CRendBin_Combined_HRIR_max_num_iterations_32kHz = 1; +const UWord16 CRendBin_Combined_HRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; +const UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz = 0; const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz_fx[15]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; -const uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 16000 */ -const int16_t CRendBin_Combined_HRIR_max_num_iterations_16kHz = 1; -const uint16_t CRendBin_Combined_HRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; -const uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz = 0; +const Word16 CRendBin_Combined_HRIR_max_num_iterations_16kHz = 1; +const UWord16 CRendBin_Combined_HRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; +const UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz = 0; const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz_fx[15]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; -const uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -96,35 +96,35 @@ const Word32 CRendBin_FOA_HRIR_latency_s_fx = 44741; // Q31 /* Sample Rate = 48000 */ -const int16_t CRendBin_FOA_HRIR_max_num_iterations_48kHz = 1; -const uint16_t CRendBin_FOA_HRIR_num_iterations_48kHz[4][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[4][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; -const uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz = 0; +const Word16 CRendBin_FOA_HRIR_max_num_iterations_48kHz = 1; +const UWord16 CRendBin_FOA_HRIR_num_iterations_48kHz[4][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[4][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; +const UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz = 0; const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz_fx[4]={0, 0, 0, 0}; -const uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 32000 */ -const int16_t CRendBin_FOA_HRIR_max_num_iterations_32kHz = 1; -const uint16_t CRendBin_FOA_HRIR_num_iterations_32kHz[4][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[4][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; -const uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz = 0; +const Word16 CRendBin_FOA_HRIR_max_num_iterations_32kHz = 1; +const UWord16 CRendBin_FOA_HRIR_num_iterations_32kHz[4][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[4][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; +const UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz = 0; const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz_fx[4]={0, 0, 0, 0}; -const uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 16000 */ -const int16_t CRendBin_FOA_HRIR_max_num_iterations_16kHz = 1; -const uint16_t CRendBin_FOA_HRIR_num_iterations_16kHz[4][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[4][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; -const uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz = 0; +const Word16 CRendBin_FOA_HRIR_max_num_iterations_16kHz = 1; +const UWord16 CRendBin_FOA_HRIR_num_iterations_16kHz[4][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[4][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; +const UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz = 0; const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz_fx[4]={0, 0, 0, 0}; -const uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -135,35 +135,35 @@ const Word32 CRendBin_HOA2_HRIR_latency_s_fx = 44741; // Q31 /* Sample Rate = 48000 */ -const int16_t CRendBin_HOA2_HRIR_max_num_iterations_48kHz = 1; -const uint16_t CRendBin_HOA2_HRIR_num_iterations_48kHz[9][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[9][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; -const uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz = 0; +const Word16 CRendBin_HOA2_HRIR_max_num_iterations_48kHz = 1; +const UWord16 CRendBin_HOA2_HRIR_num_iterations_48kHz[9][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[9][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; +const UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz = 0; const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz_fx[9]={0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 32000 */ -const int16_t CRendBin_HOA2_HRIR_max_num_iterations_32kHz = 1; -const uint16_t CRendBin_HOA2_HRIR_num_iterations_32kHz[9][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[9][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; -const uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz = 0; +const Word16 CRendBin_HOA2_HRIR_max_num_iterations_32kHz = 1; +const UWord16 CRendBin_HOA2_HRIR_num_iterations_32kHz[9][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[9][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; +const UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz = 0; const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz_fx[9]={0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 16000 */ -const int16_t CRendBin_HOA2_HRIR_max_num_iterations_16kHz = 1; -const uint16_t CRendBin_HOA2_HRIR_num_iterations_16kHz[9][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[9][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; -const uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz = 0; +const Word16 CRendBin_HOA2_HRIR_max_num_iterations_16kHz = 1; +const UWord16 CRendBin_HOA2_HRIR_num_iterations_16kHz[9][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[9][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; +const UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz = 0; const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz_fx[9]={0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -173,36 +173,36 @@ const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={N const Word32 CRendBin_HOA3_HRIR_latency_s_fx = 44741;/*Q-31*/ /* Sample Rate = 48000 */ -const int16_t CRendBin_HOA3_HRIR_max_num_iterations_48kHz = 1; -const uint16_t CRendBin_HOA3_HRIR_num_iterations_48kHz[16][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[16][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; -const uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz = 0; +const Word16 CRendBin_HOA3_HRIR_max_num_iterations_48kHz = 1; +const UWord16 CRendBin_HOA3_HRIR_num_iterations_48kHz[16][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[16][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; +const UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz = 0; const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz_fx[16]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 32000 */ -const int16_t CRendBin_HOA3_HRIR_max_num_iterations_32kHz = 1; -const uint16_t CRendBin_HOA3_HRIR_num_iterations_32kHz[16][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[16][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; -const uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz = 0; +const Word16 CRendBin_HOA3_HRIR_max_num_iterations_32kHz = 1; +const UWord16 CRendBin_HOA3_HRIR_num_iterations_32kHz[16][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[16][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; +const UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz = 0; const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz_fx[16]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; /* Sample Rate = 16000 */ -const int16_t CRendBin_HOA3_HRIR_max_num_iterations_16kHz = 1; -const uint16_t CRendBin_HOA3_HRIR_num_iterations_16kHz[16][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; -const uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; -const uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[16][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; -const uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz = 0; +const Word16 CRendBin_HOA3_HRIR_max_num_iterations_16kHz = 1; +const UWord16 CRendBin_HOA3_HRIR_num_iterations_16kHz[16][BINAURAL_CHANNELS]={{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1} }; +const UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; +const UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[16][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; +const UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz = 0; const float CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[16]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz_fx[16]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; +const UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -212,34 +212,34 @@ const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={N const Word32 CRendBin_Combined_BRIR_latency_s_fx = 313176;/*Q-31*/ /* Sample Rate = 48000 */ -const int16_t CRendBin_Combined_BRIR_max_num_iterations_48kHz = 22; -const uint16_t CRendBin_Combined_BRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]={{22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22} }; -const uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {40, 40}; -const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][22]={{{116, 118, 117, 121, 112, 119, 121, 131, 134, 131, 137, 127, 134, 135, 134, 135, 129, 139, 135, 130, 128, 240},{116, 118, 117, 121, 112, 119, 121, 131, 134, 131, 137, 127, 134, 135, 134, 135, 129, 139, 135, 130, 128, 240}},{{122, 106, 121, 114, 121, 123, 119, 126, 123, 126, 127, 130, 128, 136, 132, 131, 129, 141, 137, 131, 129, 240},{122, 106, 121, 114, 121, 123, 119, 126, 123, 126, 127, 130, 128, 136, 132, 131, 129, 141, 137, 131, 129, 240}},{{118, 104, 116, 104, 123, 123, 122, 125, 130, 128, 132, 135, 131, 132, 131, 132, 135, 137, 144, 129, 129, 240},{118, 104, 116, 104, 123, 123, 122, 125, 130, 128, 132, 135, 131, 132, 131, 132, 135, 137, 144, 129, 129, 240}},{{102, 117, 116, 121, 117, 114, 115, 125, 126, 124, 125, 142, 133, 124, 129, 132, 134, 137, 143, 125, 125, 240},{102, 117, 116, 121, 117, 114, 115, 125, 126, 124, 125, 142, 133, 124, 129, 132, 134, 137, 143, 125, 125, 240}},{{116, 115, 117, 120, 121, 119, 125, 129, 123, 129, 124, 127, 128, 143, 133, 131, 136, 141, 158, 127, 131, 240},{116, 115, 117, 120, 121, 119, 125, 129, 123, 129, 124, 127, 128, 143, 133, 131, 136, 141, 158, 127, 131, 240}},{{112, 106, 118, 123, 115, 120, 129, 123, 130, 127, 130, 130, 131, 131, 131, 135, 134, 153, 138, 132, 127, 240},{112, 106, 118, 123, 115, 120, 129, 123, 130, 127, 130, 130, 131, 131, 131, 135, 134, 153, 138, 132, 127, 240}},{{107, 112, 111, 120, 115, 125, 122, 123, 132, 123, 133, 138, 125, 134, 130, 131, 135, 137, 136, 127, 121, 240},{107, 112, 111, 120, 115, 125, 122, 123, 132, 123, 133, 138, 125, 134, 130, 131, 135, 137, 136, 127, 121, 240}},{{111, 113, 132, 115, 121, 123, 121, 127, 135, 128, 129, 128, 133, 130, 133, 138, 134, 137, 152, 138, 124, 240},{111, 113, 132, 115, 121, 123, 121, 127, 135, 128, 129, 128, 133, 130, 133, 138, 134, 137, 152, 138, 124, 240}},{{114, 104, 114, 117, 125, 127, 123, 129, 123, 127, 144, 131, 138, 132, 129, 129, 132, 134, 136, 127, 121, 240},{114, 104, 114, 117, 125, 127, 123, 129, 123, 127, 144, 131, 138, 132, 129, 129, 132, 134, 136, 127, 121, 240}},{{100, 102, 112, 118, 115, 116, 118, 116, 121, 124, 125, 121, 125, 130, 127, 132, 133, 134, 134, 129, 132, 240},{100, 102, 112, 118, 115, 116, 118, 116, 121, 124, 125, 121, 125, 130, 127, 132, 133, 134, 134, 129, 132, 240}},{{106, 93, 103, 108, 124, 111, 114, 115, 120, 121, 119, 123, 131, 130, 132, 132, 132, 131, 140, 129, 131, 240},{106, 93, 103, 108, 124, 111, 114, 115, 120, 121, 119, 123, 131, 130, 132, 132, 132, 131, 140, 129, 131, 240}},{{108, 101, 115, 115, 115, 110, 121, 124, 124, 120, 122, 129, 124, 128, 125, 132, 135, 133, 138, 160, 119, 240},{108, 101, 115, 115, 115, 110, 121, 124, 124, 120, 122, 129, 124, 128, 125, 132, 135, 133, 138, 160, 119, 240}},{{112, 106, 114, 110, 128, 117, 120, 126, 124, 128, 126, 132, 129, 127, 133, 134, 136, 133, 154, 197, 129, 240},{112, 106, 114, 110, 128, 117, 120, 126, 124, 128, 126, 132, 129, 127, 133, 134, 136, 133, 154, 197, 129, 240}},{{102, 107, 111, 116, 116, 120, 118, 115, 120, 119, 128, 131, 131, 130, 128, 126, 126, 132, 145, 136, 133, 240},{102, 107, 111, 116, 116, 120, 118, 115, 120, 119, 128, 131, 131, 130, 128, 126, 126, 132, 145, 136, 133, 240}},{{111, 117, 106, 120, 123, 121, 125, 125, 130, 125, 123, 123, 127, 131, 125, 131, 135, 134, 148, 134, 132, 240},{111, 117, 106, 120, 123, 121, 125, 125, 130, 125, 123, 123, 127, 131, 125, 131, 135, 134, 148, 134, 132, 240}}}; -const uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz = 98; +const Word16 CRendBin_Combined_BRIR_max_num_iterations_48kHz = 22; +const UWord16 CRendBin_Combined_BRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS]={{22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22} }; +const UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {40, 40}; +const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][22]={{{116, 118, 117, 121, 112, 119, 121, 131, 134, 131, 137, 127, 134, 135, 134, 135, 129, 139, 135, 130, 128, 240},{116, 118, 117, 121, 112, 119, 121, 131, 134, 131, 137, 127, 134, 135, 134, 135, 129, 139, 135, 130, 128, 240}},{{122, 106, 121, 114, 121, 123, 119, 126, 123, 126, 127, 130, 128, 136, 132, 131, 129, 141, 137, 131, 129, 240},{122, 106, 121, 114, 121, 123, 119, 126, 123, 126, 127, 130, 128, 136, 132, 131, 129, 141, 137, 131, 129, 240}},{{118, 104, 116, 104, 123, 123, 122, 125, 130, 128, 132, 135, 131, 132, 131, 132, 135, 137, 144, 129, 129, 240},{118, 104, 116, 104, 123, 123, 122, 125, 130, 128, 132, 135, 131, 132, 131, 132, 135, 137, 144, 129, 129, 240}},{{102, 117, 116, 121, 117, 114, 115, 125, 126, 124, 125, 142, 133, 124, 129, 132, 134, 137, 143, 125, 125, 240},{102, 117, 116, 121, 117, 114, 115, 125, 126, 124, 125, 142, 133, 124, 129, 132, 134, 137, 143, 125, 125, 240}},{{116, 115, 117, 120, 121, 119, 125, 129, 123, 129, 124, 127, 128, 143, 133, 131, 136, 141, 158, 127, 131, 240},{116, 115, 117, 120, 121, 119, 125, 129, 123, 129, 124, 127, 128, 143, 133, 131, 136, 141, 158, 127, 131, 240}},{{112, 106, 118, 123, 115, 120, 129, 123, 130, 127, 130, 130, 131, 131, 131, 135, 134, 153, 138, 132, 127, 240},{112, 106, 118, 123, 115, 120, 129, 123, 130, 127, 130, 130, 131, 131, 131, 135, 134, 153, 138, 132, 127, 240}},{{107, 112, 111, 120, 115, 125, 122, 123, 132, 123, 133, 138, 125, 134, 130, 131, 135, 137, 136, 127, 121, 240},{107, 112, 111, 120, 115, 125, 122, 123, 132, 123, 133, 138, 125, 134, 130, 131, 135, 137, 136, 127, 121, 240}},{{111, 113, 132, 115, 121, 123, 121, 127, 135, 128, 129, 128, 133, 130, 133, 138, 134, 137, 152, 138, 124, 240},{111, 113, 132, 115, 121, 123, 121, 127, 135, 128, 129, 128, 133, 130, 133, 138, 134, 137, 152, 138, 124, 240}},{{114, 104, 114, 117, 125, 127, 123, 129, 123, 127, 144, 131, 138, 132, 129, 129, 132, 134, 136, 127, 121, 240},{114, 104, 114, 117, 125, 127, 123, 129, 123, 127, 144, 131, 138, 132, 129, 129, 132, 134, 136, 127, 121, 240}},{{100, 102, 112, 118, 115, 116, 118, 116, 121, 124, 125, 121, 125, 130, 127, 132, 133, 134, 134, 129, 132, 240},{100, 102, 112, 118, 115, 116, 118, 116, 121, 124, 125, 121, 125, 130, 127, 132, 133, 134, 134, 129, 132, 240}},{{106, 93, 103, 108, 124, 111, 114, 115, 120, 121, 119, 123, 131, 130, 132, 132, 132, 131, 140, 129, 131, 240},{106, 93, 103, 108, 124, 111, 114, 115, 120, 121, 119, 123, 131, 130, 132, 132, 132, 131, 140, 129, 131, 240}},{{108, 101, 115, 115, 115, 110, 121, 124, 124, 120, 122, 129, 124, 128, 125, 132, 135, 133, 138, 160, 119, 240},{108, 101, 115, 115, 115, 110, 121, 124, 124, 120, 122, 129, 124, 128, 125, 132, 135, 133, 138, 160, 119, 240}},{{112, 106, 114, 110, 128, 117, 120, 126, 124, 128, 126, 132, 129, 127, 133, 134, 136, 133, 154, 197, 129, 240},{112, 106, 114, 110, 128, 117, 120, 126, 124, 128, 126, 132, 129, 127, 133, 134, 136, 133, 154, 197, 129, 240}},{{102, 107, 111, 116, 116, 120, 118, 115, 120, 119, 128, 131, 131, 130, 128, 126, 126, 132, 145, 136, 133, 240},{102, 107, 111, 116, 116, 120, 118, 115, 120, 119, 128, 131, 131, 130, 128, 126, 126, 132, 145, 136, 133, 240}},{{111, 117, 106, 120, 123, 121, 125, 125, 130, 125, 123, 123, 127, 131, 125, 131, 135, 134, 148, 134, 132, 240},{111, 117, 106, 120, 123, 121, 125, 125, 130, 125, 123, 123, 127, 131, 125, 131, 135, 134, 148, 134, 132, 240}}}; +const UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz = 98; const float CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[15]={0.224183f, 0.227455f, 0.241830f, 0.207155f, 0.218087f, 0.222942f, 0.232158f, 0.248203f, 0.249262f, 0.261591f, 0.246276f, 0.279163f, 0.285701f, 0.262541f, 0.271844f}; const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz_fx[15]={7346, 7453, 7924, 6788, 7146, 7305, 7607, 8133, 8167, 8571, 8069, 9147, 9361, 8602, 8907,}; -const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98},{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98}}; +const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98},{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98}}; /* Sample Rate = 32000 */ -const int16_t CRendBin_Combined_BRIR_max_num_iterations_32kHz = 22; -const uint16_t CRendBin_Combined_BRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]={{22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22} }; -const uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {40, 40}; -const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][22]={{{115, 117, 117, 120, 112, 118, 121, 130, 126, 130, 136, 127, 133, 135, 132, 133, 129, 137, 134, 129, 128, 160},{115, 117, 117, 120, 112, 118, 121, 130, 126, 130, 136, 127, 133, 135, 132, 133, 129, 137, 134, 129, 128, 160}},{{121, 106, 119, 113, 120, 123, 114, 126, 123, 125, 127, 128, 127, 134, 132, 130, 129, 139, 133, 131, 128, 160},{121, 106, 119, 113, 120, 123, 114, 126, 123, 125, 127, 128, 127, 134, 132, 130, 129, 139, 133, 131, 128, 160}},{{113, 103, 116, 104, 123, 123, 122, 124, 130, 128, 132, 131, 131, 132, 130, 132, 130, 135, 137, 128, 128, 160},{113, 103, 116, 104, 123, 123, 122, 124, 130, 128, 132, 131, 131, 132, 130, 132, 130, 135, 137, 128, 128, 160}},{{102, 116, 116, 121, 116, 114, 115, 121, 125, 123, 124, 130, 132, 122, 127, 131, 131, 135, 133, 124, 125, 160},{102, 116, 116, 121, 116, 114, 115, 121, 125, 123, 124, 130, 132, 122, 127, 131, 131, 135, 133, 124, 125, 160}},{{115, 115, 115, 119, 121, 119, 125, 127, 123, 129, 122, 126, 128, 134, 130, 130, 131, 140, 146, 127, 131, 160},{115, 115, 115, 119, 121, 119, 125, 127, 123, 129, 122, 126, 128, 134, 130, 130, 131, 140, 146, 127, 131, 160}},{{112, 106, 118, 121, 115, 117, 129, 123, 128, 126, 130, 130, 131, 131, 130, 134, 133, 149, 130, 132, 126, 160},{112, 106, 118, 121, 115, 117, 129, 123, 128, 126, 130, 130, 131, 131, 130, 134, 133, 149, 130, 132, 126, 160}},{{107, 112, 110, 119, 114, 124, 121, 121, 132, 122, 131, 134, 124, 133, 130, 129, 134, 134, 135, 127, 120, 160},{107, 112, 110, 119, 114, 124, 121, 121, 132, 122, 131, 134, 124, 133, 130, 129, 134, 134, 135, 127, 120, 160}},{{110, 113, 123, 113, 121, 120, 120, 126, 131, 123, 128, 128, 132, 130, 132, 136, 133, 136, 135, 128, 124, 160},{110, 113, 123, 113, 121, 120, 120, 126, 131, 123, 128, 128, 132, 130, 132, 136, 133, 136, 135, 128, 124, 160}},{{114, 101, 113, 113, 124, 126, 123, 128, 122, 127, 132, 127, 136, 128, 128, 127, 132, 132, 129, 125, 120, 160},{114, 101, 113, 113, 124, 126, 123, 128, 122, 127, 132, 127, 136, 128, 128, 127, 132, 132, 129, 125, 120, 160}},{{99, 100, 111, 117, 114, 114, 118, 116, 121, 124, 124, 121, 125, 130, 127, 132, 132, 130, 133, 128, 131, 160},{99, 100, 111, 117, 114, 114, 118, 116, 121, 124, 124, 121, 125, 130, 127, 132, 132, 130, 133, 128, 131, 160}},{{105, 93, 103, 108, 119, 110, 111, 114, 120, 121, 119, 122, 130, 128, 130, 131, 132, 131, 136, 128, 128, 160},{105, 93, 103, 108, 119, 110, 111, 114, 120, 121, 119, 122, 130, 128, 130, 131, 132, 131, 136, 128, 128, 160}},{{105, 100, 112, 114, 115, 108, 117, 120, 123, 117, 122, 129, 124, 128, 124, 132, 135, 131, 139, 153, 116, 160},{105, 100, 112, 114, 115, 108, 117, 120, 123, 117, 122, 129, 124, 128, 124, 132, 135, 131, 139, 153, 116, 160}},{{110, 106, 113, 110, 122, 116, 119, 125, 123, 128, 125, 127, 128, 127, 133, 130, 132, 132, 143, 155, 127, 160},{110, 106, 113, 110, 122, 116, 119, 125, 123, 128, 125, 127, 128, 127, 133, 130, 132, 132, 143, 155, 127, 160}},{{102, 107, 110, 112, 115, 117, 117, 115, 120, 118, 127, 130, 130, 129, 126, 126, 125, 130, 141, 135, 127, 160},{102, 107, 110, 112, 115, 117, 117, 115, 120, 118, 127, 130, 130, 129, 126, 126, 125, 130, 141, 135, 127, 160}},{{110, 117, 106, 118, 118, 116, 121, 124, 128, 125, 122, 122, 126, 131, 124, 130, 133, 131, 139, 134, 131, 160},{110, 117, 106, 118, 118, 116, 121, 124, 128, 125, 122, 122, 126, 131, 124, 130, 133, 131, 139, 134, 131, 160}}}; -const uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz = 97; +const Word16 CRendBin_Combined_BRIR_max_num_iterations_32kHz = 22; +const UWord16 CRendBin_Combined_BRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS]={{22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22}, {22, 22} }; +const UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {40, 40}; +const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][22]={{{115, 117, 117, 120, 112, 118, 121, 130, 126, 130, 136, 127, 133, 135, 132, 133, 129, 137, 134, 129, 128, 160},{115, 117, 117, 120, 112, 118, 121, 130, 126, 130, 136, 127, 133, 135, 132, 133, 129, 137, 134, 129, 128, 160}},{{121, 106, 119, 113, 120, 123, 114, 126, 123, 125, 127, 128, 127, 134, 132, 130, 129, 139, 133, 131, 128, 160},{121, 106, 119, 113, 120, 123, 114, 126, 123, 125, 127, 128, 127, 134, 132, 130, 129, 139, 133, 131, 128, 160}},{{113, 103, 116, 104, 123, 123, 122, 124, 130, 128, 132, 131, 131, 132, 130, 132, 130, 135, 137, 128, 128, 160},{113, 103, 116, 104, 123, 123, 122, 124, 130, 128, 132, 131, 131, 132, 130, 132, 130, 135, 137, 128, 128, 160}},{{102, 116, 116, 121, 116, 114, 115, 121, 125, 123, 124, 130, 132, 122, 127, 131, 131, 135, 133, 124, 125, 160},{102, 116, 116, 121, 116, 114, 115, 121, 125, 123, 124, 130, 132, 122, 127, 131, 131, 135, 133, 124, 125, 160}},{{115, 115, 115, 119, 121, 119, 125, 127, 123, 129, 122, 126, 128, 134, 130, 130, 131, 140, 146, 127, 131, 160},{115, 115, 115, 119, 121, 119, 125, 127, 123, 129, 122, 126, 128, 134, 130, 130, 131, 140, 146, 127, 131, 160}},{{112, 106, 118, 121, 115, 117, 129, 123, 128, 126, 130, 130, 131, 131, 130, 134, 133, 149, 130, 132, 126, 160},{112, 106, 118, 121, 115, 117, 129, 123, 128, 126, 130, 130, 131, 131, 130, 134, 133, 149, 130, 132, 126, 160}},{{107, 112, 110, 119, 114, 124, 121, 121, 132, 122, 131, 134, 124, 133, 130, 129, 134, 134, 135, 127, 120, 160},{107, 112, 110, 119, 114, 124, 121, 121, 132, 122, 131, 134, 124, 133, 130, 129, 134, 134, 135, 127, 120, 160}},{{110, 113, 123, 113, 121, 120, 120, 126, 131, 123, 128, 128, 132, 130, 132, 136, 133, 136, 135, 128, 124, 160},{110, 113, 123, 113, 121, 120, 120, 126, 131, 123, 128, 128, 132, 130, 132, 136, 133, 136, 135, 128, 124, 160}},{{114, 101, 113, 113, 124, 126, 123, 128, 122, 127, 132, 127, 136, 128, 128, 127, 132, 132, 129, 125, 120, 160},{114, 101, 113, 113, 124, 126, 123, 128, 122, 127, 132, 127, 136, 128, 128, 127, 132, 132, 129, 125, 120, 160}},{{99, 100, 111, 117, 114, 114, 118, 116, 121, 124, 124, 121, 125, 130, 127, 132, 132, 130, 133, 128, 131, 160},{99, 100, 111, 117, 114, 114, 118, 116, 121, 124, 124, 121, 125, 130, 127, 132, 132, 130, 133, 128, 131, 160}},{{105, 93, 103, 108, 119, 110, 111, 114, 120, 121, 119, 122, 130, 128, 130, 131, 132, 131, 136, 128, 128, 160},{105, 93, 103, 108, 119, 110, 111, 114, 120, 121, 119, 122, 130, 128, 130, 131, 132, 131, 136, 128, 128, 160}},{{105, 100, 112, 114, 115, 108, 117, 120, 123, 117, 122, 129, 124, 128, 124, 132, 135, 131, 139, 153, 116, 160},{105, 100, 112, 114, 115, 108, 117, 120, 123, 117, 122, 129, 124, 128, 124, 132, 135, 131, 139, 153, 116, 160}},{{110, 106, 113, 110, 122, 116, 119, 125, 123, 128, 125, 127, 128, 127, 133, 130, 132, 132, 143, 155, 127, 160},{110, 106, 113, 110, 122, 116, 119, 125, 123, 128, 125, 127, 128, 127, 133, 130, 132, 132, 143, 155, 127, 160}},{{102, 107, 110, 112, 115, 117, 117, 115, 120, 118, 127, 130, 130, 129, 126, 126, 125, 130, 141, 135, 127, 160},{102, 107, 110, 112, 115, 117, 117, 115, 120, 118, 127, 130, 130, 129, 126, 126, 125, 130, 141, 135, 127, 160}},{{110, 117, 106, 118, 118, 116, 121, 124, 128, 125, 122, 122, 126, 131, 124, 130, 133, 131, 139, 134, 131, 160},{110, 117, 106, 118, 118, 116, 121, 124, 128, 125, 122, 122, 126, 131, 124, 130, 133, 131, 139, 134, 131, 160}}}; +const UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz = 97; const float CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[15]={0.224190f, 0.227445f, 0.241827f, 0.207131f, 0.218113f, 0.222941f, 0.232139f, 0.248192f, 0.249239f, 0.261572f, 0.246309f, 0.279145f, 0.285786f, 0.262528f, 0.271847f}; const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz_fx[15]={7346, 7452, 7924, 6787, 7147, 7305, 7606, 8132, 8167, 8571, 8071, 9147, 9364, 8602, 8907,}; -const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 63, 63, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97},{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 63, 63, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97}}; +const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 63, 63, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97},{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 63, 63, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97}}; /* Sample Rate = 16000 */ -const int16_t CRendBin_Combined_BRIR_max_num_iterations_16kHz = 23; -const uint16_t CRendBin_Combined_BRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]={{23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23} }; -const uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {40, 40}; -const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][23]={{{77, 76, 77, 77, 77, 76, 77, 76, 77, 76, 77, 77, 77, 78, 76, 76, 77, 77, 77, 77, 77, 76, 80},{77, 76, 77, 77, 77, 76, 77, 76, 77, 76, 77, 77, 77, 78, 76, 76, 77, 77, 77, 77, 77, 76, 80}},{{76, 77, 77, 75, 77, 78, 77, 76, 77, 77, 76, 77, 77, 77, 77, 77, 76, 77, 76, 76, 77, 78, 80},{76, 77, 77, 75, 77, 78, 77, 76, 77, 77, 76, 77, 77, 77, 77, 77, 76, 77, 76, 76, 77, 78, 80}},{{77, 76, 76, 78, 75, 76, 74, 78, 77, 76, 77, 77, 77, 76, 76, 77, 78, 78, 77, 77, 77, 77, 80},{77, 76, 76, 78, 75, 76, 74, 78, 77, 76, 77, 77, 77, 76, 76, 77, 78, 78, 77, 77, 77, 77, 80}},{{76, 76, 76, 76, 77, 77, 76, 78, 77, 77, 77, 77, 78, 78, 77, 77, 77, 77, 77, 78, 77, 78, 80},{76, 76, 76, 76, 77, 77, 76, 78, 77, 77, 77, 77, 78, 78, 77, 77, 77, 77, 77, 78, 77, 78, 80}},{{76, 77, 77, 76, 77, 77, 75, 77, 77, 77, 76, 77, 77, 77, 77, 78, 77, 77, 77, 77, 76, 76, 80},{76, 77, 77, 76, 77, 77, 75, 77, 77, 77, 76, 77, 77, 77, 77, 78, 77, 77, 77, 77, 76, 76, 80}},{{77, 76, 77, 77, 77, 77, 77, 77, 76, 78, 76, 78, 75, 76, 77, 77, 76, 76, 77, 78, 78, 77, 80},{77, 76, 77, 77, 77, 77, 77, 77, 76, 78, 76, 78, 75, 76, 77, 77, 76, 76, 77, 78, 78, 77, 80}},{{77, 77, 75, 76, 76, 77, 77, 77, 77, 77, 77, 75, 77, 76, 76, 76, 77, 77, 76, 77, 76, 77, 80},{77, 77, 75, 76, 76, 77, 77, 77, 77, 77, 77, 75, 77, 76, 76, 76, 77, 77, 76, 77, 76, 77, 80}},{{75, 76, 77, 77, 75, 77, 75, 76, 76, 77, 77, 77, 78, 78, 77, 77, 76, 77, 78, 78, 78, 76, 80},{75, 76, 77, 77, 75, 77, 75, 76, 76, 77, 77, 77, 78, 78, 77, 77, 76, 77, 78, 78, 78, 76, 80}},{{77, 77, 77, 76, 77, 77, 76, 76, 76, 77, 77, 75, 76, 78, 78, 77, 77, 78, 78, 77, 76, 76, 80},{77, 77, 77, 76, 77, 77, 76, 76, 76, 77, 77, 75, 76, 78, 78, 77, 77, 78, 78, 77, 76, 76, 80}},{{76, 75, 76, 76, 77, 77, 77, 77, 77, 77, 74, 78, 77, 78, 78, 77, 76, 77, 77, 77, 77, 76, 80},{76, 75, 76, 76, 77, 77, 77, 77, 77, 77, 74, 78, 77, 78, 78, 77, 76, 77, 77, 77, 77, 76, 80}},{{76, 76, 77, 76, 77, 77, 76, 76, 76, 76, 77, 77, 76, 76, 77, 75, 77, 76, 76, 76, 77, 77, 80},{76, 76, 77, 76, 77, 77, 76, 76, 76, 76, 77, 77, 76, 76, 77, 75, 77, 76, 76, 76, 77, 77, 80}},{{76, 76, 77, 75, 78, 77, 77, 77, 77, 77, 77, 77, 77, 76, 78, 77, 76, 78, 76, 77, 76, 77, 80},{76, 76, 77, 75, 78, 77, 77, 77, 77, 77, 77, 77, 77, 76, 78, 77, 76, 78, 76, 77, 76, 77, 80}},{{76, 77, 77, 76, 76, 77, 77, 75, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 77, 76, 76, 78, 80},{76, 77, 77, 76, 76, 77, 77, 75, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 77, 76, 76, 78, 80}},{{74, 76, 74, 76, 75, 76, 76, 76, 76, 77, 77, 78, 77, 78, 75, 76, 77, 76, 78, 76, 78, 77, 80},{74, 76, 74, 76, 75, 76, 76, 76, 76, 77, 77, 78, 77, 78, 75, 76, 77, 76, 78, 76, 78, 77, 80}},{{76, 77, 77, 77, 76, 78, 77, 76, 75, 77, 77, 77, 76, 78, 77, 78, 78, 78, 77, 76, 77, 75, 80},{76, 77, 77, 77, 76, 78, 77, 76, 75, 77, 77, 77, 76, 78, 77, 78, 78, 78, 77, 76, 77, 75, 80}}}; -const uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz = 77; +const Word16 CRendBin_Combined_BRIR_max_num_iterations_16kHz = 23; +const UWord16 CRendBin_Combined_BRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS]={{23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23}, {23, 23} }; +const UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {40, 40}; +const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][23]={{{77, 76, 77, 77, 77, 76, 77, 76, 77, 76, 77, 77, 77, 78, 76, 76, 77, 77, 77, 77, 77, 76, 80},{77, 76, 77, 77, 77, 76, 77, 76, 77, 76, 77, 77, 77, 78, 76, 76, 77, 77, 77, 77, 77, 76, 80}},{{76, 77, 77, 75, 77, 78, 77, 76, 77, 77, 76, 77, 77, 77, 77, 77, 76, 77, 76, 76, 77, 78, 80},{76, 77, 77, 75, 77, 78, 77, 76, 77, 77, 76, 77, 77, 77, 77, 77, 76, 77, 76, 76, 77, 78, 80}},{{77, 76, 76, 78, 75, 76, 74, 78, 77, 76, 77, 77, 77, 76, 76, 77, 78, 78, 77, 77, 77, 77, 80},{77, 76, 76, 78, 75, 76, 74, 78, 77, 76, 77, 77, 77, 76, 76, 77, 78, 78, 77, 77, 77, 77, 80}},{{76, 76, 76, 76, 77, 77, 76, 78, 77, 77, 77, 77, 78, 78, 77, 77, 77, 77, 77, 78, 77, 78, 80},{76, 76, 76, 76, 77, 77, 76, 78, 77, 77, 77, 77, 78, 78, 77, 77, 77, 77, 77, 78, 77, 78, 80}},{{76, 77, 77, 76, 77, 77, 75, 77, 77, 77, 76, 77, 77, 77, 77, 78, 77, 77, 77, 77, 76, 76, 80},{76, 77, 77, 76, 77, 77, 75, 77, 77, 77, 76, 77, 77, 77, 77, 78, 77, 77, 77, 77, 76, 76, 80}},{{77, 76, 77, 77, 77, 77, 77, 77, 76, 78, 76, 78, 75, 76, 77, 77, 76, 76, 77, 78, 78, 77, 80},{77, 76, 77, 77, 77, 77, 77, 77, 76, 78, 76, 78, 75, 76, 77, 77, 76, 76, 77, 78, 78, 77, 80}},{{77, 77, 75, 76, 76, 77, 77, 77, 77, 77, 77, 75, 77, 76, 76, 76, 77, 77, 76, 77, 76, 77, 80},{77, 77, 75, 76, 76, 77, 77, 77, 77, 77, 77, 75, 77, 76, 76, 76, 77, 77, 76, 77, 76, 77, 80}},{{75, 76, 77, 77, 75, 77, 75, 76, 76, 77, 77, 77, 78, 78, 77, 77, 76, 77, 78, 78, 78, 76, 80},{75, 76, 77, 77, 75, 77, 75, 76, 76, 77, 77, 77, 78, 78, 77, 77, 76, 77, 78, 78, 78, 76, 80}},{{77, 77, 77, 76, 77, 77, 76, 76, 76, 77, 77, 75, 76, 78, 78, 77, 77, 78, 78, 77, 76, 76, 80},{77, 77, 77, 76, 77, 77, 76, 76, 76, 77, 77, 75, 76, 78, 78, 77, 77, 78, 78, 77, 76, 76, 80}},{{76, 75, 76, 76, 77, 77, 77, 77, 77, 77, 74, 78, 77, 78, 78, 77, 76, 77, 77, 77, 77, 76, 80},{76, 75, 76, 76, 77, 77, 77, 77, 77, 77, 74, 78, 77, 78, 78, 77, 76, 77, 77, 77, 77, 76, 80}},{{76, 76, 77, 76, 77, 77, 76, 76, 76, 76, 77, 77, 76, 76, 77, 75, 77, 76, 76, 76, 77, 77, 80},{76, 76, 77, 76, 77, 77, 76, 76, 76, 76, 77, 77, 76, 76, 77, 75, 77, 76, 76, 76, 77, 77, 80}},{{76, 76, 77, 75, 78, 77, 77, 77, 77, 77, 77, 77, 77, 76, 78, 77, 76, 78, 76, 77, 76, 77, 80},{76, 76, 77, 75, 78, 77, 77, 77, 77, 77, 77, 77, 77, 76, 78, 77, 76, 78, 76, 77, 76, 77, 80}},{{76, 77, 77, 76, 76, 77, 77, 75, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 77, 76, 76, 78, 80},{76, 77, 77, 76, 76, 77, 77, 75, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 77, 76, 76, 78, 80}},{{74, 76, 74, 76, 75, 76, 76, 76, 76, 77, 77, 78, 77, 78, 75, 76, 77, 76, 78, 76, 78, 77, 80},{74, 76, 74, 76, 75, 76, 76, 76, 76, 77, 77, 78, 77, 78, 75, 76, 77, 76, 78, 76, 78, 77, 80}},{{76, 77, 77, 77, 76, 78, 77, 76, 75, 77, 77, 77, 76, 78, 77, 78, 78, 78, 77, 76, 77, 75, 80},{76, 77, 77, 77, 76, 78, 77, 76, 75, 77, 77, 77, 76, 78, 77, 78, 78, 78, 77, 76, 77, 75, 80}}}; +const UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz = 77; const float CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[15]={0.223532f, 0.226827f, 0.248830f, 0.208782f, 0.220391f, 0.219790f, 0.231187f, 0.248730f, 0.251408f, 0.263698f, 0.243858f, 0.281483f, 0.283080f, 0.261660f, 0.273527f}; const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz_fx[15]={7346, 7452, 7924, 6787, 7147, 7305, 7606, 8132, 8167, 8571, 8071, 9147, 9364, 8602, 8907}; -const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]={{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 55, 55, 61, 61, 61, 65, 67, 67, 67, 67, 67, 67, 69, 72, 72, 72, 73, 73, 75, 75, 75, 75, 75, 75, 75, 75, 75, 77},{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 55, 55, 61, 61, 61, 65, 67, 67, 67, 67, 67, 67, 69, 72, 72, 72, 73, 73, 75, 75, 75, 75, 75, 75, 75, 75, 75, 77}}; +const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]={{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 55, 55, 61, 61, 61, 65, 67, 67, 67, 67, 67, 67, 69, 72, 72, 72, 73, 73, 75, 75, 75, 75, 75, 75, 75, 75, 75, 77},{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 55, 55, 61, 61, 61, 65, 67, 67, 67, 67, 67, 67, 69, 72, 72, 72, 73, 73, 75, 75, 75, 75, 75, 75, 75, 75, 75, 77}}; //BRIR and HRIR coeff tables in Q29 const Word32 CRendBin_Combined_BRIR_coeff_re_48kHz_fx[15][BINAURAL_CHANNELS][2955] ={ { diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c index 54940355c..2b46ff611 100644 --- a/lib_rend/ivas_rom_rend_fx.c +++ b/lib_rend/ivas_rom_rend_fx.c @@ -49,9 +49,9 @@ const Word16 diffuse_response_CICP6_fx[5] = { 13824, 13824, 12137, 16495, 16495 const Word16 diffuse_response_CICP14_fx[7] = { 12507, 12507, 9237, 17691, 17691, 4977, 4977 };//Q15 const Word16 diffuse_response_CICP16_fx[9] = { 11324, 11324, 9945, 13513, 13513, 8853, 8853, 9905, 9905 };//Q15 -const int16_t ap_pre_delay[DIRAC_DECORR_NUM_SPLIT_BANDS] = { 7, 2, 1 }; +const Word16 ap_pre_delay[DIRAC_DECORR_NUM_SPLIT_BANDS] = { 7, 2, 1 }; -const int16_t ap_filter_length[DIRAC_DECORR_NUM_SPLIT_BANDS] = { 15, 6, 3 }; +const Word16 ap_filter_length[DIRAC_DECORR_NUM_SPLIT_BANDS] = { 15, 6, 3 }; const Word16 ap_lattice_delta_phi_fx[DIRAC_MAX_NUM_DECORR_FILTERS*DIRAC_MAX_DECORR_FILTER_LEN] /*Q14*/ = { @@ -91,11 +91,11 @@ const Word16 ap_split_frequencies_fx[DIRAC_DECORR_NUM_SPLIT_BANDS + 1]/*Q14*/ = 0 , 2048, 6144, 16384 }; -const int16_t sba_map_tc[11] = +const Word16 sba_map_tc[11] = { 0, 1, 2, 3, 4, 8, 9, 15, 5, 6, 7 }; -const int16_t sba_map_tc_512[11] = +const Word16 sba_map_tc_512[11] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15 }; @@ -121,11 +121,11 @@ const int16_t sba_map_tc_512[11] = * 13 = 135, 35 * 14 = -135, 35 */ -const int16_t channelIndex_CICP6[5] = { 0, 1, 2, 5, 6 }; -const int16_t channelIndex_CICP12[7] = { 0, 1, 2, 5, 6, 3, 4 }; -const int16_t channelIndex_CICP14[7] = { 0, 1, 2, 5, 6, 9, 10 }; -const int16_t channelIndex_CICP16[9] = { 0, 1, 2, 5, 6, 9, 10, 11, 12 }; -const int16_t channelIndex_CICP19[11] = { 0, 1, 2, 3, 4, 7, 8, 9, 10, 13, 14 }; +const Word16 channelIndex_CICP6[5] = { 0, 1, 2, 5, 6 }; +const Word16 channelIndex_CICP12[7] = { 0, 1, 2, 5, 6, 3, 4 }; +const Word16 channelIndex_CICP14[7] = { 0, 1, 2, 5, 6, 9, 10 }; +const Word16 channelIndex_CICP16[9] = { 0, 1, 2, 5, 6, 9, 10, 11, 12 }; +const Word16 channelIndex_CICP19[11] = { 0, 1, 2, 3, 4, 7, 8, 9, 10, 13, 14 }; const Word16 surCohEne_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] /* Q13 */ = { @@ -160,7 +160,7 @@ const Word32 diffuseFieldCoherenceDifferenceZ_fx[BINAURAL_COHERENCE_DIFFERENCE_B * TD ISM binaural renderer ROM tables *----------------------------------------------------------------------------------*/ -const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS] = +const Word16 HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS] = { 13, 12, 11 }; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 22ed7ed65..0a489600a 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -88,7 +88,7 @@ typedef enum IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN, } IVAS_REND_AudioConfigType; -typedef uint16_t IVAS_REND_InputId; +typedef UWord16 IVAS_REND_InputId; typedef enum _IVAS_REND_COMPLEXITY_LEVEL { -- GitLab From d94a7eff4bf5be0f0b522420ddb8463d14c81108 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 11 Mar 2025 07:57:46 +0100 Subject: [PATCH 64/97] move switches in options.h to have porting section last --- lib_com/options.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7aeea040f..5ce425476 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,6 +168,9 @@ #define FIX_1301_CORRECT_TD_CNST /* VA: Fix 1301, correct wrong constant in TD stereo */ #define NONBE_FIX_1277_EVS_DTX_HIGH_RATE_THRESHOLD /* VA/Eri: FLP issue 1277: Fix Mismatch in DTX high-rate threshold between EVS float and BASOP */ #define NONBE_FIX_708_OSBA_BR_SWITCHING_CRASH /* FhG: issue 708: fix crash in OSBA BR switching with long test vectors */ +//#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ +#define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ +#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ /* #################### Start BASOP porting switches ############################ */ @@ -179,7 +182,4 @@ /* #################### End BASOP porting switches ############################ */ -//#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ -#define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ -#define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ #endif -- GitLab From 919bec712ef79ca4e3f5d4f559c28d5032974833 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 12:49:24 +0530 Subject: [PATCH 65/97] Fix for 3GPP issue 1342: Decoder crash for Stereo at 48/64 kbps mono decoding in IMDCT_ivas_fx() Link #1342 --- lib_com/edct_fx.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index 8d77da13a..b1e2a7dd9 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -592,11 +592,12 @@ void edxt_fx( const UWord16 synthesis /* i : nonzero for inverse Q0*/ ) { - Word16 k, m, fac; + Word16 k, m, fac, hdrm, tmp = 0; const Word16 *cosPtr, *sinPtr; Word16 n; n = 0; move16(); + move16(); cosPtr = NULL; sinPtr = NULL; IF( EQ_16( length, 512 ) ) @@ -735,7 +736,23 @@ void edxt_fx( IF( EQ_16( length, 512 ) ) { + /* Scaling down re and im buffers to avoid overflow in DoRTFTn_fx if the minimum headroom is less than 4 bits */ + hdrm = s_min( L_norm_arr( re, 512 ), L_norm_arr( im, 512 ) ); + IF( LT_16( hdrm, 4 ) ) + { + tmp = sub( hdrm, 4 ); + scale_sig32( re, 512, tmp ); + scale_sig32( im, 512, tmp ); + } + DoRTFTn_fx( re, im, 512 ); + + IF( LT_16( hdrm, 4 ) ) + { + tmp = negate( tmp ); + scale_sig32( re, 512, tmp ); + scale_sig32( im, 512, tmp ); + } } ELSE /* fft() doesn't support 512 */ { @@ -831,7 +848,23 @@ void edxt_fx( IF( EQ_16( length, 512 ) ) { + /* Scaling down re and im buffers to avoid overflow in DoRTFTn_fx if the minimum headroom is less than 4 bits */ + hdrm = s_min( L_norm_arr( re, 512 ), L_norm_arr( im, 512 ) ); + IF( LT_16( hdrm, 4 ) ) + { + tmp = sub( hdrm, 4 ); + scale_sig32( re, 512, tmp ); + scale_sig32( im, 512, tmp ); + } + DoRTFTn_fx( re, im, 512 ); + + IF( LT_16( hdrm, 4 ) ) + { + tmp = negate( tmp ); + scale_sig32( re, 512, tmp ); + scale_sig32( im, 512, tmp ); + } } ELSE /* fft() doesn't support 512 */ { -- GitLab From 9d3de014d988ce108565071fe569b5f88bd9faed Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 13:51:43 +0530 Subject: [PATCH 66/97] Fix for 3GPP issue 1202: BASOP encoder ParamISM: strong timbre differences in the noise track - 2 [x] Link #1202 [x] Corrected the formula for the computation of xcorr_ene_fx which then rectifies the computation of hISMDTX->coh_fx that leads to proper value of idx being written to the bitstream on the encoder side. --- lib_enc/ivas_ism_dtx_enc_fx.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 64b8991d6..f99043708 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -445,9 +445,9 @@ void ivas_ism_coh_estim_dtx_enc_fx( Word16 sce_id, i; Word32 acorr_ene_fx[MAX_NUM_OBJECTS], xcorr_ene_fx; Word16 acorr_ene_e[MAX_NUM_OBJECTS], xcorr_ene_e; - Word16 norm_inp; - Word16 tot_exp; - Word32 scaled_inp; + Word16 norm_inp, norm_inp0; + Word16 tot_exp, tot_exp2; + Word32 scaled_inp, scaled_inp0; set16_fx( acorr_ene_e, 0, MAX_NUM_OBJECTS ); IF( EQ_16( nchan_transport, 1 ) ) @@ -493,10 +493,13 @@ void ivas_ism_coh_estim_dtx_enc_fx( { norm_inp = norm_l( st->input32_fx[i] ); scaled_inp = L_shl( st->input32_fx[i], norm_inp ); - tot_exp = shl( sub( 20, norm_inp ), 1 ); + tot_exp = shl( sub( sub(31, st->q_inp32), norm_inp ), 1 ); acorr_ene_fx[sce_id] = BASOP_Util_Add_Mant32Exp( acorr_ene_fx[sce_id], acorr_ene_e[sce_id], Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &acorr_ene_e[sce_id] ); /* exp(acorr_ene_e) */ move32(); - xcorr_ene_fx = BASOP_Util_Add_Mant32Exp( xcorr_ene_fx, xcorr_ene_e, Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &xcorr_ene_e ); /* exp(xcorr_ene_e) */ + norm_inp0 = norm_l( st_id0->input32_fx[i] ); + scaled_inp0 = L_shl( st_id0->input32_fx[i], norm_inp0 ); + tot_exp2 = add( sub( sub( 31, st_id0->q_inp32 ), norm_inp0 ), sub( sub( 31, st->q_inp32 ), norm_inp ) ); + xcorr_ene_fx = BASOP_Util_Add_Mant32Exp( xcorr_ene_fx, xcorr_ene_e, Mult_32_32( scaled_inp, scaled_inp0 ), tot_exp2, &xcorr_ene_e ); /* exp(xcorr_ene_e) */ } Word16 coh_e; Word16 temp_e = acorr_ene_e[hISMDTX->sce_id_dtx] + acorr_ene_e[sce_id]; -- GitLab From 22acde4d19351ed8a7c2fc93c338e6eb44276da5 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 14:01:34 +0530 Subject: [PATCH 67/97] Clang formatting changes --- lib_enc/ivas_ism_dtx_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index f99043708..1a4110245 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -493,7 +493,7 @@ void ivas_ism_coh_estim_dtx_enc_fx( { norm_inp = norm_l( st->input32_fx[i] ); scaled_inp = L_shl( st->input32_fx[i], norm_inp ); - tot_exp = shl( sub( sub(31, st->q_inp32), norm_inp ), 1 ); + tot_exp = shl( sub( sub( 31, st->q_inp32 ), norm_inp ), 1 ); acorr_ene_fx[sce_id] = BASOP_Util_Add_Mant32Exp( acorr_ene_fx[sce_id], acorr_ene_e[sce_id], Mult_32_32( scaled_inp, scaled_inp ), tot_exp, &acorr_ene_e[sce_id] ); /* exp(acorr_ene_e) */ move32(); norm_inp0 = norm_l( st_id0->input32_fx[i] ); -- GitLab From 4d386408b80762fd726b85cf4b3c4923be40ee8b Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 14:07:06 +0530 Subject: [PATCH 68/97] Fix for 3GPP issue 1004: Modulation artifact in OMASA at 24 kbps using LTV 3ISM 2TC input and output to MONO Link #1004, #1363 Fixes 3GPP issue #1363: Assert in BASOP decoder function protoSignalComputation2_fx when fed with BASOP encoder MASA bitstream --- lib_rend/ivas_dirac_rend_fx.c | 93 ++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 35 deletions(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index cc8e4d8bd..958a23a3f 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -1692,7 +1692,7 @@ void protoSignalComputation2_fx( Word32 min_sum_total_ratio_fx, min_sum_total_ratio_db_fx; Word32 sum_total_ratio_fx[MASA_SUM_FREQ_RANGE_BINS]; Word16 q_sum_total_ratio; - Word32 a_fx, b_fx; + Word32 a_fx, b_fx, a2_fx, b2_fx; Word16 interpolatorSpaced_fx, interpolatorDmx_fx; Word32 tempSpaced_fx, tempDmx_fx; Word16 q_shift, min_q_shift, exp, q_temp, temp_q_shift, q_temp2; @@ -1700,6 +1700,7 @@ void protoSignalComputation2_fx( Word64 W_tmp1, W_tmp2; Word64 reference_power_64fx[CLDFB_NO_CHANNELS_MAX]; Word16 q_reference_power_64fx; + Word16 head_room, q_Left_Right_power; /* Calculate maximum possible shift for the buffers RealBuffer_fx and ImagBuffer_fx */ min_q_shift = Q31; move16(); @@ -1866,8 +1867,10 @@ void protoSignalComputation2_fx( a_fx = 21474836; /*0.01 in Q31*/ /* Temporal smoothing coefficient */ move32(); b_fx = L_sub( ONE_IN_Q31, a_fx ); /* Temporal smoothing coefficient q31*/ - // a2_fx = 214748365; /*0.1 in Q31*/ /* Temporal smoothing coefficient */ - // b2_fx = L_sub( ONE_IN_Q31, a2_fx ); /* Temporal smoothing coefficient */ + move32(); + a2_fx = 214748365; /*0.1 in Q31*/ /* Temporal smoothing coefficient */ + move32(); + b2_fx = L_sub( ONE_IN_Q31, a2_fx ); /* Temporal smoothing coefficient */ IF( stereo_type_detect->interpolator > 0 ) { @@ -1890,6 +1893,23 @@ void protoSignalComputation2_fx( q_temp = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); q_temp2 = sub( add( add( q_cldfb, temp_q_shift ), add( q_cldfb, temp_q_shift ) ), 31 ); + head_room = 63; + move16(); + FOR( l = 0; l < num_freq_bands; l++ ) + { + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift + + W_tmp1 = W_add( W_mult0_32_32( re1, re1 ), W_mult0_32_32( im1, im1 ) ); + W_tmp2 = W_add( W_mult0_32_32( re2, re2 ), W_mult0_32_32( im2, im2 ) ); + + head_room = s_min( head_room, W_norm( W_add( W_tmp1, W_tmp2 ) ) ); + } + head_room = sub( head_room, find_guarded_bits_fx( num_freq_bands ) ); + q_Left_Right_power = add( shl( add( q_cldfb, min_q_shift ), 1 ), sub( head_room, 32 ) ); + FOR( l = 0; l < num_freq_bands; l++ ) { re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift @@ -1904,26 +1924,26 @@ void protoSignalComputation2_fx( /* Compute reference power */ // Left_power_fx = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); W_tmp1 = W_add( W_mult0_32_32( re1, re1 ), W_mult0_32_32( im1, im1 ) ); // 2*(q_cldfb+min_q_shift) - Left_power_fx = W_extract_l( W_shr( W_tmp1, 31 ) ); + Left_power_fx = W_extract_h( W_shl( W_tmp1, head_room ) ); // q_Left_Right_power // Right_power_fx = Madd_32_32( Mpy_32_32( re2, re2 ), im2, im2 ); W_tmp2 = W_add( W_mult0_32_32( re2, re2 ), W_mult0_32_32( im2, im2 ) ); // 2*(q_cldfb+min_q_shift) - Right_power_fx = W_extract_l( W_shr( W_tmp2, 31 ) ); + Right_power_fx = W_extract_h( W_shl( W_tmp2, head_room ) ); // q_Left_Right_power // reference_power_fx[l] = L_add( Left_power_fx, Right_power_fx ); reference_power_64fx[l] = W_add( W_tmp1, W_tmp2 ); // 2*(q_cldfb+min_q_shift) move64(); - left_bb_power_fx = L_add( left_bb_power_fx, Left_power_fx ); // 2*(q_cldfb+min_q_shift) -31 - right_bb_power_fx = L_add( right_bb_power_fx, Right_power_fx ); // 2*(q_cldfb+min_q_shift) -31 + left_bb_power_fx = L_add( left_bb_power_fx, Left_power_fx ); // q_Left_Right_power + right_bb_power_fx = L_add( right_bb_power_fx, Right_power_fx ); // q_Left_Right_power // total_bb_power_fx = L_add( total_bb_power_fx, reference_power_fx[l] ); - total_bb_power_fx = L_add( total_bb_power_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // 2*(q_cldfb+min_q_shift) -31 + total_bb_power_fx = L_add( total_bb_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power IF( GT_16( l, MASA_HI_FREQ_START_BIN ) ) { - left_hi_power_fx = L_add( left_hi_power_fx, Left_power_fx ); // 2*(q_cldfb+min_q_shift) -31 - right_hi_power_fx = L_add( right_hi_power_fx, Right_power_fx ); // 2*(q_cldfb+min_q_shift) -31 + left_hi_power_fx = L_add( left_hi_power_fx, Left_power_fx ); // q_Left_Right_power + right_hi_power_fx = L_add( right_hi_power_fx, Right_power_fx ); // q_Left_Right_power // total_hi_power_fx = L_add( total_hi_power_fx, reference_power_fx[l] ); - total_hi_power_fx = L_add( total_hi_power_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // 2*(q_cldfb+min_q_shift) -31 + total_hi_power_fx = L_add( total_hi_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power } IF( LT_16( l, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ) ) @@ -1960,12 +1980,17 @@ void protoSignalComputation2_fx( test(); IF( ( stereo_type_detect->sum_power_fx[l] == 0 ) && ( stereo_type_detect->total_power_fx[l] == 0 ) ) { - sum_total_ratio_fx[l] = MAX_16; // q15 + sum_total_ratio_fx[l] = MAX_32; // q15 + move32(); + } + ELSE IF( stereo_type_detect->total_power_fx[l] == 0 ) + { + sum_total_ratio_fx[l] = MAX_32; // q15 move32(); } ELSE { - sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale( stereo_type_detect->sum_power_fx[l], L_add( stereo_type_detect->total_power_fx[l], EPSILON_FX ), &exp ); // 15-(exp+s_min( stereo_type_detect->q_total_power, q_temp )-s_min( stereo_type_detect->q_sum_power, q_temp2 )) + sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale( stereo_type_detect->sum_power_fx[l], stereo_type_detect->total_power_fx[l], &exp ); // 15-(exp+s_min( stereo_type_detect->q_total_power, q_temp )-s_min( stereo_type_detect->q_sum_power, q_temp2 )) move32(); q_sum_total_ratio = add( sub( 15, exp ), sub( s_min( stereo_type_detect->q_sum_power, q_temp2 ), s_min( stereo_type_detect->q_total_power, q_temp ) ) ); sum_total_ratio_fx[l] = L_shl( sum_total_ratio_fx[l], sub( Q15, q_sum_total_ratio ) ); // q15 @@ -2237,45 +2262,45 @@ void protoSignalComputation2_fx( } } - temp = Mpy_32_32( a_fx, left_bb_power_fx ); // 2*(q_cldfb+min_q_shift) -31 - IF( LT_16( q_temp, stereo_type_detect->q_left_bb_power ) ) + temp = Mpy_32_32( a_fx, left_bb_power_fx ); // q_Left_Right_power + IF( LT_16( q_Left_Right_power, stereo_type_detect->q_left_bb_power ) ) { - stereo_type_detect->left_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->left_bb_power_fx ), sub( stereo_type_detect->q_left_bb_power, q_temp ) ) ); // q_temp + stereo_type_detect->left_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->left_bb_power_fx ), sub( stereo_type_detect->q_left_bb_power, q_Left_Right_power ) ) ); // q_Left_Right_power move32(); - stereo_type_detect->q_left_bb_power = q_temp; + stereo_type_detect->q_left_bb_power = q_Left_Right_power; move16(); } ELSE { - stereo_type_detect->left_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_left_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->left_bb_power_fx ) ); // stereo_type_detect->q_left_bb_power + stereo_type_detect->left_bb_power_fx = Madd_32_32( L_shr( temp, sub( q_Left_Right_power, stereo_type_detect->q_left_bb_power ) ), b_fx, stereo_type_detect->left_bb_power_fx ); // stereo_type_detect->q_left_bb_power move32(); } - temp = Mpy_32_32( a_fx, right_bb_power_fx ); // 2*(q_cldfb+min_q_shift) -31 - IF( LT_16( q_temp, stereo_type_detect->q_right_bb_power ) ) + temp = Mpy_32_32( a_fx, right_bb_power_fx ); // q_Left_Right_power + IF( LT_16( q_Left_Right_power, stereo_type_detect->q_right_bb_power ) ) { - stereo_type_detect->right_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->right_bb_power_fx ), sub( stereo_type_detect->q_right_bb_power, q_temp ) ) ); // q_temp + stereo_type_detect->right_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->right_bb_power_fx ), sub( stereo_type_detect->q_right_bb_power, q_Left_Right_power ) ) ); // q_Left_Right_power move32(); - stereo_type_detect->q_right_bb_power = q_temp; + stereo_type_detect->q_right_bb_power = q_Left_Right_power; move16(); } ELSE { - stereo_type_detect->right_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_right_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->right_bb_power_fx ) ); // stereo_type_detect->q_right_bb_power + stereo_type_detect->right_bb_power_fx = Madd_32_32( L_shr( temp, sub( q_Left_Right_power, stereo_type_detect->q_right_bb_power ) ), b_fx, stereo_type_detect->right_bb_power_fx ); // stereo_type_detect->q_right_bb_power move32(); } - temp = Mpy_32_32( a_fx, total_bb_power_fx ); // 2*(q_cldfb+min_q_shift) -31 - IF( LT_16( q_temp, stereo_type_detect->q_total_bb_power ) ) + temp = Mpy_32_32( a_fx, total_bb_power_fx ); // q_Left_Right_power + IF( LT_16( q_Left_Right_power, stereo_type_detect->q_total_bb_power ) ) { - stereo_type_detect->total_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_bb_power_fx ), sub( stereo_type_detect->q_total_bb_power, q_temp ) ) ); // q_temp + stereo_type_detect->total_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_bb_power_fx ), sub( stereo_type_detect->q_total_bb_power, q_Left_Right_power ) ) ); // q_Left_Right_power move32(); - stereo_type_detect->q_total_bb_power = q_temp; + stereo_type_detect->q_total_bb_power = q_Left_Right_power; move16(); } ELSE { - stereo_type_detect->total_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_bb_power_fx ) ); // stereo_type_detect->q_total_bb_power + stereo_type_detect->total_bb_power_fx = Madd_32_32( L_shr( temp, sub( q_Left_Right_power, stereo_type_detect->q_total_bb_power ) ), b_fx, stereo_type_detect->total_bb_power_fx ); // stereo_type_detect->q_total_bb_power move32(); } @@ -2293,8 +2318,7 @@ void protoSignalComputation2_fx( q_lr_bb_power = stereo_type_detect->q_right_bb_power; move16(); } - q_lr_bb_power = sub( q_lr_bb_power, 1 ); /* = (lr_bb_power_fx * 2) */ - + q_lr_bb_power = sub( q_lr_bb_power, 1 ); /* = (lr_bb_power_fx * 2) */ temp = BASOP_Util_Divide3232_Scale_cadence( lr_bb_power_fx, L_add( stereo_type_detect->total_bb_power_fx, EPSILON_FX ), &exp ); // Q(31-(exp+stereo_type_detect->q_total_bb_power-q_lr_bb_power)) exp = sub( 31, add( sub( 31, exp ), sub( q_lr_bb_power, stereo_type_detect->q_total_bb_power ) ) ); temp = BASOP_Util_Log2( temp ); // q25 @@ -2305,15 +2329,15 @@ void protoSignalComputation2_fx( // 20480 = 10 in Q11 lr_total_bb_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21 - stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, left_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power ); + stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power ); move32(); stereo_type_detect->q_left_hi_power = sub( 31, stereo_type_detect->q_left_hi_power ); move16(); - stereo_type_detect->right_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, right_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b_fx, stereo_type_detect->right_hi_power_fx ), sub( 31, stereo_type_detect->q_right_hi_power ), &stereo_type_detect->q_right_hi_power ); + stereo_type_detect->right_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, right_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b2_fx, stereo_type_detect->right_hi_power_fx ), sub( 31, stereo_type_detect->q_right_hi_power ), &stereo_type_detect->q_right_hi_power ); move32(); stereo_type_detect->q_right_hi_power = sub( 31, stereo_type_detect->q_right_hi_power ); move16(); - stereo_type_detect->total_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, total_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b_fx, stereo_type_detect->total_hi_power_fx ), sub( 31, stereo_type_detect->q_total_hi_power ), &stereo_type_detect->q_total_hi_power ); + stereo_type_detect->total_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, total_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b2_fx, stereo_type_detect->total_hi_power_fx ), sub( 31, stereo_type_detect->q_total_hi_power ), &stereo_type_detect->q_total_hi_power ); move32(); stereo_type_detect->q_total_hi_power = sub( 31, stereo_type_detect->q_total_hi_power ); move16(); @@ -2330,8 +2354,7 @@ void protoSignalComputation2_fx( move32(); q_lr_hi_power = stereo_type_detect->q_right_hi_power; } - q_lr_hi_power = sub( q_lr_hi_power, 1 ); /* = (q_lr_hi_power * 2) */ - + q_lr_hi_power = sub( q_lr_hi_power, 1 ); /* = (q_lr_hi_power * 2) */ temp = BASOP_Util_Divide3232_Scale_cadence( lr_hi_power_fx, L_add( stereo_type_detect->total_hi_power_fx, EPSILON_FX ), &exp ); // Q=31-(exp+ stereo_type_detect->q_total_hi_power-q_lr_hi_power) exp = sub( 31, add( sub( 31, exp ), sub( q_lr_hi_power, stereo_type_detect->q_total_hi_power ) ) ); temp = BASOP_Util_Log2( temp ); // q25 -- GitLab From b2a9054e28a698b6e1f7f91f85e98a0c1d23a73f Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 14:14:28 +0530 Subject: [PATCH 69/97] Fix for 3GPP issue 1048: Problem in stereo during bitrate switching and frame erasure Link #1048 --- lib_dec/er_dec_tcx_fx.c | 2 +- lib_dec/ivas_mdct_core_dec_fx.c | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 8c10e5f81..5cc06dabf 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -1168,7 +1168,7 @@ void con_tcx_ivas_fx( /* apply pre-emphasis to the signal */ mem = synth[( -( ( ( L_frame / 2 ) + hTcxDec->pit_max_TCX ) + M + M ) - 1 )]; /*Q0*/ move16(); - Q_exc = E_UTIL_f_preemph3_ivas_fx( &( synth[-add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 ); + Q_exc = E_UTIL_f_preemph3_ivas_fx( &( synth[-( ( ( L_frame / 2 ) + hTcxDec->pit_max_TCX ) + 2 * M )] ), st->preemph_fac, add( add( shr( L_frame, 1 ), hTcxDec->pit_max_TCX ), shl( M, 1 ) ), &mem, 1 ); st->Mode2_lp_gainc = L_deposit_l( 0 ); st->Mode2_lp_gainp = get_gain2( synth - shl( L_subfr, 1 ), synth - add( shl( L_subfr, 1 ), Tc ), shl( L_subfr, 1 ) ); diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 7f079277a..a5855a0f6 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1282,11 +1282,6 @@ void ivas_mdct_core_reconstruct_fx( ELSE /*ACELP core for ACELP-PLC */ { assert( EQ_16( st->bfi, 1 ) ); - - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( -2, q_syn ) ); // Q0 - Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( -2, q_syn ) ); // Q0 - q_syn = -2; - move16(); /* PLC: [TCX: TD PLC] */ IF( MCT_flag != 0 ) { @@ -1316,11 +1311,11 @@ void ivas_mdct_core_reconstruct_fx( IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) ) { - Scale_sig( synthFB_fx - add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), sub( q_syn, sub( st->Q_exc, 1 ) ) ); // 2 * q_syn - (st->Q_exc - 1) + Scale_sig( synthFB_fx - add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), sub( add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), 1 ), sub( q_syn, sub( st->Q_exc, 1 ) ) ); // 2 * q_syn - (st->Q_exc - 1) } ELSE { - Scale_sig( synthFB_fx - st->hTcxDec->L_frameTCX, st->hTcxDec->L_frameTCX, sub( q_syn, sub( st->Q_exc, 1 ) ) ); // 2 * q_syn - (st->Q_exc - 1) + Scale_sig( synthFB_fx - st->hTcxDec->L_frameTCX, sub( st->hTcxDec->L_frameTCX, 1 ), sub( q_syn, sub( st->Q_exc, 1 ) ) ); // 2 * q_syn - (st->Q_exc - 1) } lerp( synthFB_fx, synth_fx, st->L_frame, st->hTcxDec->L_frameTCX ); -- GitLab From f0586ef9c852dfb866511c4c31789b6e39d82b34 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 14:34:44 +0530 Subject: [PATCH 70/97] Fix for 3GPP issue 1327: Glitch when stereo is switching from TD to FD Link #1327 --- lib_com/options.h | 1 + lib_enc/ivas_stereo_switching_enc_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 563855275..d03261715 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,4 +171,5 @@ //#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ #define DOT_PROD_CHOLESKY_64BIT /* FhG: Issue 1323, optimized 64 bit implementation of dot_product_cholesky() */ #define OPT_BASOP_ADD_v1 /* optimizations to avoid usage of BASOP_Util_Add_MantExp */ +#define FIX_ISSUE_1327 /* Ittiam: Fix for issue 1327: Glitch when stereo is switching from TD to FD*/ #endif diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 6513a3fa7..cbdbc0501 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -680,6 +680,10 @@ void stereo_switching_enc_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { Copy( sts[n]->input_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl ); /* sts[n]->q_inp */ +#ifdef FIX_ISSUE_1327 + hCPE->q_input_mem[n] = sts[n]->q_inp; + move16(); +#endif } } -- GitLab From c2d223dab8078c0e12726f33b7396c1235f43dbe Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 19:34:14 +0530 Subject: [PATCH 71/97] Bug fixes, ivas_prot.h cleanup, Q documentation updates --- lib_com/bitstream.c | 1 - lib_com/core_com_config.c | 1 - lib_com/fft_fx.c | 20 + lib_com/gs_bitallocation_ivas_fx.c | 1 - lib_com/ivas_agc_com_fx.c | 1 - lib_com/ivas_arith_fx.c | 1 - lib_com/ivas_cov_smooth_fx.c | 1 - lib_com/ivas_dirac_com_fx.c | 1 - lib_com/ivas_entropy_coder_common_fx.c | 1 - lib_com/ivas_fb_mixer_fx.c | 1 - lib_com/ivas_filters_fx.c | 1 - lib_com/ivas_ism_com_fx.c | 1 - lib_com/ivas_lfe_com_fx.c | 1 - lib_com/ivas_masa_com_fx.c | 1 - lib_com/ivas_mc_com_fx.c | 1 - lib_com/ivas_mc_param_com_fx.c | 1 - lib_com/ivas_mcmasa_com-fx.c | 1 - lib_com/ivas_mct_com_fx.c | 2 +- lib_com/ivas_mdct_core_com_fx.c | 1 - lib_com/ivas_mdft_imdft_fx.c | 1 - lib_com/ivas_omasa_com_fx.c | 1 - lib_com/ivas_pca_tools_fx.c | 1 - lib_com/ivas_prot_fx.h | 817 ++++++++++++++++++ lib_com/ivas_qmetadata_com_fx.c | 1 - lib_com/ivas_qspherical_com_fx.c | 1 - lib_com/ivas_sba_config_fx.c | 1 - lib_com/ivas_sns_com_fx.c | 177 ++-- lib_com/ivas_spar_com_fx.c | 1 - lib_com/ivas_spar_com_quant_util_fx.c | 1 - lib_com/ivas_stereo_dft_com_fx.c | 1 - lib_com/ivas_stereo_eclvq_com_fx.c | 1 - lib_com/ivas_stereo_ica_com_fx.c | 1 - lib_com/ivas_stereo_mdct_bands_com_fx.c | 1 - lib_com/ivas_stereo_mdct_stereo_com_fx.c | 1 - lib_com/ivas_stereo_psychlpc_com_fx.c | 2 - lib_com/ivas_stereo_td_bit_alloc_fx.c | 1 - lib_com/ivas_tools_fx.c | 1 - lib_com/ivas_transient_det_fx.c | 1 - lib_com/mslvq_com.c | 1 - lib_com/prot_fx.h | 1 + lib_com/swb_tbe_com.c | 1 - lib_dec/ACcontextMapping_dec_fx.c | 1 - lib_dec/acelp_core_dec_ivas_fx.c | 1 - lib_dec/dec_tcx_fx.c | 1 - lib_dec/igf_dec_fx.c | 5 +- lib_dec/ivas_agc_dec_fx.c | 1 - lib_dec/ivas_binRenderer_internal_fx.c | 1 - lib_dec/ivas_core_dec_fx.c | 1 - lib_dec/ivas_corecoder_dec_reconfig_fx.c | 1 - lib_dec/ivas_cpe_dec_fx.c | 1 - lib_dec/ivas_decision_matrix_dec_fx.c | 1 - lib_dec/ivas_dirac_dec_fx.c | 1 - lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 1 - lib_dec/ivas_entropy_decoder_fx.c | 1 - lib_dec/ivas_init_dec.c | 1 - lib_dec/ivas_ism_dec_fx.c | 1 - lib_dec/ivas_ism_dtx_dec_fx.c | 1 - lib_dec/ivas_ism_metadata_dec_fx.c | 1 - lib_dec/ivas_ism_param_dec_fx.c | 1 - lib_dec/ivas_ism_renderer_fx.c | 1 - lib_dec/ivas_jbm_dec_fx.c | 1 - lib_dec/ivas_lfe_dec_fx.c | 1 - lib_dec/ivas_lfe_plc_fx.c | 1 - lib_dec/ivas_ls_custom_dec_fx.c | 1 - lib_dec/ivas_masa_dec_fx.c | 1 - lib_dec/ivas_mc_param_dec_fx.c | 1 - lib_dec/ivas_mc_paramupmix_dec_fx.c | 1 - lib_dec/ivas_mcmasa_dec_fx.c | 1 - lib_dec/ivas_mct_core_dec_fx.c | 1 - lib_dec/ivas_mct_dec_fx.c | 1 - lib_dec/ivas_mct_dec_mct_fx_fx.c | 1 - lib_dec/ivas_mdct_core_dec_fx.c | 1 - lib_dec/ivas_mono_dmx_renderer_fx.c | 1 - lib_dec/ivas_objectRenderer_internal_fx.c | 1 - lib_dec/ivas_omasa_dec_fx.c | 1 - lib_dec/ivas_osba_dec_fx.c | 1 - lib_dec/ivas_out_setup_conversion_fx.c | 1 - lib_dec/ivas_output_config_fx.c | 1 - lib_dec/ivas_pca_dec_fx.c | 1 - lib_dec/ivas_post_proc_fx.c | 1 - lib_dec/ivas_qmetadata_dec_fx.c | 1 - lib_dec/ivas_qspherical_dec_fx.c | 1 - lib_dec/ivas_range_uni_dec_fx.c | 1 - lib_dec/ivas_sba_dec_fx.c | 1 - lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 1 - lib_dec/ivas_sba_rendering_internal_fx.c | 1 - lib_dec/ivas_sce_dec_fx.c | 1 - lib_dec/ivas_sns_dec_fx.c | 1 - lib_dec/ivas_spar_decoder_fx.c | 1 - lib_dec/ivas_spar_md_dec_fx.c | 1 - lib_dec/ivas_stereo_adapt_GR_dec_fx.c | 1 - lib_dec/ivas_stereo_cng_dec.c | 1 - lib_dec/ivas_stereo_dft_dec.c | 1 - lib_dec/ivas_stereo_dft_dec_dmx_fx.c | 1 - lib_dec/ivas_stereo_dft_dec_fx.c | 1 - lib_dec/ivas_stereo_dft_plc_fx.c | 1 - lib_dec/ivas_stereo_eclvq_dec_fx.c | 1 - lib_dec/ivas_stereo_esf_dec_fx.c | 1 - lib_dec/ivas_stereo_ica_dec_fx.c | 1 - lib_dec/ivas_stereo_icbwe_dec_fx.c | 1 - lib_dec/ivas_stereo_mdct_core_dec_fx.c | 1 - lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 1 - lib_dec/ivas_stereo_switching_dec_fx.c | 1 - lib_dec/ivas_stereo_td_dec_fx.c | 40 - lib_dec/ivas_svd_dec_fx.c | 1 - lib_dec/ivas_tcx_core_dec_fx.c | 1 - lib_dec/ivas_td_low_rate_dec_fx.c | 1 - lib_dec/lib_dec_fx.c | 1 - lib_dec/lsf_dec_fx.c | 1 - lib_enc/ACcontextMapping_enc_fx.c | 1 - lib_enc/acelp_core_enc_fx.c | 1 - lib_enc/cod4t64_fast.c | 1 - lib_enc/cod_tcx_fx.c | 1 - lib_enc/ext_sig_ana_fx.c | 40 +- lib_enc/igf_enc.c | 1 - lib_enc/ivas_agc_enc_fx.c | 1 - lib_enc/ivas_core_enc_fx.c | 1 - lib_enc/ivas_core_pre_proc_front_fx.c | 1 - lib_enc/ivas_core_pre_proc_fx.c | 1 - lib_enc/ivas_corecoder_enc_reconfig_fx.c | 1 - lib_enc/ivas_cpe_enc_fx.c | 1 - lib_enc/ivas_decision_matrix_enc_fx.c | 1 - lib_enc/ivas_dirac_enc_fx.c | 1 - lib_enc/ivas_enc_cov_handler_fx.c | 1 - lib_enc/ivas_enc_fx.c | 1 - lib_enc/ivas_entropy_coder_fx.c | 1 - lib_enc/ivas_front_vad_fx.c | 25 - lib_enc/ivas_init_enc_fx.c | 1 - lib_enc/ivas_ism_dtx_enc_fx.c | 1 - lib_enc/ivas_ism_enc_fx.c | 1 - lib_enc/ivas_ism_metadata_enc_fx.c | 1 - lib_enc/ivas_ism_param_enc_fx.c | 1 - lib_enc/ivas_lfe_enc_fx.c | 1 - lib_enc/ivas_masa_enc_fx.c | 1 - lib_enc/ivas_mc_param_enc_fx.c | 1 - lib_enc/ivas_mc_paramupmix_enc_fx.c | 1 - lib_enc/ivas_mcmasa_enc_fx.c | 1 - lib_enc/ivas_mct_core_enc_fx.c | 1 - lib_enc/ivas_mct_enc_fx.c | 1 - lib_enc/ivas_mct_enc_mct_fx.c | 1 - lib_enc/ivas_mdct_core_enc_fx.c | 29 +- lib_enc/ivas_omasa_enc_fx.c | 1 - lib_enc/ivas_osba_enc_fx.c | 1 - lib_enc/ivas_pca_enc_fx.c | 1 - lib_enc/ivas_qmetadata_enc_fx.c | 1 - lib_enc/ivas_qspherical_enc_fx.c | 1 - lib_enc/ivas_range_uni_enc_fx.c | 1 - lib_enc/ivas_sba_enc_fx.c | 1 - lib_enc/ivas_sce_enc_fx.c | 1 - lib_enc/ivas_sns_enc_fx.c | 1 - lib_enc/ivas_spar_encoder_fx.c | 1 - lib_enc/ivas_spar_md_enc_fx.c | 1 - lib_enc/ivas_stereo_adapt_GR_enc_fx.c | 1 - lib_enc/ivas_stereo_classifier_fx.c | 1 - lib_enc/ivas_stereo_cng_enc_fx.c | 1 - lib_enc/ivas_stereo_dft_enc_fx.c | 1 - lib_enc/ivas_stereo_dft_enc_itd_fx.c | 1 - lib_enc/ivas_stereo_dft_td_itd_fx.c | 1 - lib_enc/ivas_stereo_dmx_evs_fx.c | 1 - lib_enc/ivas_stereo_eclvq_enc_fx.c | 1 - lib_enc/ivas_stereo_ica_enc_fx.c | 1 - lib_enc/ivas_stereo_icbwe_enc_fx.c | 1 - lib_enc/ivas_stereo_mdct_core_enc_fx.c | 1 - lib_enc/ivas_stereo_mdct_igf_enc_fx.c | 1 - lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 1 - lib_enc/ivas_stereo_switching_enc_fx.c | 1 - lib_enc/ivas_stereo_td_analysis_fx.c | 1 - lib_enc/ivas_stereo_td_enc_fx.c | 1 - lib_enc/ivas_tcx_core_enc_fx.c | 1 - lib_enc/ivas_td_low_rate_enc_fx.c | 1 - lib_enc/lib_enc.c | 1 - lib_enc/lp_exc_e_fx.c | 106 +-- lib_enc/lsf_enc_fx.c | 147 ++-- lib_enc/lsf_msvq_ma_enc.c | 27 +- lib_enc/lsf_msvq_ma_enc_fx.c | 52 +- lib_enc/ltd_stable_fx.c | 63 +- lib_enc/mdct_classifier_fx.c | 99 +-- lib_enc/mdct_selector_fx.c | 36 +- lib_enc/mslvq_enc_fx.c | 52 +- lib_enc/multi_harm_fx.c | 16 +- lib_enc/speech_music_classif_fx.c | 1 - lib_enc/swb_pre_proc_fx.c | 1 - lib_enc/swb_tbe_enc_fx.c | 1 - lib_rend/ivas_allrad_dec_fx.c | 1 - lib_rend/ivas_crend_fx.c | 1 - lib_rend/ivas_dirac_ana_fx.c | 1 - .../ivas_dirac_dec_binaural_functions_fx.c | 1 - lib_rend/ivas_dirac_decorr_dec_fx.c | 1 - lib_rend/ivas_dirac_onsets_dec_fx.c | 1 - lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 1 - lib_rend/ivas_dirac_rend_fx.c | 1 - lib_rend/ivas_efap_fx.c | 1 - lib_rend/ivas_hrtf_fx.c | 1 - lib_rend/ivas_masa_merge_fx.c | 1 - lib_rend/ivas_mcmasa_ana_fx.c | 1 - lib_rend/ivas_objectRenderer_fx.c | 1 - lib_rend/ivas_omasa_ana_fx.c | 1 - lib_rend/ivas_orient_trk_fx.c | 1 - lib_rend/ivas_output_init.c | 1 - lib_rend/ivas_output_init_fx.c | 1 - lib_rend/ivas_reflections_fx.c | 1 - lib_rend/ivas_reverb_delay_line_fx.c | 1 - lib_rend/ivas_sba_rendering_fx.c | 1 - lib_rend/ivas_td_decorr_fx.c | 1 - lib_rend/ivas_vbap_fx.c | 1 - lib_rend/lib_rend.c | 1 - lib_util/hrtf_file_reader.c | 1 - lib_util/ls_custom_file_reader.c | 2 +- lib_util/masa_file_reader.c | 1 - 209 files changed, 1267 insertions(+), 679 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 9c0a53f8f..90b49f8c2 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -43,7 +43,6 @@ #include "stat_dec.h" #include "rom_com.h" #include "mime.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index ed72605de..f0ee8efd8 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -40,7 +40,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #define FSCALE_DENOM_BY_12800_Q15 1311 diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 73ff582df..7b63e9c67 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -7636,6 +7636,26 @@ Word16 norm_arr( Word16 *arr, Word16 size ) return q; } +Word16 W_norm_arr( Word64 *arr, Word16 size ) +{ + Word16 q = 63; + Word16 exp = 0; + move16(); + move16(); + FOR( Word16 i = 0; i < size; i++ ) + { + if ( arr[i] != 0 ) + { + exp = W_norm( arr[i] ); + } + if ( arr[i] != 0 ) + { + q = s_min( q, exp ); + } + } + return q; +} + Word16 get_min_scalefactor( Word32 x, Word32 y ) { #ifndef FIX_1104_OPT_GETMINSCALEFAC diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c index 0921dc88c..71b30ea75 100644 --- a/lib_com/gs_bitallocation_ivas_fx.c +++ b/lib_com/gs_bitallocation_ivas_fx.c @@ -6,7 +6,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "ivas_prot.h" /* Function prototypes */ #include "assert.h" /* Debug prototypes */ #include "stl.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_agc_com_fx.c b/lib_com/ivas_agc_com_fx.c index 94e6b222f..3f6e181ef 100644 --- a/lib_com/ivas_agc_com_fx.c +++ b/lib_com/ivas_agc_com_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include #include "wmc_auto.h" diff --git a/lib_com/ivas_arith_fx.c b/lib_com/ivas_arith_fx.c index 006a31177..311bccff8 100644 --- a/lib_com/ivas_arith_fx.c +++ b/lib_com/ivas_arith_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "wmc_auto.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "stat_dec.h" diff --git a/lib_com/ivas_cov_smooth_fx.c b/lib_com/ivas_cov_smooth_fx.c index acc0df821..3a93ed1f5 100644 --- a/lib_com/ivas_cov_smooth_fx.c +++ b/lib_com/ivas_cov_smooth_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "cnst.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 9b60b2c5c..146587791 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -36,7 +36,6 @@ #include #include "ivas_cnst.h" #include "ivas_rom_com.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_entropy_coder_common_fx.c b/lib_com/ivas_entropy_coder_common_fx.c index 99381d19a..f52d59859 100644 --- a/lib_com/ivas_entropy_coder_common_fx.c +++ b/lib_com/ivas_entropy_coder_common_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "math.h" #include "prot_fx.h" diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c index 883861024..d5cd8d4f1 100644 --- a/lib_com/ivas_fb_mixer_fx.c +++ b/lib_com/ivas_fb_mixer_fx.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index 7705deb6a..1e9aaf0c2 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_stat_com.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index f1201b06c..5f1a13afb 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_lfe_com_fx.c b/lib_com/ivas_lfe_com_fx.c index 7464c41c2..3d1e7aee6 100644 --- a/lib_com/ivas_lfe_com_fx.c +++ b/lib_com/ivas_lfe_com_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "ivas_stat_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "cnst.h" diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index fbe752aad..cfed06357 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -36,7 +36,6 @@ #include #include "prot_fx.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_mc_com_fx.c b/lib_com/ivas_mc_com_fx.c index 62d623b83..8201037a1 100644 --- a/lib_com/ivas_mc_com_fx.c +++ b/lib_com/ivas_mc_com_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_mc_param_com_fx.c b/lib_com/ivas_mc_param_com_fx.c index a54abe7ab..4469e7f93 100644 --- a/lib_com/ivas_mc_param_com_fx.c +++ b/lib_com/ivas_mc_param_com_fx.c @@ -36,7 +36,6 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_mcmasa_com-fx.c b/lib_com/ivas_mcmasa_com-fx.c index da0b8f1c4..23a3800fb 100644 --- a/lib_com/ivas_mcmasa_com-fx.c +++ b/lib_com/ivas_mcmasa_com-fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include "ivas_cnst.h" -#include "ivas_prot.h" #include "options.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_mct_com_fx.c b/lib_com/ivas_mct_com_fx.c index 1f3c58153..81a56df14 100644 --- a/lib_com/ivas_mct_com_fx.c +++ b/lib_com/ivas_mct_com_fx.c @@ -33,8 +33,8 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" +#include "ivas_prot_fx.h" #include "wmc_auto.h" #include diff --git a/lib_com/ivas_mdct_core_com_fx.c b/lib_com/ivas_mdct_core_com_fx.c index 000f3992f..fe313eecd 100644 --- a/lib_com/ivas_mdct_core_com_fx.c +++ b/lib_com/ivas_mdct_core_com_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_mdft_imdft_fx.c b/lib_com/ivas_mdft_imdft_fx.c index b10444307..5d7bee1a6 100644 --- a/lib_com/ivas_mdft_imdft_fx.c +++ b/lib_com/ivas_mdft_imdft_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" diff --git a/lib_com/ivas_omasa_com_fx.c b/lib_com/ivas_omasa_com_fx.c index ef6350285..1c1d4bf6c 100644 --- a/lib_com/ivas_omasa_com_fx.c +++ b/lib_com/ivas_omasa_com_fx.c @@ -33,7 +33,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_pca_tools_fx.c b/lib_com/ivas_pca_tools_fx.c index 1e36c5e8e..c84078a7d 100644 --- a/lib_com/ivas_pca_tools_fx.c +++ b/lib_com/ivas_pca_tools_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include #include diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 4a72b194a..6b23f8eed 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5896,4 +5896,821 @@ void reset_metadata_spatial_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 nb_bits_metadata /* i : number of meatdata bits */ ); + +/*=============================================================================================*/ +/* clang-format off */ + +/*----------------------------------------------------------------------------------* + * General IVAS prototypes + *----------------------------------------------------------------------------------*/ + +/*! r: number of channels to be analysed */ + +void copy_encoder_config_ivas_fx( + Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ + Encoder_State *st, /* o : encoder state structure */ + const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ +); + +ivas_error create_mct_enc_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void destroy_cpe_enc( + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ +); + +void ivas_mct_enc_close_fx( + MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */ +); + +ivas_error pre_proc_front_ivas_fx( + 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*/ + const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + const Word16 n, /* i : channel number Q0*/ + Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/ + Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/ + Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ + Word16 *relE_fx, /* o : frame relative energy Q8*/ + Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/ + Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/ + Word16 *epsP_fx_q, + Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/ + Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/ + Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/ + Word16 *attack_flag, /* o : flag signaling attack Q0*/ + Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/ + Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/ + Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */ + Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/ + Word16 *q_old_wsp, + Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/ + Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/ + Word16 *loc_harm, /* o : harmonicity flag Q0*/ + Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/ + Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/ + Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ + Word16 *enerBuffer_fx_exp, /* o : energy buffer */ + Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/ + Word16 *fft_buff_fx_q, /* o : FFT buffer */ + const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/ + const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/ + const Word16 currFlatness_fx, /* i : flatness parameter Q7*/ + const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/ + Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/ + Word16 fr_bands_LR_fx_q[CPE_CHANNELS], + const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/ + Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/ + Word16 lf_E_LR_fx_q, + const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ + Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/ + Word16 band_energies_LR_fx_q, + const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ + const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ + const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ + const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ +#ifdef NONBE_1211_DTX_BR_SWITCHING + const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ +#endif + const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ + Word16 *Q_new +#ifdef DEBUG_MODE_INFO + , + const Word16 ch_idx +#endif +); +ivas_error pre_proc_ivas_fx( + 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*/ + const Word32 last_element_brate, /* i : last element bitrate Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */ + Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */ + Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/ + Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ + Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/ + Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/ + Word16 *epsP_fx_q, /* i : LP prediction errors */ + Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ + Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ + Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/ + Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/ + Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/ + Word16 e_old_wsp, + const Word16 loc_harm, /* i : harmonicity flag Q0*/ + const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ + Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */ + Word16 e_enerBuffer, + Word16 fft_buff_fx[2 * L_FFT], /* Qx */ + Word16 cor_map_sum_fx, /* Q8 */ + Word16 *Q_new +); +/*! r: number of clipped samples */ +void ivas_initialize_handles_enc_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +ivas_error ivas_init_encoder( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void ivas_destroy_enc_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +ivas_error ivas_initialize_MD_bstr_enc_fx( + BSTR_ENC_HANDLE *hBstr, /* o : encoder MD bitstream handle */ + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void ivas_destroy_MD_bstr_enc_fx( + BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle */ +); + +ivas_error ivas_init_decoder_front( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + + +void ivas_mct_dec_close( + MCT_DEC_HANDLE *hMCT /* i/o: MCT decoder structure */ +); + +/*! r: number of channels to be synthesised */ + +void copy_decoder_config( + Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ + Decoder_State *st /* o : decoder state structure */ +); + +void ivas_initialize_handles_dec( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +ivas_error ivas_core_enc_fx( + SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ + const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/ + Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/ + Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/ + Word16 Q_new[], + Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/ + Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes Q12*/ + Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/ + Word16 epsP_fx_q[], /* i : LP prediction errors */ + Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag[], /* i : VAD hanglover flag Q0*/ + Word16 attack_flag[], /* i : attack flag (GSC or TC) Q0*/ + Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer q_re_im_buf*/ + Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer q_re_im_buf*/ + Word16 *q_re_im_buf, + Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer e_old_wsp*/ + Word16 e_old_wsp[], + const Word16 loc_harm[], /* i : harmonicity flag Q0*/ + const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/ + const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/ + Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ + Word16 enerBuffer_fx_exp[], /* o : energy buffer */ + Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/ + const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/ + const Word16 ivas_format, /* i : IVAS format Q0*/ + const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ +); + +void ivas_renderer_select( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +ivas_error ivas_mc_enc_config_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +/*! r: flag indicating a valid bitrate */ +Word16 is_IVAS_bitrate_fx( + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); + +int16_t is_DTXrate( + const int32_t ivas_total_brate /* i : IVAS total bitrate */ +); + + +/*----------------------------------------------------------------------------------* + * JBM prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_jbm_dec_set_discard_samples( + Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ +); + +TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +); + +void ivas_jbm_dec_tc_buffer_close( + DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ +); + +void ivas_jbm_dec_td_renderers_adapt_subframes( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +ivas_error ivas_jbm_dec_metadata_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void ivas_jbm_masa_sf_to_sf_map( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + + +/*----------------------------------------------------------------------------------* + * ISM prototypes + *----------------------------------------------------------------------------------*/ + +void bitbudget_to_brate( + const Word16 x[], /* i : bitbudgets Q0 */ + Word32 y[], /* o : bitrates Q0 */ + const Word16 N /* i : number of entries to be converted */ +); + +void ivas_ism_reset_metadata( + ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ +); + +void ivas_ism_reset_metadata_enc( + ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */ +); +void ivas_ism_reset_metadata_API( + ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ +); + +/*! r: index of the winning codeword */ +Word16 ism_quant_meta_fx( + const Word32 val, /* i : scalar value to quantize Q22 */ + Word32 *valQ, /* o : quantized value Q22 */ + const Word32 borders_fx[], /* i : level borders Q22 */ + const Word32 q_step_fx, /* i : quantization step Q22 */ + const Word32 q_step_border_fx, /* i : quantization step at the border Q22 */ + const Word16 cbsize /* i : codebook size */ +); + +ivas_error ivas_ism_metadata_enc_create_fx( + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + const Word16 n_ISms, /* i : number of objects */ + Word32 element_brate_tmp[] /* o : element bitrate per object */ +); + +/*----------------------------------------------------------------------------------* + * Parametric ISM prototypes + *----------------------------------------------------------------------------------*/ + +/*! r: ISM format mode */ + +ivas_error ivas_param_ism_enc_open_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void ivas_param_ism_enc_close_fx( + PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */ + const Word32 input_Fs /* i : input sampling_rate */ +); + +void ivas_ism_metadata_close( + ISM_METADATA_HANDLE hIsmMetaData[], /* i/o : object metadata handles */ + const Word16 first_idx /* i : index of first handle to deallocate */ +); + + +ivas_error ivas_ism_enc_config( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +/*----------------------------------------------------------------------------------* + * ISM DTX prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_ism_dtx_open( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void ivas_ism_metadata_sid_enc_fx( + ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ + const Word16 flag_noisy_speech, /* i : noisy speech flag */ + const Word16 nchan_ism, /* i : number of objects */ + const Word16 nchan_transport, /* i : number of transport channels */ + const ISM_MODE ism_mode, /* i : ISM mode */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ + const Word16 sid_flag, /* i : indication of SID frame */ + const Word16 md_diff_flag[], /* i : metadata differental flag */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + Word16 nb_bits_metadata[] /* o : number of metadata bits */ +); + + + +void ivas_param_ism_compute_noisy_speech_flag_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +/*----------------------------------------------------------------------------------* + * DFT Stereo prototypes + *----------------------------------------------------------------------------------*/ + +void stereo_dft_dec_destroy( + STEREO_DFT_DEC_DATA_HANDLE *hStereoDft /* i/o: decoder DFT stereo handle */ +); + +/*----------------------------------------------------------------------------------* + * Range Coder prototypes + *----------------------------------------------------------------------------------*/ + +/*! r: Read bit */ +UWord16 rc_uni_dec_read_bit( + RangeUniDecState *rc_st_dec /* i/o: RC state handle */ +); + +/*! r: Read bit */ +UWord16 rc_uni_dec_read_bit_prob_fast( + RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ + const Word16 freq0, /* i : Frequency for symbol 0 */ + const UWord16 tot_shift /* i : Total frequency as a power of 2 */ +); + +/*! r: Read bits */ +UWord16 rc_uni_dec_read_bits( + RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ + const Word16 bits /* i : Number of bits */ +); + + +/*----------------------------------------------------------------------------------* + * TD Stereo prototypes + *----------------------------------------------------------------------------------*/ + +void tdm_bit_alloc( + const Word16 ivas_format, /* i : IVAS format */ + const Word16 ism_mode, /* i : ISM mode in combined format */ + const Word32 element_brate_wo_meta, /* i : element bitrate without metadata */ + const Word16 tdm_lp_reuse_flag, /* i : LPC reusage flag */ + Word32 *total_brate_pri, /* o : Allocated primary channel bitrate */ + Word32 *total_brate_sec, /* o : Allocated secondary channel bitrate */ + Word16 *tdm_low_rate_mode, /* o : secondary channel low rate mode flag */ + const Word16 coder_type, /* i : secondary channel coder type */ + const Word16 ener_ratio_idx, /* i : correlation ratio indexe */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 bwidth_pri, /* i : bandwidth of the primary channel */ + const Word16 bwidth_sec, /* i : bandwidth of the secondary channel */ + const Word16 flag_ACELP16k_pri, /* i : ACELP@16kHz core flag, primary chan. */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word16 coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */ + const Word16 tdm_inst_ratio_idx /* i : instantaneous correlation ratio index */ +); + + +/*! r: value of the indice */ +uint16_t get_indice_st( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 pos, /* i : absolute position in the bitstream */ + const Word16 nb_bits /* i : number of bits to quantize the indice */ +); + +/*----------------------------------------------------------------------------------* + * MDCT Stereo prototypes + *----------------------------------------------------------------------------------*/ + +void stereo_mdct_core_enc_fx( + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/ + Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ + Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ +); + +Word16 write_stereo_to_bitstream_fx +( + STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */ + Encoder_State **sts, /* i/o: Encoder state structure */ + Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/ + const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ + BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ +); + +/*----------------------------------------------------------------------------------* + * Stereo CNG prototypes + *----------------------------------------------------------------------------------*/ +void stereo_cng_dec_update( + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ +); + + +/*----------------------------------------------------------------------------------* + * Framework general prototypes + *----------------------------------------------------------------------------------*/ + +void mvc2c( + const uint8_t x[], /* i : input vector */ + uint8_t y[], /* o : output vector */ + const int16_t n /* i : vector size */ +); + +void stereo_switching_dec( + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ +); + + +/*! r: number of bits written */ + + + +/*----------------------------------------------------------------------------------* + * MCT prototypes + *----------------------------------------------------------------------------------*/ +void ivas_mdct_core_whitening_enc_fx( + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples */ + Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ + Word16 pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */ + Word32 *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */ + Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* o : buffer TNS bits */ + Word32 *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening */ + Word16 tnsSize[CPE_CHANNELS][NB_DIV], /* o : size of TNS */ + Word16 p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to parameter array */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */ + const Word16 nChannels, /* i : total number of coded channels */ +Word16 mdst_spectrum_e[CPE_CHANNELS][NB_DIV], +Word16 orig_spectrum_e[CPE_CHANNELS][NB_DIV] +); + +void splitAvailableBitsMCT_fx( + void **sts, /* i/o: encoder/decoder state structure */ + const Word16 total_bits, /* i : total number of available bits */ + const Word16 split_ratio[MCT_MAX_CHANNELS], /* i : ratio for splitting the bits Q0 */ + const Word16 enc_dec, /* i : encoder or decoder flag */ + const Word16 nchan /* i : number of channels */ +); + +void enc_prm_igf_mdct( + Encoder_State *st, /* i : Encoder state handle */ + BSTR_ENC_HANDLE hBstr /* i/o: Bitstream handle */ +); + +/*----------------------------------------------------------------------------------* + * Q Metadata prototypes for DirAC and MASA + *----------------------------------------------------------------------------------*/ +/*! r: number of bits written */ + +/*! r: number of bits read */ +Word16 ivas_qmetadata_dec_decode( + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ + UWord16 *bitstream, /* i : bitstream */ + Word16 *index, /* i/o: bitstream position */ + const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */ +); + +/*! r: number of bits read */ +Word16 ivas_qmetadata_dec_decode_hr_384_512( + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */ + UWord16 *bitstream, /* i : bitstream */ + Word16 *index, /* i/o: bitstream position */ + const SPHERICAL_GRID_DATA *sph_grid16, /* i : spherical grid for deindexing */ + const Word16 bits_sph_idx, + const Word16 bits_sp_coh, + const UWord8 ncoding_bands_config +); + +/*! r: number of bits read */ +Word16 ivas_qmetadata_dec_sid_decode( + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ + UWord16 *bitstream, /* i : bitstream */ + Word16 *index, /* i/o: bitstream position */ + const Word16 nchan_transport, /* i : number of transport channels */ + Word16 *element_mode, /* o : element mode */ + const Word16 ivas_format /* i : IVAS format */ +); + + +UWord16 ivas_qmetadata_reorder_generic_fx( + const Word16 signed_value +); + +void ivas_sba_set_cna_cng_flag( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +/*! r: number of ambisonics metadata channels */ + +void ivas_sba_dirac_stereo_config( + STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */ +); + + +Word16 ivas_get_sba_dirac_stereo_flag( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + + +/*----------------------------------------------------------------------------------* + * DirAC prototypes + *----------------------------------------------------------------------------------*/ + + +ivas_error ivas_dirac_enc_reconfigure( + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ +); + +ivas_error ivas_mc_paramupmix_enc_open_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ +); + +void ivas_mc_paramupmix_enc_close_fx( + MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ + const int32_t input_Fs /* i : input sampling rate */ +); + +ivas_error ivas_mc_paramupmix_dec_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void ivas_mc_paramupmix_dec_close( + MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */ +); + +void ivas_mc_paramupmix_dec_read_BS( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_State *st, /* i/o: decoder state structure */ + MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */ + Word16 *nb_bits /* o : number of bits written */ +); + +void ivas_mc_paramupmix_dec_digest_tc( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + const Word16 nSamplesForRendering /* i : number of samples provided */ +); + +void ivas_param_mc_set_coded_bands_fx( + HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* i/o: handle for the Parametric MC parameter coding state */ +); + +UWord16 ivas_param_mc_get_configuration_index_fx( + const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); + +/*----------------------------------------------------------------------------------* + * SPAR prototypes + *----------------------------------------------------------------------------------*/ + +/* MD module */ + +/*! r: number of MD subframes */ +ivas_error ivas_spar_md_dec_open( + ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ + const Word16 num_channels, /* i : number of internal channels */ + const Word16 sba_order, /* i : SBA order */ + const Word16 sid_format, /* i : SID format */ + const Word32 last_active_ivas_total_brate /* i : IVAS last active bitrate */ +); + +void ivas_spar_md_dec_close( + ivas_spar_md_dec_state_t **hMdDec /* i/o: SPAR MD decoder handle */ +); + +ivas_error ivas_spar_md_dec_init( + ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ + const Word16 num_channels, /* i : number of internal channels */ + const Word16 sba_order /* i : SBA order */ +); + +/* Transient detector module */ +ivas_error ivas_transient_det_open_fx( + ivas_trans_det_state_t **hTranDet, /* i/o: Transient detector handle */ + const Word32 sampling_rate /* i : sampling rate */ +); + +void ivas_transient_det_close_fx( + ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */ +); + +void ivas_huffman_encode_fx( + ivas_huffman_cfg_t *huff_cfg, + Word16 in, + Word16 *hcode, + Word16 *hlen +); + +ivas_error ivas_huffman_decode( + ivas_huffman_cfg_t *huff_cfg, + Decoder_State *st0, + Word16 *dec_out +); + +void ivas_arith_decode_cmplx_cell_array( + ivas_arith_t *pArith_re, + ivas_arith_t *pArith_re_diff, + Decoder_State *st0, + ivas_cell_dim_t *pCell_dims, + Word16 *pDo_diff, const Word16 nB, + Word16 *pSymbol_re, + Word16 *pSymbol_re_old +); + +void ivas_map_prior_coeffs_quant( + ivas_spar_md_prev_t *pSpar_md_prior, + ivas_spar_md_com_cfg *pSpar_md_cfg, + const Word16 qsi, + const Word16 nB +); + +void ivas_clear_band_coeff_idx( + ivas_band_coeffs_ind_t *pband_coeff_idx, + const UWord16 num_bands +); + + +/*----------------------------------------------------------------------------------* + * MASA prototypes + *----------------------------------------------------------------------------------*/ +ivas_error ivas_masa_enc_open_fx( + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ +); + +void ivas_masa_enc_close_fx( + MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */ +); + +int16_t ivas_qmetadata_encode_extended_gr_length_fx( + const UWord16 value, + const UWord16 alphabet_size, + const Word16 gr_param); + +void ivas_qmetadata_encode_extended_gr_fx( + BSTR_ENC_HANDLE hMetaData, /* i/o: q_metadata handle */ + const UWord16 value, /* i : value to be encoded */ + const UWord16 alphabet_size, /* i : alphabet size */ + const Word16 gr_param); /* i : GR order */ + + +void ivas_set_qmetadata_maxbit_req_fx( + IVAS_QMETADATA_HANDLE hQMetaData, /* o : qmetadata structure where the requirement value is set */ + const IVAS_FORMAT ivas_format /* i : IVAS format */ +); + + +/*---------------------------------------------------------------------------------* + * Binaural FastConv Renderer Prototypes +*-----------------------------------------------------------------------------------*/ + + +void ivas_binaural_hrtf_close( + HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */ +); + +/*----------------------------------------------------------------------------------* + * renderer prototypes + *----------------------------------------------------------------------------------*/ + +void ivas_ism_renderer_close( + ISM_RENDERER_HANDLE *hIsmRendererData /* i/o: ISM renderer handle */ +); + + +/*----------------------------------------------------------------------------------* + * Amplitude Panning VBAP prototypes + *----------------------------------------------------------------------------------*/ + +void panning_wrap_angles( + const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ + const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ + float *azi_wrapped, /* o : wrapped azimuth component */ + float *ele_wrapped /* o : wrapped elevation component */ +); + + +/*----------------------------------------------------------------------------------* + * McMASA prototypes + *----------------------------------------------------------------------------------*/ + + +ivas_error ivas_mcmasa_dec_reconfig( + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +); + +void ivas_mcmasa_dmx_modify_fx( + const Word16 n_samples, /* i : input frame length in samples */ + Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/ + Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/ + const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */ + const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/ +); + +ivas_error ivas_mono_dmx_renderer_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + + +void ivas_mono_dmx_renderer_close( + MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ +); + + +/*----------------------------------------------------------------------------------* + * LFE encoder low pass filter prototypes + *----------------------------------------------------------------------------------*/ + +void ivas_lfe_lpf_enc_close_fx( + ivas_filters_process_state_t **hLfeLpf /* i/o: LFE LPF handle */ +); + + +/*----------------------------------------------------------------------------------* + * LFE Coding prototypes + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_create_lfe_enc_fx( + LFE_ENC_HANDLE *hLFE, /* o : IVAS LFE encoder structure */ + const Word32 input_Fs /* i : input sampling rate */ +); + +void ivas_lfe_enc_close_fx( + LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */ +); + +void ivas_filters_init_fx( + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + const Word32 *filt_coeff_fx, /* i : filter coefficients Q31- *filt_coeff_e */ + const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */ + const Word16 order ) ; + +void ivas_filter_process_fx( + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ + const Word16 length, /* i : filter order */ + Word16 q_factor ); + +/*----------------------------------------------------------------------------------* + * OSBA prototypes + *----------------------------------------------------------------------------------*/ +ivas_error ivas_osba_enc_reconfig( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +void ivas_set_surplus_brate_enc( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +#ifdef DEBUG_MODE_INFO + , + const int16_t *nb_bits_metadata /* i : number of metadata bits */ +#endif +); + +void ivas_set_surplus_brate_dec( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + int32_t *ism_total_brate /* i : ISM total bitrate */ +); + +ivas_error ivas_omasa_separate_object_renderer_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void ivas_omasa_separate_object_renderer_close( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +/*----------------------------------------------------------------------------------* + * Filter-bank (FB) Mixer + *----------------------------------------------------------------------------------*/ + +ivas_error ivas_fb_set_cfg( + IVAS_FB_CFG **pFb_cfg_out, /* o : FB config. handle */ + const Word16 ivas_format, /* i : IVAS format */ + const Word16 num_in_chans, /* i : number of FB input channels */ + const Word16 num_out_chans, /* i : number of FB output channels */ + const Word16 active_w_mixing, /* i : active_w_mixing flag */ + const Word32 sampling_Fs, /* i : sampling rate */ + const Word16 nachan_dirac_ana /* i : number of DirAR analysis channels */ +); + + +/*=============================================================================================*/ + #endif diff --git a/lib_com/ivas_qmetadata_com_fx.c b/lib_com/ivas_qmetadata_com_fx.c index 79a585e8b..c9ad84097 100644 --- a/lib_com/ivas_qmetadata_com_fx.c +++ b/lib_com/ivas_qmetadata_com_fx.c @@ -36,7 +36,6 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_qspherical_com_fx.c b/lib_com/ivas_qspherical_com_fx.c index 5caa850cb..6661026a8 100644 --- a/lib_com/ivas_qspherical_com_fx.c +++ b/lib_com/ivas_qspherical_com_fx.c @@ -36,7 +36,6 @@ #include #include "ivas_cnst.h" #include "ivas_rom_com.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_sba_config_fx.c b/lib_com/ivas_sba_config_fx.c index 38785956c..b3a0806d4 100644 --- a/lib_com/ivas_sba_config_fx.c +++ b/lib_com/ivas_sba_config_fx.c @@ -38,7 +38,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index f35de8eb0..fa64b0092 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include @@ -61,12 +60,11 @@ void sns_compute_scf_fx( Word64 sum; Word32 L_tmp; const Word32 *pow_tilt; + Word16 q_shift, q_out, f_tmp; + Word16 bw, inv_bw, exp; const UWord8 nBands = pPsychParams->nBands; move16(); const UWord8 *bandLengths = pPsychParams->bandLengths; - Word8 bw = 0; - move16(); - Word16 q_shift; const Word16 w_0 = 2730; // (1.0f / 12.0f) in Q15 move16(); @@ -88,91 +86,83 @@ void sns_compute_scf_fx( IF( bandLengths == NULL ) { - bw = (Word8) shr( L_frame, 6 ); + bw = shr( L_frame, 6 ); move16(); + + exp = norm_s( bw ); + inv_bw = div_s( ONE_IN_Q14, shl( bw, exp ) ); // Q:15+14-exp = 29-exp + inv_bw = shl( inv_bw, sub( exp, 14 ) ); // Q15 + /* Energy per band */ k = 0; move16(); FOR( i = 0; i < nBands; ++i ) { - x_64[i] = 0; + sum = 0; move64(); FOR( n = 0; n < bw; ( ++n, ++k ) ) { - x_64[i] = W_add( x_64[i], W_deposit32_l( spectrum[k] ) ); // Q_in - move64(); + /* x[i] += spectrum[k]; + inv_bw is for x[i] /= bw; */ + sum = W_mac_32_16( sum, spectrum[k], inv_bw ); // Q_in+15+1 } + x_64[i] = sum; // Q_in+16 + move64(); } } ELSE { /* Energy per band */ k = 0; - move32(); + move16(); FOR( i = 0; i < nBands; ++i ) { - x_64[i] = 0; + exp = norm_s( bandLengths[i] ); + inv_bw = div_s( ONE_IN_Q14, shl( bandLengths[i], exp ) ); // Q:15+14-exp + inv_bw = shl( inv_bw, sub( exp, 14 ) ); // Q15 + + sum = 0; move64(); FOR( n = 0; n < bandLengths[i]; ( ++n, ++k ) ) { - x_64[i] = W_add( x_64[i], W_deposit32_l( spectrum[k] ) ); // Q_in - move64(); + /* x[i] += spectrum[k]; + inv_bw is for x[i] /= bandLengths[i]; */ + sum = W_mac_32_16( sum, spectrum[k], inv_bw ); // Q_in+15+1 } + x_64[i] = sum; // Q_in+16 + move64(); } } /* Move accumulated values to 32-bit */ - q_shift = 0; - move16(); - IF( x_64[0] != 0 ) + q_shift = W_norm_arr( x_64, nBands ); // W_norm_arr return 63 when all the values of the input buffer are zeroes + IF( EQ_16( q_shift, 63 ) ) { - q_shift = W_norm( x_64[0] ); - } - FOR( i = 1; i < nBands; ++i ) - { - IF( x_64[i] != 0 ) - { - q_shift = s_min( q_shift, W_norm( x_64[i] ) ); - } - } - FOR( i = 0; i < nBands; ++i ) - { - x[i] = W_extract_l( W_shl( x_64[i], sub( q_shift, 32 ) ) ); // Q_in + (q_shift - 32) - } + /* If all the values of x_64 are zeros, the scale factor (scf) values will be calculated as zeroes as per the below operations. + To avoid extra computations in such a case, set scf values as zeroes and return. */ - IF( bandLengths == NULL ) - { - Word16 inv_bw; - bw = (Word8) shr( L_frame, 6 ); - move16(); - inv_bw = div_l( ONE_IN_Q16 /*1 Q16*/, bw ); // Q15 - FOR( i = 0; i < nBands; ++i ) - { - x[i] = Mpy_32_16_1( x[i], inv_bw ); // Q_in + (q_shift - 32) - move32(); - } + set_zero_fx( scf, SNS_NPTS ); + + return; } - ELSE + + FOR( i = 0; i < nBands; ++i ) { - FOR( i = 0; i < nBands; ++i ) - { - Word16 inv_bw = div_l( ONE_IN_Q16 /*1 Q16*/, bandLengths[i] ); // Q15 - x[i] = Mpy_32_16_1( x[i], inv_bw ); // Q_in + (q_shift - 32) - move32(); - } + x[i] = W_extract_h( W_shl( x_64[i], q_shift ) ); // Q: Q_in+16+q_shift-32 = Q_in+q_shift-16 + move32(); } /* Smoothing */ - xs[0] = L_add( Mpy_32_16_1( x[0], 24576 /* 0.75 in Q15 */ ), Mpy_32_16_1( x[1], 8192 /* 0.25 in Q15 */ ) ); // Q_in + (q_shift - 32) + xs[0] = Madd_32_16( Mpy_32_16_1( x[0], 24576 /* 0.75 in Q15 */ ), x[1], 8192 /* 0.25 in Q15 */ ); // Q_in+q_shift-16 move32(); FOR( i = 1; i < FDNS_NPTS - 1; i++ ) { - xs[i] = L_add( L_add( Mpy_32_16_1( x[i], 16384 /* 0.5 in Q15 */ ), Mpy_32_16_1( x[i - 1], 8192 /* 0.25 in Q15 */ ) ), Mpy_32_16_1( x[i + 1], 8192 /* 0.25 in Q15 */ ) ); // Q_in + (q_shift - 32) + xs[i] = Madd_32_16( Madd_32_16( Mpy_32_16_1( x[i], 16384 /* 0.5 in Q15 */ ), x[i - 1], 8192 /* 0.25 in Q15 */ ), x[i + 1], 8192 /* 0.25 in Q15 */ ); // Q_in+q_shift-16 move32(); } - xs[FDNS_NPTS - 1] = L_add( Mpy_32_16_1( x[FDNS_NPTS - 1], 24576 /* 0.75 in Q15 */ ), Mpy_32_16_1( x[FDNS_NPTS - 2], 8192 /* 0.25 in Q15 */ ) ); // Q_in + (q_shift - 32) + xs[FDNS_NPTS - 1] = Madd_32_16( Mpy_32_16_1( x[FDNS_NPTS - 1], 24576 /* 0.75 in Q15 */ ), x[FDNS_NPTS - 2], 8192 /* 0.25 in Q15 */ ); // Q_in+q_shift-16 move32(); /* Pre-emphasis */ @@ -194,86 +184,83 @@ void sns_compute_scf_fx( FOR( i = 0; i < FDNS_NPTS; i++ ) { - xs[i] = Mpy_32_32( xs[i], pow_tilt[i] ); // Q_in + (q_shift - 32) + xs[i] = Mpy_32_32( xs[i], pow_tilt[i] ); // Q_in+q_shift-16+23-31 = Q_in+q_shift-24 move32(); } /* Noise floor at -40dB */ sum = 0; move64(); - FOR( Word16 ind = 0; ind < FDNS_NPTS; ind++ ) + FOR( i = 0; i < FDNS_NPTS; i++ ) { - sum = W_add( sum, W_deposit32_l( xs[ind] ) ); // Q_in + (q_shift - 32) + sum = W_mac_32_16( sum, xs[i], 1 ); // Q_in+q_shift-24+1 } - mean = W_extract_l( W_shr( sum, 6 ) ); // Q_in + (q_shift - 32) - nf = Mpy_32_32( mean, 214748 /* powf( 10.0f, -4.0f ) in Q31 */ ); // Q_in + (q_shift - 32) - nf = L_max( nf, 0 /* powf( 2.0f, -32.0f ) in Q31 */ ); // Q_in + (q_shift - 32) + q_out = sub( add( Q_in, q_shift ), 24 ); + + /* mean = sum / FDNS_NPTS; + -Q6 is for division with FDNS_NPTS and -Q1 is to reduce Q by one */ + mean = W_shl_sat_l( sum, -Q7 ); // q_out + nf = Mpy_32_32( mean, 214748 /* powf( 10.0f, -4.0f ) in Q31 */ ); // q_out + nf = L_max( nf, L_shl( 256, sub( q_out, 40 ) ) /* powf( 2.0f, -32.0f ) in Q40 */ ); // q_out FOR( i = 0; i < FDNS_NPTS; i++ ) { - if ( LT_32( xs[i], nf ) ) - { - xs[i] = nf; // Q_in + (q_shift - 32) - move32(); - } + xs[i] = L_max( xs[i], nf ); // q_out + move32(); } /* Log-domain */ FOR( i = 0; i < FDNS_NPTS; i++ ) { - Word16 e_tmp = norm_l( xs[i] ); - Word16 f_tmp = Log2_norm_lc( L_shl( xs[i], e_tmp ) ); /*Q16*/ - e_tmp = sub( sub( 34, e_tmp ), Q_in ); - /* Note: Mpy_32_16 is used temporarily for this computation, It needs to be replaced with appropriate BASOP. */ - xl[i] = Mpy_32_16( e_tmp, f_tmp, 16384 ); /* Q16 */ + /* xl[i] = logf( xs[i] ) * scale_log; + scale_log = INV_LOG_2 * 0.5f; */ + + exp = norm_l( xs[i] ); + f_tmp = Log2_norm_lc( L_shl( xs[i], exp ) ); // Q15 + exp = sub( sub( 30, exp ), q_out ); + L_tmp = L_mac( L_deposit_h( exp ), f_tmp, 1 ); // Q16 + xl[i] = L_shr( L_tmp, 1 ); // Q16 move32(); } /* Downsampling */ - L_tmp = L_deposit_l( 0 ); - L_tmp = Madd_32_16( L_tmp, xl[0], w_0 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[0], w_1 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[1], w_2 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[2], w_3 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[3], w_4 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[4], w_5 ); // Q16 - xl4[0] = L_tmp; // Q16 - move32(); + L_tmp = Madd_32_16( Mpy_32_16_1( xl[0], w_0 ), xl[0], w_1 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[1], w_2 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[2], w_3 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[3], w_4 ); // Q16 + xl4[0] = Madd_32_16( L_tmp, xl[4], w_5 ); // Q16 + FOR( n = 1; n < SNS_NPTS - 1; n++ ) { - Word16 n4 = shl( n, 2 ); - - L_tmp = L_deposit_l( 0 ); - L_tmp = Madd_32_16( L_tmp, xl[n4 - 1], w_0 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[n4], w_1 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[n4 + 1], w_2 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[n4 + 2], w_3 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[n4 + 3], w_4 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[n4 + 4], w_5 ); // Q16 - xl4[n] = L_tmp; // Q16 + L_tmp = Mpy_32_16_1( xl[4 * n - 1], w_0 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[4 * n], w_1 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[4 * n + 1], w_2 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[4 * n + 2], w_3 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[4 * n + 3], w_4 ); // Q16 + xl4[n] = Madd_32_16( L_tmp, xl[4 * n + 4], w_5 ); // Q16 move32(); } - L_tmp = L_deposit_l( 0 ); - L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 5], w_0 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 4], w_1 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 3], w_2 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 2], w_3 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 1], w_4 ); // Q16 - L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 1], w_5 ); // Q16 - xl4[SNS_NPTS - 1] = L_tmp; // Q16 + L_tmp = Mpy_32_16_1( xl[FDNS_NPTS - 5], w_0 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 4], w_1 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 3], w_2 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 2], w_3 ); // Q16 + L_tmp = Madd_32_16( L_tmp, xl[FDNS_NPTS - 1], w_4 ); // Q16 + xl4[SNS_NPTS - 1] = Madd_32_16( L_tmp, xl[FDNS_NPTS - 1], w_5 ); // Q16 move32(); /* Remove mean and scaling */ sum = 0; move64(); - FOR( Word16 ind = 0; ind < SNS_NPTS; ind++ ) + FOR( i = 0; i < SNS_NPTS; i++ ) { - sum = W_add( sum, W_deposit32_l( xl4[ind] ) ); // Q16 + sum = W_mac_32_16( sum, xl4[i], 1 ); // Q16+1 } - mean = W_extract_l( W_shr( sum, 4 ) ); // Q16 + /* mean = sum / SNS_NPTS; + -Q4 is for division with SNS_NPTS and -Q1 is to reduce Q by one */ + mean = W_shl_sat_l( sum, -Q5 ); // Q16 FOR( i = 0; i < SNS_NPTS; i++ ) { diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 96df64aa5..929eaa2c5 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -36,7 +36,6 @@ #include "basop_util.h" #include "ivas_stat_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "cnst.h" diff --git a/lib_com/ivas_spar_com_quant_util_fx.c b/lib_com/ivas_spar_com_quant_util_fx.c index 8292de5c1..cfd03a3b3 100644 --- a/lib_com/ivas_spar_com_quant_util_fx.c +++ b/lib_com/ivas_spar_com_quant_util_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "math.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" diff --git a/lib_com/ivas_stereo_dft_com_fx.c b/lib_com/ivas_stereo_dft_com_fx.c index 80e64c0cc..6d63bc6d1 100644 --- a/lib_com/ivas_stereo_dft_com_fx.c +++ b/lib_com/ivas_stereo_dft_com_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "cnst.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_stereo_eclvq_com_fx.c b/lib_com/ivas_stereo_eclvq_com_fx.c index d0ffff39c..958781473 100644 --- a/lib_com/ivas_stereo_eclvq_com_fx.c +++ b/lib_com/ivas_stereo_eclvq_com_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c index 9aa880842..8548797a4 100644 --- a/lib_com/ivas_stereo_ica_com_fx.c +++ b/lib_com/ivas_stereo_ica_com_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_stereo_mdct_bands_com_fx.c b/lib_com/ivas_stereo_mdct_bands_com_fx.c index c21abcf8c..43f2f16c7 100644 --- a/lib_com/ivas_stereo_mdct_bands_com_fx.c +++ b/lib_com/ivas_stereo_mdct_bands_com_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" -#include "ivas_prot.h" #include "rom_com.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_stereo_mdct_stereo_com_fx.c b/lib_com/ivas_stereo_mdct_stereo_com_fx.c index dd94358af..0a773169d 100644 --- a/lib_com/ivas_stereo_mdct_stereo_com_fx.c +++ b/lib_com/ivas_stereo_mdct_stereo_com_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include #include "prot_fx.h" diff --git a/lib_com/ivas_stereo_psychlpc_com_fx.c b/lib_com/ivas_stereo_psychlpc_com_fx.c index cb3c39df2..df5140895 100644 --- a/lib_com/ivas_stereo_psychlpc_com_fx.c +++ b/lib_com/ivas_stereo_psychlpc_com_fx.c @@ -33,9 +33,7 @@ #include #include "options.h" #include "ivas_rom_com.h" -#include "ivas_prot.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include diff --git a/lib_com/ivas_stereo_td_bit_alloc_fx.c b/lib_com/ivas_stereo_td_bit_alloc_fx.c index 9074473d7..b54c1d3de 100644 --- a/lib_com/ivas_stereo_td_bit_alloc_fx.c +++ b/lib_com/ivas_stereo_td_bit_alloc_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "stat_enc.h" #include "rom_com.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" #include "prot_fx.h" diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index e15db9a15..04d6f7bf5 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 97025b46f..3b9a8cfd7 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -36,7 +36,6 @@ #include "wmc_auto.h" #include "prot_fx.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_stat_com.h" diff --git a/lib_com/mslvq_com.c b/lib_com/mslvq_com.c index 6bd8026c4..12234a4c0 100644 --- a/lib_com/mslvq_com.c +++ b/lib_com/mslvq_com.c @@ -40,7 +40,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------* diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index d0f0efb72..db0953cd9 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4701,6 +4701,7 @@ Word16 find_guarded_bits_fx( Word32 n ); Word16 L_norm_arr( const Word32 *arr, Word16 size ); Word16 norm_arr( Word16 *arr, Word16 size ); +Word16 W_norm_arr( Word64 *arr, Word16 size ); Word16 get_min_scalefactor( Word32 x, Word32 y ); diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index 1f112c911..7905c7145 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -41,7 +41,6 @@ #include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" -#include "ivas_prot.h" #include diff --git a/lib_dec/ACcontextMapping_dec_fx.c b/lib_dec/ACcontextMapping_dec_fx.c index 34e74a06f..22e9fff01 100644 --- a/lib_dec/ACcontextMapping_dec_fx.c +++ b/lib_dec/ACcontextMapping_dec_fx.c @@ -12,7 +12,6 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" /*-------------------------------------------------------------------* * ACcontextMapping_decode2_no_mem_s17_LC() diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 11379a62d..782654623 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -41,7 +41,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 191065855..d1ed7ad8c 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -10,7 +10,6 @@ #include "stl.h" #include "options.h" #include "math.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 907a4a350..c1b0ce93a 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -9,7 +9,6 @@ #include "options.h" #include "stl.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "cnst.h" #include "stat_dec.h" @@ -2932,14 +2931,14 @@ static void IGF_getWhiteSpectralData_ivas( { ak = 0; move32(); - move16(); FOR( j = i - level; j < stop; j++ ) { tmp_16 = extract_h( L_shl( in[j], s_l ) ); // e: in_e - s_l ak = L_mac( ak, tmp_16, tmp_16 ); // e: 2 * (in_e - s_l) } - ak = Mult_32_16( ak, quo ); + ak = L_deposit_h( BASOP_Util_Divide3216_Scale( ak, sub( stop, sub( i, level ) ), &tmp_e ) ); + ak_e = add( tmp_e, sub( shl( sub( in_e, s_l ), 1 ), 15 ) ); // tmp_e + 2 * (in_e - s_l) - 15 n = sub( 30, add( norm_l( ak ), sub( 31, ak_e ) ) ); n = shr( n, 1 ); diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index e73d89158..a196a1abd 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 3c234c098..8527e6703 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "cnst.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 5bb4736e9..7b4e5f267 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_corecoder_dec_reconfig_fx.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c index 697f9d715..25c0bea42 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig_fx.c +++ b/lib_dec/ivas_corecoder_dec_reconfig_fx.c @@ -32,7 +32,6 @@ #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 9bf53f1de..6a6294377 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -37,7 +37,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_decision_matrix_dec_fx.c b/lib_dec/ivas_decision_matrix_dec_fx.c index f7fd5e8e2..717bb3b93 100644 --- a/lib_dec/ivas_decision_matrix_dec_fx.c +++ b/lib_dec/ivas_decision_matrix_dec_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "stat_dec.h" #include "rom_com.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 59d9c9e38..d8288e561 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index e03913f8a..b247fd653 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -41,7 +41,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_entropy_decoder_fx.c b/lib_dec/ivas_entropy_decoder_fx.c index e637a6a93..f8bf3c091 100644 --- a/lib_dec/ivas_entropy_decoder_fx.c +++ b/lib_dec/ivas_entropy_decoder_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 8db782c4e..b11669460 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 664e3eeac..643874a82 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index cbf088597..0f023a7ef 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index a6f5e47b6..3288903ab 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index eae0e9069..3aed4d3b1 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -34,7 +34,6 @@ #include #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "prot_fx.h" #include "rom_com.h" diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index a19ba70ec..7cd93affa 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_stat_com.h" diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 428c817ef..210425b88 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index e68c0142d..672d3fbe6 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "rom_com.h" diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index 018f99fe7..210c266eb 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" diff --git a/lib_dec/ivas_ls_custom_dec_fx.c b/lib_dec/ivas_ls_custom_dec_fx.c index 45f59d82f..5ad390f9a 100644 --- a/lib_dec/ivas_ls_custom_dec_fx.c +++ b/lib_dec/ivas_ls_custom_dec_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include #include "options.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 806785c15..384865a1a 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index be2363469..697ae6345 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -37,7 +37,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 9ea666237..3c2ba7587 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "rom_com.h" diff --git a/lib_dec/ivas_mcmasa_dec_fx.c b/lib_dec/ivas_mcmasa_dec_fx.c index c2228b610..1b1715c21 100644 --- a/lib_dec/ivas_mcmasa_dec_fx.c +++ b/lib_dec/ivas_mcmasa_dec_fx.c @@ -33,7 +33,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index be457da47..fe39fd8e3 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -39,7 +39,6 @@ #include "cnst.h" #include "basop_proto_func.h" #include "stat_com.h" -#include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_stat_com.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 081eca88d..884a44c9e 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -38,7 +38,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c index 69f601724..c275820fb 100644 --- a/lib_dec/ivas_mct_dec_mct_fx_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "wmc_auto.h" #include diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index a5855a0f6..35d38d03a 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -40,7 +40,6 @@ #include "cnst.h" #include "basop_proto_func.h" #include "stat_com.h" -#include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_stat_com.h" #include diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index bb5dead22..2eb8d84df 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -35,7 +35,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 391a27522..b88b68915 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index bf7fba094..afa604684 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -33,7 +33,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_prot_rend.h" diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 07ea14ea2..6f1a233c9 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -33,7 +33,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 4811911fd..84b6fe46d 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -35,7 +35,6 @@ #include #include #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index cb96d3b0d..3a0960960 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c index 08ac17799..98611ab7c 100644 --- a/lib_dec/ivas_pca_dec_fx.c +++ b/lib_dec/ivas_pca_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index 397f26bbc..9357394a5 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index 81768af44..c78c51c52 100644 --- a/lib_dec/ivas_qmetadata_dec_fx.c +++ b/lib_dec/ivas_qmetadata_dec_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_qspherical_dec_fx.c b/lib_dec/ivas_qspherical_dec_fx.c index d34b5402a..f6ac39a99 100644 --- a/lib_dec/ivas_qspherical_dec_fx.c +++ b/lib_dec/ivas_qspherical_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_range_uni_dec_fx.c b/lib_dec/ivas_range_uni_dec_fx.c index e629111ce..9a49680e8 100644 --- a/lib_dec/ivas_range_uni_dec_fx.c +++ b/lib_dec/ivas_range_uni_dec_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_stat_dec.h" #include "cnst.h" diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index efd766f76..f04350366 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 573a9c17f..0c7544682 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index a42c67389..8748342ed 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index 89581565c..a6be10c08 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -37,7 +37,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index 170256181..fd25e7ea7 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index 812027468..34a194898 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -37,7 +37,6 @@ #include "ivas_stat_dec.h" #include "prot_fx.h" #include "string.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index bb79b956c..7f487a75c 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "math.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" diff --git a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c index 8446af47d..2bade4786 100644 --- a/lib_dec/ivas_stereo_adapt_GR_dec_fx.c +++ b/lib_dec/ivas_stereo_adapt_GR_dec_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "rom_dec.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 4d50ba350..223860db0 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -35,7 +35,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 166ac72e5..f0fd1978b 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -38,7 +38,6 @@ #include "rom_com.h" #include "rom_dec.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c index 0781d49a6..e82005965 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index fb54476fa..1c18ffacb 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -38,7 +38,6 @@ #include "rom_com.h" #include "rom_dec.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index d3415a8eb..90d9c5823 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "prot_fx.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "math.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_stereo_eclvq_dec_fx.c b/lib_dec/ivas_stereo_eclvq_dec_fx.c index 693df8c77..dfa411145 100644 --- a/lib_dec/ivas_stereo_eclvq_dec_fx.c +++ b/lib_dec/ivas_stereo_eclvq_dec_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_stereo_esf_dec_fx.c b/lib_dec/ivas_stereo_esf_dec_fx.c index 80603f6c0..d4219f1e6 100644 --- a/lib_dec/ivas_stereo_esf_dec_fx.c +++ b/lib_dec/ivas_stereo_esf_dec_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index b49ab5399..694aad0b4 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index 22a8c4a90..3b32072f3 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" #include "rom_com.h" diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 04781a9cb..a6b350d33 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -37,7 +37,6 @@ #include "prot_fx.h" #include "cnst.h" #include "stat_com.h" -#include "ivas_prot.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 69083a078..3f39bd9ac 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index e5e18083d..09b683a16 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "assert.h" diff --git a/lib_dec/ivas_stereo_td_dec_fx.c b/lib_dec/ivas_stereo_td_dec_fx.c index 8ab7da035..023c9a2e5 100644 --- a/lib_dec/ivas_stereo_td_dec_fx.c +++ b/lib_dec/ivas_stereo_td_dec_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" #include "wmc_auto.h" @@ -338,45 +337,6 @@ void tdm_configure_dec_fx( return; } -/*-------------------------------------------------------------------* - * Function tdm_downmix_plain() - * - * downmix Left+Right to Primary+Secondary channel - *-------------------------------------------------------------------*/ - -void tdm_upmix_plain( - float Left[], /* o : left channel */ - float Right[], /* o : right channel */ - const float PCh_2_L[], /* i : primary channel */ - const float SCh_2_R[], /* i : secondary channel */ - const float LR_ratio, /* i : mixing ratio */ - const float inv_den_LR_ratio, /* i : inverse mixing ration */ - const int16_t start_index, /* i : start index */ - const int16_t end_index, /* i : end index */ - const int16_t plus_minus_flag /* i : plus/minus flag */ -) -{ - int16_t i; - - if ( plus_minus_flag == 1 ) - { - for ( i = start_index; i < end_index; i++ ) - { - Left[i] = ( LR_ratio * ( PCh_2_L[i] - SCh_2_R[i] ) + SCh_2_R[i] ) * inv_den_LR_ratio; - Right[i] = ( -LR_ratio * ( PCh_2_L[i] + SCh_2_R[i] ) + PCh_2_L[i] ) * inv_den_LR_ratio; - } - } - else - { - for ( i = start_index; i < end_index; i++ ) - { - Left[i] = ( LR_ratio * ( PCh_2_L[i] + SCh_2_R[i] ) - SCh_2_R[i] ) * inv_den_LR_ratio; - Right[i] = ( LR_ratio * ( PCh_2_L[i] - SCh_2_R[i] ) - PCh_2_L[i] ) * inv_den_LR_ratio; - } - } - - return; -} void tdm_upmix_plain_fx( Word32 Left_fx[], /* o : left channel Qx*/ Word32 Right_fx[], /* o : right channel Qx*/ diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index 375dbdad0..1467687d8 100644 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index c908e4dc3..07eba9e64 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -40,7 +40,6 @@ #include "wmc_auto.h" #include "basop_proto_func.h" #include "stat_com.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------* diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 63819b056..98c1a6a79 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -38,7 +38,6 @@ #include "ivas_rom_com.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" void tdm_low_rate_dec_fx( diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 66109b555..ef3baee3c 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -35,7 +35,6 @@ #include #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index d263e6dd3..21e8705f3 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -7,7 +7,6 @@ #include "cnst.h" /* Common constants */ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ -#include "ivas_prot.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* * Local functions diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 44439540f..c52fddf97 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -13,7 +13,6 @@ #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "prot_fx_enc.h" -#include "ivas_prot.h" /* Range coder header file */ #define MAKE_NUMBER_QX( number, QX ) ( ( number ) << ( QX ) ) /* evaulated at compile time */ #define MAKE_VARIABLE_QX( variable, QX ) W_shl( W_deposit32_l( L_deposit_l( ( variable ) ) ), ( QX ) ) /* evaluated at run time */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 0f58bcdad..782006108 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -13,7 +13,6 @@ #include "rom_com_fx.h" /* Static table prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/cod4t64_fast.c b/lib_enc/cod4t64_fast.c index a901690e3..0e4c02744 100644 --- a/lib_enc/cod4t64_fast.c +++ b/lib_enc/cod4t64_fast.c @@ -35,7 +35,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index c54e8ccf4..7c28c3309 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -16,7 +16,6 @@ #include "prot_fx_enc.h" #ifdef IVAS_FLOAT_FIXED_CONVERSIONS #include -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" #endif diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 9e6318591..f546c3ef8 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -1165,18 +1165,30 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { + Word16 q_mdstWin, scale; L_subframe = idiv1616( L_frameTCX, nSubframes ); /* Q0 */ test(); IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { wtda_ext_fx( hTcxEnc->new_speech_TCX, mdstWin, overlap_mode[frameno], overlap_mode[frameno + 1], L_frameTCX, 3 ); - Scale_sig( mdstWin, L_frameTCX, 1 ); + scale = sub( norm_arr( mdstWin, L_frameTCX ), 1 ); + scale = s_min( 1, scale ); // restricting the Q to zero or less + scale_sig( mdstWin, L_frameTCX, scale ); + q_mdstWin = add( -1, scale ); + move16(); } ELSE { + Word16 sig_len; /* Windowing for the MDST */ WindowSignal( st->hTcxCfg, st->hTcxCfg->tcx_offsetFB, overlap_mode[frameno] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno], overlap_mode[frameno + 1] == ALDO_WINDOW ? FULL_OVERLAP : overlap_mode[frameno + 1], &left_overlap, &right_overlap, &hTcxEnc->speech_TCX[frameno * tcx10SizeFB], &L_subframe, mdstWin, 0, 1 ); + sig_len = add( L_subframe, shr( add( left_overlap, right_overlap ), 1 ) ); + scale = sub( norm_arr( mdstWin, sig_len ), 1 ); + scale = s_min( 0, scale ); // restricting the Q to zero or less + scale_sig( mdstWin, sig_len, scale ); + q_mdstWin = scale; + move16(); } IF( EQ_16( transform_type[frameno], TCX_5 ) ) @@ -1184,7 +1196,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( /* Outer left folding */ FOR( i = 0; i < left_overlap / 2; i++ ) { - mdstWin[left_overlap / 2 + i] = add_sat( mdstWin[left_overlap / 2 + i], mdstWin[left_overlap / 2 - 1 - i] ); // Q0 + mdstWin[left_overlap / 2 + i] = add( mdstWin[left_overlap / 2 + i], mdstWin[left_overlap / 2 - 1 - i] ); // q_mdstWin } test(); @@ -1197,16 +1209,16 @@ void core_signal_analysis_high_bitrate_ivas_fx( { L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( 0, Q16 ) ); // Q0 - mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 + L_tmp = L_shl( L_tmp, sub( q_mdstWin, Q16 ) ); // q_mdstWin + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( 0, Q16 ) ); // Q0 - mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 + L_tmp = L_shl( L_tmp, sub( q_mdstWin, Q16 ) ); // q_mdstWin + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin move32(); } } @@ -1214,7 +1226,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( /* Outer right folding */ FOR( i = 0; i < right_overlap / 2; i++ ) { - mdstWin[L_subframe + left_overlap / 2 - 1 - i] = sub_sat( mdstWin[L_subframe + left_overlap / 2 - 1 - i], mdstWin[L_subframe + left_overlap / 2 + i] ); // Q0 + mdstWin[L_subframe + left_overlap / 2 - 1 - i] = sub( mdstWin[L_subframe + left_overlap / 2 - 1 - i], mdstWin[L_subframe + left_overlap / 2 + i] ); // q_mdstWin move16(); } @@ -1229,7 +1241,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( assert( st->mct_chan_mode != MCT_CHAN_MODE_LFE ); WindowSignal( st->hTcxCfg, folding_offset, i == 0 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, i == 1 ? RECTANGULAR_OVERLAP : MIN_OVERLAP, &left_overlap, &right_overlap, mdstWin + i * tcx5SizeFB, &L_subframe, tcx5Win, 0, 1 ); - spectrum_e[frameno] = 16; + spectrum_e[frameno] = sub( 16, q_mdstWin ); move16(); TCX_MDST( tcx5Win, spectrum[frameno] + i * tcx5SizeFB, &spectrum_e[frameno], left_overlap, L_subframe - ( left_overlap + right_overlap ) / 2, right_overlap, st->element_mode ); /* high-band gain control in case of BWS */ @@ -1250,14 +1262,14 @@ void core_signal_analysis_high_bitrate_ivas_fx( } ELSE /* transform_type[frameno] != TCX_5 */ { - spectrum_e[frameno] = 16; + spectrum_e[frameno] = sub( 16, q_mdstWin ); test(); IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { Word16 Q; Copy_Scale_sig_16_32_no_sat( mdstWin, L_tmpbuf, N_MAX + L_MDCT_OVLP_MAX, 16 ); - Q = 16; + Q = add( q_mdstWin, 16 ); move16(); edst_fx( L_tmpbuf, spectrum[frameno], L_subframe, &Q ); spectrum_e[frameno] = 31 - Q; @@ -1284,16 +1296,16 @@ void core_signal_analysis_high_bitrate_ivas_fx( { L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( 0, Q16 ) ); // Q0 - mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 + L_tmp = L_shl( L_tmp, sub( q_mdstWin, Q16 ) ); // q_mdstWin + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ { L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (Q0, Q15) -> Q16 L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16, Q15) -> Q16 - L_tmp = L_shl( L_tmp, sub( 0, Q16 ) ); // Q0 - mdstWin[left_overlap + i] = add_sat( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // Q0 + L_tmp = L_shl( L_tmp, sub( q_mdstWin, Q16 ) ); // q_mdstWin + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin move32(); } } diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index f6adb0f31..fc7c32fdb 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -39,7 +39,6 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot.h" #include "cnst.h" #include "stat_enc.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_agc_enc_fx.c b/lib_enc/ivas_agc_enc_fx.c index 104eeb998..d74e10bda 100644 --- a/lib_enc/ivas_agc_enc_fx.c +++ b/lib_enc/ivas_agc_enc_fx.c @@ -35,7 +35,6 @@ #include #include #include "options.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 5f318e959..f88288ea1 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -36,7 +36,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 46de4e232..42920a46a 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -38,7 +38,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "prot_fx_enc.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" #include diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 73403a848..8d00e608c 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 32e3e7107..f21c8e262 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -35,7 +35,6 @@ #include "ivas_cnst.h" #include "prot_fx.h" #include "prot_fx_enc.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "math.h" diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index a9d62a2b0..1152736f6 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -37,7 +37,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "prot_fx_enc.h" #include "ivas_rom_com.h" #ifdef DEBUGGING diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index 1158f72fa..bd63553bd 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" /* Function prototypes */ diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 7bfa9f268..ac0ce9556 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c index 576bbb2c6..c05d59b90 100644 --- a/lib_enc/ivas_enc_cov_handler_fx.c +++ b/lib_enc/ivas_enc_cov_handler_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index 0a2d976e1..e8e1bc59e 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -37,7 +37,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_enc/ivas_entropy_coder_fx.c b/lib_enc/ivas_entropy_coder_fx.c index a95f2884c..3c8cf92e2 100644 --- a/lib_enc/ivas_entropy_coder_fx.c +++ b/lib_enc/ivas_entropy_coder_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "math.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index f1aeb5398..8b76b37a4 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -37,7 +37,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "prot_fx_enc.h" #include #include "wmc_auto.h" @@ -433,30 +432,6 @@ ivas_error front_vad_create_fx( return IVAS_ERR_OK; } -/*-----------------------------------------------------------------------------------------* - * Function front_vad_destroy() - * - * Deallocate Standalone front-VAD module - *-----------------------------------------------------------------------------------------*/ - -void front_vad_destroy( - FRONT_VAD_ENC_HANDLE *hFrontVad /* i/o: front-VAD handle */ -) -{ - IF( *hFrontVad != NULL ) - { - free( ( *hFrontVad )->hNoiseEst ); - ( *hFrontVad )->hNoiseEst = NULL; - - free( ( *hFrontVad )->hVAD ); - ( *hFrontVad )->hVAD = NULL; - - free( *hFrontVad ); - *hFrontVad = NULL; - } - - return; -} void front_vad_destroy_fx( FRONT_VAD_ENC_HANDLE *hFrontVad /* i/o: front-VAD handle */ ) diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index c65c85356..b49fc9716 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_stat_enc.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 64b8991d6..b29b0c15b 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 22bf88df8..1b648cc98 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index 4305e5bca..6a2e54db6 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -35,7 +35,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index e6b23fcfc..cda8cffd6 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -34,7 +34,6 @@ #include #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "cnst.h" diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 11056b535..96959c9dd 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "math.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 21c23c34a..6960629c8 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 2797fa5e4..17fefec7e 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -38,7 +38,6 @@ #include "ivas_rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c index abd09cbbd..fd5cb6217 100644 --- a/lib_enc/ivas_mc_paramupmix_enc_fx.c +++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c @@ -37,7 +37,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "basop_util.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index c4d3908ca..22f21dceb 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -35,7 +35,6 @@ #include #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "options.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index 439c227ae..71515571d 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "wmc_auto.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index d6bc4c7f0..56f5e44db 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 88d773b53..a8ba9a320 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 70b2b0034..3272768e9 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -37,7 +37,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" @@ -705,8 +704,8 @@ static void applyStereoPreProcessingCplx( } ELSE { - dmxR2_fx = L_sub( Mpy_32_32( valR1_fx, factIn_fx ), Mpy_32_32( valR2_fx, factDe_fx ) ); // Q = q_com + Q22 - 31 - dmxI2_fx = L_sub( Mpy_32_32( valI1_fx, factIn_fx ), Mpy_32_32( valI2_fx, factDe_fx ) ); // Q = q_com + Q22 - 31 + dmxR2_fx = L_sub( Mpy_32_32( valR2_fx, factDe_fx ), Mpy_32_32( valR1_fx, factIn_fx ) ); // Q = q_com + Q22 - 31 + dmxI2_fx = L_sub( Mpy_32_32( valI2_fx, factDe_fx ), Mpy_32_32( valI1_fx, factIn_fx ) ); // Q = q_com + Q22 - 31 } } ELSE @@ -1923,7 +1922,6 @@ void ivas_mdct_core_whitening_enc_fx( tcx_subframe_coded_lines = shr( tcx_subframe_coded_lines, shift ); /*tcx_subframe_coded_lines / nSubframes*/ Word16 q_pow = 62, q_pow_tmp = sub( 63, shl( mdst_spectrum_e[0][0], 1 ) ); // add( shl( sub( Q31, mdst_spectrum_e[0][0] ), 1 ), 1 ); move16(); - FOR( n = 0; n < nSubframes; n++ ) { IF( st->hTcxEnc->fUseTns[n] ) @@ -1932,34 +1930,19 @@ void ivas_mdct_core_whitening_enc_fx( { powerSpec_fx64[i] = W_mult_32_32( st->hTcxEnc->spectrum_fx[n][i], st->hTcxEnc->spectrum_fx[n][i] ); move64(); - IF( powerSpec_fx64[i] == 0 ) - { - q_pow = s_min( q_pow, 62 ); - } - ELSE - - { - q_pow = s_min( q_pow, W_norm( powerSpec_fx64[i] ) ); - } } + q_pow = W_norm_arr( powerSpec_fx64, L_subframeTCX ); } ELSE { FOR( i = 0; i < L_subframeTCX; i++ ) { - powerSpec_fx64[i] = W_add( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), W_mult_32_32( st->hTcxEnc->spectrum_fx[n][i], st->hTcxEnc->spectrum_fx[n][i] ) ); + powerSpec_fx64[i] = W_mac_32_32( W_mult_32_32( mdst_spectrum_fx[ch][n][i], mdst_spectrum_fx[ch][n][i] ), st->hTcxEnc->spectrum_fx[n][i], st->hTcxEnc->spectrum_fx[n][i] ); move64(); - IF( powerSpec_fx64[i] == 0 ) - { - q_pow = s_min( q_pow, 62 ); - } - ELSE - - { - q_pow = s_min( q_pow, W_norm( powerSpec_fx64[i] ) ); - } } + q_pow = W_norm_arr( powerSpec_fx64, L_subframeTCX ); } + FOR( i = 0; i < L_subframeTCX; i++ ) { powerSpec_fx64[i] = W_shl( powerSpec_fx64[i], q_pow ); diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 7c8b78ffb..5d79265f4 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -35,7 +35,6 @@ #include #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 1229624de..2a6944c50 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -35,7 +35,6 @@ #include #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" diff --git a/lib_enc/ivas_pca_enc_fx.c b/lib_enc/ivas_pca_enc_fx.c index 410d5dd52..2cb347a02 100644 --- a/lib_enc/ivas_pca_enc_fx.c +++ b/lib_enc/ivas_pca_enc_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include #include diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index b32c80404..2d6080995 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -36,7 +36,6 @@ #include #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" diff --git a/lib_enc/ivas_qspherical_enc_fx.c b/lib_enc/ivas_qspherical_enc_fx.c index a6f40c8f0..2e7a289f9 100644 --- a/lib_enc/ivas_qspherical_enc_fx.c +++ b/lib_enc/ivas_qspherical_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_range_uni_enc_fx.c b/lib_enc/ivas_range_uni_enc_fx.c index cf32c644d..6c322a3d9 100644 --- a/lib_enc/ivas_range_uni_enc_fx.c +++ b/lib_enc/ivas_range_uni_enc_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_stat_enc.h" diff --git a/lib_enc/ivas_sba_enc_fx.c b/lib_enc/ivas_sba_enc_fx.c index 8fdca5815..e630a70d9 100644 --- a/lib_enc/ivas_sba_enc_fx.c +++ b/lib_enc/ivas_sba_enc_fx.c @@ -39,7 +39,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 8c2c945d6..2983ea2f0 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -38,7 +38,6 @@ #include "rom_com.h" #include "prot_fx.h" #include "prot_fx_enc.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index e321f1c7c..93ee56461 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index 674a80549..3b380f2eb 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index 2ace35473..997581476 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "math.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c index 70c2165f8..8e79b2288 100644 --- a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c +++ b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "stat_enc.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c index bfe683d6b..3e148a5ae 100644 --- a/lib_enc/ivas_stereo_classifier_fx.c +++ b/lib_enc/ivas_stereo_classifier_fx.c @@ -39,7 +39,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_stereo_cng_enc_fx.c b/lib_enc/ivas_stereo_cng_enc_fx.c index 255b6e938..aa7c2d0aa 100644 --- a/lib_enc/ivas_stereo_cng_enc_fx.c +++ b/lib_enc/ivas_stereo_cng_enc_fx.c @@ -37,7 +37,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index ede3d3ad9..3eb6c0e82 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -38,7 +38,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index 862102d3b..8a887de89 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -38,7 +38,6 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index 58e66a01a..df4fe3edd 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "prot_fx.h" #include "rom_com.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index c3cb68719..ae8a8203e 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -37,7 +37,6 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_enc/ivas_stereo_eclvq_enc_fx.c b/lib_enc/ivas_stereo_eclvq_enc_fx.c index f4962c802..3abc07811 100644 --- a/lib_enc/ivas_stereo_eclvq_enc_fx.c +++ b/lib_enc/ivas_stereo_eclvq_enc_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index 78c324cce..057798706 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -37,7 +37,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 78891c5f7..bc84ba419 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index 28b0e41b9..b68578542 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c index 57bb18e80..851df60d5 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c @@ -38,7 +38,6 @@ #include "cnst.h" #include "stat_enc.h" #include "ivas_stat_enc.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index b1213a750..a61b2b010 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index cbdbc0501..2fe8b6c84 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -35,7 +35,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com_fx.h" #include "ivas_rom_com.h" #include "assert.h" diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c index efae1e80d..44c08efa8 100644 --- a/lib_enc/ivas_stereo_td_analysis_fx.c +++ b/lib_enc/ivas_stereo_td_analysis_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" #include "rom_enc.h" diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index 979978c03..d2ff2c0c2 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -36,7 +36,6 @@ #include "cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #ifdef DEBUGGING diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 28044b45d..1e66c1488 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -39,7 +39,6 @@ #include "rom_com.h" #include "basop_proto_func.h" #include "wmc_auto.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" #include "rom_com_fx.h" diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 34215025f..2daa9ed50 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -39,7 +39,6 @@ #include "ivas_cnst.h" #include "prot_fx.h" #include "prot_fx_enc.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 9d4736368..9093ffc40 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -39,7 +39,6 @@ #include "debug.h" #endif #include "lib_enc.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "prot_fx_enc.h" diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index 0887698f7..01005f641 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -53,7 +53,8 @@ Word16 lp_filt_exc_enc_fx( Word16 wtmp, wtmp1; Word32 Ltmp; - Word16 use_prev_sf_pit_gain = 0; + Word16 use_prev_sf_pit_gain = 0; // Q0 + move16(); gain1 = 0; move16(); @@ -66,7 +67,8 @@ Word16 lp_filt_exc_enc_fx( test(); IF( EQ_16( codec_mode, MODE2 ) && EQ_16( coder_type, 100 ) ) { - use_prev_sf_pit_gain = 1; + use_prev_sf_pit_gain = 1; // Q0 + move16(); } exp_ener = 0; move16(); @@ -75,7 +77,7 @@ Word16 lp_filt_exc_enc_fx( test(); IF( EQ_16( *lp_flag, FULL_BAND ) || EQ_16( *lp_flag, NORMAL_OPERATION ) ) { - wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, &gain1, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain ); + wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, &gain1, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain ); // exp_ener move16(); } @@ -89,7 +91,7 @@ Word16 lp_filt_exc_enc_fx( wtmp1 = 0; move16(); test(); - IF( ( EQ_16( *lp_flag, LOW_PASS ) ) || ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) + IF( ( ( *lp_flag == LOW_PASS ) ) || ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) { test(); IF( EQ_16( codec_mode, MODE2 ) && EQ_16( L_frame, L_FRAME16k ) ) @@ -100,6 +102,7 @@ Word16 lp_filt_exc_enc_fx( Ltmp = L_mac( Ltmp, 19005, exc[i + i_subfr] ); Ltmp = L_mac( Ltmp, 6881, exc[i + 1 + i_subfr] ); exc_tmp[i] = round_fx( Ltmp ); + move16(); } } ELSE @@ -110,20 +113,21 @@ Word16 lp_filt_exc_enc_fx( Ltmp = L_mac( Ltmp, 20972, exc[i + i_subfr] ); Ltmp = L_mac( Ltmp, 5898, exc[i + 1 + i_subfr] ); exc_tmp[i] = round_fx( Ltmp ); + move16(); } } - wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, &gain2, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); + wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, &gain2, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); // exp_ener1 } if ( LT_16( exp_ener, exp_ener1 ) ) { - wtmp = shr( wtmp, 1 ); + wtmp = shr( wtmp, 1 ); // exp_ener + 1 } if ( GT_16( exp_ener, exp_ener1 ) ) { - wtmp1 = shr( wtmp1, 1 ); + wtmp1 = shr( wtmp1, 1 ); // exp_ener1 + 1 } /*-----------------------------------------------------------------* @@ -132,18 +136,18 @@ Word16 lp_filt_exc_enc_fx( test(); test(); - IF( ( ( LT_16( wtmp1, wtmp ) ) && ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) || ( EQ_16( *lp_flag, LOW_PASS ) ) ) + IF( ( ( LT_16( wtmp1, wtmp ) ) && ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) || ( ( *lp_flag == LOW_PASS ) ) ) { /* use the LP filter for pitch excitation prediction */ select = LOW_PASS; move16(); - Copy( exc_tmp, &exc[i_subfr], L_subfr ); - Copy( y1_tmp, y1, L_subfr ); - Copy( xn2_tmp, xn2, L_subfr ); + Copy( exc_tmp, &exc[i_subfr], L_subfr ); // Q_new + Copy( y1_tmp, y1, L_subfr ); // Q_new-1+shift + Copy( xn2_tmp, xn2, L_subfr ); // Q_new-1+shift IF( use_prev_sf_pit_gain == 0 ) { - *gain_pit = gain2; + *gain_pit = gain2; // Q14 move16(); g_corr[0] = g_corr2[0]; move16(); @@ -162,7 +166,7 @@ Word16 lp_filt_exc_enc_fx( move16(); IF( use_prev_sf_pit_gain == 0 ) { - *gain_pit = gain1; + *gain_pit = gain1; // Q14 move16(); } } @@ -193,7 +197,8 @@ Word16 lp_filt_exc_enc_ivas_fx( Word16 wtmp, wtmp1; Word32 Ltmp; - Word16 use_prev_sf_pit_gain = 0; + Word16 use_prev_sf_pit_gain = 0; // Q0 + move16(); gain1 = 0; move16(); @@ -206,7 +211,8 @@ Word16 lp_filt_exc_enc_ivas_fx( test(); IF( EQ_16( codec_mode, MODE2 ) && EQ_16( coder_type, 100 ) ) { - use_prev_sf_pit_gain = 1; + use_prev_sf_pit_gain = 1; // Q0 + move16(); } exp_ener = 0; move16(); @@ -215,13 +221,13 @@ Word16 lp_filt_exc_enc_ivas_fx( test(); IF( EQ_16( *lp_flag, FULL_BAND ) || EQ_16( *lp_flag, NORMAL_OPERATION ) ) { - IF( use_prev_sf_pit_gain == 1 ) + IF( EQ_16( use_prev_sf_pit_gain, 1 ) ) { - wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, gain_pit, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain ); + wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, gain_pit, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain ); // exp_ener } - else + ELSE { - wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, &gain1, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain ); + wtmp = adpt_enr_fx( codec_mode, &exc[i_subfr], h1, y1, L_subfr, &gain1, g_corr, clip_gain, xn, xn2, &exp_ener, use_prev_sf_pit_gain ); // exp_ener } } @@ -235,7 +241,7 @@ Word16 lp_filt_exc_enc_ivas_fx( wtmp1 = 0; move16(); test(); - IF( ( EQ_16( *lp_flag, LOW_PASS ) ) || ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) + IF( ( ( *lp_flag == LOW_PASS ) ) || ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) { test(); IF( EQ_16( codec_mode, MODE2 ) && EQ_16( L_frame, L_FRAME16k ) ) @@ -246,6 +252,7 @@ Word16 lp_filt_exc_enc_ivas_fx( Ltmp = L_mac( Ltmp, 19005, exc[i + i_subfr] ); Ltmp = L_mac( Ltmp, 6881, exc[i + 1 + i_subfr] ); exc_tmp[i] = round_fx( Ltmp ); + move16(); } } ELSE @@ -256,15 +263,16 @@ Word16 lp_filt_exc_enc_ivas_fx( Ltmp = L_mac( Ltmp, 20972, exc[i + i_subfr] ); Ltmp = L_mac( Ltmp, 5898, exc[i + 1 + i_subfr] ); exc_tmp[i] = round_fx( Ltmp ); + move16(); } } - IF( use_prev_sf_pit_gain == 1 ) + IF( EQ_16( use_prev_sf_pit_gain, 1 ) ) { - wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, gain_pit, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); + wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, gain_pit, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); // exp_ener1 } ELSE { - wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, &gain2, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); + wtmp1 = adpt_enr_fx( codec_mode, exc_tmp, h1, y1_tmp, L_subfr, &gain2, g_corr2, clip_gain, xn, xn2_tmp, &exp_ener1, use_prev_sf_pit_gain ); // exp_ener1 } } @@ -284,18 +292,18 @@ Word16 lp_filt_exc_enc_ivas_fx( test(); test(); - IF( ( ( LT_16( wtmp1, wtmp ) ) && ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) || ( EQ_16( *lp_flag, LOW_PASS ) ) ) + IF( ( ( LT_16( wtmp1, wtmp ) ) && ( EQ_16( *lp_flag, NORMAL_OPERATION ) ) ) || ( ( *lp_flag == LOW_PASS ) ) ) { /* use the LP filter for pitch excitation prediction */ select = LOW_PASS; move16(); - Copy( exc_tmp, &exc[i_subfr], L_subfr ); - Copy( y1_tmp, y1, L_subfr ); - Copy( xn2_tmp, xn2, L_subfr ); + Copy( exc_tmp, &exc[i_subfr], L_subfr ); // Q_new + Copy( y1_tmp, y1, L_subfr ); // Q_new-1+shift + Copy( xn2_tmp, xn2, L_subfr ); // Q_new-1+shift IF( use_prev_sf_pit_gain == 0 ) { - *gain_pit = gain2; + *gain_pit = gain2; // Q14 move16(); g_corr[0] = g_corr2[0]; move16(); @@ -314,7 +322,7 @@ Word16 lp_filt_exc_enc_ivas_fx( move16(); IF( use_prev_sf_pit_gain == 0 ) { - *gain_pit = gain1; + *gain_pit = gain1; // Q14 move16(); } } @@ -367,9 +375,9 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation { FOR( i = 0; i < L_subfr; i++ ) { - exc_tmp[i] = mult( exc[i], 8192 ); + exc_tmp[i] = mult( exc[i], 8192 /*0.25.Q15*/ ); // Q_new move16(); - xn_tmp[i] = mult( xn[i], 8192 ); + xn_tmp[i] = mult( xn[i], 8192 /*0.25.Q15*/ ); // Q_new move16(); } Overflow = 0; @@ -383,14 +391,14 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation test(); if ( EQ_16( clip_gain, 1 ) && GT_16( *gain, 15565 ) ) /* constant in Q14 */ { - *gain = 15565; + *gain = 15565; // 0.95.Q14 move16(); } test(); - if ( EQ_16( clip_gain, 2 ) && GT_16( *gain, 10650 ) ) + IF( EQ_16( clip_gain, 2 ) && GT_16( *gain, 10650 ) ) // 0.65.Q14 { - *gain = 10650; + *gain = 10650; // 0.65.Q14 move16(); } } @@ -403,14 +411,14 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation /* could possibly happen in GSC */ Ltmp = Calc_Energy_Autoscaled( xn2, 0, L_subfr, exp_ener ); i = norm_l( Ltmp ); - ener = extract_h( L_shl( Ltmp, i ) ); + ener = extract_h( L_shl( Ltmp, i ) ); // exp_ener i = sub( 31, i ); *exp_ener = sub( i, *exp_ener ); move16(); } ELSE { - ener = extract_h( Dot_product12( xn2, xn2, L_SUBFR, exp_ener ) ); + ener = extract_h( Dot_product12( xn2, xn2, L_SUBFR, exp_ener ) ); // Q15 } return ener; @@ -424,9 +432,9 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation *-------------------------------------------------------------------*/ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) */ - const Word16 xn_1[], /* i : target signal */ - const Word16 y1_1[], /* i : filtered adaptive codebook excitation */ - Word16 g_corr[], /* o : correlations and -2 */ + const Word16 xn_1[], /* i : target signal Q_new*/ + const Word16 y1_1[], /* i : filtered adaptive codebook excitation 12 bits*/ + Word16 g_corr[], /* o : correlations and -2 mant/exp*/ const Word16 L_subfr, /* i : vector length */ const Word16 norm_flag /* i : flag for constraining pitch contribution */ , @@ -446,7 +454,7 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) *----------------------------------------------------------------*/ /* Compute scalar product */ - Copy( xn_1, xn, L_subfr ); + Copy( xn_1, xn, L_subfr ); // Q_new Copy( y1_1, y1, L_subfr ); Overflow = 0; move16(); @@ -457,9 +465,9 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) { FOR( i = 0; i < L_subfr; i++ ) { - xn[i] = mult_r( xn_1[i], 4096 ); + xn[i] = mult_r( xn_1[i], 4096 /*0.125.Q15*/ ); // Q-new move16(); - y1[i] = mult_r( y1_1[i], 4096 ); + y1[i] = mult_r( y1_1[i], 4096 /*0.125.Q15*/ ); move16(); } @@ -484,7 +492,7 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) } ELSE { - yy = extract_h( Ltmp1 ); + yy = extract_h( Ltmp1 ); // exp_yy /* Ltmp1 = L_shr(Ltmp1, sub(30, exp_yy));*/ /* Compute scalar product */ @@ -499,7 +507,7 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) g_corr[1] = exp_yy; move16(); /* -2.0*temp1 + 0.01 is done in Gain_enc_2 function*/ - g_corr[2] = xy; + g_corr[2] = xy; // exp_xy move16(); g_corr[3] = exp_xy; move16(); @@ -510,8 +518,8 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) IF( xy >= 0 && NE_16( s_or( yy, xy ), 16384 ) ) { /* compute gain = xy/yy */ - xy = shr( xy, 1 ); /* be sure that xy < yy */ - gain = div_s( xy, yy ); + xy = shr( xy, 1 ); /* be sure that xy < yy */ + gain = div_s( xy, yy ); // Q15 i = sub( exp_xy, exp_yy ); gain = shl_o( gain, i, &Overflow ); /* saturation can occur here */ *Overflow_out |= Overflow; @@ -536,7 +544,7 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) /* gain_p_snr = sqrt(/) */ tmp = BASOP_Util_Divide1616_Scale( xx, yy, &exp_div ); exp_xx = add( sub( exp_xx, exp_yy ), exp_div ); - tmp = Sqrt16( tmp, &exp_xx ); + tmp = Sqrt16( tmp, &exp_xx ); // exp_xx /* Note: shl works as shl or shr. */ exp_xx = sub( exp_xx, 1 ); @@ -544,8 +552,8 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) gain_p_snr = round_fx_sat( L_shl_sat( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_xx ) ); BASOP_SATURATE_WARNING_ON_EVS - gain = s_min( gain, gain_p_snr ); + gain = s_min( gain, gain_p_snr ); // Q14 } - return gain; + return gain; // Q14 } diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 24179f375..6761dfb82 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -74,8 +74,10 @@ void lsf_enc_fx( const Word16 Q_new ) { Word16 nBits = 0; + move16(); Word16 int_fs; Word16 force_sf = 0; + move16(); Word16 fec_lsf[M], stab, i; Word32 L_tmp; Word16 coder_type, ppp_mode, nelp_mode; @@ -189,7 +191,7 @@ void lsf_enc_fx( lsf2lsp_fx( lsf_new, lsp_new, M, int_fs ); test(); - IF( EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->core, ACELP_CORE ) ) + IF( EQ_16( st_fx->last_core, HQ_CORE ) && ( st_fx->core == ACELP_CORE ) ) { /* don't use old LSF values if this is the first ACELP frame after HQ frames */ Copy( lsf_new, st_fx->lsf_old_fx, M ); @@ -216,7 +218,7 @@ void lsf_enc_fx( FEC_lsf_estim_enc_fx( st_fx, fec_lsf ); /* in case of FEC in decoder - calculate LSF stability */ - stab = lsf_stab_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); + stab = lsf_stab_fx( lsf_new, fec_lsf, 0, st_fx->L_frame ); // Q15 test(); test(); @@ -255,8 +257,8 @@ void lsf_enc_fx( if ( st_fx->rate_switching_reset ) { /*extrapolation in case of unstable LSF convert*/ - Copy( lsp_new, st_fx->lsp_old_fx, M ); - Copy( lsf_new, st_fx->lsf_old_fx, M ); + Copy( lsp_new, st_fx->lsp_old_fx, M ); // Q15 + Copy( lsf_new, st_fx->lsf_old_fx, M ); // Q15 } /* Mid-frame LSF encoding */ lsf_mid_enc_fx( st_fx->hBstr, st_fx->acelp_cfg.mid_lsf_bits, int_fs, st_fx->lsp_old_fx, lsp_new, lsp_mid, coder_type, st_fx->bwidth, st_fx->Bin_E_old_fx, st_fx->Bin_E_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode ); @@ -265,7 +267,7 @@ void lsf_enc_fx( IF( EQ_16( st_fx->last_core, HQ_CORE ) && EQ_16( st_fx->core, ACELP_CORE ) ) { /* don't use old LSP/LSF values if this is the first ACELP frame after HQ frames */ - Copy( lsp_mid, st_fx->lsp_old_fx, M ); + Copy( lsp_mid, st_fx->lsp_old_fx, M ); // Q15 lsp2lsf_fx( lsp_mid, st_fx->lsf_old_fx, M, int_fs ); } @@ -299,10 +301,10 @@ void lsf_enc_fx( void lsf_enc_ivas_fx( Encoder_State *st, /* i/o: state structure */ - Word16 *lsf_new, /* o : quantized LSF vector */ - Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */ - Word16 *lsp_mid, /* i/o : mid-frame LSP vector */ - Word16 *Aq, /* o : quantized A(z) for 4 subframes */ + Word16 *lsf_new, /* o : quantized LSF vector Q(x2.56)*/ + Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized Q15*/ + Word16 *lsp_mid, /* i/o : mid-frame LSP vector Q15*/ + Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ @@ -462,15 +464,15 @@ void lsf_enc_ivas_fx( IF( NE_16( st->last_L_frame, st->L_frame ) ) { /* FEC - in case of core switching, use old LSFs */ - Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); - Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); - Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); + Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); // Q15 + Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); // Q15 + Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); // Q15 } FEC_lsf_estim_enc_fx( st, fec_lsf ); /* in case of FEC in decoder - calculate LSF stability */ - stab = lsf_stab_ivas_fx( lsf_new, fec_lsf, 0, st->L_frame ); + stab = lsf_stab_ivas_fx( lsf_new, fec_lsf, 0, st->L_frame ); // Q15 test(); test(); @@ -509,8 +511,8 @@ void lsf_enc_ivas_fx( IF( st->rate_switching_reset ) { /*extrapolation in case of unstable LSF convert*/ - Copy( lsp_new, st->lsp_old_fx, M ); - Copy( lsf_new, st->lsf_old_fx, M ); + Copy( lsp_new, st->lsp_old_fx, M ); // Q15 + Copy( lsf_new, st->lsf_old_fx, M ); // Q15 } /* Mid-frame LSF encoding */ lsf_mid_enc_ivas_fx( st->hBstr, st->acelp_cfg.mid_lsf_bits, st->sr_core, st->lsp_old_fx, lsp_new, lsp_mid, coder_type, st->bwidth, st->Bin_E_old_fx, Q_new + QSCALE - 2, ppp_mode, nelp_mode ); @@ -529,9 +531,9 @@ void lsf_enc_ivas_fx( { IF( EQ_16( st->active_cnt, 1 ) ) { - Copy( lsp_mid, st->lsp_old_fx, M ); + Copy( lsp_mid, st->lsp_old_fx, M ); // Q15 lsp2lsf_fx( lsp_mid, st->lsf_old_fx, M, st->sr_core ); - Copy( lsp_new, lsp_mid, M ); + Copy( lsp_new, lsp_mid, M ); // Q15 } /* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */ @@ -546,7 +548,7 @@ void lsf_enc_ivas_fx( *------------------------------------------------------------------*/ IF( NE_32( st->core_brate, SID_2k40 ) ) { - st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st->lsf_old_fx, 0, st->L_frame ); + st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st->lsf_old_fx, 0, st->L_frame ); // Q15 } return; } @@ -847,8 +849,8 @@ static Word16 qlsf_Mode_Select_fx( /*========================================================================*/ void lsf_end_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ - Word16 *qlsf, /* o : quantized LSF */ + const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/ + Word16 *qlsf, /* o : quantized LSF x2.56*/ const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */ const Word16 coder_type_org, /* i : coding type */ Word16 Q_ener, /* i : Q valuen for Bin_Ener */ @@ -1008,7 +1010,7 @@ void lsf_end_enc_fx( IF( ( ( GT_16( st->pstreaklen, ( STREAKLEN + 3 ) ) ) && ( EQ_16( coder_type, VOICED ) ) ) || ( ( GT_16( st->pstreaklen, ( STREAKLEN ) ) ) && ( NE_16( coder_type, VOICED ) ) ) ) { /* update the adaptive scaling factor to become smaller with increasing number of concecutive predictive frames. */ - st->streaklimit_fx = mult( st->streaklimit_fx, STREAKMULT_FX ); + st->streaklimit_fx = mult( st->streaklimit_fx, STREAKMULT_FX ); // Q15 move16(); } @@ -1211,7 +1213,7 @@ void lsf_end_enc_fx( { lpc_param[i] = TCQIdx0[i]; move16(); - bits_param_lpc[i] = BC_TCVQ_BIT_ALLOC_40B[i]; + bits_param_lpc[i] = BC_TCVQ_BIT_ALLOC_40B[i]; // Q0 move16(); } } @@ -1352,8 +1354,8 @@ void lsf_end_enc_fx( void lsf_end_enc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) */ - Word16 *qlsf, /* o : quantized LSF */ + const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/ + Word16 *qlsf, /* o : quantized LSF x2.56*/ const Word16 nBits_in, /* i : number of bits to spend on ISF quantization */ const Word16 coder_type_org, /* i : coding type */ Word16 Q_ener, /* i : Q valuen for Bin_Ener */ @@ -1944,10 +1946,10 @@ void lsf_end_enc_ivas_fx( static void first_VQstages( const Word16 *const *cb, - Word16 u[], /* i : vector to be encoded (prediction and mean removed) */ + Word16 u[], /* i : vector to be encoded (prediction and mean removed) x2.56*/ Word16 *levels, /* i : number of levels in each stage */ Word16 stagesVQ, /* i : number of stages */ - Word16 w[], /* i : weights */ + Word16 w[], /* i : weights Q8*/ Word16 N, /* i : vector dimension */ Word16 max_inner, /* i : maximum number of swaps in inner loop */ Word16 indices_VQstage[] ) @@ -2338,10 +2340,10 @@ static void first_VQstages_ivas_fx( static Word32 vq_lvq_lsf_enc( Word16 pred_flag, Word16 mode, - Word16 u[], + Word16 u[], // x2.56 Word16 *levels, Word16 stages, - Word16 w[], + Word16 w[], // Q8 Word16 Idx[], const Word16 *lsf, const Word16 *pred, @@ -2370,13 +2372,13 @@ static Word32 vq_lvq_lsf_enc( { cb = &Quantizers_fx[CB_lsf[mode]]; move16(); - mode_glb = add( offset_lvq_modes_SN_fx[mode], offset_in_lvq_mode_SN_fx[mode][sub( levels[stagesVQ], min_lat_bits_SN_fx[mode] )] ); + mode_glb = add( offset_lvq_modes_SN_fx[mode], offset_in_lvq_mode_SN_fx[mode][( levels[stagesVQ] - min_lat_bits_SN_fx[mode] )] ); // Q0 } ELSE /* predictive */ { cb = &Quantizers_p_fx[CB_p_lsf[mode]]; move16(); - mode_glb = add( offset_lvq_modes_pred_fx[mode], offset_in_lvq_mode_pred_fx[mode][sub( levels[stagesVQ], min_lat_bits_pred_fx[mode] )] ); + mode_glb = add( offset_lvq_modes_pred_fx[mode], offset_in_lvq_mode_pred_fx[mode][( levels[stagesVQ] - min_lat_bits_pred_fx[mode] )] ); // Q0 } IF( stagesVQ > 0 ) { @@ -2421,7 +2423,7 @@ static Word32 vq_lvq_lsf_enc( { L_tmp = L_mac( L_tmp, mult( diff[j], shl_o( w[j], 1, &Overflow ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ } - e[i] = L_tmp; + e[i] = L_tmp; /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ move32(); } @@ -2447,10 +2449,10 @@ static Word32 vq_lvq_lsf_enc( static Word32 vq_lvq_lsf_enc_ivas_fx( Word16 pred_flag, Word16 mode, - Word16 u[], + Word16 u[], // x2.56 Word16 *levels, Word16 stages, - Word16 w[], + Word16 w[], // Q8 Word16 Idx[], const Word16 *lsf, const Word16 *pred, @@ -2478,7 +2480,7 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( IF( LT_16( mode, 6 ) ) { move16(); - mode_glb = add( offset_lvq_modes_SN[mode], offset_in_lvq_mode_SN[mode][sub( levels[stagesVQ], min_lat_bits_SN[mode] )] ); + mode_glb = add( offset_lvq_modes_SN[mode], offset_in_lvq_mode_SN[mode][( levels[stagesVQ] - min_lat_bits_SN[mode] )] ); } ELSE { @@ -2492,7 +2494,7 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( IF( LT_16( mode, 6 ) || EQ_16( mode, 12 ) ) { move16(); - mode_glb = add( offset_lvq_modes_pred[mode], offset_in_lvq_mode_pred[mode][sub( levels[stagesVQ], min_lat_bits_pred_fx[mode] )] ); + mode_glb = add( offset_lvq_modes_pred[mode], offset_in_lvq_mode_pred[mode][( levels[stagesVQ] - min_lat_bits_pred_fx[mode] )] ); } ELSE { @@ -2572,7 +2574,7 @@ static void BcTcvq_1st_fx( Word16 c[][16], Word32 cDist_fx[][16], /*2.56*2.56*Q(-5 - 2)*/ Word16 Q_fx[][16][2], - Word16 W_fx[][2] /*Q10*/ + Word16 W_fx[][2] /*Q8*/ ) { Word16 state, prev_state; @@ -2633,7 +2635,7 @@ static void BcTcvq_2nd_fx( Word16 c[][16], Word32 cDist_fx[][16], /*2.56*2.56*Q(-5 - 2) */ Word16 Q_fx[][16][2], /*x2.56*/ - Word16 W_fx[][2], /*Q10*/ + Word16 W_fx[][2], /*Q8*/ const Word16 itc_fx[][2][2] /*Q15*/ ) { @@ -2921,12 +2923,12 @@ static Word32 BcTcvq_FixSearch_fx( Q_fx[stage][*prev_state][1] = add( CB_fx[stage4][bestCode][1], pred_fx[1] ); move16(); - minDist_fx = L_shr( minDist_fx, 2 ); + minDist_fx = L_shr( minDist_fx, 2 ); /*2.56*2.56*Q(-5 - 2)*/ return minDist_fx; } static Word16 optimalPath_fx( - Word32 cDist_fx[][16], - Word32 blockDist_fx[], + Word32 cDist_fx[][16], /*2.56*2.56*Q(-5 - 2)*/ + Word32 blockDist_fx[], /*2.56*2.56*Q(-5 - 2)*/ Word16 blockCodeword[][4], Word16 bestCodeword[], Word16 codeWord[][16], @@ -2985,10 +2987,11 @@ static Word16 optimalPath_fx( static void quantEnc_fx( Word16 *y_fx, Word16 c[], - const Word16 CB_SUB1_fx[][128][2], - const Word16 CB_SUB2_fx[][64][2], - const Word16 CB_SUB3_fx[][32][2], - const Word16 itc_fx[][2][2] ) + const Word16 CB_SUB1_fx[][128][2], /*x2.56*/ + const Word16 CB_SUB2_fx[][64][2], /*x2.56*/ + const Word16 CB_SUB3_fx[][32][2], /*x2.56*/ + const Word16 itc_fx[][2][2] // Q15 +) { Word16 i, j; Word16 stage; @@ -3103,9 +3106,9 @@ static void buildCode_fx( } static void BcTcvq_fx( Word16 snFlag, - const Word16 *x_fx, - Word16 *y_fx, - const Word16 *weight_fx, + const Word16 *x_fx, // x2.65 + Word16 *y_fx, // x2.65 + const Word16 *weight_fx, // Q8 Word16 *ind ) { Word16 X_fx[N_STAGE_VQ][N_DIM], W_fx[N_STAGE_VQ][N_DIM]; @@ -3162,9 +3165,9 @@ static void BcTcvq_fx( { FOR( j = 0; j < N_DIM; j++ ) { - X_fx[i][j] = x_fx[( N_DIM * i ) + j]; + X_fx[i][j] = x_fx[( N_DIM * i ) + j]; // x2.65 move16(); - W_fx[i][j] = weight_fx[( N_DIM * i ) + j]; + W_fx[i][j] = weight_fx[( N_DIM * i ) + j]; // x2.56 move16(); } } @@ -3259,10 +3262,10 @@ static void BcTcvq_fx( } static Word16 SVQ_2d_fx( - Word16 *x_fx, - Word16 *y_fx, - const Word16 *W_fx, - const Word16 CB_fx[][8], + Word16 *x_fx, // x2.65 + Word16 *y_fx, // x2.65 + const Word16 *W_fx, // Q8 + const Word16 CB_fx[][8], // x2.65 Word16 Size ) { Word16 i, j; @@ -3280,7 +3283,7 @@ static Word16 SVQ_2d_fx( { temp16_fx = sub( x_fx[j], CB_fx[i][j] ); distortion_fx = L_add( distortion_fx, - L_shr( Mult_32_16( L_mult( temp16_fx, temp16_fx ), W_fx[j] ), 1 ) ); + L_shr( Mult_32_16( L_mult( temp16_fx, temp16_fx ), W_fx[j] ), 1 ) ); // (2*x2.65 + Q1 + Q8) - Q15 - Q1 } IF( LT_32( distortion_fx, temp_fx ) ) @@ -3403,9 +3406,9 @@ Word32 qlsf_ARSN_tcvq_Enc_16k_fx( } static void FFT_Mid_Interpol_16k_fx( - Word32 Bin_Ener_old[], /* i/o: Old 2nd FFT Bin energy (128) */ - Word32 Bin_Ener[], /* i : Current 2nd FFT Bin energy (128) */ - Word32 Bin_Ener_mid[] /* o : LP weighting filter (numerator) */ + Word32 Bin_Ener_old[], /* i/o: Old 2nd FFT Bin energy (128) Q_ener*/ + Word32 Bin_Ener[], /* i : Current 2nd FFT Bin energy (128) Q_ener*/ + Word32 Bin_Ener_mid[] /* o : LP weighting filter (numerator) Q_ener*/ ) { Word16 i; @@ -3642,12 +3645,12 @@ static void lsf_mid_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 nb_bits, /* i : number of bits */ const Word32 int_fs, /* i : internal (ACELP) sampling frequency*/ - const Word16 qlsp0[], /* i : quantized LSPs from frame beginning*/ - const Word16 qlsp1[], /* i : quantized LSPs from frame end */ - Word16 lsp[], /* i/o: mid-frame LSP */ + const Word16 qlsp0[], /* i : quantized LSPs from frame beginning Q15*/ + const Word16 qlsp1[], /* i : quantized LSPs from frame end Q15*/ + Word16 lsp[], /* i/o: mid-frame LSP Q15*/ const Word16 coder_type, /* i : coding type */ const Word16 bwidth, /* i : input signal bandwidth */ - Word32 Bin_Ener[], /* i : per bin log energy spectrum */ + Word32 Bin_Ener[], /* i : per bin log energy spectrum Q_ener*/ Word16 Q_ener, /* i : Q value of Bin_ener */ Word16 ppp_mode, Word16 nelp_mode ) @@ -3681,19 +3684,19 @@ static void lsf_mid_enc_ivas_fx( { case 5: { - ratio = tbl_mid_voi_wb_5b_fx; + ratio = tbl_mid_voi_wb_5b_fx; // Q13 move16(); BREAK; } case 4: { - ratio = tbl_mid_voi_wb_4b_fx; + ratio = tbl_mid_voi_wb_4b_fx; // Q13 move16(); BREAK; } case 1: { - ratio = tbl_mid_voi_wb_1b_fx; + ratio = tbl_mid_voi_wb_1b_fx; // Q13 move16(); BREAK; } @@ -3701,7 +3704,7 @@ static void lsf_mid_enc_ivas_fx( } ELSE IF( EQ_16( coder_type, UNVOICED ) ) { - ratio = tbl_mid_unv_wb_5b_fx; + ratio = tbl_mid_unv_wb_5b_fx; // Q13 } ELSE { @@ -3710,19 +3713,19 @@ static void lsf_mid_enc_ivas_fx( { case 5: { - ratio = tbl_mid_gen_wb_5b_fx; + ratio = tbl_mid_gen_wb_5b_fx; // Q13 move16(); BREAK; } case 4: { - ratio = tbl_mid_gen_wb_4b_fx; + ratio = tbl_mid_gen_wb_4b_fx; // Q13 move16(); BREAK; } case 2: { - ratio = tbl_mid_gen_wb_2b_fx; + ratio = tbl_mid_gen_wb_2b_fx; // Q13 move16(); BREAK; } @@ -3734,7 +3737,7 @@ static void lsf_mid_enc_ivas_fx( } ELSE IF( EQ_16( ppp_mode, 1 ) ) { - ratio = tbl_mid_voi_wb_1b_fx; + ratio = tbl_mid_voi_wb_1b_fx; // Q13 move16(); nb_bits = 1; move16(); @@ -3743,7 +3746,7 @@ static void lsf_mid_enc_ivas_fx( } ELSE IF( EQ_16( nelp_mode, 1 ) ) { - ratio = tbl_mid_unv_wb_4b_fx; + ratio = tbl_mid_unv_wb_4b_fx; // Q13 move16(); nb_bits = 4; move16(); @@ -3765,7 +3768,7 @@ static void lsf_mid_enc_ivas_fx( FOR( j = 0; j < M; j++ ) { /* qlsf[j] = (1.0f - ratio[k*M+j]) * qlsf0[j] + ratio[k*M+j] * qlsf1[j]; */ - L_tmp = L_mult( sub( 0x2000, ratio[k1 + j] ), qlsf0[j] ); + L_tmp = L_mult( sub( 0x2000 /*1.Q13*/, ratio[k1 + j] ), qlsf0[j] ); L_tmp = L_mac( L_tmp, ratio[k1 + j], qlsf1[j] ); qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); @@ -3802,7 +3805,7 @@ static void lsf_mid_enc_ivas_fx( FOR( j = 0; j < M; j++ ) { /* qlsf[j] = (1.0f - ratio[idx*M+j]) * qlsf0[j] + ratio[idx*M+j] * qlsf1[j]; */ - L_tmp = L_mult( sub( 0x2000, ratio[idx * M + j] ), qlsf0[j] ); + L_tmp = L_mult( sub( 0x2000 /*1.Q13*/, ratio[idx * M + j] ), qlsf0[j] ); L_tmp = L_mac( L_tmp, ratio[idx * M + j], qlsf1[j] ); qlsf[j] = round_fx( L_shl( L_tmp, 2 ) ); diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 28e1a39de..60375ddcc 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -37,7 +37,6 @@ #include #include "options.h" #include "cnst.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "rom_com.h" #include "rom_enc.h" @@ -93,7 +92,7 @@ Word16 msvq_stage1_dct_search_fx( Word32 *dist1_ptr_fx, /* o : resulting stage 1 MSEs in DCT-N domain */ Word16 *dist1_ptr_e ) { - Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; + Word32 dct_target_fx[FDCNG_VQ_DCT_MAXTRUNC]; // Q20 Word32 u_mr_fx[FDCNG_VQ_MAX_LEN]; Word16 dist1_ptr_e_buf[2 * LSFMBEST_MAX]; Word64 mse_trunc_segm_fx[FDCNG_VQ_DCT_NSEGM]; @@ -127,7 +126,7 @@ Word16 msvq_stage1_dct_search_fx( tmp_e = s_max( 12, u_e ); FOR( i = 0; i < n_ana; i++ ) { - u_mr_fx[i] = L_sub( L_shl( u_fx[i], sub( u_e, tmp_e ) ), L_shl( midQ_truncQ_fx[i], sub( Q31 - Q10, tmp_e ) ) ); + u_mr_fx[i] = L_sub( L_shl( u_fx[i], sub( u_e, tmp_e ) ), L_shl( midQ_truncQ_fx[i], sub( Q31 - Q10, tmp_e ) ) ); // tmp_e move32(); } @@ -136,9 +135,9 @@ Word16 msvq_stage1_dct_search_fx( /* init search state ptr's at the top */ set32_fx( dist1_ptr_fx, MAX_32, maxC_st1 ); set16_fx( dist1_ptr_e_buf, 32, maxC_st1 ); - st1_mse_pair_fx = &( dist1_ptr_fx[0] ); /* req. ptr post upd +=2 */ - st1_mse_pair_e = &( dist1_ptr_e_buf[0] ); /* req. ptr post upd +=2 */ - st1_idx_pair = &( indices_st1_local[0] ); /* req. ptr post upd +=2 */ + st1_mse_pair_fx = &( dist1_ptr_fx[0] ); /* req. ptr post upd +=2 */ // st1_mse_pair_e + st1_mse_pair_e = &( dist1_ptr_e_buf[0] ); /* req. ptr post upd +=2 */ + st1_idx_pair = &( indices_st1_local[0] ); /* req. ptr post upd +=2 */ set64_fx( mse_trunc_segm_fx, 0, n_segm ); // set16_fx( mse_trunc_segm_e, u_e, FDCNG_VQ_DCT_NSEGM ); @@ -152,7 +151,7 @@ Word16 msvq_stage1_dct_search_fx( FOR( i = 0; i < trunc_dct_cols_per_segment[segm]; i++ ) { - mse_trunc_segm_fx[segm] = W_mac_32_32( mse_trunc_segm_fx[segm], dct_target_fx[cols_per_segment[segm] + i], dct_target_fx[cols_per_segment[segm] + i] ); + mse_trunc_segm_fx[segm] = W_mac_32_32( mse_trunc_segm_fx[segm], dct_target_fx[cols_per_segment[segm] + i], dct_target_fx[cols_per_segment[segm] + i] ); // Q41 move64(); } @@ -163,7 +162,7 @@ Word16 msvq_stage1_dct_search_fx( /* unweighted segmented search DCT domain loop */ j_full = add( j, cum_entries_per_segment[segm] ); /* or simply use j_full++ */ - mse_fx = mse_trunc_segm_fx[segm]; /* init mse with with common mse truncation part, in BASOP a move32() */ + mse_fx = mse_trunc_segm_fx[segm]; /* init mse with with common mse truncation part, in BASOP a move32() */ // Q41 move64(); dct_col_shift_tab = col_syn_shift[segm]; /* ptr init */ @@ -176,10 +175,10 @@ Word16 msvq_stage1_dct_search_fx( SHIFT( 1 ); ADD( 1 ); /* in BASOP: s_and(for W8->W16), shl(), sub()*/ #undef WMC_TOOL_SKIP - mse_fx = W_mac_32_32( mse_fx, tmp_fx, tmp_fx ); /* L_mac or L_mac0() square Word16 -> Word32*/ + mse_fx = W_mac_32_32( mse_fx, tmp_fx, tmp_fx ); /* L_mac or L_mac0() square Word16 -> Word32*/ // Q41 } Word16 L_tmp = W_norm( mse_fx ); - st1_mse_ptr_fx[j_full] = W_extract_h( W_lshl( mse_fx, L_tmp ) ); /* save MSE in shared dynamic RAM, move32() in BASOP */ + st1_mse_ptr_fx[j_full] = W_extract_h( W_lshl( mse_fx, L_tmp ) ); /* save MSE in shared dynamic RAM, move32() in BASOP */ // st1_mse_ptr_e move32(); st1_mse_ptr_e[j_full] = sub( shl( tmp_e, 1 ), L_tmp ); move16(); @@ -362,9 +361,9 @@ Word16 msvq_stage1_dct_search_fx( /*! r: (updated p_max) */ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( - const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors */ + const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors st1_syn_vec_e*/ const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ - const Word32 *u_fx, /* i : target signal */ + const Word32 *u_fx, /* i : target signal u_e*/ const Word16 u_e, /* i : exp for target signal */ const Word16 maxC_st1, /* i : number of candidates in stage1 */ Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ @@ -390,7 +389,7 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( /* for stage#1 use "u" instead of the shortened resid[0], to access the extended/extrapolated input target */ FOR( i = 0; i < FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB; i++ ) { - high_diff_fx[i] = L_sub( L_shr( p2_fx[i], sub( tmp_e, st1_syn_vec_e ) ), L_shr( u_fx[FDCNG_VQ_MAX_LEN_WB + i], sub( tmp_e, u_e ) ) ); + high_diff_fx[i] = L_sub( L_shr( p2_fx[i], sub( tmp_e, st1_syn_vec_e ) ), L_shr( u_fx[FDCNG_VQ_MAX_LEN_WB + i], sub( tmp_e, u_e ) ) ); // tmp_e move32(); } acc = 0; @@ -457,7 +456,7 @@ void msvq_enc_ivas_fx( Word16 j; const Word16 *cbp, *cb_stage; Word32 resid_buf_fx[2 * LSFMBEST_MAX * M_MAX], *resid_fx[2]; - Word32 *pTmp, *p1, *p2; + Word32 *pTmp, *p1, *p2; // pTmp_e Word16 pTmp_e; Word16 *indices[2], m, s, c, c2, p_max, i; Word16 idx_buf[2 * LSFMBEST_MAX * MAX_VQ_STAGES_USED], parents[LSFMBEST_MAX]; diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index b81cc18e8..aa2255c68 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -36,10 +36,10 @@ val2 = shr( ( cbp )[2], 4 ); \ val3 = add( add( shr( lshl( ( cbp )[2], 12 ), 4 ), lshr( lshl( ( cbp )[1], 12 ), 8 ) ), s_and( ( cbp )[0], 0xF ) ); /*--------------------------------------------------------------------------* - * depack_mul_values() + * depack_mul_values_fx() * *--------------------------------------------------------------------------*/ -static Word32 depack_mul_values( Word16 *Tmp, const Word16 *w, const Word16 *cbp, const Word16 N ) +static Word32 depack_mul_values_fx( Word16 *Tmp, const Word16 *w, const Word16 *cbp, const Word16 N ) { Word16 i, val0, val1, val2, val3; Word32 en; @@ -69,7 +69,7 @@ static Word32 depack_mul_values( Word16 *Tmp, const Word16 *w, const Word16 *cbp * depack_sub_values() * *--------------------------------------------------------------------------*/ -static void depack_sub_values( Word16 *pTmp, const Word16 *p1, const Word16 *cbp, const Word16 N ) +static void depack_sub_values_fx( Word16 *pTmp, const Word16 *p1, const Word16 *cbp, const Word16 N ) { Word16 j, val0, val1, val2, val3; @@ -93,7 +93,7 @@ static void depack_sub_values( Word16 *pTmp, const Word16 *p1, const Word16 *cbp * * Unroll of inner search loop for maxC == 8 *--------------------------------------------------------------------------*/ -static Word16 msvq_enc_find_p_max_8( Word32 dist[] ) +static Word16 msvq_enc_find_p_max_8_fx( Word32 dist[] ) { Word16 p_max; @@ -144,7 +144,7 @@ static Word16 msvq_enc_find_p_max_8( Word32 dist[] ) * * Unroll of inner search loop for maxC == 6 *--------------------------------------------------------------------------*/ -static Word16 msvq_enc_find_p_max_6( Word32 dist[] ) +static Word16 msvq_enc_find_p_max_6_fx( Word32 dist[] ) { Word16 p_max; @@ -194,7 +194,7 @@ void msvq_enc_fx( const Word16 maxC, /* i : Tree search size (number of candidates kept from */ /* one stage to the next == M-best) */ const Word16 stages, /* i : Number of stages */ - const Word16 w[], /* i : Weights */ + const Word16 w[], /* i : Weights Q8*/ const Word16 N, /* i : Vector dimension */ const Word16 maxN, /* i : Codebook dimension */ Word16 Idx[] /* o : Indices */ @@ -231,11 +231,11 @@ void msvq_enc_fx( set16_fx( parents, 0, maxC ); - func_ptr = msvq_enc_find_p_max_6; + func_ptr = msvq_enc_find_p_max_6_fx; move16(); if ( EQ_16( maxC, 8 ) ) { - func_ptr = msvq_enc_find_p_max_8; + func_ptr = msvq_enc_find_p_max_8_fx; move16(); } @@ -326,7 +326,7 @@ void msvq_enc_fx( FOR( j = 0; j < levels[s]; j++ ) { /* Compute weighted codebook element and its energy */ - en = depack_mul_values( Tmp + start, w + start, cbp, n ); + en = depack_mul_values_fx( Tmp + start, w + start, cbp, n ); cbp += N34; /* pointer is incremented */ @@ -378,7 +378,7 @@ void msvq_enc_fx( move16(); Copy( p1, pTmp, start ); - depack_sub_values( pTmp + start, p1 + start, &cb[s][p2i * N34], n ); + depack_sub_values_fx( pTmp + start, p1 + start, &cb[s][p2i * N34], n ); Copy( p1 + start + n, pTmp + start + n, sub( N, add( start, n ) ) ); pTmp += N; @@ -407,12 +407,12 @@ void msvq_enc_fx( *--------------------------------------------------------------------------*/ void midlsf_enc_fx( - const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 lsf[], /* i: lsf coefficients (3Q12) */ - Word16 *idx, /* o: codebook index */ - const Word16 lpcorder, /* i: order of the lpc */ - const Word32 *Bin_Ener_128_fx, + const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 lsf[], /* i: lsf coefficients (3Q12) */ + Word16 *idx, /* o: codebook index */ + const Word16 lpcorder, /* i: order of the lpc */ + const Word32 *Bin_Ener_128_fx, // Q_ener const Word16 Q_ener, const Word8 narrowBand, const Word32 sr_core, @@ -502,8 +502,8 @@ void midlsf_enc_fx( * Returns: number of indices *--------------------------------------------------------------------------*/ Word16 Q_lsf_tcxlpc_fx( - /* const */ Word16 lsf[], /* i : original lsf */ - Word16 lsf_q[], /* o : quantized lsf */ + /* const */ Word16 lsf[], /* i : original lsf 14Q1 * 1.28 */ + Word16 lsf_q[], /* o : quantized lsf (14Q1*1.28)*/ Word16 lsp_q_ind[], /* o : quantized lsp (w/o MA prediction) */ Word16 indices[], /* o : VQ indices */ const Word16 lpcorder, /* i : LPC order */ @@ -511,7 +511,7 @@ Word16 Q_lsf_tcxlpc_fx( const Word16 cdk, /* i : codebook selector */ const Word16 mem_MA[], /* i : MA memory */ const Word16 coder_type, - const Word32 *Bin_Ener, + const Word32 *Bin_Ener, // Q_ener const Word16 Q_ener ) { Word16 weights[M + 1]; @@ -578,7 +578,7 @@ Word16 Q_lsf_tcxlpc_fx( FOR( i = 0; i < lpcorder; ++i ) { - lsf_q_ind[i] = lsf_q[i]; + lsf_q_ind[i] = lsf_q[i]; /*(14Q1*1.28)*/ move16(); } @@ -891,7 +891,7 @@ Word16 enc_lsf_tcxlpc_ivas_fx( Word16 lsf_msvq_ma_encprm_fx( BSTR_ENC_HANDLE hBstr, - Word16 *param_lpc, + Word16 *param_lpc, // Q0 Word16 core, Word16 acelp_mode, Word16 acelp_midLpc, @@ -916,7 +916,7 @@ Word16 lsf_msvq_ma_encprm_fx( IF( NE_16( acelp_mode, VOICED ) ) { test(); - IF( EQ_16( core, ACELP_CORE ) && acelp_midLpc ) + IF( ( core == ACELP_CORE ) && acelp_midLpc ) { push_next_indice_fx( hBstr, *param_lpc, bits_midlpc ); @@ -928,7 +928,7 @@ Word16 lsf_msvq_ma_encprm_fx( } Word16 lsf_msvq_ma_encprm_ivas_fx( BSTR_ENC_HANDLE hBstr, - const Word16 *param_lpc, + const Word16 *param_lpc, // Q0 const Word16 core, const Word16 acelp_mode, const Word16 acelp_midLpc, @@ -953,7 +953,7 @@ Word16 lsf_msvq_ma_encprm_ivas_fx( IF( NE_16( acelp_mode, VOICED ) ) { test(); - IF( EQ_16( core, ACELP_CORE ) && acelp_midLpc ) + IF( ( core == ACELP_CORE ) && acelp_midLpc ) { push_next_indice( hBstr, *param_lpc, bits_midlpc ); @@ -971,7 +971,7 @@ Word16 lsf_msvq_ma_encprm_ivas_fx( *--------------------------------------------------------------------------*/ Word16 lsf_bctcvq_encprm_fx( BSTR_ENC_HANDLE hBstr, - Word16 *param_lpc, + Word16 *param_lpc, // Q0 Word16 *bits_param_lpc, Word16 no_indices ) { @@ -990,7 +990,7 @@ Word16 lsf_bctcvq_encprm_fx( } Word16 lsf_bctcvq_encprm_ivas_fx( BSTR_ENC_HANDLE hBstr, - const Word16 *param_lpc, + const Word16 *param_lpc, // Q0 const Word16 *bits_param_lpc, const Word16 no_indices ) { diff --git a/lib_enc/ltd_stable_fx.c b/lib_enc/ltd_stable_fx.c index a6e3ae1cc..036fe2a7e 100644 --- a/lib_enc/ltd_stable_fx.c +++ b/lib_enc/ltd_stable_fx.c @@ -21,7 +21,7 @@ void ltd_stable_fx( VAD_CLDFB_HANDLE hVAD_CLDFB, /* i/o: CLDFB VAD state */ Word16 *ltd_stable_rate, /* o : time-domain stable rate*/ - const Word32 frame_energy, /* i : current frame energy*/ + const Word32 frame_energy, /* i : current frame energy Q_frames_power*/ const Word16 frameloop, /* i : amount of frames*/ const Word16 Q_frames_power /* i : the Scaling of frames_power*/ ) @@ -57,7 +57,7 @@ void ltd_stable_fx( move16(); Q_apow = 0; move16(); - frames_power_32 = hVAD_CLDFB->frames_power_32; + frames_power_32 = hVAD_CLDFB->frames_power_32; // Q_frames_power_last_32 Q_frames_power_last_32 = hVAD_CLDFB->Q_frames_power_32; move16(); leadingzero_midamp = 31; @@ -76,7 +76,7 @@ void ltd_stable_fx( IF( GE_16( Q_frames_power32, 40 ) ) { zerop001 = L_shr( CNT0P001, 1 ); - frame_energy_Sqr32 = L_shr( frame_energy_Sqr32, sub( Q_frames_power32, 39 ) ); + frame_energy_Sqr32 = L_shr( frame_energy_Sqr32, sub( Q_frames_power32, 39 ) ); // Q_frames_power32 Q_frames_power32 = 39; move16(); } @@ -86,14 +86,14 @@ void ltd_stable_fx( frame_energy_Sqr32 = L_shr( frame_energy_Sqr32, 1 ); zerop001 = L_shr( CNT0P001, sub( 40, Q_frames_power32 ) ); } - frames_power_32[0] = L_add( frame_energy_Sqr32, zerop001 ); + frames_power_32[0] = L_add( frame_energy_Sqr32, zerop001 ); // Q_frames_power32 move32(); IF( LT_16( frameloop, 3 ) ) { FOR( i = 1; i < 40; i++ ) { - frames_power_32[i] = frames_power_32[0]; + frames_power_32[i] = frames_power_32[0]; // Q_frames_power32 move32(); } } @@ -104,7 +104,7 @@ void ltd_stable_fx( move32(); FOR( i = 1; i < 40; i++ ) { - maxVal = L_max( maxVal, frames_power_32[i] ); + maxVal = L_max( maxVal, frames_power_32[i] ); // Q_frames_power32 } leadingzero = 31; move16(); @@ -119,7 +119,7 @@ void ltd_stable_fx( scale1 = sub( scale1, leadingzero ); FOR( i = 1; i < 40; i++ ) { - frames_power_32[i] = L_shr( frames_power_32[i], scale1 ); + frames_power_32[i] = L_shr( frames_power_32[i], scale1 ); // Q_frames_power32 move32(); } } @@ -140,7 +140,7 @@ void ltd_stable_fx( FOR( i = 0; i < 20; i++ ) { - mid_frame_ampadd32[i] = L_add( L_shr( frames_power_32[2 * i], 1 ), L_shr( frames_power_32[2 * i + 1], 1 ) ); + mid_frame_ampadd32[i] = L_add( L_shr( frames_power_32[2 * i], 1 ), L_shr( frames_power_32[2 * i + 1], 1 ) ); // Q_frames_power32 move32(); } @@ -148,16 +148,18 @@ void ltd_stable_fx( move32(); FOR( i = 0; i < 20; i++ ) { - maxVal = L_max( maxVal, mid_frame_ampadd32[i] ); + maxVal = L_max( maxVal, mid_frame_ampadd32[i] ); // Q_frames_power32 } leadingzero_midamp = 31; move16(); if ( maxVal ) + { leadingzero_midamp = norm_l( maxVal ); + } FOR( i = 0; i < 20; i++ ) { - mid_frame_amp32[i] = L_shl( mid_frame_ampadd32[i], leadingzero_midamp ); + mid_frame_amp32[i] = L_shl( mid_frame_ampadd32[i], leadingzero_midamp ); // Q_frames_power32 + leadingzero_midamp move32(); } @@ -165,19 +167,19 @@ void ltd_stable_fx( move32(); FOR( i = 0; i < 20; i++ ) { - seg_amp32 = L_add( seg_amp32, L_shr( mid_frame_amp32[i], 5 ) ); + seg_amp32 = L_add( seg_amp32, L_shr( mid_frame_amp32[i], 5 ) ); // Q_frames_power32 + leadingzero_midamp - 5 } - seg_amp32 = MUL_F( seg_amp32, 0x0666 ); + seg_amp32 = MUL_F( seg_amp32, 0x0666 /*(1/20).Q15*/ ); dif32 = 0; move32(); apow32 = 0; move32(); - seg_amp32tmp = L_shl( seg_amp32, 5 ); + seg_amp32tmp = L_shl( seg_amp32, 5 ); // Q_frames_power32 + leadingzero_midamp FOR( i = 0; i < 20; i++ ) { - tmp32[i] = L_sub( mid_frame_amp32[i], seg_amp32tmp ); + tmp32[i] = L_sub( mid_frame_amp32[i], seg_amp32tmp ); // Q_frames_power32 + leadingzero_midamp move32(); } @@ -185,22 +187,24 @@ void ltd_stable_fx( move32(); FOR( i = 0; i < 20; i++ ) { - maxVal = L_max( maxVal, L_abs( tmp32[i] ) ); + maxVal = L_max( maxVal, L_abs( tmp32[i] ) ); // Q_frames_power32 + leadingzero_midamp - 5 } leadingzero_tmp32 = 31; move16(); if ( maxVal ) + { leadingzero_tmp32 = norm_l( maxVal ); + } FOR( i = 0; i < 20; i++ ) { - tmp16[i] = extract_h( L_shl( tmp32[i], leadingzero_tmp32 ) ); + tmp16[i] = extract_h( L_shl( tmp32[i], leadingzero_tmp32 ) ); //// Q_frames_power32 + leadingzero_midamp + leadingzero_tmp32 - 16 } FOR( i = 0; i < 20; i++ ) { - tmp_mul = L_mult_sat( tmp16[i], tmp16[i] ); - tmp_mul = L_shr( tmp_mul, 5 ); + tmp_mul = L_mult_sat( tmp16[i], tmp16[i] ); // 2 * (Q_frames_power32 + leadingzero_midamp + leadingzero_tmp32 - 16) + 1 + tmp_mul = L_shr( tmp_mul, 5 ); // 2 * (Q_frames_power32 + leadingzero_midamp + leadingzero_tmp32 - 16) - 4 dif32 = L_add( dif32, tmp_mul ); tmp = extract_h( mid_frame_amp32[i] ); @@ -244,7 +248,9 @@ void ltd_stable_fx( leadingzero_midamp = 31; move16(); if ( maxVal ) + { leadingzero_midamp = norm_l( maxVal ); + } FOR( i = 0; i < 14; i++ ) { @@ -256,15 +262,15 @@ void ltd_stable_fx( move32(); FOR( i = 0; i < 14; i++ ) { - seg_amp32 = L_add( seg_amp32, L_shr( mid_frame_amp32[i], 4 ) ); + seg_amp32 = L_add( seg_amp32, L_shr( mid_frame_amp32[i], 4 ) ); // Q_frames_power32 - 4 } - seg_amp32 = MUL_F( seg_amp32, 0x0924 ); + seg_amp32 = MUL_F( seg_amp32, 0x0924 /*(1/14).Q15*/ ); dif32 = 0; move32(); apow32 = 0; move32(); - seg_amp32tmp = L_shl( seg_amp32, 4 ); + seg_amp32tmp = L_shl( seg_amp32, 4 ); // Q_frames_power32 FOR( i = 0; i < 14; i++ ) { tmp32[i] = L_sub( mid_frame_amp32[i], seg_amp32tmp ); @@ -280,7 +286,9 @@ void ltd_stable_fx( leadingzero_tmp32 = 31; move16(); if ( maxVal ) + { leadingzero_tmp32 = norm_l( maxVal ); + } FOR( i = 0; i < 14; i++ ) { @@ -367,8 +375,10 @@ void ltd_stable_fx( } leadingzero_midamp = 31; move16(); - if ( maxVal ) + IF( maxVal ) + { leadingzero_midamp = norm_l( maxVal ); + } FOR( i = 0; i < 8; i++ ) { @@ -382,7 +392,7 @@ void ltd_stable_fx( { seg_amp32 = L_add( seg_amp32, L_shr( mid_frame_amp32[i], 3 ) ); } - seg_amp32 = MUL_F( seg_amp32, 0x1000 ); + seg_amp32 = MUL_F( seg_amp32, 0x1000 /*(1/8).Q15*/ ); dif32 = 0; move32(); @@ -403,9 +413,10 @@ void ltd_stable_fx( } leadingzero_tmp32 = 31; move16(); - if ( maxVal ) + IF( maxVal ) + { leadingzero_tmp32 = norm_l( maxVal ); - + } FOR( i = 0; i < 8; i++ ) { tmp32[i] = L_shl( tmp32[i], leadingzero_tmp32 ); @@ -482,7 +493,7 @@ void ltd_stable_fx( ltd_stable_rate[2] = shr( ltd_stable_rate[2], ltd_stable_rate_Qtmp ); move16(); - ltd_stable_rate[3] = add( mult( ltd_stable_rate[3], 0x7333 ), mult( ltd_stable_rate[2], 0x0ccc ) ); + ltd_stable_rate[3] = add( mult( ltd_stable_rate[3], 0x7333 /*0.9.Q15*/ ), mult( ltd_stable_rate[2], 0x0ccc /*0.1.Q15*/ ) ); move16(); FOR( i = 55; i > 0; i-- ) diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index eec85c254..a4e19e040 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -46,7 +46,7 @@ * Square magnitude of fft spectrum *----------------------------------------------------------------------------*/ static void dft_mag_square_fx( - const Word16 x[], /* i : Input vector: re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ + const Word16 x[], /* i : Input vector: re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] Qx*/ Word32 magSq[], /* o : Magnitude square spectrum */ const Word16 n /* i : Input vector length */ ) @@ -57,7 +57,7 @@ static void dft_mag_square_fx( /* Magnitude square at 0. */ pMagSq = &magSq[0]; - pRe = &x[0]; + pRe = &x[0]; // Qx *pMagSq++ = L_mult0( *pRe, *pRe ); pRe++; move32(); @@ -70,13 +70,13 @@ static void dft_mag_square_fx( { acc = L_mult0( *pRe, *pRe ); pRe++; - *pMagSq++ = L_mac0( acc, *pIm, *pIm ); + *pMagSq++ = L_mac0( acc, *pIm, *pIm ); // 2*Qx pIm--; move32(); } /* The magnitude square at N/2 */ - *pMagSq = L_mult0( *pRe, *pRe ); + *pMagSq = L_mult0( *pRe, *pRe ); // 2*Qx move32(); return; } @@ -89,7 +89,7 @@ static void dft_mag_square_fx( Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ const Word16 *fft_buff, /* i: re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ Encoder_State *st_fx, /* i/o: Encoder state variable */ - Word32 *cldfbBuf_Ener, + Word32 *cldfbBuf_Ener, // enerBuffer_exp Word16 enerBuffer_exp, const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ) @@ -260,7 +260,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision { IF( max_i > 0 ) { - IF( GT_16( np, 0 ) ) + IF( ( np > 0 ) ) { d_acc = sub( add( d_acc, max_i ), pos_last ); } @@ -277,7 +277,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision IF( pe != 0 ) { expo = norm_l( pe ); - man = L_shl( pe, expo ); + man = L_shl( pe, expo ); // expo Mpy_32_32_ss( man, man, &man, &lsb32 ); /* pe square */ expo = shl( expo, 1 ); /* Multiply by 2 due to squaring. */ floating_point_add( &p_energy_man, &p_energy_exp, man, expo ); @@ -309,35 +309,35 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision /* gain11 = 8*(gain1 - cldfbBuf_Ener[0]/8)/7; */ acc = L_shr( cldfbBuf_Ener[0], 3 ); acc = L_sub( gain1, acc ); - acc = Mult_32_16( acc, 4681 ); + acc = Mult_32_16( acc, 4681 /*(1/7).Q15*/ ); gain11 = L_shl( acc, 3 ); gain4 = L_deposit_l( 0 ); FOR( k = 0; k < 12; k++ ) { - gain4 = L_add( gain4, Mult_32_16( cldfbBuf_Ener[k + 12], 2731 ) ); + gain4 = L_add( gain4, Mult_32_16( cldfbBuf_Ener[k + 12], 2731 /*(1/12).Q15*/ ) ); } peak_H1 = L_add( cldfbBuf_Ener[25], 0 ); - Mpy_32_16_ss( cldfbBuf_Ener[25], 6554, &avrg_H1, &lsb16 ); + Mpy_32_16_ss( cldfbBuf_Ener[25], 6554 /*0.4.Q15*/, &avrg_H1, &lsb16 ); FOR( k = 1; k < 5; k++ ) { IF( GT_32( cldfbBuf_Ener[k + 25], peak_H1 ) ) { peak_H1 = L_add( cldfbBuf_Ener[k + 25], 0 ); } - avrg_H1 = L_add( avrg_H1, Mult_32_16( cldfbBuf_Ener[k + 25], 6554 ) ); + avrg_H1 = L_add( avrg_H1, Mult_32_16( cldfbBuf_Ener[k + 25], 6554 /*0.4.Q15*/ ) ); } peak_H2 = L_add( cldfbBuf_Ener[20], 0 ); - Mpy_32_16_ss( cldfbBuf_Ener[20], 6554, &avrg_H2, &lsb16 ); + Mpy_32_16_ss( cldfbBuf_Ener[20], 6554 /*0.4.Q15*/, &avrg_H2, &lsb16 ); FOR( k = 1; k < 5; k++ ) { IF( GT_32( cldfbBuf_Ener[k + 20], peak_H2 ) ) { peak_H2 = L_add( cldfbBuf_Ener[k + 20], 0 ); } - avrg_H2 = L_add( avrg_H2, Mult_32_16( cldfbBuf_Ener[k + 20], 6554 ) ); + avrg_H2 = L_add( avrg_H2, Mult_32_16( cldfbBuf_Ener[k + 20], 6554 /*0.4.Q15*/ ) ); } // End peak_l = L_deposit_l( 0 ); @@ -400,7 +400,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision condition4 = 0; move16(); - L_tmp = Mult_32_16( peak_h, 12603 ); + L_tmp = Mult_32_16( peak_h, 12603 /*1/2.56.Q15*/ ); IF( GT_32( peak_l, L_tmp ) ) { exp = norm_l( peak_l ); @@ -418,7 +418,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision exp1 = norm_l( avrg_l ); } - L_tmp1 = Mult_32_16( peak_l, 12603 ); + L_tmp1 = Mult_32_16( peak_l, 12603 /*1/2.56.Q15*/ ); IF( GT_32( peak_h, L_tmp1 ) ) { exp2 = norm_l( peak_h ); @@ -438,7 +438,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision move16(); } - L_tmp = Mult_32_16( peak_h, 12800 ); + L_tmp = Mult_32_16( peak_h, 12800 /*(1/2.56).Q15*/ ); IF( GT_32( peak_l, L_tmp ) ) { exp = norm_l( peak_l ); @@ -448,7 +448,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision exp = norm_l( L_tmp ); } - L_tmp1 = Mult_32_16( peak_l, 6400 ); + L_tmp1 = Mult_32_16( peak_l, 6400 /*(1/5.12).Q15*/ ); IF( GT_32( peak_h, L_tmp1 ) ) { exp2 = norm_l( peak_h ); @@ -476,7 +476,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision test(); test(); test(); - IF( ( GT_32( gain4, Mult_32_16( gain11, 26214 ) ) && GT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 ), exp ), L_shl( avrg_l, exp1 ) ) ) && LT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 6400 ), exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) || ( GT_32( gain4, Mult_32_16( gain11, 9830 ) ) && LT_32( Mult_32_16( peak_h, 21845 ), avrg_h ) && LT_32( Mult_32_16( peak_H2, 21845 ), avrg_H2 ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 ), exp ), L_shl( avrg_l, exp1 ) ) ) && GT_32( Mult_32_16( peak_h, 21845 ), avrg_h ) ) || ( GT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 12800 ), exp3 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp3 ), L_shl( avrg_l, exp1 ) ) ) > 0 && LT_32( Mult_32_16( peak_h, 21845 ), avrg_h ) ) ) + IF( ( GT_32( gain4, Mult_32_16( gain11, 26214 /*0.8.Q15*/ ) ) && GT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 /*(1/2.56).Q15*/ ), exp ), L_shl( avrg_l, exp1 ) ) ) && LT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 6400 /*(1/5.12).Q15*/ ), exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) || ( GT_32( gain4, Mult_32_16( gain11, 9830 /*0.3.Q15*/ ) ) && LT_32( Mult_32_16( peak_h, 21845 /*(1/1.5).Q15*/ ), avrg_h ) && LT_32( Mult_32_16( peak_H2, 21845 /*(1/1.5).Q15*/ ), avrg_H2 ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 /*(1/2.56).Q15*/ ), exp ), L_shl( avrg_l, exp1 ) ) ) && GT_32( Mult_32_16( peak_h, 21845 /*(1/1.5).Q15*/ ), avrg_h ) ) || ( GT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 12800 /*(1/2.56).Q15*/ ), exp3 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp3 ), L_shl( avrg_l, exp1 ) ) ) > 0 && LT_32( Mult_32_16( peak_h, 21845 /*(1/1.5).Q15*/ ), avrg_h ) ) ) { condition4 = 1; move16(); @@ -498,21 +498,21 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision } /* Smooth decision from instantaneous decision*/ - acc = L_mult( hTcxEnc->clas_sec_old_fx, MDCT_CLASSIFER_SMOOTH_FILT_COEFF ); /* st_fx->clas_sec_old_fx in Q13 */ - clas_sec = mac_r( acc, c, 0x7fff - MDCT_CLASSIFER_SMOOTH_FILT_COEFF ); /* clas_sec and c are in Q13 */ + acc = L_mult( hTcxEnc->clas_sec_old_fx, MDCT_CLASSIFER_SMOOTH_FILT_COEFF ); /* st_fx->clas_sec_old_fx in Q13 */ + clas_sec = mac_r( acc, c, 0x7fff /*1.Q15*/ - MDCT_CLASSIFER_SMOOTH_FILT_COEFF ); /* clas_sec and c are in Q13 */ /* Do thresholding with hysteresis */ IF( GT_16( st_fx->last_enerBuffer_exp, enerBuffer_exp ) ) { - gain1_tmp = L_shr( gain1, sub( st_fx->last_enerBuffer_exp, enerBuffer_exp ) ); + gain1_tmp = L_shr( gain1, sub( st_fx->last_enerBuffer_exp, enerBuffer_exp ) ); // st_fx->last_enerBuffer_exp move32(); - gain2_tmp = L_shr( gain2, sub( st_fx->last_enerBuffer_exp, enerBuffer_exp ) ); + gain2_tmp = L_shr( gain2, sub( st_fx->last_enerBuffer_exp, enerBuffer_exp ) ); // st_fx->last_enerBuffer_exp move32(); } ELSE { - hTcxEnc->last_gain1 = L_shr( hTcxEnc->last_gain1, sub( enerBuffer_exp, st_fx->last_enerBuffer_exp ) ); + hTcxEnc->last_gain1 = L_shr( hTcxEnc->last_gain1, sub( enerBuffer_exp, st_fx->last_enerBuffer_exp ) ); // enerBuffer_exp move32(); - hTcxEnc->last_gain2 = L_shr( hTcxEnc->last_gain2, sub( enerBuffer_exp, st_fx->last_enerBuffer_exp ) ); + hTcxEnc->last_gain2 = L_shr( hTcxEnc->last_gain2, sub( enerBuffer_exp, st_fx->last_enerBuffer_exp ) ); // enerBuffer_exp move32(); gain1_tmp = gain1; move32(); @@ -582,10 +582,11 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision return clas_final; /* Q0 */ } + Word16 mdct_classifier_ivas_fx( Encoder_State *st, /* i/o: Encoder state variable */ const Word16 *fft_buff, /* i : FFT spectrum from fft_rel */ - const Word32 enerBuffer[], /* i : energy buffer */ + const Word32 enerBuffer[], /* i : energy buffer enerBuffer_exp*/ Word16 enerBuffer_exp, const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ) @@ -772,7 +773,7 @@ Word16 mdct_classifier_ivas_fx( IF( pe != 0 ) { expo = norm_l( pe ); - man = L_shl( pe, expo ); + man = L_shl( pe, expo ); // expo Mpy_32_32_ss( man, man, &man, &lsb32 ); /* pe square */ expo = shl( expo, 1 ); /* Multiply by 2 due to squaring. */ floating_point_add( &p_energy_man, &p_energy_exp, man, expo ); @@ -795,32 +796,32 @@ Word16 mdct_classifier_ivas_fx( { IF( EQ_16( gain2_start, GAIN2_START_SWB ) ) { - gain1 = L_add( gain1, L_shr( enerBuffer[i], 3 ) ); - gain2 = L_add( gain2, L_shr( enerBuffer[gain2_start + i], 3 ) ); - gain3 = L_add( gain3, L_shr( enerBuffer[gain3_start + i], 3 ) ); + gain1 = L_add( gain1, L_shr( enerBuffer[i], 3 ) ); // enerBuffer_exp - 3 + gain2 = L_add( gain2, L_shr( enerBuffer[gain2_start + i], 3 ) ); // enerBuffer_exp - 3 + gain3 = L_add( gain3, L_shr( enerBuffer[gain3_start + i], 3 ) ); // enerBuffer_exp - 3 } ELSE { - gain1 = L_add( gain1, Mult_32_16( enerBuffer[i], 5461 ) ); - gain2 = L_add( gain2, Mult_32_16( enerBuffer[gain2_start + i], 5461 ) ); - gain3 = L_add( gain3, Mult_32_16( enerBuffer[gain3_start + i], 5461 ) ); + gain1 = L_add( gain1, Mult_32_16( enerBuffer[i], 5461 ) ); // enerBuffer_exp + gain2 = L_add( gain2, Mult_32_16( enerBuffer[gain2_start + i], 5461 /*0.16.Q15*/ ) ); // enerBuffer_exp + gain3 = L_add( gain3, Mult_32_16( enerBuffer[gain3_start + i], 5461 /*0.16.Q15*/ ) ); // enerBuffer_exp } } IF( EQ_16( gain2_start, GAIN2_START_SWB ) ) { - acc = L_shr( enerBuffer[0], 3 ); - acc = L_sub( gain1, acc ); - acc = Mult_32_16( acc, 4681 ); - gain11 = L_shl( acc, 3 ); + acc = L_shr( enerBuffer[0], 3 ); // enerBuffer_exp - 3 + acc = L_sub( gain1, acc ); // enerBuffer_exp - 3 + acc = Mult_32_16( acc, 4681 /*(1/7).Q15*/ ); // enerBuffer_exp - 3 + gain11 = L_shl( acc, 3 ); // enerBuffer_exp gain4 = L_deposit_l( 0 ); } ELSE { - acc = Mult_32_16( enerBuffer[0], 5461 ); - acc = L_sub( gain1, acc ); - acc = Mult_32_16( acc, 6553 ); + acc = Mult_32_16( enerBuffer[0], 5461 /*0.16.Q15*/ ); // enerBuffer_exp + acc = L_sub( gain1, acc ); // enerBuffer_exp + acc = Mult_32_16( acc, 6553 /*0.4.Q15*/ ); // enerBuffer_exp gain11 = (Word32) W_mult_32_16( acc, 6 ); gain4 = L_deposit_l( 0 ); } @@ -830,28 +831,28 @@ Word16 mdct_classifier_ivas_fx( { IF( EQ_16( gain4_start, GAIN4_START_SWB ) ) { - gain4 = L_add( gain4, Mult_32_16( enerBuffer[gain4_start + i], 2731 ) ); + gain4 = L_add( gain4, Mult_32_16( enerBuffer[gain4_start + i], 2731 /*(1/12).Q15*/ ) ); } ELSE { - gain4 = L_add( gain4, Mult_32_16( enerBuffer[gain4_start + i], 3641 ) ); + gain4 = L_add( gain4, Mult_32_16( enerBuffer[gain4_start + i], 3641 /*(1/9).Q1.15*/ ) ); } } - peak_H1 = enerBuffer[H1_start]; + peak_H1 = enerBuffer[H1_start]; // enerBuffer_exp move32(); - avrg_H1 = enerBuffer[H1_start]; + avrg_H1 = enerBuffer[H1_start]; // enerBuffer_exp move32(); FOR( i = 1; i < H_length; i++ ) { IF( GT_32( enerBuffer[H1_start + i], peak_H1 ) ) { - peak_H1 = enerBuffer[H1_start + i]; + peak_H1 = enerBuffer[H1_start + i]; // enerBuffer_exp move32(); } - avrg_H1 = L_add( avrg_H1, enerBuffer[H1_start + i] ); + avrg_H1 = L_add( avrg_H1, enerBuffer[H1_start + i] ); // enerBuffer_exp } peak_H2 = enerBuffer[H2_start]; @@ -969,7 +970,7 @@ Word16 mdct_classifier_ivas_fx( move16(); } - L_tmp = Mult_32_16( peak_h, 12800 ); + L_tmp = Mult_32_16( peak_h, 12800 /*(1/2.56).Q15*/ ); IF( GT_32( peak_l, L_tmp ) ) { exp = norm_l( peak_l ); @@ -979,7 +980,7 @@ Word16 mdct_classifier_ivas_fx( exp = norm_l( L_tmp ); } - L_tmp1 = Mult_32_16( peak_l, 6400 ); + L_tmp1 = Mult_32_16( peak_l, 6400 /*(1/5.12).Q15*/ ); IF( GT_32( peak_h, L_tmp1 ) ) { exp2 = norm_l( peak_h ); @@ -1007,8 +1008,8 @@ Word16 mdct_classifier_ivas_fx( test(); test(); test(); - IF( ( GT_32( gain4, Mult_32_16( gain11, 26214 ) ) && GT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 ), exp ), L_shl( avrg_l, exp1 ) ) ) && LT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 6400 ), exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) || ( GT_32( gain4, Mult_32_16( gain11, 9830 ) ) && LT_32( Mult_32_16( peak_h, 21845 ), avrg_h ) && LT_32( Mult_32_16( peak_H2, 21845 ), avrg_H2 ) ) || - ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 ), exp ), L_shl( avrg_l, exp1 ) ) ) && GT_32( Mult_32_16( peak_h, 21845 ), avrg_h ) ) || ( GT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 12800 ), exp3 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp3 ), L_shl( avrg_l, exp1 ) ) ) > 0 && LT_32( Mult_32_16( peak_h, 21845 ), avrg_h ) ) ) + IF( ( GT_32( gain4, Mult_32_16( gain11, 26214 /*0.8.Q15*/ ) ) && GT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 /*(1/2.56).Q15*/ ), exp ), L_shl( avrg_l, exp1 ) ) ) && LT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 6400 /*(1/5.12).Q15*/ ), exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) || ( GT_32( gain4, Mult_32_16( gain11, 9830 /*0.3.Q15*/ ) ) && LT_32( Mult_32_16( peak_h, 21845 /*(1/1.5).Q15*/ ), avrg_h ) && LT_32( Mult_32_16( peak_H2, 21845 /*(1/1.5).Q15*/ ), avrg_H2 ) ) || + ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( Mult_32_16( peak_h, 12800 /*(1/2.56).Q15*/ ), exp ), L_shl( avrg_l, exp1 ) ) ) && GT_32( Mult_32_16( peak_h, 21845 /*(1/1.5).Q15*/ ), avrg_h ) ) || ( GT_32( Mult_32_32( L_shl( Mult_32_16( peak_l, 12800 /*(1/2.56).Q15*/ ), exp3 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp3 ), L_shl( avrg_l, exp1 ) ) ) > 0 && LT_32( Mult_32_16( peak_h, 21845 /*(1/1.5).Q15*/ ), avrg_h ) ) ) { condition4 = 1; move16(); diff --git a/lib_enc/mdct_selector_fx.c b/lib_enc/mdct_selector_fx.c index 52c30f7ef..c4cc7d0db 100644 --- a/lib_enc/mdct_selector_fx.c +++ b/lib_enc/mdct_selector_fx.c @@ -62,14 +62,14 @@ static Word16 get_sparseness( /* Returns sparseness measur FOR( i = 1; i < n - 1; ++i ) { - if ( GT_16( Bin_E[i], s_max( s_max( Bin_E[i - 1], Bin_E[i + 1] ), thr ) ) ) + IF( GT_16( Bin_E[i], s_max( s_max( Bin_E[i - 1], Bin_E[i + 1] ), thr ) ) ) { num_max = add( num_max, 1 ); } } n = shr( sub( n, 2 ), 1 ); - return div_s( sub( n, num_max ), n ); + return div_s( sub( n, num_max ), n ); // Q15 } /*--------------------------------------------------------------------------* * get_mean_ener() @@ -78,7 +78,7 @@ static Word16 get_sparseness( /* Returns sparseness measur *--------------------------------------------------------------------------*/ static Word16 get_mean_ener( /* Returns mean energy in dB (Q8) */ - const Word32 enerBuffer[], /* i : CLDFB buffers */ + const Word32 enerBuffer[], /* i : CLDFB buffers enerBuffer_exp*/ Word16 enerBuffer_exp, /* i : exponent of enerBuffer */ Word16 n /* i : number of bins */ ) @@ -87,8 +87,10 @@ static Word16 get_mean_ener( /* Returns mean energy i Word16 i, shift, frac_nrg, exp_nrg; shift = sub( 14, norm_s( n ) ); - if ( LT_16( shl( 1, shift ), n ) ) + IF( LT_16( shl( 1, shift ), n ) ) + { shift = add( shift, 1 ); + } L_tmp = L_deposit_l( 0 ); FOR( i = 0; i < n; ++i ) @@ -104,7 +106,7 @@ static Word16 get_mean_ener( /* Returns mean energy i exp_nrg = sub( add( exp_nrg, shift ), sub( 31, enerBuffer_exp ) ); L_tmp = Mpy_32_16( exp_nrg, frac_nrg, 9864 ); /* log10(2) in Q15 */ - return round_fx( L_shl( L_tmp, 8 ) ); + return round_fx( L_shl( L_tmp, 8 ) ); // Q8 } /*--------------------------------------------------------------------------* * MDCT_selector_fx() @@ -117,7 +119,7 @@ void MDCT_selector_fx( Word16 sp_floor, /* i : Noise floor estimate Q7 */ const Word16 Etot, /* i : Total energy Q8 */ const Word16 cor_map_sum, /* i : harmonicity factor Q8 */ - const Word32 enerBuffer[], /* i : CLDFB buffers */ + const Word32 enerBuffer[], /* i : CLDFB buffers enerBuffer_exp*/ const Word16 enerBuffer_exp /* i : exponent of enerBuffer */ ) { @@ -135,7 +137,7 @@ void MDCT_selector_fx( sp_floor = shl( sp_floor, 1 ); /* convert to Q8 */ - IF( EQ_16( st->bwidth, NB ) ) + IF( ( st->bwidth == NB ) ) { lob_cldfb = 3200 / 400; move16(); @@ -188,7 +190,7 @@ void MDCT_selector_fx( frame_voicing = add( shr( st->voicing_fx[0], 1 ), shr( st->voicing_fx[1], 1 ) ); /* Spectral sparseness */ - sparseness = get_sparseness( st->lgBin_E_fx, lob_fft, sub( Etot, MDCT_SW_SIG_PEAK_THR ) ); + sparseness = get_sparseness( st->lgBin_E_fx, lob_fft, sub( Etot, MDCT_SW_SIG_PEAK_THR ) ); // Q15 /* Hi band energy */ hi_ener = get_mean_ener( &enerBuffer[lob_cldfb], enerBuffer_exp, sub( hib_cldfb, lob_cldfb ) ); @@ -255,23 +257,23 @@ void MDCT_selector_fx( IF( EQ_16( st->mdct_sw_enable, MODE1 ) ) { - sig_lo_level_thr = MDCT_SW_1_SIG_LO_LEVEL_THR; + sig_lo_level_thr = MDCT_SW_1_SIG_LO_LEVEL_THR; // Q8 move16(); - sig_hi_level_thr = MDCT_SW_1_SIG_HI_LEVEL_THR; + sig_hi_level_thr = MDCT_SW_1_SIG_HI_LEVEL_THR; // Q8 move16(); - cor_thr = MDCT_SW_1_COR_THR; + cor_thr = MDCT_SW_1_COR_THR; // Q8 move16(); - cor_thr2 = MDCT_SW_1_COR_THR2; + cor_thr2 = MDCT_SW_1_COR_THR2; // Q8 move16(); - voicing_thr = MDCT_SW_1_VOICING_THR; + voicing_thr = MDCT_SW_1_VOICING_THR; // Q15 move16(); - voicing_thr2 = MDCT_SW_1_VOICING_THR2; + voicing_thr2 = MDCT_SW_1_VOICING_THR2; // Q15 move16(); - sparseness_thr = MDCT_SW_1_SPARSENESS_THR; + sparseness_thr = MDCT_SW_1_SPARSENESS_THR; // Q15 move16(); - sparseness_thr2 = MDCT_SW_1_SPARSENESS_THR2; + sparseness_thr2 = MDCT_SW_1_SPARSENESS_THR2; // Q15 move16(); - hi_ener_lo_thr = MDCT_SW_1_HI_ENER_LO_THR; + hi_ener_lo_thr = MDCT_SW_1_HI_ENER_LO_THR; // Q8 move16(); } ELSE /* st->mdct_sw_enable == MODE2 */ diff --git a/lib_enc/mslvq_enc_fx.c b/lib_enc/mslvq_enc_fx.c index 771ef480b..af5a82b69 100644 --- a/lib_enc/mslvq_enc_fx.c +++ b/lib_enc/mslvq_enc_fx.c @@ -58,19 +58,19 @@ Word32 mslvq_fx( IF( pred_flag == 0 ) { - p_sigma = sigma_MSLVQ_fx[mode]; + p_sigma = sigma_MSLVQ_fx[mode]; // Qlog2(2.56) /* inverse sigma is precomputed to save complexity */ - p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; - p_scales = scales_fx[mode_glb]; - p_no_lead = no_lead_fx[mode_glb]; + p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; // Q15 + p_scales = scales_fx[mode_glb]; // Q11 + p_no_lead = no_lead_fx[mode_glb]; // Q0 } ELSE { - p_sigma = sigma_p_fx[mode]; + p_sigma = sigma_p_fx[mode]; // Qlog2(2.56) /* inverse sigma is precomputed to save complexity */ - p_inv_sigma = inv_sigma_p_fx[mode]; - p_scales = scales_p_fx[mode_glb]; - p_no_lead = no_lead_p_fx[mode_glb]; + p_inv_sigma = inv_sigma_p_fx[mode]; // Q15 + p_scales = scales_p_fx[mode_glb]; // Q11 + p_no_lead = no_lead_p_fx[mode_glb]; // Q0 } /* first subvector */ @@ -184,15 +184,15 @@ Word32 mslvq_cng_fx( mode_glb = add( START_CNG, idx_cv ); move16(); - p_sigma = sigma_MSLVQ_fx[mode]; + p_sigma = sigma_MSLVQ_fx[mode]; // x2.56 move16(); - p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; + p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; // Q15 move16(); - p_scales = scales_fx[mode_glb]; + p_scales = scales_fx[mode_glb]; // Q11 move16(); - p_no_lead = no_lead_fx[mode_glb]; + p_no_lead = no_lead_fx[mode_glb]; // Q0 move16(); - p_no_scales = &no_scales[shl( mode_glb, 1 )]; + p_no_scales = &no_scales[( mode_glb << 1 )]; move16(); /* check if LSF component permutation is needed or not */ @@ -247,11 +247,11 @@ Word32 mslvq_cng_ivas_fx( mode_glb = add( START_CNG, idx_cv ); move16(); - p_sigma = sigma_MSLVQ_fx[mode]; + p_sigma = sigma_MSLVQ_fx[mode]; // x2.56 move16(); - p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; + p_inv_sigma = inv_sigma_MSLVQ_fx[mode]; // Q15 move16(); - p_scales = scales_fx[mode_glb]; + p_scales = scales_fx[mode_glb]; // Q11 move16(); no_scales[0] = 0; @@ -773,7 +773,7 @@ static void sort_desc_ind_fx( move16(); } sorted = 0; - FOR( k = sub( len, 1 ); k > 0; k-- ) + FOR( k = ( len - 1 ); k > 0; k-- ) { IF( sorted ) { @@ -837,7 +837,7 @@ void index_lvq_fx( /* for first subvector */ IF( GT_16( idx_scale[0], -1 ) ) { - index1 = L_add( encode_comb_fx( quant, idx_lead[0] ), L_add( table_no_cv_fx[idx_lead[0]], p_offset_scale1[i_mult2( mode, len_offset ) + idx_scale[0]] ) ); + index1 = L_add( encode_comb_fx( quant, idx_lead[0] ), L_add( table_no_cv_fx[idx_lead[0]], p_offset_scale1[( mode * len_offset ) + idx_scale[0]] ) ); } /* for second subvector */ @@ -845,7 +845,7 @@ void index_lvq_fx( IF( GT_16( idx_scale[1], -1 ) ) { - index2 = L_add( encode_comb_fx( &quant[LATTICE_DIM], idx_lead[1] ), L_add( table_no_cv_fx[idx_lead[1]], p_offset_scale2[i_mult2( mode, len_offset ) + idx_scale[1]] ) ); + index2 = L_add( encode_comb_fx( &quant[LATTICE_DIM], idx_lead[1] ), L_add( table_no_cv_fx[idx_lead[1]], p_offset_scale2[( mode * len_offset ) + idx_scale[1]] ) ); } idx64 = W_mult0_32_32( index1, p_offset_scale2[mode * len_offset + p_no_scales[mode * 2 + 1]] ); index2_64 = W_deposit32_l( index2 ); @@ -854,9 +854,9 @@ void index_lvq_fx( /* convert to 3 short */ index[0] = ( ( idx64 ) & ( 0x7fff ) ); move16(); - index[1] = ( idx64 >> 15 ) & ( 0x7fff ); + index[1] = ( W_shr( idx64, 15 ) ) & ( 0x7fff ); move16(); - index[2] = ( idx64 >> 30 ) & ( 0x7fff ); + index[2] = ( W_shr( idx64, 30 ) ) & ( 0x7fff ); move16(); return; } @@ -900,9 +900,9 @@ void index_lvq_ivas_fx( /* convert to 3 short */ index[0] = ( ( idx64 ) & ( 0x7fff ) ); move16(); - index[1] = ( idx64 >> 15 ) & ( 0x7fff ); + index[1] = ( W_shr( idx64, 15 ) ) & ( 0x7fff ); move16(); - index[2] = ( idx64 >> 30 ) & ( 0x7fff ); + index[2] = ( W_shr( idx64, 30 ) ) & ( 0x7fff ); move16(); return; @@ -1059,7 +1059,7 @@ static Word16 encode_sign_pc1_fx( /* o : index of signs IF( cv[i] < 0 ) { idx_sign = add( idx_sign, ( shl( 1, cnt ) ) ); - cnt++; + cnt = add( cnt, 1 ); } if ( cv[i] > 0 ) @@ -1091,7 +1091,7 @@ static void take_out_val_fx( FOR( i = 0; i < len; i++ ) { - IF( NE_16( v[i], val ) ) + if ( NE_16( v[i], val ) ) { v_out[cnt++] = v[i]; move16(); @@ -1125,7 +1125,7 @@ Word16 c2idx_fx( /* o: index */ move16(); FOR( i = 1; i <= p[0]; i++ ) { - skip = add( skip, C_VQ[sub( n, i )][sub( k, 1 )] ); + skip = add( skip, C_VQ[( n - i )][( k - 1 )] ); // Q0 } p0 = p[0]; diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 78ef81c60..1bae597b6 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -53,7 +53,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity /* length of the useful part of the spectrum (up to 6.4kHz) */ L = L_FFT / 2; move16(); - if ( EQ_16( bwidth, NB ) ) + if ( ( bwidth == NB ) ) { /* length of the useful part of the spectrum (up to 3.6kHz) */ L = 76; @@ -170,14 +170,14 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity mean_dyn = round_fx( L_acc ); /*Q7*/ test(); - IF( LT_16( mean_dyn, 1229 ) /*9.6f*/ && *cor_strong_limit != 0 ) + IF( LT_16( mean_dyn, 1229 ) /*9.6f.Q7*/ && *cor_strong_limit != 0 ) { *cor_strong_limit = 0; move16(); *st_last_sw_dyn = mean_dyn; move16(); } - ELSE IF( GT_16( sub( mean_dyn, *st_last_sw_dyn ), 576 ) /*4.5f*/ ) + ELSE IF( GT_16( sub( mean_dyn, *st_last_sw_dyn ), 576 ) /*4.5f.Q7*/ ) { *cor_strong_limit = 1; move16(); @@ -290,7 +290,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity cor_strong = 0; move16(); - pt1 = cor_map_LT; + pt1 = cor_map_LT; // Q15 move16(); pt2 = cor_map; move16(); @@ -306,7 +306,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity /* cor_map_LT_sum += *pt1 */ Lcor_map_LT_sum = L_add( Lcor_map_LT_sum, *pt1 ); /* cor_map_LT_sum in Q15; max value is 128) */ - if ( GT_16( *pt1, 31130 ) /*0.95f*/ ) + if ( GT_16( *pt1, 31130 ) /*0.95f.Q15*/ ) { cor_strong = 1; move16(); @@ -316,7 +316,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity pt2++; } - IF( EQ_16( bwidth, NB ) ) + IF( ( bwidth == NB ) ) { /* cor_map_LT_sum *= 1.53f; */ /* tmp2 *= 1.53f; */ @@ -396,7 +396,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni /* length of the useful part of the spectrum (up to 6.4kHz) */ L = L_FFT / 2; move16(); - if ( EQ_16( bwidth, NB ) ) + if ( ( bwidth == NB ) ) { /* length of the useful part of the spectrum (up to 3.6kHz) */ L = 76; @@ -654,7 +654,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni } tmp2 = extract_l( L_shr_sat( tmp2_32, 7 ) ); // q15-> q8 - IF( EQ_16( bwidth, NB ) ) + IF( ( bwidth == NB ) ) { /* cor_map_LT_sum *= 1.53f; */ /* tmp2 *= 1.53f; */ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 353de8ec9..e04f5172b 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -17,7 +17,6 @@ #include "debug.h" #endif #include -#include "ivas_prot.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 7bbc54780..5c96a2f29 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -10,7 +10,6 @@ #include "rom_com.h" #include "stl.h" #include "prot_fx.h" /* Function prototypes */ -#include "ivas_prot.h" /* Function prototypes */ #include "ivas_prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 61ca9b101..ba8ee5aa8 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -10,7 +10,6 @@ #include "rom_com.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ -#include "ivas_prot.h" /* Function prototypes */ #include "stl.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_allrad_dec_fx.c b/lib_rend/ivas_allrad_dec_fx.c index 008e27d6c..770b62764 100644 --- a/lib_rend/ivas_allrad_dec_fx.c +++ b/lib_rend/ivas_allrad_dec_fx.c @@ -36,7 +36,6 @@ #include #include #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 81437c49d..e50ad32e1 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 9cc764afb..93a100e17 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -34,7 +34,6 @@ #include #include "ivas_cnst.h" #include "ivas_prot_rend.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 730705ffd..0deb14c9b 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -35,7 +35,6 @@ #include #include #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_binauralRenderer.h" diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index e89414542..b8b3c3ac7 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" diff --git a/lib_rend/ivas_dirac_onsets_dec_fx.c b/lib_rend/ivas_dirac_onsets_dec_fx.c index 4eae9c286..e9af8483a 100644 --- a/lib_rend/ivas_dirac_onsets_dec_fx.c +++ b/lib_rend/ivas_dirac_onsets_dec_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 29eac3635..40ed0ad58 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 958a23a3f..e254ed6dd 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -36,7 +36,6 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 52ca3e6f9..7a74e62da 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -36,7 +36,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 5d53d2ae3..e3965fbff 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -36,7 +36,6 @@ #include "ivas_prot_rend.h" #include "ivas_error.h" #include "wmc_auto.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 8b7e6575d..430fab2c7 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "lib_rend.h" #include "ivas_prot_rend.h" -#include "ivas_prot.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 25fddaa80..8b56b6855 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "options.h" #include "ivas_prot_rend.h" -#include "ivas_prot.h" #include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 93fe67436..7b1e1fe91 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index d7387ecd4..2c28b32bd 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -35,7 +35,6 @@ #include #include "ivas_cnst.h" #include "ivas_prot_rend.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_stat_rend.h" diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index bb6f26346..a124bf4bd 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -33,7 +33,6 @@ #include "common_api_types.h" #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 054e5e981..6fba496d5 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -37,7 +37,6 @@ #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" -#include "ivas_prot.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------------------* diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index bbe6ae4b5..74be74497 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -1,6 +1,5 @@ #include "ivas_prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #ifdef FIX_DISCLAIMER #include diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c index a02a29d0d..d6e397234 100644 --- a/lib_rend/ivas_reflections_fx.c +++ b/lib_rend/ivas_reflections_fx.c @@ -39,7 +39,6 @@ #include "ivas_prot_rend.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" -#include "ivas_prot.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "debug.h" diff --git a/lib_rend/ivas_reverb_delay_line_fx.c b/lib_rend/ivas_reverb_delay_line_fx.c index 44550803a..ab41b43c2 100644 --- a/lib_rend/ivas_reverb_delay_line_fx.c +++ b/lib_rend/ivas_reverb_delay_line_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c index 4323fc96f..d544acd13 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_td_decorr_fx.c b/lib_rend/ivas_td_decorr_fx.c index 6d5b23f12..0fc5c21df 100644 --- a/lib_rend/ivas_td_decorr_fx.c +++ b/lib_rend/ivas_td_decorr_fx.c @@ -35,7 +35,6 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "math.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c index 06cbd83a6..b90b3a456 100644 --- a/lib_rend/ivas_vbap_fx.c +++ b/lib_rend/ivas_vbap_fx.c @@ -35,7 +35,6 @@ #include #include #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index ae3166520..2c81911a1 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -33,7 +33,6 @@ #include "options.h" #include "lib_rend.h" #include "prot_fx.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 930bb79dc..0316d8b30 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -34,7 +34,6 @@ #include #include "prot_fx.h" #include "ivas_prot_rend.h" -#include "ivas_prot.h" #include "ivas_prot_fx.h" /*---------------------------------------------------------------------* diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 90d47b7c9..f4f43e496 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -33,7 +33,7 @@ #include "ls_custom_file_reader.h" #include #include -#include "ivas_prot.h" +#include "ivas_prot_fx.h" #include "prot_fx.h" diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 9351d9bc9..efab80b79 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include "masa_file_reader.h" -#include "ivas_prot.h" #include "ivas_stat_com.h" #include #include -- GitLab From 7027097814fca9e108640c2793a4620025705dfc Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 19:41:16 +0530 Subject: [PATCH 72/97] Clang formatting changes --- lib_com/gs_bitallocation_ivas_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/gs_bitallocation_ivas_fx.c b/lib_com/gs_bitallocation_ivas_fx.c index 71b30ea75..9243f640e 100644 --- a/lib_com/gs_bitallocation_ivas_fx.c +++ b/lib_com/gs_bitallocation_ivas_fx.c @@ -2,11 +2,11 @@ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ #include -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -#include "rom_com.h" /* Static table prototypes */ -#include "prot_fx.h" /* Function prototypes */ -#include "assert.h" /* Debug prototypes */ +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ +#include "rom_com.h" /* Static table prototypes */ +#include "prot_fx.h" /* Function prototypes */ +#include "assert.h" /* Debug prototypes */ #include "stl.h" #include "ivas_prot_fx.h" -- GitLab From a9c9fd5c18a642694f5e0ecd1ebc26d7cb82718e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 11 Mar 2025 12:32:57 +0530 Subject: [PATCH 73/97] Fix for 3GPP issue 1341: Usage of open/deleteCldfb() functions - multiple variants Link #1341 --- lib_com/cldfb.c | 107 +++-------------------- lib_com/cnst.h | 6 +- lib_com/prot_fx.h | 15 +--- lib_dec/init_dec_fx.c | 6 +- lib_dec/ivas_corecoder_dec_reconfig_fx.c | 4 +- lib_dec/ivas_init_dec.c | 4 +- lib_dec/ivas_sce_dec_fx.c | 2 +- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 4 +- lib_dec/ivas_stereo_switching_dec_fx.c | 10 +-- lib_enc/init_enc_fx.c | 4 +- lib_enc/ivas_masa_enc_fx.c | 4 +- lib_enc/ivas_omasa_enc_fx.c | 4 +- lib_enc/ivas_stereo_switching_enc_fx.c | 10 +-- lib_enc/ivas_stereo_td_enc_fx.c | 8 +- lib_rend/ivas_dirac_ana_fx.c | 2 +- lib_rend/ivas_masa_merge_fx.c | 2 +- lib_rend/ivas_mcmasa_ana_fx.c | 2 +- lib_rend/ivas_omasa_ana_fx.c | 2 +- lib_rend/lib_rend.c | 4 +- 19 files changed, 53 insertions(+), 147 deletions(-) diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 38195b65d..7fc8026b5 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1364,8 +1364,8 @@ ivas_error openCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ CLDFB_TYPE type, /* i : analysis or synthesis */ const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -) + CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ + CODE_TYPE code_type ) { HANDLE_CLDFB_FILTER_BANK hs; Word16 buf_len; @@ -1379,7 +1379,14 @@ ivas_error openCldfb_ivas_fx( move32(); hs->prototype = prototype; move32(); - configureCldfb_ivas_fx( hs, sampling_rate ); + IF( code_type == IVAS_ENC ) + { + configureCldfb_ivas_enc_fx( hs, sampling_rate ); + } + ELSE + { + configureCldfb_ivas_fx( hs, sampling_rate ); + } hs->memory32 = NULL; hs->FilterStates = NULL; hs->memory_length = 0; @@ -1413,65 +1420,6 @@ ivas_error openCldfb_ivas_fx( return IVAS_ERR_OK; } -ivas_error openCldfb_ivas_enc( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -) -{ - HANDLE_CLDFB_FILTER_BANK hs; - Word16 buf_len; - - IF( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); - } - - hs->type = type; - move32(); - hs->prototype = prototype; - move32(); - - configureCldfb_ivas_enc_fx( hs, sampling_rate ); - hs->memory_length = 0; - move32(); - - IF( type == CLDFB_ANALYSIS ) - { - buf_len = sub( hs->p_filter_length, hs->no_channels ); - hs->FilterStates = (Word16 *) malloc( ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) ); - hs->FilterStates_eg = 0; - move16(); - } - ELSE - { - buf_len = hs->p_filter_length; - move16(); - hs->FilterStates = (Word16 *) malloc( 2 * ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) ); - hs->FilterStates_eg = 0; - move16(); - } - - if ( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); - } - hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer - move16(); - hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/ - move16(); - set32_fx( hs->cldfb_state_fx, 0, buf_len ); - hs->Q_cldfb_state = 0; - move16(); - set16_fx( hs->FilterStates, 0, i_mult( 9 + 16, hs->no_channels ) ); - set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) ); - - *h_cldfb = hs; - - return IVAS_ERR_OK; -} - /*-------------------------------------------------------------------* * resampleCldfb_ivas() * @@ -1563,41 +1511,6 @@ void analysisCldfbEncoder_ivas_fx( return; } - -/*-------------------------------------------------------------------* - * GetEnergyCldfb_ivas() - * - * Remove handle - *--------------------------------------------------------------------*/ - -void deleteCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ -) -{ - HANDLE_CLDFB_FILTER_BANK hs = *h_cldfb; - - test(); - IF( h_cldfb == NULL || *h_cldfb == NULL ) - { - return; - } - - IF( hs->cldfb_state_fx ) - { - free( hs->cldfb_state_fx ); - } - - IF( hs->FilterStates ) - { - free( hs->FilterStates ); - } - - free( hs ); - *h_cldfb = NULL; - - return; -} - void deleteCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ ) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 7c93498af..3c014325e 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -803,7 +803,11 @@ typedef enum CLDFB_ANALYSIS, CLDFB_SYNTHESIS } CLDFB_TYPE; - +typedef enum +{ + IVAS_ENC, + IVAS_DEC_REND +} CODE_TYPE; typedef enum { CLDFB_PROTOTYPE_1_25MS, diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index db0953cd9..c1aefbe36 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9803,8 +9803,8 @@ ivas_error openCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ CLDFB_TYPE type, /* i : analysis or synthesis */ const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -); + CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ + CODE_TYPE code_type ); Word32 rand_gauss_fx( Word32 *x, @@ -11944,13 +11944,6 @@ ivas_error openCldfb_ivas( CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ ); -ivas_error openCldfb_ivas_enc( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -); - void resampleCldfb_ivas( HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ const Word32 newSamplerate /* i : new samplerate to operate */ @@ -11960,10 +11953,6 @@ ivas_error cldfb_save_memory_ivas( HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ ); -void deleteCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ -); - /*! r: flag indicating a valid bitrate */ Word16 is_EVS_bitrate( const Word32 ivas_total_brate, /* i : EVS total bitrate */ diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 3865cd61c..4e0cfda18 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1447,13 +1447,13 @@ ivas_error init_decoder_ivas_fx( IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { /* open analysis for max. SR 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } /* open analysis BPF for max. SR 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -1465,7 +1465,7 @@ ivas_error init_decoder_ivas_fx( } /* open synthesis for output SR */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_corecoder_dec_reconfig_fx.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c index 25c0bea42..111c0be0e 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig_fx.c +++ b/lib_dec/ivas_corecoder_dec_reconfig_fx.c @@ -602,7 +602,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* create additional CLDFB synthesis instances */ FOR( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -622,7 +622,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* create additional CLDFB synthesis instances */ FOR( i = numCldfbSyntheses_old; i < numCldfbSyntheses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index b11669460..236eaad54 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2264,7 +2264,7 @@ ivas_error ivas_init_decoder_fx( FOR( i = 0; i < numCldfbAnalyses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -2276,7 +2276,7 @@ ivas_error ivas_init_decoder_fx( FOR( i = 0; i < numCldfbSyntheses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index a6be10c08..cc3980b12 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -438,7 +438,7 @@ ivas_error create_sce_dec( IF( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && EQ_16( st_ivas->nchan_transport, 1 ) ) ) ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 3f39bd9ac..c8dde0837 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -601,7 +601,7 @@ ivas_error initMdctStereoDtxData_fx( IF( st->cldfbAna == NULL ) { /* open analysis for max. sampling rate 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -610,7 +610,7 @@ ivas_error initMdctStereoDtxData_fx( IF( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 09b683a16..34eef94ed 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -205,7 +205,7 @@ static ivas_error allocate_CoreCoder_fx( IF( st->cldfbAna == NULL ) { /* open analysis for max. sampling rate 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -214,7 +214,7 @@ static ivas_error allocate_CoreCoder_fx( IF( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -752,7 +752,7 @@ ivas_error stereo_memory_dec_fx( IF( st->cldfbAna == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -761,7 +761,7 @@ ivas_error stereo_memory_dec_fx( IF( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -1100,7 +1100,7 @@ ivas_error stereo_memory_dec_fx( { IF( hCPE->hCoreCoder[i]->cldfbSyn == NULL ) /* could be NULL when we had the MCT LFE channel */ { - IF( NE_32( ( error = openCldfb_ivas_fx( &hCPE->hCoreCoder[i]->cldfbSyn, CLDFB_SYNTHESIS, hCPE->hCoreCoder[i]->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &hCPE->hCoreCoder[i]->cldfbSyn, CLDFB_SYNTHESIS, hCPE->hCoreCoder[i]->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 615ca1b33..f0338b461 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1695,7 +1695,7 @@ ivas_error init_encoder_ivas_fx( test(); IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { - IF( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ) != IVAS_ERR_OK ) { return error; } @@ -1809,7 +1809,7 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - IF( ( error = openCldfb_ivas_enc( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 6960629c8..9fdebed7a 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -152,7 +152,7 @@ ivas_error ivas_masa_enc_open_fx( FOR( i = 0; i < hMasa->data.num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_enc( &( hMasa->data.cldfbAnaEnc[i] ), CLDFB_ANALYSIS, hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasa->data.cldfbAnaEnc[i] ), CLDFB_ANALYSIS, hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -260,7 +260,7 @@ void ivas_masa_enc_close_fx( FOR( i = 0; i < ( *hMasa )->data.num_Cldfb_instances; i++ ) { - deleteCldfb_ivas( &( ( *hMasa )->data.cldfbAnaEnc[i] ) ); + deleteCldfb_ivas_fx( &( ( *hMasa )->data.cldfbAnaEnc[i] ) ); } IF( ( *hMasa )->data.hOmasaData != NULL ) diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 5d79265f4..50fb49355 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -124,7 +124,7 @@ ivas_error ivas_omasa_enc_open_fx( move16(); FOR( i = 0; i < hOMasa->num_Cldfb_instances; i++ ) { - IF( ( error = openCldfb_ivas_enc( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, st_ivas->hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, st_ivas->hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_ENC ) ) != IVAS_ERR_OK ) { return error; } @@ -227,7 +227,7 @@ void ivas_omasa_enc_close_fx( FOR( i = 0; i < ( *hOMasa )->num_Cldfb_instances; i++ ) { - deleteCldfb_ivas( &( ( *hOMasa )->cldfbAnaEnc[i] ) ); + deleteCldfb_ivas_fx( &( ( *hOMasa )->cldfbAnaEnc[i] ) ); } FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 2fe8b6c84..6c7a1e68d 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -366,8 +366,8 @@ ivas_error stereo_memory_enc_fx( IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) && ( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) || EQ_16( hCPE->element_mode, IVAS_CPE_TD ) ) ) { /* Deallocate MDCT CNG structures */ - deleteCldfb_ivas( &hCPE->hCoreCoder[0]->cldfbAnaEnc ); - deleteCldfb_ivas( &hCPE->hCoreCoder[1]->cldfbAnaEnc ); + deleteCldfb_ivas_fx( &hCPE->hCoreCoder[0]->cldfbAnaEnc ); + deleteCldfb_ivas_fx( &hCPE->hCoreCoder[1]->cldfbAnaEnc ); IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { @@ -417,7 +417,7 @@ ivas_error stereo_memory_enc_fx( /* allocate CLDFB for primary channel */ IF( st->cldfbAnaEnc == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -433,7 +433,7 @@ ivas_error stereo_memory_enc_fx( IF( st->cldfbSynTd == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_enc( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -587,7 +587,7 @@ ivas_error stereo_memory_enc_fx( FOR( i = 0; i < CPE_CHANNELS; i++ ) { st = hCPE->hCoreCoder[i]; - IF( NE_32( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index d2ff2c0c2..de9bc09b5 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -263,7 +263,7 @@ ivas_error stereo_set_tdm_fx( /* deallocate CLDFB ana for secondary channel */ IF( st->cldfbAnaEnc != NULL ) { - deleteCldfb_ivas( &st->cldfbAnaEnc ); + deleteCldfb_ivas_fx( &st->cldfbAnaEnc ); } /* deallocate BWEs for secondary channel */ @@ -275,7 +275,7 @@ ivas_error stereo_set_tdm_fx( st->hBWE_TD = NULL; } - deleteCldfb_ivas( &st->cldfbSynTd ); + deleteCldfb_ivas_fx( &st->cldfbSynTd ); IF( st->hBWE_FD != NULL ) { @@ -309,7 +309,7 @@ ivas_error stereo_set_tdm_fx( /* allocate CLDFB ana for secondary channel */ IF( st->cldfbAnaEnc == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_enc( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -322,7 +322,7 @@ ivas_error stereo_set_tdm_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - IF( NE_32( ( error = openCldfb_ivas_enc( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 93a100e17..5dd3f8384 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -107,7 +107,7 @@ ivas_error ivas_dirac_ana_open_fx( move16(); FOR( i = 0; i < hDirAC->num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hDirAC->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hDirAC->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 430fab2c7..3aa9f62a9 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -499,7 +499,7 @@ ivas_error masaPrerendOpen_fx( move16(); FOR( i = 0; i < hMasaPrerend->num_Cldfb_instances; i++ ) { - IF( ( error = openCldfb_ivas_fx( &( hMasaPrerend->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hMasaPrerend->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 8b56b6855..d56ba2685 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -224,7 +224,7 @@ ivas_error ivas_mcmasa_ana_open( move16(); FOR( i = 0; i < hMcMasa->num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMcMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMcMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 2c28b32bd..1d849a90f 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -133,7 +133,7 @@ ivas_error ivas_omasa_ana_open( hOMasa->num_Cldfb_instances = numAnalysisChannels; FOR( i = 0; i < hOMasa->num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 2c81911a1..041f278f1 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8187,7 +8187,7 @@ static ivas_error initMasaExtRenderer( { FOR( i = 0; i < hMasaExtRend->nchan_input; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbAnaRend[i] ), CLDFB_ANALYSIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbAnaRend[i] ), CLDFB_ANALYSIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } @@ -8195,7 +8195,7 @@ static ivas_error initMasaExtRenderer( FOR( i = 0; i < hMasaExtRend->nchan_output; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbSynRend[i] ), CLDFB_SYNTHESIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbSynRend[i] ), CLDFB_SYNTHESIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) { return error; } -- GitLab From 0c4a9f1957c11cb72f48d19ccabeb118dec895e5 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Mar 2025 11:42:57 +0530 Subject: [PATCH 74/97] Address review comments --- lib_com/cldfb.c | 10 ++++++---- lib_com/cnst.h | 6 +----- lib_com/prot_fx.h | 2 +- lib_dec/init_dec_fx.c | 6 +++--- lib_dec/ivas_corecoder_dec_reconfig_fx.c | 4 ++-- lib_dec/ivas_init_dec.c | 4 ++-- lib_dec/ivas_sce_dec_fx.c | 2 +- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 4 ++-- lib_dec/ivas_stereo_switching_dec_fx.c | 10 +++++----- lib_enc/init_enc_fx.c | 4 ++-- lib_enc/ivas_masa_enc_fx.c | 2 +- lib_enc/ivas_omasa_enc_fx.c | 2 +- lib_enc/ivas_stereo_switching_enc_fx.c | 6 +++--- lib_enc/ivas_stereo_td_enc_fx.c | 4 ++-- lib_rend/ivas_dirac_ana_fx.c | 2 +- lib_rend/ivas_masa_merge_fx.c | 2 +- lib_rend/ivas_mcmasa_ana_fx.c | 2 +- lib_rend/ivas_omasa_ana_fx.c | 2 +- lib_rend/lib_rend.c | 4 ++-- 19 files changed, 38 insertions(+), 40 deletions(-) diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 7fc8026b5..246a8a8e8 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1365,7 +1365,7 @@ ivas_error openCldfb_ivas_fx( CLDFB_TYPE type, /* i : analysis or synthesis */ const Word32 sampling_rate, /* i : sampling rate */ CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ - CODE_TYPE code_type ) + const Word16 enc_dec ) /* i : encoder/decoder flag */ { HANDLE_CLDFB_FILTER_BANK hs; Word16 buf_len; @@ -1379,14 +1379,17 @@ ivas_error openCldfb_ivas_fx( move32(); hs->prototype = prototype; move32(); - IF( code_type == IVAS_ENC ) + IF( enc_dec == ENC ) { configureCldfb_ivas_enc_fx( hs, sampling_rate ); + hs->Q_cldfb_state = 0; } ELSE { configureCldfb_ivas_fx( hs, sampling_rate ); + hs->Q_cldfb_state = Q11; } + move16(); hs->memory32 = NULL; hs->FilterStates = NULL; hs->memory_length = 0; @@ -1412,8 +1415,7 @@ ivas_error openCldfb_ivas_fx( hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/ move16(); set32_fx( hs->cldfb_state_fx, 0, buf_len ); - hs->Q_cldfb_state = Q11; - move16(); + *h_cldfb = hs; move16(); diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 3c014325e..7c93498af 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -803,11 +803,7 @@ typedef enum CLDFB_ANALYSIS, CLDFB_SYNTHESIS } CLDFB_TYPE; -typedef enum -{ - IVAS_ENC, - IVAS_DEC_REND -} CODE_TYPE; + typedef enum { CLDFB_PROTOTYPE_1_25MS, diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c1aefbe36..9fe14b5bd 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9804,7 +9804,7 @@ ivas_error openCldfb_ivas_fx( CLDFB_TYPE type, /* i : analysis or synthesis */ const Word32 sampling_rate, /* i : sampling rate */ CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ - CODE_TYPE code_type ); + const Word16 enc_dec ); /* i : encoder/decoder flag */ Word32 rand_gauss_fx( Word32 *x, diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 4e0cfda18..bd8a2cbd3 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1447,13 +1447,13 @@ ivas_error init_decoder_ivas_fx( IF( ( idchan == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { /* open analysis for max. SR 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } /* open analysis BPF for max. SR 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -1465,7 +1465,7 @@ ivas_error init_decoder_ivas_fx( } /* open synthesis for output SR */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st_fx->cldfbSyn, CLDFB_SYNTHESIS, st_fx->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_corecoder_dec_reconfig_fx.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c index 111c0be0e..8333f146f 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig_fx.c +++ b/lib_dec/ivas_corecoder_dec_reconfig_fx.c @@ -602,7 +602,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* create additional CLDFB synthesis instances */ FOR( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -622,7 +622,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* create additional CLDFB synthesis instances */ FOR( i = numCldfbSyntheses_old; i < numCldfbSyntheses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 236eaad54..1ab797ded 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2264,7 +2264,7 @@ ivas_error ivas_init_decoder_fx( FOR( i = 0; i < numCldfbAnalyses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -2276,7 +2276,7 @@ ivas_error ivas_init_decoder_fx( FOR( i = 0; i < numCldfbSyntheses; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index cc3980b12..12549f49d 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -438,7 +438,7 @@ ivas_error create_sce_dec( IF( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && EQ_16( st_ivas->nchan_transport, 1 ) ) ) ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index c8dde0837..5b1378a89 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -601,7 +601,7 @@ ivas_error initMdctStereoDtxData_fx( IF( st->cldfbAna == NULL ) { /* open analysis for max. sampling rate 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -610,7 +610,7 @@ ivas_error initMdctStereoDtxData_fx( IF( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 34eef94ed..c70e606ac 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -205,7 +205,7 @@ static ivas_error allocate_CoreCoder_fx( IF( st->cldfbAna == NULL ) { /* open analysis for max. sampling rate 48kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -214,7 +214,7 @@ static ivas_error allocate_CoreCoder_fx( IF( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -752,7 +752,7 @@ ivas_error stereo_memory_dec_fx( IF( st->cldfbAna == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAna, CLDFB_ANALYSIS, 48000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -761,7 +761,7 @@ ivas_error stereo_memory_dec_fx( IF( st->cldfbBPF == NULL ) { /* open analysis BPF for max. internal sampling rate 16kHz */ - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbBPF, CLDFB_ANALYSIS, 16000, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -1100,7 +1100,7 @@ ivas_error stereo_memory_dec_fx( { IF( hCPE->hCoreCoder[i]->cldfbSyn == NULL ) /* could be NULL when we had the MCT LFE channel */ { - IF( NE_32( ( error = openCldfb_ivas_fx( &hCPE->hCoreCoder[i]->cldfbSyn, CLDFB_SYNTHESIS, hCPE->hCoreCoder[i]->output_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &hCPE->hCoreCoder[i]->cldfbSyn, CLDFB_SYNTHESIS, hCPE->hCoreCoder[i]->output_Fs, CLDFB_PROTOTYPE_1_25MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index f0338b461..cd5db5377 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1695,7 +1695,7 @@ ivas_error init_encoder_ivas_fx( test(); IF( ( NE_16( st->element_mode, IVAS_CPE_MDCT ) && idchan == 0 ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->Opt_DTX_ON ) ) { - IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) { return error; } @@ -1809,7 +1809,7 @@ ivas_error init_encoder_ivas_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - IF( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, ENC ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 9fdebed7a..da1f836df 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -152,7 +152,7 @@ ivas_error ivas_masa_enc_open_fx( FOR( i = 0; i < hMasa->data.num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasa->data.cldfbAnaEnc[i] ), CLDFB_ANALYSIS, hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasa->data.cldfbAnaEnc[i] ), CLDFB_ANALYSIS, hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS, ENC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 50fb49355..b5258712b 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -124,7 +124,7 @@ ivas_error ivas_omasa_enc_open_fx( move16(); FOR( i = 0; i < hOMasa->num_Cldfb_instances; i++ ) { - IF( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, st_ivas->hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_ENC ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, st_ivas->hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS, ENC ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 6c7a1e68d..0a526561a 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -417,7 +417,7 @@ ivas_error stereo_memory_enc_fx( /* allocate CLDFB for primary channel */ IF( st->cldfbAnaEnc == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -433,7 +433,7 @@ ivas_error stereo_memory_enc_fx( IF( st->cldfbSynTd == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -587,7 +587,7 @@ ivas_error stereo_memory_enc_fx( FOR( i = 0; i < CPE_CHANNELS; i++ ) { st = hCPE->hCoreCoder[i]; - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index de9bc09b5..1544aab76 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -309,7 +309,7 @@ ivas_error stereo_set_tdm_fx( /* allocate CLDFB ana for secondary channel */ IF( st->cldfbAnaEnc == NULL ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbAnaEnc, CLDFB_ANALYSIS, st->input_Fs, CLDFB_PROTOTYPE_1_25MS, ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -322,7 +322,7 @@ ivas_error stereo_set_tdm_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n" ) ); } - IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, IVAS_ENC ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynTd, CLDFB_SYNTHESIS, 16000, CLDFB_PROTOTYPE_1_25MS, ENC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 5dd3f8384..1a5013059 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -107,7 +107,7 @@ ivas_error ivas_dirac_ana_open_fx( move16(); FOR( i = 0; i < hDirAC->num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hDirAC->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hDirAC->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 3aa9f62a9..c74477365 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -499,7 +499,7 @@ ivas_error masaPrerendOpen_fx( move16(); FOR( i = 0; i < hMasaPrerend->num_Cldfb_instances; i++ ) { - IF( ( error = openCldfb_ivas_fx( &( hMasaPrerend->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hMasaPrerend->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index d56ba2685..e17b2f9f6 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -224,7 +224,7 @@ ivas_error ivas_mcmasa_ana_open( move16(); FOR( i = 0; i < hMcMasa->num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMcMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMcMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 1d849a90f..5e175fae5 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -133,7 +133,7 @@ ivas_error ivas_omasa_ana_open( hOMasa->num_Cldfb_instances = numAnalysisChannels; FOR( i = 0; i < hOMasa->num_Cldfb_instances; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 041f278f1..129f72388 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8187,7 +8187,7 @@ static ivas_error initMasaExtRenderer( { FOR( i = 0; i < hMasaExtRend->nchan_input; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbAnaRend[i] ), CLDFB_ANALYSIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbAnaRend[i] ), CLDFB_ANALYSIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } @@ -8195,7 +8195,7 @@ static ivas_error initMasaExtRenderer( FOR( i = 0; i < hMasaExtRend->nchan_output; i++ ) { - IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbSynRend[i] ), CLDFB_SYNTHESIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS, IVAS_DEC_REND ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = openCldfb_ivas_fx( &( hMasaExtRend->cldfbSynRend[i] ), CLDFB_SYNTHESIS, *inputMasa->base.ctx.pOutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ), IVAS_ERR_OK ) ) { return error; } -- GitLab From 3a76357964d1df534da0093c5c51d0cd9f9db74e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Mar 2025 11:49:56 +0530 Subject: [PATCH 75/97] Fix for 3GPP issue 1361: Assert in BASOP decoder function ivas_dirac_dec_render_sf_fx for LTV MASA bitstream Link #1361 --- lib_dec/ivas_cpe_dec_fx.c | 4 ---- lib_dec/ivas_dirac_dec_fx.c | 37 ++++++++++++++++++++------------ lib_dec/ivas_stereo_dft_dec_fx.c | 3 ++- lib_rend/ivas_dirac_rend_fx.c | 2 ++ 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 6a6294377..9e934cc88 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -352,10 +352,6 @@ ivas_error ivas_cpe_dec_fx( { sts[0]->total_brate = hCPE->element_brate; /* Only mono downmix was transmitted in this case */ move32(); -#ifdef MSAN_FIX - hCPE->hStereoDft->frame_sid_nodata = 0; - move16(); -#endif } ELSE { diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index d8288e561..422622552 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2204,13 +2204,15 @@ void ivas_dirac_dec_render_sf_fx( Word32 Cldfb_RealBuffer_Temp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Temp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word16 cldfb_buf_q; - Word16 offset, buff_len; + Word16 offset = 0, buff_len = 0; + move16(); + move16(); Word16 q_cldfb, q_temp_cldfb = 0; move16(); Word16 proto_length = 0; move16(); - Word16 q_proto_direct_buffer[CLDFB_SLOTS_PER_SUBFRAME]; - Word16 q_proto_diffuse_buffer[CLDFB_SLOTS_PER_SUBFRAME]; + Word16 q_proto_direct_buffer[CLDFB_SLOTS_PER_SUBFRAME + 1]; + Word16 q_proto_diffuse_buffer[CLDFB_SLOTS_PER_SUBFRAME + 1]; Word16 size, size_ho; DIRAC_DEC_STACK_MEM DirAC_mem; @@ -2258,8 +2260,8 @@ void ivas_dirac_dec_render_sf_fx( } q_cldfb = Q11; move16(); - set16_fx( q_proto_direct_buffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, CLDFB_SLOTS_PER_SUBFRAME ); - set16_fx( q_proto_diffuse_buffer, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, CLDFB_SLOTS_PER_SUBFRAME ); + set16_fx( q_proto_direct_buffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, CLDFB_SLOTS_PER_SUBFRAME + 1 ); + set16_fx( q_proto_diffuse_buffer, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, CLDFB_SLOTS_PER_SUBFRAME + 1 ); set_zero_fx( surCohRatio_fx, CLDFB_NO_CHANNELS_MAX ); IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) @@ -3252,22 +3254,21 @@ void ivas_dirac_dec_render_sf_fx( } } - minimum_s( q_proto_direct_buffer, hSpatParamRendCom->subframe_nbslots[subframe_idx], &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q ); + minimum_s( q_proto_direct_buffer, add( hSpatParamRendCom->subframe_nbslots[subframe_idx], 1 ), &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q ); IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - minimum_s( q_proto_diffuse_buffer, hSpatParamRendCom->subframe_nbslots[subframe_idx], &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ); + minimum_s( q_proto_diffuse_buffer, add( hSpatParamRendCom->subframe_nbslots[subframe_idx], 1 ), &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ); } FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) ); - buff_len = i_mult( 2, i_mult( nchan_transport, hSpatParamRendCom->num_freq_bands ) ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); // proto_direct_buffer_f_q - offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); buff_len = i_mult( 2, i_mult( hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands ) ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, q_proto_diffuse_buffer[slot_idx] ) ); // proto_diffuse_buffer_f_q + offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) ); + buff_len = i_mult( 2, i_mult( nchan_transport, hSpatParamRendCom->num_freq_bands ) ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + offset, buff_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); // proto_direct_buffer_f_q } ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { @@ -3307,10 +3308,18 @@ void ivas_dirac_dec_render_sf_fx( BREAK; } } - q_proto_direct_buffer[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; - move16(); } - + test(); + IF( EQ_16( slot_idx, hSpatParamRendCom->subframe_nbslots[subframe_idx] ) && sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len, add( offset, buff_len ) ) > 0 ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx + add( offset, buff_len ), sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len, add( offset, buff_len ) ), sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, q_proto_direct_buffer[slot_idx] ) ); // proto_direct_buffer_f_q + offset = i_mult( i_mult( sub( slot_idx, 1 ), 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); + buff_len = i_mult( 2, i_mult( hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands ) ); + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) && sub( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, add( offset, buff_len ) ) > 0 ) + { + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx + add( offset, buff_len ), sub( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, add( offset, buff_len ) ), sub( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, q_proto_diffuse_buffer[slot_idx] ) ); // proto_direct_buffer_f_q + } + } ivas_dirac_dec_output_synthesis_get_interpolator_fx( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); size = i_mult( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ); diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 1c18ffacb..3d9e58ad1 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -258,7 +258,8 @@ void stereo_dft_dec_reset_fx( move16(); hStereoDft->ipd_xfade_prev_fx = 0; move32(); - + hStereoDft->frame_sid_nodata = 0; + move16(); #ifdef MSAN_FIX FOR( b = 0; b < 2 * IVAS_MAX_NUM_BANDS; b++ ) { diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index e254ed6dd..35fedfc81 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -871,6 +871,8 @@ ivas_error ivas_dirac_alloc_mem_fx( } hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len = imult1616( imult1616( 2 * MAX_PARAM_SPATIAL_SUBFRAMES, num_protos_dir ), num_freq_bands ); move16(); + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q = Q31; + move16(); IF( hDirACRend->proto_signal_decorr_on ) { -- GitLab From 4d1e1c0534ed71289e06ca2e88d94e83e2a4dd82 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Mar 2025 11:52:47 +0530 Subject: [PATCH 76/97] Fix for 3GPP issue 1373: Decoder crash for stereo at 80kbps JBM decoding to Mono in get_scaling_quality_fx() Link #1373 --- lib_dec/jbm_pcmdsp_apa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index ac6a28b86..fc793dff0 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -900,7 +900,7 @@ UWord8 apa_exec_ivas_fx( UWord32 statsResetThreshold, statsResetShift; Word16 Q_a_out; - Q_a_out = add( getScaleFactor32_copy( a_in, L_mult0( ps->num_channels, APA_BUF_PER_CHANNEL ) ), Q11 - Q16 ); + Q_a_out = add( getScaleFactor32_copy( a_in, L_mult0( ps->num_channels, APA_BUF_PER_CHANNEL ) ), Q11 - Q16 - Q1 ); statsResetThreshold = 1637; move32(); statsResetShift = 2; -- GitLab From 29426491cb92052cc83785b30729f3e30e83c66e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Mar 2025 12:52:44 +0530 Subject: [PATCH 77/97] USAN fix for decoder --- lib_dec/ivas_lfe_plc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index 210c266eb..8ed450435 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -387,7 +387,7 @@ static Word16 lfeplc_lev_dur_fx( s = W_extract_h( W_shl( s_fx, exp1 ) ); s_q_fx = sub( add( s_q_fx, exp1 ), 32 ); - rc_fx[i - 1] = L_shr( BASOP_Util_Divide3232_Scale_cadence( -s, err_fx, &temp_q2 ), 1 ); + rc_fx[i - 1] = L_shr( BASOP_Util_Divide3232_Scale_cadence( L_negate(s), err_fx, &temp_q2 ), 1 ); move32(); rc_q_fx[i - 1] = sub( add( sub( s_q_fx, err_q_fx ), sub( 31, temp_q2 ) ), 1 ); move16(); -- GitLab From 2e871041f0a632bd97de676a98e07331e2961624 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Mar 2025 12:55:14 +0530 Subject: [PATCH 78/97] Clang formatting changes --- lib_dec/ivas_lfe_plc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index 8ed450435..d98603d2a 100644 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -387,7 +387,7 @@ static Word16 lfeplc_lev_dur_fx( s = W_extract_h( W_shl( s_fx, exp1 ) ); s_q_fx = sub( add( s_q_fx, exp1 ), 32 ); - rc_fx[i - 1] = L_shr( BASOP_Util_Divide3232_Scale_cadence( L_negate(s), err_fx, &temp_q2 ), 1 ); + rc_fx[i - 1] = L_shr( BASOP_Util_Divide3232_Scale_cadence( L_negate( s ), err_fx, &temp_q2 ), 1 ); move32(); rc_q_fx[i - 1] = sub( add( sub( s_q_fx, err_q_fx ), sub( 31, temp_q2 ) ), 1 ); move16(); -- GitLab From 501aeb9eeb59fea7e379084771af936b51aabea8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 13 Mar 2025 08:55:12 +0530 Subject: [PATCH 79/97] Cleanup of ivas_prot_rend.h, bug fixes and instrumentation changes --- Workspace_msvc/lib_rend.vcxproj | 2 +- Workspace_msvc/lib_rend.vcxproj.filters | 6 +- lib_com/ivas_prot.h | 4065 ----------------- lib_dec/ivas_binRenderer_internal_fx.c | 2 +- lib_dec/ivas_dirac_dec_fx.c | 2 +- lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_ism_dec_fx.c | 2 +- lib_dec/ivas_ism_param_dec_fx.c | 2 +- lib_dec/ivas_ism_renderer_fx.c | 2 +- lib_dec/ivas_jbm_dec_fx.c | 2 +- lib_dec/ivas_masa_dec_fx.c | 2 +- lib_dec/ivas_mc_param_dec_fx.c | 8 +- lib_dec/ivas_mc_paramupmix_dec_fx.c | 2 +- lib_dec/ivas_mcmasa_dec_fx.c | 2 +- lib_dec/ivas_mct_core_dec_fx.c | 14 +- lib_dec/ivas_mct_dec_fx.c | 2 +- lib_dec/ivas_mdct_core_dec_fx.c | 2 +- lib_dec/ivas_objectRenderer_internal_fx.c | 2 +- lib_dec/ivas_omasa_dec_fx.c | 2 +- lib_dec/ivas_osba_dec_fx.c | 2 +- lib_dec/ivas_out_setup_conversion_fx.c | 2 +- lib_dec/ivas_sba_dec_fx.c | 2 +- lib_dec/ivas_sba_rendering_internal_fx.c | 4 +- lib_dec/ivas_sns_dec_fx.c | 2 +- lib_dec/ivas_spar_decoder_fx.c | 2 +- lib_dec/lib_dec_fx.c | 2 +- lib_enc/cod_tcx_fx.c | 2 +- lib_enc/ivas_ism_dtx_enc_fx.c | 2 +- lib_enc/ivas_mdct_core_enc_fx.c | 10 +- lib_enc/ivas_sns_enc_fx.c | 2 +- lib_enc/swb_bwe_enc_fx.c | 9 +- lib_rend/ivas_allrad_dec_fx.c | 2 +- lib_rend/ivas_crend_fx.c | 2 +- lib_rend/ivas_dirac_ana_fx.c | 2 +- .../ivas_dirac_dec_binaural_functions_fx.c | 2 +- lib_rend/ivas_dirac_decorr_dec_fx.c | 2 +- lib_rend/ivas_dirac_onsets_dec_fx.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 2 +- lib_rend/ivas_dirac_rend_fx.c | 2 +- lib_rend/ivas_efap_fx.c | 2 +- lib_rend/ivas_hrtf_fx.c | 2 +- lib_rend/ivas_limiter_fx.c | 2 +- lib_rend/ivas_masa_merge_fx.c | 2 +- lib_rend/ivas_mcmasa_ana_fx.c | 2 +- lib_rend/ivas_objectRenderer_fx.c | 2 +- lib_rend/ivas_objectRenderer_hrFilt_fx.c | 2 +- lib_rend/ivas_objectRenderer_mix_fx.c | 2 +- lib_rend/ivas_objectRenderer_sfx_fx.c | 2 +- lib_rend/ivas_objectRenderer_sources_fx.c | 2 +- lib_rend/ivas_objectRenderer_vec_fx.c | 43 +- lib_rend/ivas_omasa_ana_fx.c | 2 +- lib_rend/ivas_orient_trk_fx.c | 2 +- lib_rend/ivas_output_init.c | 2 +- lib_rend/ivas_output_init_fx.c | 2 +- .../{ivas_prot_rend.h => ivas_prot_rend_fx.h} | 571 +-- lib_rend/ivas_reflections_fx.c | 2 +- lib_rend/ivas_render_config_fx.c | 2 +- lib_rend/ivas_reverb_delay_line_fx.c | 2 +- lib_rend/ivas_reverb_fft_filter_fx.c | 2 +- lib_rend/ivas_reverb_filter_design_fx.c | 2 +- lib_rend/ivas_reverb_fx.c | 2 +- lib_rend/ivas_reverb_iir_filter_fx.c | 2 +- lib_rend/ivas_reverb_utils_fx.c | 2 +- lib_rend/ivas_rotation_fx.c | 2 +- lib_rend/ivas_sba_rendering_fx.c | 2 +- lib_rend/ivas_shoebox_fx.c | 2 +- lib_rend/ivas_td_decorr_fx.c | 2 +- lib_rend/ivas_vbap_fx.c | 2 +- lib_rend/lib_rend.c | 2 +- lib_util/hrtf_file_reader.c | 2 +- 70 files changed, 111 insertions(+), 4741 deletions(-) delete mode 100644 lib_com/ivas_prot.h rename lib_rend/{ivas_prot_rend.h => ivas_prot_rend_fx.h} (69%) diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 1ffab139a..e47858ae3 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -179,7 +179,7 @@ - + diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 47b4fee01..5c4a49011 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -125,9 +125,6 @@ - - rend_h - rend_h @@ -143,6 +140,9 @@ rend_h + + rend_h + diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h deleted file mode 100644 index 34f11c01f..000000000 --- a/lib_com/ivas_prot.h +++ /dev/null @@ -1,4065 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#ifndef IVAS_PROT_H -#define IVAS_PROT_H - -#include -#include "options.h" -#include -#include "typedef.h" -#include "stat_enc.h" -#include "stat_dec.h" -#include "stat_com.h" -#include "ivas_stat_enc.h" -#include "ivas_stat_dec.h" -#include "ivas_stat_com.h" -#include "ivas_error_utils.h" - - -/* clang-format off */ - -/*----------------------------------------------------------------------------------* - * General IVAS prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_enc( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ - const int16_t *data, /* i : input signal */ - const int16_t n_samples /* i : number of input samples */ -); - -void stereo_dmx_evs_enc( - STEREO_DMX_EVS_ENC_HANDLE hStereoDmxEVS, /* i/o: Stereo downmix for EVS encoder handle */ - const int32_t input_Fs, /* i : input sampling rate */ - int16_t data[CPE_CHANNELS * L_FRAME48k], /* i/o: input signal */ - const int16_t n_samples, /* i : number of input samples */ - const bool is_binaural /* i : indication that input is binaural audio */ -); - -/*! r: number of channels to be analysed */ - -void copy_encoder_config_ivas_fx( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ - Encoder_State *st, /* o : encoder state structure */ - const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ -); - - - -ivas_error create_sce_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t sce_id, /* i : SCE # identifier */ - const int32_t element_brate /* i : element bitrate */ -); - -ivas_error create_cpe_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t cpe_id, /* i : CPE # identifier */ - const int32_t element_brate /* i : element bitrate */ -); - -ivas_error create_mct_enc_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void destroy_cpe_enc( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ -); - -void ivas_mct_enc_close_fx( - MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */ -); - -ivas_error ivas_corecoder_enc_reconfig( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t nSCE_old, /* i : number of SCEs in previous frame */ - const int16_t nCPE_old, /* i : number of CPEs in previous frame */ - const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ - const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ - const int32_t brate_CPE, /* i : bitrate to be set for the CPEs */ - const MC_MODE last_mc_mode /* i : switching between MC modes: last mode */ -); - -ivas_error ivas_sce_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t sce_id, /* i : SCE # identifier */ - const float data_f[], /* i : input signal for single channel */ - const int16_t input_frame, /* i : input frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - - -ivas_error ivas_cpe_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const Word16 cpe_id, /* i : CPE # identifier */ - float data_f_ch0[], /* i : input signal for channel 0 */ - float data_f_ch1[], /* i : input signal for channel 1 */ - const Word16 input_frame, /* i : input frame length per channel */ - const Word16 nb_bits_metadata /* i : number of metadata bits */ -); - -ivas_error ivas_mct_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *data[MCT_MAX_CHANNELS], /* i : input signal buffers */ - const int16_t input_frame, /* i : input frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -ivas_error pre_proc_front_ivas( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int32_t element_brate, /* i : SCE/CPE element bitrate */ - const int16_t nb_bits_metadata, /* i : number of metadata bits */ - const int16_t input_frame, /* i : frame length */ - const int16_t n, /* i : channel number */ - float old_inp_12k8[], /* o : buffer of old input signal */ - float old_inp_16k[], /* o : buffer of old input signal @16kHz */ - float *ener, /* o : residual energy from Levinson-Durbin */ - float *relE, /* o : frame relative energy */ - float A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ - float Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ - float epsP[M + 1], /* o : LP prediction errors */ - float lsp_new[M], /* o : LSPs at the end of the frame */ - float lsp_mid[M], /* o : LSPs in the middle of the frame */ - int16_t *vad_hover_flag, /* o : VAD hangover flag */ - int16_t *attack_flag, /* o : flag signaling attack */ - float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */ - float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */ - float old_wsp[], /* o : weighted input signal buffer */ - float pitch_fr[NB_SUBFR], /* o : fractional pitch values */ - float voicing_fr[NB_SUBFR], /* o : fractional pitch gains */ - int16_t *loc_harm, /* o : harmonicity flag */ - float *cor_map_sum, /* o : speech/music clasif. parameter */ - int16_t *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO */ - float enerBuffer[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */ - float fft_buff[2 * L_FFT], /* o : FFT buffer */ - const float tdm_A_PCh[M + 1], /* i : unq. LP coeff. of primary channel */ - const float tdm_lsp_new_PCh[M], /* i : unq. LSPs of primary channel */ - const float currFlatness, /* i : flatness parameter */ - const int16_t tdm_ratio_idx, /* i : Current Ratio_L index */ - float fr_bands_LR[][2 * NB_BANDS], /* i : energy in frequency bands */ - const float Etot_LR[], /* i : total energy Left & Right channel */ - float lf_E_LR[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */ - const int16_t localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */ - float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */ - const int16_t flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */ - const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ - const int16_t force_front_vad, /* i : flag to force VAD decision */ - const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ -); - -ivas_error pre_proc_front_ivas_fx( - 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*/ - const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - const Word16 n, /* i : channel number Q0*/ - Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/ - Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 *relE_fx, /* o : frame relative energy Q8*/ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/ - Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/ - Word16 *epsP_fx_q, - Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/ - Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/ - Word16 *attack_flag, /* o : flag signaling attack Q0*/ - Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/ - Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/ - Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */ - Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/ - Word16 *q_old_wsp, - Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/ - Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/ - Word16 *loc_harm, /* o : harmonicity flag Q0*/ - Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/ - Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/ - Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ - Word16 *enerBuffer_fx_exp, /* o : energy buffer */ - Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/ - Word16 *fft_buff_fx_q, /* o : FFT buffer */ - const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/ - const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/ - const Word16 currFlatness_fx, /* i : flatness parameter Q7*/ - const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/ - Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/ - Word16 fr_bands_LR_fx_q[CPE_CHANNELS], - const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/ - Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/ - Word16 lf_E_LR_fx_q, - const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ - Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/ - Word16 band_energies_LR_fx_q, - const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ - const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ - const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ - const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ -#ifdef NONBE_1211_DTX_BR_SWITCHING - const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ -#endif - const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ - Word16 *Q_new -#ifdef DEBUG_MODE_INFO - , - const Word16 ch_idx -#endif -); -ivas_error pre_proc_ivas_fx( - 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*/ - const Word32 last_element_brate, /* i : last element bitrate Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */ - Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */ - Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/ - Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/ - Word16 *epsP_fx_q, /* i : LP prediction errors */ - Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ - Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/ - Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/ - Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/ - Word16 e_old_wsp, - const Word16 loc_harm, /* i : harmonicity flag Q0*/ - const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ - Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */ - Word16 e_enerBuffer, - Word16 fft_buff_fx[2 * L_FFT], /* Qx */ - Word16 cor_map_sum_fx, /* Q8 */ - Word16 *Q_new -); -/*! r: number of clipped samples */ -void ivas_initialize_handles_enc_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -ivas_error ivas_init_encoder( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void ivas_destroy_enc_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -ivas_error ivas_initialize_MD_bstr_enc_fx( - BSTR_ENC_HANDLE *hBstr, /* o : encoder MD bitstream handle */ - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void ivas_destroy_MD_bstr_enc_fx( - BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle */ -); - -ivas_error ivas_init_decoder_front( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_init_decoder( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_output_buff_dec( - float *p_output_f[], /* i/o: output audio buffers */ - const int16_t nchan_out_buff_old, /* i : previous frame number of output channels*/ - const int16_t nchan_out_buff /* i : number of output channels */ -); -#endif - -ivas_error stereo_dmx_evs_init_encoder( - STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS, /* o : Stereo downmix for EVS encoder handle */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void stereo_dmx_evs_close_encoder( - STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS /* i/o: Stereo downmix for EVS encoder handle */ -); - -ivas_error ivas_dec( - Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ - int16_t *data /* o : output synthesis signal */ -); - - -ivas_error mct_dec_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t b_nchan_change /* i : flag indicating different channel count */ -); - - -void ivas_mct_dec_close( - MCT_DEC_HANDLE *hMCT /* i/o: MCT decoder structure */ -); - -ivas_error ivas_corecoder_dec_reconfig( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSCE_old, /* i : number of SCEs in previous frame */ - int16_t nCPE_old, /* i : number of CPEs in previous frame */ - const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ - const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */ - const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ - const int32_t brate_CPE /* i : bitrate to be set for the CPEs */ -); - -ivas_error ivas_hp20_dec_reconfig( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nchan_hp20_old /* i : number of HP20 filters in previous frame*/ -); - -ivas_error ivas_sce_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t sce_id, /* i : SCE # identifier */ - float *output[1], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -ivas_error ivas_cpe_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t cpe_id, /* i : CPE # identifier */ - float *output[CPE_CHANNELS], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -ivas_error ivas_mct_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -/*! r: number of channels to be synthesised */ - -void copy_decoder_config( - Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ - Decoder_State *st /* o : decoder state structure */ -); - -void destroy_core_dec( - DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ -); - - -void ivas_initialize_handles_dec( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_core_enc_fx( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/ - Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/ - Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/ - Word16 Q_new[], - Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes Q12*/ - Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/ - Word16 epsP_fx_q[], /* i : LP prediction errors */ - Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag[], /* i : VAD hanglover flag Q0*/ - Word16 attack_flag[], /* i : attack flag (GSC or TC) Q0*/ - Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer q_re_im_buf*/ - Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer q_re_im_buf*/ - Word16 *q_re_im_buf, - Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer e_old_wsp*/ - Word16 e_old_wsp[], - const Word16 loc_harm[], /* i : harmonicity flag Q0*/ - const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/ - const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/ - Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ - Word16 enerBuffer_fx_exp[], /* o : energy buffer */ - Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/ - const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/ - const Word16 ivas_format, /* i : IVAS format Q0*/ - const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ -); - - - -void decod_gen_2sbfr( - Decoder_State *st, /* i/o: decoder static memory */ - const int16_t sharpFlag, /* i : formant sharpening flag */ - const float *Aq, /* i : LP filter coefficient */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - float *bwe_exc, /* o : excitation for SWB TBE */ - float *gain_buf, /* o : floating pitch gain for each subframe */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const float tdm_Pri_pitch_buf[] /* i : pitch values for primary channel */ -); - -void synchro_synthesis( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : Number of samples */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void synchro_synthesis_fixed( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : Number of samples */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void stereo_tcx_init_enc( - Encoder_State *st /* i/o: encoder state structure */ -); - - - - -void stereo_tcx_init_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t last_element_mode /* i : element mode of previous frame */ -); - -/*! r: S/M decision (0 = speech or noise, 1 = unclear, 2 = music) */ -int16_t ivas_smc_gmm( - Encoder_State *st, /* i/o: encoder state structure */ - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */ - const float Etot, /* i : total frame energy */ - const float lsp_new[M], /* i : LSPs in current frame */ - const float cor_map_sum, /* i : correlation map sum (from multi-harmonic anal.) */ - const float epsP[M + 1], /* i : LP prediciton error */ - const float PS[], /* i : energy spectrum */ - const float non_sta, /* i : unbound non-stationarity */ - const float relE, /* i : relative frame energy */ - int16_t *high_lpn_flag, /* i/o: sp/mus LPN flag */ - const int16_t flag_spitch /* i : flag to indicate very short stable pitch */ -); - -void ivas_smc_mode_selection( - Encoder_State *st, /* i/o: encoder state structure */ - const int32_t element_brate, /* i : element bitrate */ - int16_t smc_dec, /* i : raw decision of the 1st stage classifier */ - const float relE, /* i : relative frame energy */ - const float Etot, /* i : total frame energy */ - int16_t *attack_flag, /* i/o: attack flag (GSC or TC) */ - const float *inp, /* i : input signal */ - const float S_map[], /* i : short-term correlation map */ - const int16_t flag_spitch /* i : flag to indicate very short stable pitch */ -); - -/*! r: S/M decision (0=speech or noise,1=unclear,2=music) */ -int16_t ivas_acelp_tcx20_switching( - Encoder_State *st, /* i/o: encoder state structure */ - const float *inp, /* i : new input signal */ - const float *wsp, /* i : input weighted signal */ - const float non_staX, /* i : unbound non-stationarity for sp/mu clas */ - const float *pitch_fr, /* i : fraction pitch values */ - const float *voicing_fr, /* i : fractional voicing values */ - const float currFlatness, /* i : flatness */ - const float lsp_mid[M], /* i : LSPs at the middle of the frame */ - const float stab_fac, /* i : LP filter stability */ - float *res_cod_SNR_M, - const int16_t flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */ -); - - - -void ivas_decision_matrix_dec( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *sharpFlag, /* o : formant sharpening flag */ - int16_t *core_switching_flag, /* o : ACELP->HQ switching frame flag */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t nchan_out /* i : Number of output channels */ -); - -void set_bw_stereo( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structures */ -); - -/*! r: flag indicating whether the coded BW has changed */ -int16_t set_bw_mct( - CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE encoder structures */ - const int16_t nCPE /* i : number of CPEs */ -); -void dec_acelp_fast( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t cdk_index, /* i : codebook index */ - float code[], /* o : algebraic (fixed) codebook excitation */ - const int16_t L_subfr /* i : subframe length */ -); - -void set_transient_stereo( - CPE_ENC_HANDLE hCPE, /* i : CPE structure */ - float currFlatness[] /* i/o: current flatness */ -); - -/*! r: preliminary flag to force ACELP */ -int16_t transient_analysis( - TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */ - const float cor_map_LT[], /* i : LT correlation map */ - const float multi_harm_limit /* i : multi harminic threshold */ -); - -void ivas_post_proc( - SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int16_t n, /* i : channel number */ - float synth[], /* i/o: output synthesis signal */ - float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : output frame length */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void ivas_renderer_select( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_mc_enc_config_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -ivas_error ivas_mc_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t idx, /* i : LS config. index */ - uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ - int16_t *data /* o : output synthesis signal */ -); - -/*! r: MC format mode (MCT, McMASA, ParamMC) */ -MC_MODE ivas_mc_mode_select( - const MC_LS_SETUP mc_ls_setup, /* i : MC loudspeaker setup */ - const int32_t total_brate /* i : IVAS total bitrate */ -); - -/*! r: number of loudspeaker channels */ -int16_t ivas_mc_ls_setup_get_num_channels( - const MC_LS_SETUP mc_ls_setup /* i : loudspeaker setup (CICP) */ -); - -/*! r: output configuration*/ -AUDIO_CONFIG ivas_mc_map_ls_setup_to_output_config( - const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup */ -); - -/*! r: multi channel loudspeaker setup */ -MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( - const AUDIO_CONFIG output_config /* i : output audio configuration */ -); - -void smooth_dft2td_transition( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: synthesis @external Fs */ - const int16_t output_frame /* i : output frame length */ -); - - -/*! r: flag indicating a valid bitrate */ -Word16 is_IVAS_bitrate_fx( - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); - -int16_t is_DTXrate( - const int32_t ivas_total_brate /* i : IVAS total bitrate */ -); - - -void TonalMdctConceal_create_concealment_noise_ivas( - float concealment_noise[L_FRAME48k], - CPE_DEC_HANDLE hCPE, - const int16_t L_frameTCX, - const int16_t L_frame, - const int16_t idchan, - const int16_t subframe_idx, - const int16_t core, - const float crossfade_gain, - const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode -); - -void TonalMdctConceal_whiten_noise_shape_ivas( - Decoder_State *st, - const int16_t L_frame, - const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE -); - -void dtx_read_padding_bits( - DEC_CORE_HANDLE st, - const int16_t num_bits -); - - - -/*----------------------------------------------------------------------------------* - * JBM prototypes - *----------------------------------------------------------------------------------*/ - - - -ivas_error ivas_jbm_dec_flush_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t tc_granularity_new, /* i : new renderer granularity */ - const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ - const AUDIO_CONFIG intern_config_old, /* i : old internal config */ - const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ - const MC_MODE mc_mode_old, /* i : old MC mode */ - const ISM_MODE ism_mode_old, /* i : old ISM mode */ - uint16_t *nSamplesRendered, /* o : number of samples flushed */ - int16_t *data /* o : output synthesis signal */ -); - -void ivas_jbm_dec_feed_tc_to_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i/o: transport channels/output synthesis signal */ -); - -ivas_error ivas_jbm_dec_set_discard_samples( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ -); - -void ivas_jbm_dec_get_adapted_linear_interpolator( - const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ - const int16_t interp_length, /* i : length of the interpolator to be created */ - float *interpolator /* o : the interpolator */ -); - - - -int16_t ivas_jbm_dec_get_num_tc_channels( - Decoder_Struct *st_ivas /* i : IVAS decoder handle */ -); - -void ivas_jbm_dec_copy_tc_no_tsm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *tc[], /* i : transport channels */ - const int16_t output_frame /* i : output frame size */ -); - - -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( - Decoder_Struct *st_ivas /* i : IVAS decoder handle */ -); - -/*! r: render granularity */ -int16_t ivas_jbm_dec_get_render_granularity_flt( - const RENDERER_TYPE rendererType, /* i : renderer type */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int32_t output_Fs /* i : sampling rate */ -); - -ivas_error ivas_jbm_dec_tc_buffer_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ - const int16_t nchan_transport_jbm, /* i : number of real transport channels */ - const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : number of channels to fully store */ - const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ -); - -ivas_error ivas_jbm_dec_tc_buffer_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ - const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ - const int16_t nchan_full, /* i : new number of channels to fully store */ - const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ -); - -void ivas_jbm_dec_tc_buffer_close( - DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ -); - -void ivas_jbm_dec_td_renderers_adapt_subframes( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_jbm_dec_metadata_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_jbm_masa_sf_to_sf_map( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - -/*----------------------------------------------------------------------------------* - * ISM prototypes - *----------------------------------------------------------------------------------*/ - -void bitbudget_to_brate( - const Word16 x[], /* i : bitbudgets Q0 */ - Word32 y[], /* o : bitrates Q0 */ - const Word16 N /* i : number of entries to be converted */ -); - -void ivas_ism_reset_metadata( - ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ -); - -void ivas_ism_reset_metadata_enc( - ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */ -); -void ivas_ism_reset_metadata_API( - ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ -); - -/*! r: index of the winning codeword */ -Word16 ism_quant_meta_fx( - const Word32 val, /* i : scalar value to quantize Q22 */ - Word32 *valQ, /* o : quantized value Q22 */ - const Word32 borders_fx[], /* i : level borders Q22 */ - const Word32 q_step_fx, /* i : quantization step Q22 */ - const Word32 q_step_border_fx, /* i : quantization step at the border Q22 */ - const Word16 cbsize /* i : codebook size */ -); - -ivas_error ivas_ism_metadata_enc_create_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t n_ISms, /* i : number of objects */ - int32_t element_brate_tmp[] /* o : element bitrate per object */ -); - -ivas_error ivas_ism_metadata_dec_create( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t n_ISms, /* i : number of objects */ - int32_t element_brate_tmp[] /* o : element bitrate per object */ -); - -ivas_error ivas_ism_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *data[], /* i : input signal [channels][samples] */ - const int16_t input_frame, /* i : input frame length per channel */ - int16_t *nb_bits_metadata, /* i : number of metadata bits */ - const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ -); - -ivas_error ivas_ism_metadata_dec( - const int32_t ism_total_brate, /* i : ISM total bitrate */ - const int16_t nchan_ism, /* i : number of ISM channels */ - int16_t *nchan_transport, /* o : number of transport channels */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder handles */ - const int16_t bfi, /* i : bfi flag */ - int16_t nb_bits_metadata[], /* o : number of metadata bits */ - ISM_MODE ism_mode, /* i : ISM mode */ - ISM_DTX_DATA_DEC hISMDTX, /* i/o: ISM DTX structure */ - const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ - int16_t *ism_extended_metadata_flag, /* i/o: Extended metadata active in renderer */ - int16_t *ism_extmeta_cnt, /* i/o: Number of change frames observed */ - DEC_CORE_HANDLE st0 /* i : core-coder handle */ -); - - -/*----------------------------------------------------------------------------------* - * Parametric ISM prototypes - *----------------------------------------------------------------------------------*/ - -/*! r: ISM format mode */ - -ivas_error ivas_param_ism_enc_open_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void ivas_param_ism_enc_close_fx( - PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */ - const int32_t input_Fs /* i : input sampling_rate */ -); - -void ivas_ism_metadata_close( - ISM_METADATA_HANDLE hIsmMetaData[], /* i/o : object metadata handles */ - const int16_t first_idx /* i : index of first handle to deallocate */ -); - - -ivas_error ivas_ism_enc_config( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - - - - -void ivas_param_ism_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ -); - -void ivas_ism_dec_digest_tc( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - - -void ivas_param_ism_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - -void ivas_param_ism_params_to_masa_param_mapping( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - -/*----------------------------------------------------------------------------------* - * ISM DTX prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_ism_dtx_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -/*! r: indication of DTX frame */ -int16_t ivas_ism_dtx_enc( - ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ - SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nchan_ism, /* i : number of objects */ - const int16_t nchan_transport, /* i : number of transport channels */ - int16_t vad_flag[MAX_NUM_OBJECTS], /* i : VAD flag */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - int16_t md_diff_flag[], /* o : metadata differential flag */ - int16_t *sid_flag /* o : indication of SID frame */ -); - -void ivas_ism_dtx_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t *nb_bits_metadata /* o : number of metadata bits */ -); - -void ivas_ism_metadata_sid_enc_fx( - ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ - const int16_t flag_noisy_speech, /* i : noisy speech flag */ - const int16_t nchan_ism, /* i : number of objects */ - const int16_t nchan_transport, /* i : number of transport channels */ - const ISM_MODE ism_mode, /* i : ISM mode */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - const int16_t sid_flag, /* i : indication of SID frame */ - const int16_t md_diff_flag[], /* i : metadata differental flag */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - int16_t nb_bits_metadata[] /* o : number of metadata bits */ -); - -void ivas_ism_metadata_sid_dec( - SCE_DEC_HANDLE hSCE[MAX_SCE], /* i/o: SCE decoder structure */ - const int32_t ism_total_brate, /* i : ISM total bitrate */ - const int16_t bfi, /* i : bfi flag */ - const int16_t nchan_ism, /* i : number of objects */ - const int16_t nchan_transport, /* i : number of transport channels */ - const ISM_MODE ism_mode, /* i : ISM mode */ - int16_t *flag_noisy_speech, /* o : noisy speech flag */ - int16_t *sce_id_dtx, /* o : SCE DTX ID */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - int16_t nb_bits_metadata[] /* o : number of metadata bits */ -); - - -void ivas_param_ism_compute_noisy_speech_flag_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - - -void update_last_metadata( - const int16_t nchan_ism, /* i : number of objects */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - const int16_t updt_flag[] /* i : last metadata update flag */ -); - -void ivas_ism_dtx_limit_noise_energy_for_near_silence( - SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ - const int16_t sce_id_dtx, /* i : SCE DTX ID */ - const int16_t nchan_transport /* i : number of transport channels */ -); - -/*----------------------------------------------------------------------------------* - * DFT Stereo prototypes - *----------------------------------------------------------------------------------*/ - - -void stereo_dft_enc_analyze( - Encoder_State **sts, /* i/o: encoder state structure */ - const int16_t n_channels, /* i : number of input channels */ - const int16_t input_frame, /* i : input frame length */ - STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: encoder MDCT stereo handle */ - float DFT[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC], /* o : DFT buffers */ - float *input_mem[CPE_CHANNELS] /* i/o: input buffer memory */ -); - -float stereo_dft_enc_synthesize( - STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ - float *output, /* o : output synthesis */ - const int16_t chan, /* i : channel number */ - const int32_t input_Fs, /* i : input sampling rate */ - const int32_t output_sampling_rate, /* i : output sampling rate */ - const int16_t L_frame /* i : frame length at internal Fs */ -); - - - - -void stereo_dtf_cng( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */ - const int16_t output_frame /* i : output frame size */ -); - -void stereo_dft_cng_side_gain( - STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo encoder handle */ - STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ - const int32_t core_brate, /* i : core bitrate */ - const int32_t last_core_brate, /* i : last core bitrate */ - const int16_t bwidth /* i : audio band-width */ -); - - -void stereo_dft_dequantize_itd( - int16_t *ind, - float *out, - const int32_t output_Fs -); - - - -void stereo_dft_dec_sid_coh( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t nbands, /* i : number of DFT stereo bands */ - float *coh, /* i/o: coherence */ - int16_t *nb_bits /* i/o: number of bits read */ -); - -ivas_error stereo_dft_dec_create( - STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ - const int32_t element_brate, /* i : element bitrate */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - const int16_t nchan_transport /* i : number of transport channels */ -); - -void stereo_dft_dec_reset( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: decoder DFT stereo handle */ -); - -void stereo_dft_dec_update( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int16_t output_frame, /* i : output frame length */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void stereo_dft_dec_destroy( - STEREO_DFT_DEC_DATA_HANDLE *hStereoDft /* i/o: decoder DFT stereo handle */ -); - -void stereo_dft_dec_analyze( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const float *input, /* i : input signal */ - float out_DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */ - const int16_t chan, /* i : channel number */ - const int16_t input_frame, /* i : input frame size */ - const int16_t output_frame, /* i : output frame size */ - const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : signal type to analyze */ - const int16_t k_offset, /* i : offset of DFT */ - const int16_t delay /* i : delay in samples for input signal */ -); - -void stereo_dft_dec_synthesize( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i : DFT buffers */ - const int16_t chan, /* i : channel number */ - float output[L_FRAME48k], /* o : output synthesis signal */ - const int16_t output_frame /* i : output frame length */ -); - - -void stereo_dft_res_ecu( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ - float *pDFT_RES, /* i/o: residual signal */ - float *const DFT_PRED_RES, /* i/o: residual prediction signal */ - const int16_t k, /* i : Subframe index */ - const int16_t output_frame, /* i : Output frame length */ - const int16_t prev_bfi, /* i : Previous BFI */ - const float dmx_nrg, /* i : Down-mix energy */ - int16_t *num_plocs, /* i/o: Number of peak locations */ - int16_t *plocs, /* i/o: Peak locations (bin) */ - float *plocsi, /* i/o: Peak locations (fractional) */ - float *input_mem /* o : Residual DFT buffer input mem */ -); - -void stereo_dft_res_subst_spec( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ - float *pDFT_RES, /* i/o: residual signal */ - const float *const DFT_PRED_RES, /* i : residual prediction signal */ - const int16_t time_offs, /* i : Time offset for phase adjustm. */ - const int16_t L_res, /* i : bandwidth of residual signal */ - const int16_t L_ana, /* i : Length of FFT analysis */ - const int16_t k, /* i : Subframe index */ - int16_t *num_plocs, /* i/o: Number of peak locations */ - int16_t *plocs, /* i/o: Peak locations (bin) */ - float *plocsi, /* i/o: Peak locations (fractional) */ - const int16_t analysis_flag /* i : Flag for running peak analysis */ -); - -void stereo_dft_res_ecu_burst_att( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ - float *pDFT_RES, /* i/o: residual signal /att. residual */ - const float dmx_nrg, /* i : dmx energy of current frame */ - const int16_t L_res, /* i : Bandwidth of residual */ - const int16_t L_ana /* i : Length of FFT analysis */ -); - -/*! r: total energy of downmix with maximum swb bandwidth max */ -float stereo_dft_dmx_swb_nrg( - const float *dmx_k0, /* i : first subframe spectrum */ - const float *dmx_k1, /* i : second subframe spectrum */ - const int16_t frame_length /* i : frame lanegth */ -); - -int16_t stereo_dft_sg_recovery( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: Decoder DFT stereo handle */ -); - -void stereo_dft_dec_res( - CPE_DEC_HANDLE hCPE, /* i/o: decoder CPE handle */ - float res_buf[STEREO_DFT_N_8k], /* i : residual buffer */ - float *output /* o : output frame */ -); - -/*! r: Decision to enable or disable BPF on DFT stereo residual */ - -void bpf_pitch_coherence( - Decoder_State *st, /* i/o: decoder state structure */ - const float pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ -); - -void stereo_dft_dec_read_BS( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int32_t element_brate, /* i : element bitrate */ - int32_t *total_brate, /* o : total bitrate */ - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int16_t bwidth, /* i : bandwidth */ - const int16_t output_frame, /* i : output frame length */ - float res_buf[STEREO_DFT_N_8k], /* o : residual buffer */ - int16_t *nb_bits, /* o : number of bits read */ - float *coh, /* i/o: Coherence */ - const int16_t ivas_format /* i : ivas format */ -); - -void stereo_dft_dec_smooth_parameters( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int16_t prev_sid_nodata, /* i : Previous SID/No data indicator */ - const int16_t active_frame_counter, /* i : Active frame counter */ - const int32_t element_brate /* i : Element bitrate */ -); - -void stereo_dft_generate_res_pred( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const float samp_ratio, /* i : sampling ratio */ - float *pDFT_DMX, /* i : downmix signal */ - float *DFT_PRED_RES, /* o : residual prediction signal */ - float *pPredGain, /* i : residual prediction gains */ - const int16_t k, /* i : subframe index */ - float *ap_filt_DMX, /* i : enhanced stereo filling signal */ - int16_t *stop, /* o : last FD stereo filling bin */ - const int16_t bfi /* i : BFI flag */ -); - -void stereo_dft_dec_core_switching( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float output[], /* i/o: synthesis @internal Fs */ - float synth[], /* i : synthesis @output Fs */ - float hb_synth[], /* i/o: hb synthesis */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */ - const int16_t output_frame, /* i : output frame length */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t sba_dirac_stereo_dtx_flag /* i : DTX indicator for SBA DirAC stereo */ -); - -void init_basic_allpass( - basic_allpass_t *ap, /* i/o: basic allpass structure */ - const float *gains, /* i : allpass filter gains */ - const int16_t *delays /* i : allpass filter delays */ -); - -void filter_with_allpass( - const float *sig, /* i : allpass input signal */ - float *out, /* o : filtered output */ - const int16_t len, /* i : length of input */ - basic_allpass_t *ap /* i/o: basic allpass structure */ -); - -/*! r: used GR order */ - -/*! r: used GR order */ - - -/*! r: number of bits written */ - -/*! r: number of bits written */ - - -void stereo_dft_enc_compute_itd( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - float *DFT_L, - float *DFT_R, - const int16_t k_offset, - const int16_t input_frame, - const int16_t vad_flag_dtx[], - const int16_t vad_hover_flag[], - float *bin_nrgL, - float *bin_nrgR -); - -void stereo_dft_config( - STEREO_DFT_CONFIG_DATA_HANDLE hConfig, /* o : DFT stereo configuration */ - const int32_t brate, /* i : IVAS/CPE/nominal total bitrate */ - int16_t *bits_frame_nominal, /* o : primary channel nominal bits per frame */ - int16_t *bits_frame_nominal_2 /* o : secondary channel nominal bits per frame*/ -); - -int16_t stereo_dft_band_config( - int16_t *band_limits, /* o : DFT band limits */ - const int16_t band_res, /* i : DFT band resolution */ - const int16_t NFFT, /* i : analysis/synthesis window length */ - const int16_t enc_dec /* i : flag to indicate enc vs dec */ -); - -void stereo_dft_dmx_out_reset( - STEREO_DFT_DMX_DATA_HANDLE hStereoDftDmx /* i/o: DFT stereo DMX decoder */ -); - -void stereo_dft_unify_dmx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder stereo handle */ - Decoder_State *st0, /* i/o: decoder state structure */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */ - float *input_mem, /* i/o: mem of buffer DFT analysis */ - const int16_t prev_sid_nodata /* i : Previous SID/No data indicator */ -); - -void add_HB_to_mono_dmx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float output[L_FRAME48k], /* i/o: output synthesis */ - float outputHB[L_FRAME48k], /* i : HB synthesis */ - const int16_t last_core, /* i : last core, primary channel */ - const int16_t output_frame /* i : frame length */ -); - -/*----------------------------------------------------------------------------------* - * Range Coder prototypes - *----------------------------------------------------------------------------------*/ - -void rc_uni_dec_init( - RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ - uint16_t *bit_buffer, /* i : Bit buffer */ - const int16_t max_available_bits /* i : Total maximum bits available */ -); - -/*! r: Read symbol */ -uint16_t rc_uni_dec_read_symbol_fastS( - RangeUniDecState *rc_st_dec, /* i/o: Decoder State */ - const uint16_t cum_freq_table[], /* i : Cumulative frequency up to symbol */ - const uint16_t sym_freq_table[], /* i : Symbol frequency */ - const uint16_t alphabet_size, /* i : Number of symbols in the alphabet */ - const uint16_t tot_shift /* i : Total frequency as a power of 2 */ -); - -/*! r: Read bit */ -uint16_t rc_uni_dec_read_bit( - RangeUniDecState *rc_st_dec /* i/o: RC state handle */ -); - -/*! r: Read bit */ -uint16_t rc_uni_dec_read_bit_prob_fast( - RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ - const int16_t freq0, /* i : Frequency for symbol 0 */ - const uint16_t tot_shift /* i : Total frequency as a power of 2 */ -); - -/*! r: Read bits */ -uint16_t rc_uni_dec_read_bits( - RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ - const int16_t bits /* i : Number of bits */ -); - -/*! r: Total number of bits consumed */ -int16_t rc_uni_dec_virtual_finish( - RangeUniDecState *rc_st_dec /* i/o: RC state handle */ -); - -/*! r: Total number of bits consumed */ -int16_t rc_uni_dec_finish( - RangeUniDecState *rc_st_dec /* i/o: RC state handle */ -); - - -/*----------------------------------------------------------------------------------* - * ECLVQ Stereo prototypes - *----------------------------------------------------------------------------------*/ - -float ECSQ_dequantize_gain( - const int16_t index -); - - - -void ECSQ_init_instance( - ECSQ_instance *ecsq_inst, - const int16_t config_index, - void *ac_handle -); - - - -void ECSQ_dequantize_vector( - const int16_t *input, - const float global_gain, - const int16_t N, - float *output -); - - -/*----------------------------------------------------------------------------------* - * ICA Stereo prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_tca_init_enc( - STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo TCA encoder handle */ - const int32_t input_Fs /* i : input sampling frequency */ -); - -void stereo_tca_enc( - CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - const int16_t input_frame /* i : length of a frame per channel */ -); - -void stereo_tca_init_dec( - STEREO_TCA_DEC_HANDLE hStereoTCA /* i/o: Stereo TCA handle */ -); - -void stereo_tca_dec( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *synth[CPE_CHANNELS], /* i/o: output synth */ - const int16_t output_frame /* i : length of a frame per channel */ -); - -void stereo_tca_scale_R_channel( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output, /* i/o: output synthesis, R channel */ - const int16_t output_frame /* i : frame length */ -); - -void adjustTargetSignal( - float *target, - const int16_t prevShift, - const int16_t currShift, - const int16_t L_shift_adapt, - const int16_t method -); - -/*----------------------------------------------------------------------------------* - * IC-BWE Stereo prototypes - *----------------------------------------------------------------------------------*/ - - -void stereo_icBWE_preproc( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int16_t input_frame, /* i : input frame length */ - float shb_speech_nonref[] /* o : SHB speech non-ref channel */ -); - -void stereo_icBWE_enc( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const float shb_speech_ref[], /* i : SHB speech ref channel */ - float shb_speech_nonref[], /* i/o: SHB speech non-ref channel */ - const float *voice_factors /* i : voicing factors */ -); - -void stereo_icBWE_init_dec( - STEREO_ICBWE_DEC_HANDLE hStereoICBWE /* i/o: Stereo inter-channel BWE handle */ -); - -void stereo_icBWE_dec( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *synthRef, /* i/o: Reference channel HB synthesis at output Fs */ - float *synth, /* o : Non reference channel HB synthesis at output Fs */ - const float *fb_synth_ref, /* i : ref. high-band synthesis 16-20 kHz */ - const float *voice_factors, /* i : voicing factors */ - const int16_t output_frame /* i : frame length */ -); - -void stereo_icBWE_decproc( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: output symthesis */ - float outputHB[CPE_CHANNELS][L_FRAME48k], /* i : HB synthesis */ - const int16_t last_core, /* i : last core, primary channel */ - const int16_t last_bwidth, /* i : last bandwidth */ - const int16_t output_frame /* i : frame length */ -); - - -/*----------------------------------------------------------------------------------* - * Stereo classifiers prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_classifier_features( - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - const int16_t idchan, /* i : channel ID */ - const int16_t element_mode, /* i : element mode */ - const int16_t vad_flag, /* i : VAD flag */ - const float lsf_new[], /* i : LSFs at the end of the frame */ - const float epsP[], /* i : LP analysis residual energies for each iteration*/ - const int16_t pitch[], /* i : open-loop pitch values for quantiz. */ - const float voicing[], /* i : OL maximum normalized correlation */ - const float cor_map_sum, /* i : speech/music clasif. parameter */ - const float non_staX, /* i : unbound non-stationarity for sp/mu clas. */ - const float sp_div, /* i : spectral diversity feature */ - const int16_t clas /* i : signal class */ -); - - -void xtalk_classifier_dft( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int16_t itd, /* i : ITD from DFT stereo - used as a feature */ - const float gcc_phat[] /* i : GPHAT cross-channel correlation function */ -); - -/*----------------------------------------------------------------------------------* - * TD Stereo prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_td_init_enc( - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - const int16_t last_element_mode /* i : last element mode */ -); - - - -void stereo_tdm_downmix( - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i : TD stereo IVAS encoder structure */ - float *Left_in, /* i/o: Left channel -> Primary channel */ - float *Right_in, /* i/o: Right channel -> Secondary channel */ - const int16_t input_frame, /* i : Number of samples */ - const int16_t tdm_ratio_idx, /* i : TDM ratio index */ - const int16_t tdm_SM_flag, /* i : channel combination scheme flag */ - const int16_t tdm_ratio_idx_SM /* i : TDM ratio index for SM mode */ -); - -void stereo_td_init_dec( - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const int16_t last_element_mode /* i : last element mode */ -); - -void tdm_configure_dec( - const int16_t ivas_format, /* i : IVAS format */ - const int16_t ism_mode, /* i : ISM mode in combined format */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - int16_t *tdm_ratio_idx, /* o : ratio index */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -void tdm_upmix_plain( - float Left[], /* o : left channel */ - float Right[], /* o : right channel */ - const float PCh_2_L[], /* i : primary channel */ - const float SCh_2_R[], /* i : secondary channel */ - const float LR_ratio, /* i : mixing ratio */ - const float inv_den_LR_ratio, /* i : inverse mixing ration */ - const int16_t start_index, /* i : start index */ - const int16_t end_index, /* i : end index */ - const int16_t plus_minus_flag /* i : plus/minus flag */ -); - -void stereo_tdm_combine( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *PCh_2_L, /* i/o: Primary channel -> output as L channel */ - float *SCh_2_R, /* i/o: Seconday channel -> output as R channel */ - const int16_t output_frame, /* i : Number of samples */ - const int16_t flag_HB, /* i : flag to distinguish between core (0) and HB (1) synthesis */ - const int16_t tdm_ratio_idx /* i : TDM ratio index */ -); - -/*! r: replication decision; 1 = Use old LP */ -void tdm_ol_pitch_comparison( - CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - float pitch_fr[CPE_CHANNELS][NB_SUBFR], /* i/o: fractional pitch values */ - float voicing_fr[CPE_CHANNELS][NB_SUBFR] /* i/o: fractional pitch gains */ -); - -void tdm_configure_enc( - const int16_t ivas_format, /* i : IVAS format */ - const int16_t ism_mode, /* i : ISM mode in combined format */ - CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - const float Etot_last[CPE_CHANNELS], /* i/o: Energy of last frame */ - const int16_t tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */ - const int16_t tdm_ratio_idx, /* i : ratio index */ - const int16_t tdm_ratio_idx_SM, /* i : ratio index in SM mode */ - const int16_t attack_flag, /* i : Primary channel attack flag */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - - -void tdm_bit_alloc( - const int16_t ivas_format, /* i : IVAS format */ - const int16_t ism_mode, /* i : ISM mode in combined format */ - const int32_t element_brate_wo_meta, /* i : element bitrate without metadata */ - const int16_t tdm_lp_reuse_flag, /* i : LPC reusage flag */ - int32_t *total_brate_pri, /* o : Allocated primary channel bitrate */ - int32_t *total_brate_sec, /* o : Allocated secondary channel bitrate */ - int16_t *tdm_low_rate_mode, /* o : secondary channel low rate mode flag */ - const int16_t coder_type, /* i : secondary channel coder type */ - const int16_t ener_ratio_idx, /* i : correlation ratio indexe */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const int16_t bwidth_pri, /* i : bandwidth of the primary channel */ - const int16_t bwidth_sec, /* i : bandwidth of the secondary channel */ - const int16_t flag_ACELP16k_pri, /* i : ACELP@16kHz core flag, primary chan. */ - const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const int16_t coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */ - const int16_t tdm_inst_ratio_idx /* i : instantaneous correlation ratio index */ -); - - -/*! r: value of the indice */ -uint16_t get_indice_st( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t pos, /* i : absolute position in the bitstream */ - const int16_t nb_bits /* i : number of bits to quantize the indice */ -); - -void tdm_low_rate_dec( - Decoder_State *st, /* i/o: decoder static memory */ - float dct_epit[], /* o : GSC excitation in DCT domain */ - float *tmp_noise, /* o : long term temporary noise energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - float *bwe_exc, /* o : excitation for SWB TBE */ - const float *lsf_new /* i : ISFs at the end of the frame */ -); - -void tdm_SCh_LSF_intra_pred( - const int32_t element_brate, /* i : element bitrate */ - const float *tdm_lsfQ_PCh, /* i : primary channel LSFs */ - float *pred_lsf_SCh /* o : predicted secondary channel LSFs */ -); - - -void first_VQstages( - const float *const *cb, - const float u[], /* i : vector to be encoded (prediction and mean removed) */ - const int16_t *levels, /* i : number of levels in each stage */ - const int16_t stagesVQ, /* i : number of stages */ - const float w[], /* i : weights */ - const int16_t N, /* i : vector dimension */ - const int16_t max_inner, /* i : maximum number of swaps in inner loop */ - int16_t indices_VQstage[] -); - - -void deindex_lvq_SHB( - UWord32 index, - float *out, - const int16_t nbits, - const int16_t mode -); - -/*----------------------------------------------------------------------------------* - * MDCT Stereo prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_td_itd_mdct_stereo( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ - const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ - const int16_t vad_hover_flag[], /* i : VAD hangover flags */ - const int16_t input_frame /* i : frame length */ -); - -void QuantizeTCXSpectrum( - Encoder_State *st, /* i : state handle */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - const float *x_orig, /* i : shaped MDCT spectrum */ - const float *gainlpc, /* i : FDNS gains */ - const Word16 *Aqind, /* i : frame-independent quantized coefficients (M+1) */ - const int16_t tnsSize, /* i : number of tns parameters put into prm */ - const int16_t nb_bits, /* i : bit budget */ - const int16_t vad_hover_flag, /* i : VAD hangover flag */ - int16_t *pL_frameTCX, /* o : full frame length */ - int16_t *pL_frame, /* o : frame length */ - int16_t *pL_spec, /* o : length of the coded spectrum */ - int16_t *ptcx_offset, /* o : folding point offset relative to the end of the previous frame */ - int16_t *pnoiseFillingBorder, /* o : noise filling border */ - float spectrum[], /* o : quantized MDCT spectrum */ - CONTEXT_HM_CONFIG *hm_cfg, /* o : Context-based harmonic model configuration */ - int16_t *hm_active, /* o : flag indicating if the harmonic model is active */ - float lf_deemph_fact[], /* o : low frequency deemphasis factors */ - int16_t *nf_seed, /* o : noise filling random seed */ - float *ener, /* o : energy of the quantized spectrum */ - float *gain_tcx, /* o : global gain */ - int16_t prm[] /* o : tcx parameters */ -); - -void EstimateStereoTCXNoiseLevel( - Encoder_State **sts, /* i : state handle */ - float *q_spectrum[CPE_CHANNELS][NB_DIV], /* i : quantized MDCT spectrum */ - float gain_tcx[][NB_DIV], /* i : global gain */ - int16_t L_frame[][NB_DIV], /* i : frame length */ - int16_t noiseFillingBorder[][NB_DIV], /* i : noise filling border */ - int16_t hm_active[][NB_DIV], /* i : flag indicating if the harmonic model is active */ - const int16_t ignore_chan[], /* i : flag indicating whether the channel should be ignored */ - float fac_ns[][NB_DIV], /* o : noise filling level */ - int16_t param_core[][NB_DIV * NPRM_DIV], /* o : quantized noise filling level */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void TNSAnalysisStereo( - Encoder_State **sts, /* i : state handle */ - float *mdst_spectrum[CPE_CHANNELS][NB_DIV], /* o : MDST spectrum */ - const int16_t bWhitenedDomain, /* i : whitened domain flag */ - int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : number of tns parameters put into prm */ - int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : number of tns bits in the frame */ - int16_t param_core[][NB_DIV * NPRM_DIV], /* o : quantized noise filling level */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ -); - -void InternalTCXDecoder( - Encoder_State *st, /* i/o: state handle */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - const int16_t L_frameTCX, /* i : full frame length */ - const int16_t L_frame, /* i : frame length */ - const int16_t L_spec, /* i : length of the coded spectrum */ - const int16_t tcx_offset, /* i : folding point offset relative to the end of the previous frame */ - const int16_t noiseFillingBorder, /* i : noise filling border */ - const float *x_quant, /* i : quantized spectrum */ - const float ener, /* i : energy of the quantized spectrum */ - float lf_deemph_fact[], /* i/o: low frequency deemphasis factors */ - const float fac_ns, /* i : noise filling level */ - const int16_t nf_seed, /* i : noise filling random seed */ - const float *A, /* i : LPC representation of the FDNS gains */ - float *gainlpc, /* i/o: FDNS gains */ - const int16_t hm_active, /* i : flag indicating if the harmonic model is active */ - float gain_tcx, /* i/o: global gain / quantized global gain */ - float spectrum[], /* o : dequantized spectrum */ - float synth[], /* o : time domain signal */ - int16_t *gain_tcx_q /* o : quantized global gain (at low bitrates) */ -); - -void stereo_mdct_core_enc_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/ - Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ - Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ -); - -void initMdctStereoEncData( - STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t element_mode, /* i : element mode */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t bwidth, /* i : bandwidth */ - const int16_t igf, /* i : flag indicating IGF activity */ - const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */ - const int16_t mem_init /* i : initialize memory after malloc */ -); - -ivas_error initMdctItdHandling( - STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void stereo_mdct_enc_destroy( - STEREO_MDCT_ENC_DATA_HANDLE *hStereoMdct /* i/o: encoder MDCT stereo handle */ -); - -void initMdctStereoDecData( - STEREO_MDCT_DEC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ - const int16_t igf, /* i : flag indicating IGF activity */ - const H_IGF_GRID igfGrid, /* i : IGF grid configuration */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void stereo_mdct_init_bands( - const int16_t L_frame, /* i : frame length */ - const int16_t tmp_tcx_mode, /* i : tcx mode (TCX10, TCX 20), -1 if transition frame */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t igf, /* i : flag indicating if IGF is used */ - const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */ - int16_t *sfbOffset, /* o : sfb offset table */ - int16_t *sfbCnt /* o : number of sfbs */ -); - -void stereo_mdct_init_igf_start_band( - STEREO_MDCT_BAND_PARAMETERS *stbParams, /* i/o: stereo frequency band parameters */ - const float transFac, /* i : transform factor */ - const int16_t bwidth, /* i : audio bandwidth */ - const int32_t element_brate /* i : element bitrate */ -); - -void init_tcx_enc_info( - Encoder_State *st, /* i : coder memory state */ - int16_t *L_frame, - int16_t *L_frameTCX, - int16_t *L_spec -); - -void decoder_tcx_invQ( - Decoder_State *st, /* i/o: coder memory state */ - int16_t prm[], /* i : parameters */ - float A[], /* i : coefficients NxAz[M+1] */ - Word16 Aind[], /* i : frame-independent coefficients Az[M+1] */ - const int16_t L_spec, - const int16_t L_frame, - const int16_t L_frameTCX, - float x[], - float gainlpc2[], - float xn_buf[], - int16_t *fUseTns, /* o : flag that is set if TNS data is present */ - STnsData *tnsData, - float *gain_tcx, - const int16_t **prm_sqQ, - int16_t *nf_seed, - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt /* i : frame counter in the super frame */ -); - -void decoder_tcx_noisefilling( - Decoder_State *st, /* i/o: coder memory state */ - float concealment_noise[L_FRAME48k], - const float A[], /* i : coefficients NxAz[M+1] */ - const int16_t L_frameTCX_glob, - const int16_t L_spec, - const int16_t L_frame, - const int16_t L_frameTCX, - float x[], - float gainlpc2[], - int16_t *temp_concealment_method, - const float gain_tcx, - const int16_t *prm_sqQ, - int16_t nf_seed, - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t frame_cnt /* i : frame counter in the super frame */ -); - -void decoder_tcx_noiseshaping_igf( - Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_spec, - const int16_t L_frame, - const int16_t L_frameTCX, - const int16_t left_rect, - float x[], - const float gainlpc2[], - int16_t *temp_concealment_method, - const int16_t bfi /* i : Bad frame indicator */ -); - -void decoder_tcx_tns( - Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_frame_glob, - const int16_t L_spec, - const int16_t L_frame, - const int16_t L_frameTCX, - float x[N_MAX], - const int16_t fUseTns, /* i : flag that is set if TNS data is present */ - STnsData *tnsData, - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt, /* i : frame counter in the super frame */ - const int16_t whitenedDomain -); - -void decoder_tcx_imdct( - Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_frame_glob, /* i : frame length */ - const int16_t L_frameTCX_glob, - const int16_t L_spec, - const int16_t tcx_offset, - const int16_t tcx_offsetFB, - const int16_t L_frame, - const int16_t L_frameTCX, - const int16_t left_rect, - float x[N_MAX], - float xn_buf[], - const uint16_t kernelType, /* i : TCX transform kernel type */ - const int16_t fUseTns, /* i : flag that is set if TNS data is present */ - float synth[], /* i/o: synth[-M..L_frame] */ - float synthFB[], - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt, /* i : frame counter in the super frame */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void init_tcx_info( - Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_frame_glob, /* i : global frame length */ - const int16_t L_frameTCX_glob, /* i : FB global frame length */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - const int16_t bfi, /* i : bad frame indicator */ - int16_t *tcx_offset, /* o : folding point offset relative to the end of the previous frame */ - int16_t *tcx_offsetFB, /* o : FB folding point offset relative to the end of the previous frame*/ - int16_t *L_frame, /* o : frame length */ - int16_t *L_frameTCX, /* o : TCX frame length */ - int16_t *left_rect, /* o : left part is rectangular */ - int16_t *L_spec /* o : spectrum length */ -); - -void decoder_tcx_IGF_mono( - Decoder_State *st, /* i/o: coder memory state */ - float x[], /* o : de-quatized coefficients */ - const int16_t L_frame, /* i : frame length */ - const int16_t left_rect, /* i : left part is rectangular */ - const int16_t bfi, /* i : bad frame indicator */ - const int16_t frame_cnt /* i : frame counter in the super_frame */ -); - -void decoder_tcx_IGF_stereo( - Decoder_State **sts, /* i/o: coder memory states */ - STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - float *x[CPE_CHANNELS][NB_DIV], /* o : de-quatized coefficients */ - const int16_t L_frame, /* i : frame length */ - const int16_t left_rect, /* i : left part is rectangular */ - const int16_t k, /* i : Subframe index */ - const int16_t bfi, /* i : bad frame indicator */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void ms_processing( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */ - Encoder_State **sts, /* i/o: Encoder state structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - const int16_t iSubframe, /* i : subframe number */ - float x_0[], /* i/o: spectrum 1 */ - float x_1[], /* i/o: spectrum 2 */ - int16_t maxSfb /* i : number of stereo frequency bands */ -); - -void ms_inv_mask_processing( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */ - Encoder_State **sts, /* i/o: Encoder state structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - const int16_t iSubframe, /* i : subframe number */ - const float x_0[], /* i : spectrum 1 */ - const float x_1[], /* i : spectrum 2 */ - float x_inv_0[], /* o : inverse spectrum 1 */ - float x_inv_1[], /* o : inverse spectrum 2 */ - int16_t maxSfb /* i : number of stereo frequency bands */ -); - -void IGFDecApplyStereo_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i : instance handle of IGF Decoder */ - const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i : instance handle of IGF Decoder */ - float *spectrumL, /* i/o: L MDCT spectrum */ - float *spectrumR, /* i/o: R MDCT spectrum */ - const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const int16_t *coreMsMask, - const int16_t restrict_hopsize, - const int16_t bfi, /* i : frame loss == 1, frame good == 0 */ - const int16_t bfi_apply_damping /* i : decoder element mode */ -); - -void IGFEncStereoEncoder( - STEREO_MDCT_BAND_PARAMETERS *sfbParam, /* i/o: sfb parameters for the right channel */ - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : IGF handle */ - const float *mdctSpectrumL, /* i : left spectrum */ - const float *mdctSpectrumR, /* i : right spectrum */ - int16_t *msMask, /* i/o: MS mask */ - int16_t *igfStereoMode, /* o : IGF stereo mode */ - const int16_t mdct_stereo_mode, /* i : MDCT stereo mode */ - const int16_t isTCX20, /* i : flag for indicating TCX20 */ - const int16_t isTransition /* i : flag for transtition */ -); - -void IGFDecReplicateTCX10State_flt( - IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: instance handle of IGF Decoder */ -); - - -void InitPsychLPC( - const int32_t sr_core, /* i : sampling rate of core-coder */ - const int16_t L_frame, /* i : frame length */ - const TCX_CONFIG_HANDLE hTcxCfg /* i : TCX configuration handle */ -); - - -void stereo_coder_tcx( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - float *mdst_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: MDST spectrum */ - float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: inverse spectrum */ - float *inv_mdst_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ -); - -void stereo_decoder_tcx( - STEREO_MDCT_DEC_DATA *hStereoMdct, /* i/o: MDCT stereo decoder structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - float *spec_r_0[NB_DIV], /* i/o: spectrum right channel */ - float *spec_l[], /* i/o: spectrum left channel [NB_DIV][N] */ - float *spec_r[], /* i/o: spectrum right channel [NB_DIV][N] */ - const int16_t mdct_stereo_mode[], /* i : stereo mode (FB/band wise MS, dual mono */ - const int16_t core_l, /* i : core for left channel (TCX20/TCX10) */ - const int16_t core_r, /* i : core for right channel (TCX20/TCX10) */ - const int16_t igf, /* i : flag for IGF activity */ - const int16_t L_frameTCX_l, /* i : TCX frame length of left channel */ - const int16_t L_frameTCX_r, /* i : TCX frame length of right channel */ - const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */ - const int16_t last_core_l, /* i : last core for left channel */ - const int16_t last_core_r, /* i : last core for right channel */ - const int16_t tmp_plc_upmix /* i : indicates temp upmix for PLC decision */ -); - -void stereo_mdct_core_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *signal_out[CPE_CHANNELS], /* o : synthesis @internal_FS */ - float signal_outFB[CPE_CHANNELS][L_FRAME48k] /* o : synthesis @output_FS */ -); - -void splitAvailableBits( - const int16_t total_bits, /* i : total available bits for TCX coding */ - const int16_t split_ratio, /* i : split ratio */ - const int16_t isSBAStereoMode, /* i : signal core coding for SBA */ - int16_t *bits_ch0, /* o : bits for channel 0 */ - int16_t *bits_ch1 /* o : bits for channel 1 */ -); - -Word16 write_stereo_to_bitstream_fx -( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */ - Encoder_State **sts, /* i/o: Encoder state structure */ - Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/ - const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ -); - - - -void ComputeSpectrumNoiseMeasure( - const float *powerSpec, - const int16_t L_frame, - const int16_t startLine, - const int16_t resetMemory, - int8_t *noiseFlags, - const int16_t lowpassLine -); - -void IGFSaveSpectrumForITF( - IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const int16_t igfGridIdx, /* i : IGF grid index */ - const float *pITFSpectrum /* i : MDCT spectrum */ -); - -void convert_coeffs_to_higher_res( - const float *in1, /* i : first subframe input */ - const float *in2, /* i : second subframe input */ - float *out, /* o : converted output */ - const int16_t len /* i : length of subframes */ -); - -int16_t quantize_sns( - float sns_in[CPE_CHANNELS][NB_DIV][M], - float snsQ_out[CPE_CHANNELS][NB_DIV][M], - Encoder_State **sts, - int16_t *indices, - int16_t *zero_side_flag, - int16_t *sns_stereo_mode -); - -void dequantize_sns( - int16_t indices[CPE_CHANNELS][NPRM_LPC_NEW], - float snsQ_out[CPE_CHANNELS][NB_DIV][M], - Decoder_State **sts -); - -void sns_avq_dec( - int16_t *index, /* i : Quantization indices */ - float SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */ - const int16_t L_frame, /* i : frame length */ - const int16_t numlpc /* i : Number of sets of lpc */ -); - -void sns_avq_dec_stereo( - int16_t *indexl, /* i : Quantization indices (left channel) */ - int16_t *indexr, /* i : Quantization indices (right channe) */ - const int16_t L_frame, /* i : frame length */ - float *SNS_Ql, /* o : Quantized SNS vectors (left channel) */ - float *SNS_Qr /* o : Quantized SNS vectors (right channe) */ -); - -void convertToMS( - const int16_t L_frame, /* i : frame length */ - float x0[], /* i/o: mid/left channel coefficients */ - float x1[], /* i/o: side/right channel coefficients */ - const float norm_fac /* i : normalization factor */ -); - -void inverseMS( - const int16_t L_frame, /* i : frame length */ - float x0[], /* i/o: mid/left channel coefficients */ - float x1[], /* i/o: side/right channel coefficients */ - const float norm_fac /* i : normalization factor */ -); - -void stereoFdCngCoherence( - Encoder_State **sts, /* i/o: core encoder structures */ - const int16_t last_element_mode, /* i : last element mode */ - float fft_buff[CPE_CHANNELS][2 * L_FFT] /* i : fft buffers for L and R channels */ -); - -void FdCngEncodeMDCTStereoSID( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ -); - -void FdCngDecodeMDCTStereoSID( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -); - -ivas_error initMdctStereoDtxData( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder handle */ -); - -void synchonize_channels_mdct_sid( - Decoder_State *sts[CPE_CHANNELS], /* i/o: decoder state structure */ - const int16_t n /* i : channel number */ -); - -void updateBuffersForDmxMdctStereo( - CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ - const int16_t output_frame, /* i : output frame length */ - float *output[CPE_CHANNELS], /* i/o: decoder output */ - float synth[CPE_CHANNELS][L_FRAME48k] /* i/o: decoder synthesis */ -); - -void applyDmxMdctStereo( - const CPE_DEC_HANDLE hCPE, /* i : CPE handle */ - float *output[CPE_CHANNELS], /* o : output from core decoder */ - const int16_t output_frame /* i : output frame length */ -); - -/*----------------------------------------------------------------------------------* - * Front-VAD prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error front_vad_create( - FRONT_VAD_ENC_HANDLE *hFrontVad, /* i/o: front-VAD handle */ - const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */ -); - -void front_vad_destroy( - FRONT_VAD_ENC_HANDLE *hFrontVad /* i/o: front-VAD handle */ -); - -ivas_error front_vad( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */ - Encoder_State *st, /* i/o: encoder state structure */ - const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ - FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: front-VAD handles */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t input_frame, /* i : frame length */ - int16_t vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO */ - float fr_bands[][2 * NB_BANDS], /* i : energy in frequency bands */ - float Etot_LR[], /* o : total energy Left & Right channel */ - float lf_E[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */ - int16_t localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels */ - int16_t vad_hover_flag[], /* o : VAD hangover flag */ - float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */ - float *PS_out, /* o : energy spectrum */ - float *Bin_E_out /* o : log-energy spectrum of the current frame*/ -); - -ivas_error front_vad_spar( - SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */ - const float *omni_in, /* i : omnidirectional input signal */ - ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */ - const int16_t input_frame /* i : input frame length */ -); - - -/*----------------------------------------------------------------------------------* - * Stereo CNG prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_enc_cng_init( - STEREO_CNG_ENC_HANDLE hStereoCng /* i/o: stereo CNG encoder structure */ -); - -void stereo_cng_upd_counters( - STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ - const int32_t element_mode, /* i : element mode */ - const int16_t nbands, /* i : Number of bands in active */ - const float sidSideGain[], /* i : SID side gains */ - const int16_t burst_ho_count, /* i : Hang-over count */ - int16_t *coh_fade_counter /* i : Coherence fade counter */ -); - -void stereo_cng_init_dec( - STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: stereo CNG decoder structure */ - const int16_t *frameSize /* i : pointer to frameSize of channel 0 to be used for channel 1 */ -); - -void stereo_cng_compute_PScorr( - float *output[CPE_CHANNELS], /* i : Output signal */ - float *c_PS_LT, /* i/o: Correlation */ - const int16_t L_frame_0, /* i : L_frame channel 0 */ - const int16_t L_frame_1 /* i : L_frame channel 1 */ -); - -void stereo_cng_dec_update( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int32_t ivas_total_brate /* i : IVAS total bitrate Q0*/ -); - -void stereo_cna_update_params( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i : Output signal */ - const int16_t output_frame, /* i : Output frame length */ - const int16_t tdm_ratio_idx /* i : TDM ratio index */ -); - -void dtx_enc_init( - Encoder_State *st, /* i : Encoder state handle */ - const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ - const int16_t interval_SID /* i : interval for SID update */ -); - - -/*----------------------------------------------------------------------------------* - * Framework general prototypes - *----------------------------------------------------------------------------------*/ - -void mvc2c( - const uint8_t x[], /* i : input vector */ - uint8_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -/*! r: Adjusted value */ -ivas_error stereo_memory_dec( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - CPE_DEC_HANDLE hCPE, /* i : CPE decoder structure */ - const int16_t nb_bits_metadata, /* i : number of metadata bits */ - const int32_t output_Fs, /* i : output sampling rate */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int16_t nchan_transport /* i : number of transport channels */ -); - -void stereo_switching_dec( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ -); - -void stereo_td2dft_update( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int16_t n, /* i : channel number */ - float output[], /* i/o: synthesis @internal Fs */ - float synth[], /* i/o: synthesis @output Fs */ - float hb_synth[], /* i/o: hb synthesis */ - const int16_t output_frame /* i : frame length */ -); - -void stereo_mdct2dft_update( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float output0[], /* i/o: synthesis @internal Fs, ch0 */ - float synth0[] /* i/o: synthesis @output Fs, ch0 */ -); - - -/*! r: number of bits written */ - - - -/*----------------------------------------------------------------------------------* - * MCT prototypes - *----------------------------------------------------------------------------------*/ -void ivas_mdct_core_whitening_enc_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples */ - Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ - Word16 pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */ - Word32 *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */ - int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* o : buffer TNS bits */ - Word32 *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening */ - int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* o : size of TNS */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to parameter array */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */ - const int16_t nChannels, /* i : total number of coded channels */ -Word16 mdst_spectrum_e[CPE_CHANNELS][NB_DIV], -Word16 orig_spectrum_e[CPE_CHANNELS][NB_DIV] -); -void ivas_mct_core_enc( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE encoder structures */ - const int16_t nChannels, /* i : number of channels to be coded */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t switch_bw, /* i : flag bandwidth switch occurance */ - const int16_t lfe_bits, /* i : bits spent for LFE */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ -); - -void ivas_mdct_quant_coder( - CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */ - int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */ - int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : size of TNS */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to parameter array */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void apply_MCT_enc( - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - float *mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: MDST spectrum */ - float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse spectrum */ - float *inv_mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */ - const int16_t nchan /* i : number of channels */ -); - -void write_mct_bitstream( - Encoder_State **sts, /* i/o: encoder state structure */ - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - const int16_t nchan /* i : number of channels */ -); - -void splitAvailableBitsMCT_fx( - void **sts, /* i/o: encoder/decoder state structure */ - const Word16 total_bits, /* i : total number of available bits */ - const Word16 split_ratio[MCT_MAX_CHANNELS], /* i : ratio for splitting the bits Q0 */ - const Word16 enc_dec, /* i : encoder or decoder flag */ - const Word16 nchan /* i : number of channels */ -); - -void getChannelEnergies( - Encoder_State **sts, /* i : Encoder state structure */ - float nrg[MCT_MAX_CHANNELS], /* o : energies */ - const int16_t nchan /* i : number of channels */ -); - -void mctStereoIGF_enc( - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - float *orig_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : MDCT spectrum for ITF */ - float powerSpec[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */ - float *powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV], /* i : same as above but for inverse spect. */ - float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */ - const int16_t sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */ -); - -void ivas_mdct_dec_side_bits_frame_channel( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* o : lpc_parameters */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to param buffer */ - Decoder_State *st0, /* i : pointer to bitstream handle */ - int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* o : number of bits for TNS */ - int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i/o: parameters buffer */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t odd_channel_cpe /* i : flag cpe with odd nb of tc channels */ -); - -void ivas_mct_side_bits( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE decoder structure */ - const int16_t nCPE, /* i : number of CPEs */ - Decoder_State *st0, /* i : decoder handle for Bstr */ - const int16_t bfi, /* i : BFI flag */ - uint16_t *bitstream, /* o : bitstream indices */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -void ivas_mdct_core_invQ( - CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ - int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* i : number of TNS bits */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to param buffer */ - int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* i : lpc parameters */ - int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i : param buffer */ - int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flag TNS enabled */ - STnsData tnsData[CPE_CHANNELS][NB_DIV], /* i : TNS parameter */ - float *x_0[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ - float *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ - float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void ivas_mdct_core_reconstruct( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *x[][NB_DIV], /* i/o: pointers to synthesis @internal_FS */ - float signal_outFB[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS */ - int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void ivas_mdct_core_tns_ns( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : two entries for each channel in TCX10 */ - STnsData tnsData[CPE_CHANNELS][NB_DIV], /* o : TNS parameter */ - float *x[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */ - float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - - -void ivas_mct_dec_mct( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - const int16_t nchan /* i : number of channels */ -); - -void apply_MCT_dec( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - float *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */ -); - -void mctStereoIGF_dec( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - float *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequantized spectrum */ - const int16_t bfi /* i : bad frame flag */ -); - -void enc_prm_igf_mdct( - Encoder_State *st, /* i : Encoder state handle */ - BSTR_ENC_HANDLE hBstr /* i/o: Bitstream handle */ -); - -void mdct_read_IGF_bits( - Decoder_State *st, /* i/o: Encoder state handle */ - Decoder_State *st0 /* i : pointer to handle where bstr is read */ -); - - -/*----------------------------------------------------------------------------------* - * Q Metadata prototypes for DirAC and MASA - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_qmetadata_enc_encode( - BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ - IVAS_QMETADATA *hQMetaData, /* i/o: q_metadata handle */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - -ivas_error ivas_qmetadata_enc_encode_hr_384_512( - BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ - IVAS_QMETADATA *hQMetaData, /* i/o: metadata handle */ - const int16_t bits_sph_idx, - const int16_t bits_sp_coh -); - -void deindex_sph_idx( - const uint16_t sphIndex, /* i : Spherical index */ - const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ - float *theta, /* o : Elevation */ - float *phi /* o : Azimuth */ -); - -/*! r: output index for direction */ -uint16_t index_theta_phi_16( - float * p_theta, /* i/o: input elevation to be indexed */ - float * p_phi, /* i/o: input azimuth to be indexed */ - const SPHERICAL_GRID_DATA *gridData /* i : generated grid data */ -); - -void reset_metadata_spatial( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ - const int32_t element_brate, /* i : element bitrate */ - int32_t *total_brate, /* o : total bitrate */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t nb_bits_metadata /* i : number of meatdata bits */ -); - -/*! r: number of bits written */ - -/*! r: number of bits read */ -int16_t ivas_qmetadata_dec_decode( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - uint16_t *bitstream, /* i : bitstream */ - int16_t *index, /* i/o: bitstream position */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - -/*! r: number of bits read */ -int16_t ivas_qmetadata_dec_decode_hr_384_512( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */ - uint16_t *bitstream, /* i : bitstream */ - int16_t *index, /* i/o: bitstream position */ - const SPHERICAL_GRID_DATA *sph_grid16, /* i : spherical grid for deindexing */ - const int16_t bits_sph_idx, - const int16_t bits_sp_coh, - const uint8_t ncoding_bands_config -); - -/*! r: number of bits read */ -int16_t ivas_qmetadata_dec_sid_decode( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - uint16_t *bitstream, /* i : bitstream */ - int16_t *index, /* i/o: bitstream position */ - const int16_t nchan_transport, /* i : number of transport channels */ - int16_t *element_mode, /* o : element mode */ - const int16_t ivas_format /* i : IVAS format */ -); - - - - -void restore_metadata_buffer( - BSTR_ENC_HANDLE hMetaData, - const int16_t next_ind_start, - const int16_t bit_pos_start -); - -/*! r: codeword index */ -int16_t masa_sq( - const float in, /* i : input value */ - const float *threshold, /* i : partition */ - const int16_t cb_sz /* i : codebook size */ -); - -void ivas_qmetadata_azimuth_elevation_to_direction_vector( - const float az, /* i : azimuth */ - const float el, /* i : elevation */ - float *dv /* o : direction vector */ -); - -ivas_error only_reduce_bits_direction( - int16_t *reduce_bits_out, - IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ - int16_t reduce_bits, - const int16_t coding_subbands, - const int16_t no_subframes, - int16_t *ind_order -); - -void quantize_direction_frame( - IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ - float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], - float elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], - const int16_t hrmasa_flag /* i : flag indicating high-rate MASA MD coding*/ -); - -/*! r: quantized spherical index */ -uint16_t quantize_direction( - const float theta, /* i : input elevation value */ - float phi, /* i : input azimuth value */ - const int16_t no_bits, /* i : number of bits */ - float *theta_q, /* o : quantized elevation */ - float *phi_q, /* o : quantized azimuth */ - uint16_t *index_theta, /* o : quantized elevation index */ - uint16_t *index_phi, /* o : quantized azimuth index */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ -); - -int16_t quantize_direction2D( - float phi, /* i : input azimuth value */ - const int16_t no_cw, /* i : number of bits */ - float *phi_q, /* o : quantized azimuth value */ - uint16_t *index_phi, /* o : quantized azimuth index */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ -); - -void quantize_direction_frame2D( - IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ - float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input azimuth values */ - float elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES] /* i : input elevation values */ -); - -void small_requantize_direction_frame( - IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ - float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input azimuth values */ - float elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input elevation values */ - const int16_t raw_flag[MASA_MAXIMUM_CODING_SUBBANDS], /* i : raw/EC encoding mode for each subband */ - int16_t bits_dir_bands[MASA_MAXIMUM_CODING_SUBBANDS], /* i/o: number of bits per subband */ - int16_t *diff /* i/o: number of bits to be reduced */ -); - -/*! r: index azimuth */ -int16_t quantize_phi( - float phi, /* i : azimuth value */ - const int16_t flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ - float *phi_hat, /* o : quantized azimuth */ - const int16_t n /* i : azimuth codebook size */ -); - -/*! r: decoded elevation value */ -float deindex_elevation( - uint16_t *id_th, /* i : input index */ - const int16_t no_bits, /* i : number of bits for the spherical grid */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ -); - -float deindex_azimuth( - int16_t id_phi, /* i : index */ - const int16_t no_bits, /* i : number of bits for the spherical grid */ - const int16_t id_th, /* i : elevation index */ - const int16_t remap, /* i : remapping flag */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ -); - -UWord16 ivas_qmetadata_reorder_generic_fx( - const Word16 signed_value -); - -void ivas_sba_config( - const int32_t sba_total_brate, /* i : SBA total bitrate */ - int16_t sba_order, /* i : Ambisonic (SBA) order */ - int16_t nb_channels, /* i : Number of Ambisonic (SBA) channels */ - int16_t *nchan_transport, /* o : number of transport channels */ - const int16_t sba_planar, /* i : SBA planar flag */ - int16_t *nSCE, /* o : number of SCEs */ - int16_t *nCPE, /* o : number of CPEs */ - int16_t *element_mode /* o : element mode of the core coder */ -); - -void ivas_sba_set_cna_cng_flag( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_sba_dec_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesFlushed, /* o : number of samples flushed */ - int16_t *data /* o : output synthesis signal */ -); - -ivas_error ivas_sba_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering, /* i : number of samples provided */ - float *data[] /* i : transport channel samples */ -); - - - -/*! r: Ambisonic (SBA) order */ -int16_t ivas_sba_get_order( - const int16_t nb_channels, /* i : Number of ambisonic channels */ - const int16_t sba_planar /* i : SBA planar flag */ -); - -/*! r: number of Ambisonic channels */ -int16_t ivas_sba_get_nchan( - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const int16_t sba_planar /* i : SBA planar flag */ -); - -/*! r: number of ambisonics metadata channels */ - -void ivas_sba_getTCs( - float *sba_data[], /* i : SBA signals */ - Encoder_Struct *st_ivas, /* i/o: Encoder struct */ - const int16_t input_frame /* i : frame length */ -); - -int16_t ivas_sba_remapTCs( - float *sba_data[], /* i/o: SBA signals */ - Decoder_Struct *st_ivas, /* i/o: decoder struct */ - const int16_t output_frame /* i : frame length */ -); - -void ivas_sba_dirac_stereo_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[CPE_CHANNELS], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t mcmasa /* i : McMASA flag */ -); - -void ivas_sba_dirac_stereo_config( - STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */ -); - - -Word16 ivas_get_sba_dirac_stereo_flag( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_sba_dirac_stereo_smooth_parameters( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */ - const int16_t cross_fade_start_offset, /* i : SPAR mixer delay compensation */ - const int32_t output_Fs, /* i : Fs for delay calculation */ - const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */ -); - - -/*----------------------------------------------------------------------------------* - * DirAC prototypes - *----------------------------------------------------------------------------------*/ - - -ivas_error ivas_dirac_enc_reconfigure( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - - - -ivas_error ivas_dirac_config( - void *st_ivas, /* i/o: IVAS encoder/decoder state structure */ - const int16_t enc_dec /* i : encoder or decoder flag */ -); - -void ivas_dirac_config_bands( - int16_t *band_grouping, /* o : band grouping */ - const int16_t nbands, /* i : number of bands */ - const int16_t max_band, /* i : maximal band index +1 */ - int16_t *dirac_to_spar_md_bands, /* o : mapping of DirAC parameter band index to SPAR FB band index */ - const int8_t useLowerBandRes, /* i : flag indicating lower band resolution for DirAC */ - const int16_t enc_param_start_band, /* i : band index of first DirAC parameter band */ - IVAS_FB_MIXER_HANDLE hFbMdft -); - -void ivas_get_dirac_sba_max_md_bits( - const int32_t sba_total_brate, - int16_t *bits_frame_nominal, - int16_t *metadata_max_bits, - int16_t *qmetadata_max_bit_req, - const int16_t nbands - , - IVAS_FORMAT ivas_format -); - -ivas_error ivas_dirac_sba_config( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - int16_t *element_mode, /* o : element mode of the core coder */ - int32_t sba_total_brate, /* i : SBA total bitrate */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const int16_t nbands /* i : number of frequency bands */ - , - IVAS_FORMAT ivas_format -); - -ivas_error ivas_dirac_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_configopen /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ -); - -void ivas_dirac_dec_close( - DIRAC_DEC_HANDLE *hDirAC_out -); - -void ivas_dirac_dec_read_BS( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - Decoder_State *st, /* i/o: decoder Core state structure */ - DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q metadata */ - int16_t *nb_bits, /* o : number of bits read */ - const int16_t last_bit_pos, /* i : last read bitstream position */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ -); - -void generate_masking_noise_lb_dirac( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ - const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ - const int16_t cna_flag /* i : CNA flag for LB and HB */ -); - - -void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - -void ivas_dirac_dec_render_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport, /* i : number of transport channels */ - float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], - float *pppQMfFrame_ts_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] -); - - -void computeDirectionVectors( - float *intensity_real_x, - float *intensity_real_y, - float *intensity_real_z, - const int16_t enc_param_start_band, - const int16_t num_frequency_bands, - float *direction_vector_x, - float *direction_vector_y, - float *direction_vector_z -); - -void computeDiffuseness( - float *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], - const float *buffer_energy, - const int16_t num_freq_bands, - float *diffuseness -); - -void ivas_dirac_dec_get_response( - const int16_t azimuth, - const int16_t elevation, - float *response, - const int16_t ambisonics_order -); - - - -ivas_error ivas_mc_paramupmix_enc_open_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -void ivas_mc_paramupmix_enc_close_fx( - MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ - const int32_t input_Fs /* i : input sampling rate */ -); - -ivas_error ivas_mc_paramupmix_dec_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_mc_paramupmix_dec_close( - MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */ -); - -void ivas_mc_paramupmix_dec_read_BS( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Decoder_State *st, /* i/o: decoder state structure */ - MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */ - int16_t *nb_bits /* o : number of bits written */ -); - -void ivas_mc_paramupmix_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - const int16_t nSamplesForRendering /* i : number of samples provided */ -); - -void ivas_param_mc_set_coded_bands_fx( - HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* i/o: handle for the Parametric MC parameter coding state */ -); - -/*! r: number of IVAS transport channels */ - -ivas_error ivas_param_mc_enc_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -ivas_error ivas_param_mc_enc_reconfig( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -void ivas_param_mc_enc_close( - PARAM_MC_ENC_HANDLE *hParamMC, /* i/o: Parametric MC encoder handle */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void ivas_param_mc_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ - float *data_f[], /* i/o: input/transport MC data */ - const int16_t input_frame /* i : input frame length */ -); - -ivas_error ivas_param_mc_dec_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_param_mc_dec_reconfig( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - - -void ivas_param_mc_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ -); - -void ivas_param_mc_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - -void ivas_param_mc_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ -); - -/*! r: number of cldfb synthesis instances */ -int16_t param_mc_get_num_cldfb_syntheses( - Decoder_Struct *st_ivas /* i : IVAS decoder structure */ -); - -UWord16 ivas_param_mc_get_configuration_index_fx( - const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); - -ivas_error ivas_dirac_dec_output_synthesis_cov_open( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: handle for the covariance synthesis state */ - const int16_t max_band_decorr, /* i : uppermost frequency band where decorrelation is applied */ - const int16_t interp_length, /* i : length for interpolating the mixing matrices in time slots */ - const int16_t num_param_bands, /* i : number of parameter bands */ - const int16_t num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ - const int16_t nchan_in, /* i : number of input (transport) channels */ - const int16_t nchan_out, /* i : number of output channels */ - const float *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */ -); - -void ivas_dirac_dec_output_synthesis_get_interpolator( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ - const uint16_t interp_length /* i : interpolator length */ -); - -void ivas_dirac_dec_output_synthesis_cov_init( - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: pointer to the state of the covariance synthesis */ - const int16_t nchan_in, /* i : number of input (tranport) channels */ - const int16_t nchan_out, /* i : number of output channels */ - const int16_t n_param_bands, /* i : number of total parameter bands */ - const int16_t n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ -); - -void ivas_dirac_dec_output_synthesis_cov_close( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i : handle for the covariance synthesis parameters */ - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */ -); - - -void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( - float *Cldfb_RealBuffer_in, /* i : input channel filter bank samples (real part) */ - float *Cldfb_ImagBuffer_in, /* i : input channel filter bank samples (imaginary part) */ - float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (real part) */ - float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (imaginary part) */ - float *mixing_matrix[], /* i : parameter band wise mixing matrices (direct part) */ - float *mixing_matrix_res[], /* i : parameter band wise mixing matrices (residual part) */ - const uint16_t slot_idx_sfr, /* i : time slot index for the current slot within the current subframe */ - const uint16_t slot_idx_tot, /* i : time slot index for the current slot within the frame */ - const int16_t nX, /* i : number of input channels */ - const int16_t nY, /* i : number of output channels */ - PARAM_MC_DEC_HANDLE hParamMC /* i : handle to the Parametric MC decoder state */ -); - - -void FdCngEncodeDiracMDCTStereoSID( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ -); - -void FdCngDecodeDiracMDCTStereoSID( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -); - - -/*----------------------------------------------------------------------------------* - * SPAR prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_spar_enc_open( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder handle */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -); - -ivas_error ivas_spar_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *data_f[], /* i/o: input/transport audio channels */ - const int16_t input_frame, /* i : input frame length */ - int16_t *nb_bits_metadata, /* i : number of MD bits written */ - BSTR_ENC_HANDLE hMetaData /* o : MetaData handle */ -); - -ivas_error ivas_spar_dec_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -); - - -ivas_error ivas_spar_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - int16_t *nb_bits_read /* o : number of MD bits read */ -); - -void ivas_spar_config( - int32_t ivas_total_brate, /* i : codec total bitrate */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - int16_t *nchan_transport, /* o : number of transport channels */ - int16_t *nSCE, /* o : number of SCEs */ - int16_t *nCPE, /* o : number of CPEs */ - int32_t *core_nominal_brate, /* o : core-coding nominal bitrate */ - const int16_t sid_format /* i : IVAS format indicator from SID frame */ -); - -ivas_error ivas_sba_linear_renderer( - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nchan_in, /* i : number of input ambisonics channels */ - const int16_t nchan_ism, /* i : number of objects */ - const AUDIO_CONFIG output_config, /* i : output audio configuration */ - const IVAS_OUTPUT_SETUP output_setup /* i : output format setup */ -); - -void ivas_sba_mix_matrix_determiner( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - float *output[], /* i/o: transport/output audio channels */ - const int16_t bfi, /* i : BFI flag */ - const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ - const int16_t output_frame, /* i : output frame length */ - const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */ -); - -/* AGC */ -/*! r: AGC enable flag */ - -ivas_error ivas_spar_agc_enc_open( - ivas_agc_enc_state_t **hAgcEnc, /* i/o: AGC decoder handle */ - const int32_t input_Fs, /* i : input sampling rate */ - const int16_t nchan_inp /* i : number of input channels */ -); - -void ivas_spar_agc_enc_close( - ivas_agc_enc_state_t **hAgcEnc /* i/o: AGC encoder handle */ -); - -void ivas_agc_enc_process( - ivas_agc_enc_state_t *hAgcEnc, /* i/o: AGC encoder handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ - float **ppPcm_in, /* i : input audio channels */ - float **ppPcm_out, /* o : output audio channels */ - const int16_t n_channels, /* i : number of channels */ - const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */ -); - -ivas_error ivas_spar_agc_dec_open( - ivas_agc_dec_state_t **hAgcDec, /* i/o: AGC decoder handle */ - const int32_t output_Fs /* i : output sampling rate */ -); - -void ivas_spar_agc_dec_close( - ivas_agc_dec_state_t **hAgcDec /* i/o: AGC decoder handle */ -); - - -void ivas_agc_dec_process( - ivas_agc_dec_state_t *hAgcDec, /* i/o: AGC decoder handle */ - float *pcm_in[], /* i : input audio channels */ - float *pcm_out[], /* o : output audio channels */ - const int16_t n_channels, /* i : number of channels */ - const int16_t output_Fs /* i : output sampling rate */ -); - -void ivas_agc_read_bits( - ivas_agc_dec_state_t *hAgcDec, /* i/o: AGC decoder handle */ - Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - const int16_t n_channels, /* i : number of channels */ - const int16_t AGC_flag /* i : AGC on/off flag */ -); - -void ivas_agc_initWindowFunc( - float *pWinFunc, - const int16_t length -); - -void ivas_agc_calcGainParams( - uint16_t *absEmin, - uint16_t *betaE, - uint16_t *maxAttExp, - const int16_t numCoeffs -); - -float ivas_get_mdct_scaling_gain( - const int16_t dct_len_by_2 -); - -void ivas_get_twid_factors( - const int16_t length, - const float **pTwid_re, - const float **pTwid_im -); - -int16_t ivas_get_bw_idx_from_sample_rate( - const int32_t sampling_rate /* i : sampling rate */ -); - -/*! r: config. table index */ -int16_t ivas_get_spar_table_idx( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t sba_order, /* i : IVAS SBA order */ - const int16_t bwidth, /* i : audio bandwidth */ - int16_t *bitlen, /* o : number of bits */ - int16_t *ind /* o : indice */ -); - -/*! r: number of transport channels */ -int16_t ivas_get_sba_num_TCs( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t sba_order /* i : IVAS SBA order */ -); - - -void ivas_spar_bitrate_dist( - int32_t core_brates_act[], /* o : bitrates per core-coder */ - const int16_t nAvailBits, /* i : number of available bits */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void ivas_mdct( - const float *pIn, - float *pOut, - const int16_t length -); - -void ivas_dct_windowing( - const int16_t fade_len, - const int16_t full_len, - const int16_t dct_len, - const int16_t zero_pad_len, - const float *pWindow_coeffs, - const int16_t frame_len, - float *pOut_buf, - float *pBuffer_prev, - float *pTemp_lfe -); - -void ivas_tda( - const float *pIn, - float *pOut, - const int16_t length -); - -void ivas_imdct( - const float *pIn, - float *pOut, - const int16_t length -); - -void ivas_itda( - const float *re, - float *pOut, - const int16_t length -); - -void ivas_spar_get_cldfb_gains( - SPAR_DEC_HANDLE hSpar, - HANDLE_CLDFB_FILTER_BANK cldfbAnaDec0, - HANDLE_CLDFB_FILTER_BANK cldfbSynDec0, - const DECODER_CONFIG_HANDLE hDecoderConfig -); - -/*! r: 1 if prediction residual channel */ - -void ivas_spar_dec_agc_pca( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* i/o: input/output audio channels */ - const Word16 output_frame /* i : output frame length */ -); - -void ivas_spar_dec_set_render_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nCldfbTs /* i : number of CLDFB time slots */ -); - -void ivas_spar_dec_set_render_params( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */ -); - -void ivas_spar_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ -); - -void ivas_sba_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ -); - -ivas_error ivas_sba_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - -void ivas_spar_dec_upmixer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* o : output audio channels */ - const int16_t nchan_internal /* i : number of internal channels */ -); - -void ivas_spar_dec_upmixer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* i/o: input/output audio channels */ - const int16_t nchan_internal, /* i : number of internal channels */ - const int16_t output_frame /* i : output frame length */ -); - -/* MD module */ - -void ivas_spar_md_enc_close( - ivas_spar_md_enc_state_t **hMdEnc /* i/o: SPAR MD encoder handle */ -); - -void ivas_compute_spar_params( - float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], - float dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], - const int16_t i_ts, - float ***mixer_mat, - const int16_t start_band, - const int16_t end_band, - const int16_t dtx_vad, - const int16_t num_ch, - const int16_t bands_bw, - const int16_t active_w, - const int16_t active_w_vlbr, - ivas_spar_md_com_cfg *hSparCfg, - ivas_spar_md_t *hSparMd, - float *pWscale, - const int16_t from_dirac, - const int16_t dyn_active_w_flag -); - -void ivas_create_fullr_dmx_mat( - float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], - float dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], - float ***mixer_mat, - const int16_t in_chans, - const int16_t start_band, - const int16_t end_band, - const int16_t active_w, - ivas_spar_md_com_cfg *hMdCfg -); - -void ivas_calc_c_p_coeffs( - ivas_spar_md_t *pSparMd, - float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], - const int16_t i_ts, - float ***mixer_mat, - const int16_t num_ch, - const int16_t num_dmx, - const int16_t band_idx, - const int16_t dtx_vad, - const int16_t compute_p_flag, - const int16_t dyn_active_w_flag -); - -void ivas_get_spar_md_from_dirac( - float azi_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES], - float ele_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES], - float diffuseness[IVAS_MAX_NUM_BANDS], - const int16_t n_ts, - float ***mixer_mat, - ivas_spar_md_t *hSpar_md, - ivas_spar_md_com_cfg *hSpar_md_cfg, - const int16_t start_band, - const int16_t end_band, - const int16_t order, - const int16_t dtx_vad, - float Wscale_d[IVAS_MAX_NUM_BANDS], - const uint8_t useLowerRes, - const int16_t active_w_vlbr, - const int16_t dyn_active_w_flag -); - -/*! r: number of MD subframes */ - -ivas_error ivas_spar_md_dec_matrix_open( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t num_md_sub_frames -); - -void ivas_spar_md_dec_matrix_close( - ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels /* i : number of internal channels */ -); - -ivas_error ivas_spar_md_dec_open( - ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t sba_order, /* i : SBA order */ - const int16_t sid_format, /* i : SID format */ - const int32_t last_active_ivas_total_brate /* i : IVAS last active bitrate */ -); - -void ivas_spar_md_dec_close( - ivas_spar_md_dec_state_t **hMdDec /* i/o: SPAR MD decoder handle */ -); - -void ivas_spar_get_parameters( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t ts, /* i : time slot index */ - const int16_t num_ch_out, /* i : number of channels out */ - const int16_t num_ch_in, /* i : number of channels in */ - const int16_t num_spar_bands, /* i : number of SPAR bands */ - float par_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] /* o : mixing matrix */ -); - -ivas_error ivas_spar_md_dec_init( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t sba_order /* i : SBA order */ -); - -void ivas_spar_md_dec_process( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t sba_order /* i : SBA order */ -); - -void ivas_spar_to_dirac( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t dtx_vad, /* i : DTX frame flag */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t bw, /* i : band joining factor */ - const int16_t dyn_active_w_flag /* i : dynamic active W flag */ -); - -void ivas_spar_update_md_hist( - ivas_spar_md_dec_state_t *hMdDec /* i/o: SPAR MD decoder handle */ -); - -int16_t ivas_spar_chk_zero_coefs( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -); - -void ivas_spar_smooth_md_dtx( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t num_md_sub_frames /* i : number of metadata subframes */ -); - -void ivas_spar_setup_md_smoothing( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t num_md_sub_frames /* i : number of metadata subframes */ -); - -void ivas_spar_dec_gen_umx_mat( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t bfi, /* i : bad frame indicator */ - const int16_t num_md_sub_frames -); - - - - - -/* Transient detector module */ -ivas_error ivas_transient_det_open_fx( - ivas_trans_det_state_t **hTranDet, /* i/o: Transient detector handle */ - const Word32 sampling_rate /* i : sampling rate */ -); - -void ivas_transient_det_close_fx( - ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */ -); - -void ivas_transient_det_process( - ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ - float *pIn_pcm, /* i : input audio channels */ - const int16_t frame_len, /* i : frame length in samples */ - int16_t transient_det[2] /* o : transient det outputs */ -); - -void ivas_td_decorr_get_ducking_gains( - ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ - float *pIn_pcm, - float *pIn_duck_gains, - float *pOut_duck_gains, - const int16_t frame_len, - const int16_t tdet_flag -); - -#define IVAS_CMULT_FLOAT( in1_re, in1_im, in2_re, in2_im, out1_re, out1_im ) \ - out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); MAC(1); MULT(1); \ - out1_im = ( in1_re * in2_im ) + ( in2_re * in1_im ); MAC(1); MULT(1); - -#define IVAS_CALCULATE_ABS( re, im, out ) \ - out = sqrtf( ( re * re ) + ( im * im ) ); MAC(1); MULT(1); SQRT(1); - -#define IVAS_CALCULATE_RABS( re, out ) \ - out = sqrtf( re * re ); MULT(1); SQRT(1); - -#define IVAS_CALCULATE_SQ_ABS( re, im, out ) \ - out = (float) ( ( re * re ) + ( im * im ) ); MAC(1); MULT(1); - -#define IVAS_RMULT_DOUBLE( in1_re, in2_re, out1_re ) \ - out1_re = ( in1_re * in2_re ); DMULT(1); \ - -#define IVAS_CALCULATE_SQ_ABS_N( re, out ) \ - out = (float) ( re * re ); MULT(1); - -#define IVAS_RMULT_FLOAT( in1_re, in2_re, out1_re ) \ - out1_re = ( in1_re * in2_re ); MULT(1); - - -/* PCA */ -void ivas_pca_enc_init( - PCA_ENC_STATE *hPCA /* i/o: PCA encoder structure */ -); - -void ivas_pca_read_bits( - Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - PCA_DEC_STATE *hPCA /* i/o: PCA encoder structure */ -); - -void ivas_pca_dec_init( - PCA_DEC_STATE *hPCA /* i/o: PCA decoder structure */ -); - -void ivas_pca_dec( - PCA_DEC_STATE *hPCA, /* i/o: PCA decoder structure */ - const int16_t n_samples, /* i : output frame length */ - const int16_t n_channels, /* i : number of channels */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */ - const int16_t bfi, /* i : bad frame indicator */ - float *pcm_out[] /* o : output audio channels */ -); - -void pca_dec_s3( - const int32_t index, - float *q -); - - -void ivas_huffman_encode_fx( - ivas_huffman_cfg_t *huff_cfg, - Word16 in, - Word16 *hcode, - Word16 *hlen -); - - - -ivas_error ivas_huffman_decode( - ivas_huffman_cfg_t *huff_cfg, - Decoder_State *st0, - int16_t *dec_out -); - -void ivas_arith_decode_cmplx_cell_array( - ivas_arith_t *pArith_re, - ivas_arith_t *pArith_re_diff, - Decoder_State *st0, - ivas_cell_dim_t *pCell_dims, - int16_t *pDo_diff, const int16_t nB, - int16_t *pSymbol_re, - int16_t *pSymbol_re_old -); - - - - -void ivas_ari_done_encoding_14bits( - BSTR_ENC_HANDLE hBstr, Tastat *s -); - - -void ivas_wrap_arround( - int16_t *pArr, - const int16_t min_val, - const int16_t max_val, - const int16_t length -); - -void ivas_get_cum_freq_model( - const int16_t *pFreq_model, - const int16_t length, - int16_t *pCum_freq_model -); - -int16_t ivas_map_num_pred_r_to_idx( - const int16_t num_quant_points_pred_r, - const int16_t active_w_flag -); - -int16_t ivas_map_num_drct_r_to_idx( - const int16_t num_quant_points_drct_r -); - -int16_t ivas_map_num_decd_r_to_idx( - const int16_t num_quant_points_decd_r -); - -/* Quantization utilities */ -void ivas_quantise_real_values( - const float *values, - const int16_t q_levels, - const float min_value, - const float max_value, - int16_t *index, - float *quant, - const int16_t dim -); - - -void ivas_spar_quant_dtx_init( - ivas_spar_md_t *spar_md, - float *min_max -); - -void ivas_map_prior_coeffs_quant( - ivas_spar_md_prev_t *pSpar_md_prior, - ivas_spar_md_com_cfg *pSpar_md_cfg, - const int16_t qsi, - const int16_t nB -); - - -void ivas_clear_band_coeffs( - ivas_band_coeffs_t *pband_coeffs, - const uint16_t num_bands -); - -void ivas_clear_band_coeff_idx( - ivas_band_coeffs_ind_t *pband_coeff_idx, - const uint16_t num_bands -); - - -/*----------------------------------------------------------------------------------* - * MASA prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_masa_decode( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *nb_bits_read /* o : number of bits read */ -); - -void generate_gridEq( - SPHERICAL_GRID_DATA *data /* o : data structure for grid */ -); - -ivas_error ivas_masa_enc_open_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -void ivas_masa_enc_close_fx( - MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */ -); - -void ivas_masa_enc_reconfigure( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -ivas_error ivas_masa_dec_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : output synthesis signal */ -); - -ivas_error ivas_masa_encode( - MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder structure */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ - int16_t *nb_bits_metadata, /* o : number of metadata bits written */ - const int16_t nchan_transport, /* i : number of MASA input/transport channels */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t Opt_DTX_ON, /* i : DTX on flag */ - const int16_t element_mode, /* i : element mode */ - const ISM_MODE ism_mode, /* i : ISM format mode */ - const int16_t nchan_ism, /* i : number of ISM channels */ - ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS], /* i : ISM metadata handle */ - const int16_t idx_separated_object, /* i : index of the separated object */ - OMASA_ENC_HANDLE hOMasa, /* i : OMASA encoder handle */ - const int16_t ism_imp, /* i : importance of separated object */ - const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ -); - -void ivas_masa_estimate_energy( - MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder structure */ - float *data_f[], /* i : Input audio channels */ - const int16_t input_frame, /* i : frame length */ - const int16_t nchan_transport /* i : number of MASA input/transport channels */ -); - - -void ivas_masa_set_elements( - const int32_t ivas_total_brate, /* i : codec total bitrate */ - const int16_t mc_mode, /* i : MC format mode */ - const int16_t nchan_transport, /* i : number of MASA input/transport channels */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - int16_t *element_mode, /* o : element mode */ - int16_t *nSCE, /* o : number of SCEs */ - int16_t *nCPE, /* o : number of CPEs */ - const int16_t ivas_format, /* i : IVAS format */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const int32_t ism_total_brate /* i : initial ISM total bitrate */ -); - -/*! r: valid or not 1/0 */ -int16_t valid_ratio_index( - int16_t index, /* i : index to be checked */ - const int16_t K, /* i : L1 norm to check against */ - const int16_t len /* i : vector length */ -); - -void reconstruct_ism_ratios( - int16_t *ratio_ism_idx, - const int16_t nchan_ism, - const float step, - float *q_energy_ratio_ism -); - -void distribute_evenly_ism( - int16_t *idx, - const int16_t K, - const int16_t nchan_ism -); - - -int16_t ivas_qmetadata_encode_extended_gr_length_fx( - const uint16_t value, - const uint16_t alphabet_size, - const int16_t gr_param); - -void ivas_qmetadata_encode_extended_gr_fx( - BSTR_ENC_HANDLE hMetaData, /* i/o: q_metadata handle */ - const uint16_t value, /* i : value to be encoded */ - const uint16_t alphabet_size, /* i : alphabet size */ - const int16_t gr_param); /* i : GR order */ - -/*! r: CPE bitrate value */ -int32_t calculate_cpe_brate_MASA_ISM( - const ISM_MODE ism_mode, /* i : ism mode */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nchan_ism /* i : number of objects */ -); - -void ivas_merge_masa_metadata( - MASA_ENCODER_HANDLE hMasa, /* i/o: MASA enc handle. source for MASA metadata and combined metadata will be here */ - OMASA_SPATIAL_META_HANDLE hOMasaMeta /* i : ISM-object metadata to be merged with the MASA metadata */ -); - - -/*!r : number of bits for ISM ratio index */ -int16_t bits_index_ism_ratio( - const int16_t nchan_ism /* i : number of objects */ -); - -void calculate_nbits_meta( - const int16_t nchan_ism, - float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], - float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], - const int16_t numSf, - const int16_t numCodingBands, - int16_t* bits_ism, - const int16_t idx_sep_obj, - const int16_t ism_imp -); - -/*! r: limitation flag */ -int16_t calculate_brate_limit_flag( - const int16_t ism_imp[], /* i : ISM importance flags */ - const int16_t nchan_ism /* i : number of objects */ -); - -void ivas_masa_set_coding_config( - MASA_CODEC_CONFIG* config, /* i/o: MASA coding config structure */ - int16_t* band_mapping, /* o : Band mapping used */ - const int32_t ivas_total_brate, /* i : codec total bitrate */ - const int16_t nchan_transport, /* i : number of transport channel (mono/stereo) */ - const uint8_t isMcMasa /* i : toggle for selecting McMASA specific config */ -); - -/*! r: Surround coherence significant flag */ -uint8_t ivas_masa_surrcoh_signicant( - float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Surround coherence */ - float diffuse_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Diffuse to total ratio */ - const int16_t nSubFrames, /* i : Number of sub frames */ - const int16_t nBands /* i : Number of frequency bands */ -); - -void masa_compensate_two_dir_energy_ratio_index( - const int16_t ratio_index_1, /* i : Input ratio for direction 1 */ - const int16_t ratio_index_2, /* i : Input ratio for direction 2 */ - int16_t *ratio_index_mod1, /* o : Output modified ratio for direction 1 */ - int16_t *ratio_index_mod2, /* o : Output modified ratio for direction 2 */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - -void ivas_set_qmetadata_maxbit_req_fx( - IVAS_QMETADATA_HANDLE hQMetaData, /* o : qmetadata structure where the requirement value is set */ - const IVAS_FORMAT ivas_format /* i : IVAS format */ -); - -void masa_sample_rate_band_correction( - MASA_CODEC_CONFIG *config, /* i/o: MASA codec config */ - int16_t *band_mapping, /* i/o: Band mapping used and modified */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ - const uint8_t maxBand, /* i : max band */ - uint8_t is_encoder, /* i : signals if called at encoder */ - MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ -); - -void invdct4_transform( - float *v, /* i : input vector */ - uint8_t *invdct_v /* o : transformed vector */ -); - - -void ivas_spar_param_to_masa_param_mapping( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ - const int16_t subframe /* i : Subframe to map */ -); - -/*---------------------------------------------------------------------------------* - * Binaural FastConv Renderer Prototypes -*-----------------------------------------------------------------------------------*/ - - -void ivas_binaural_hrtf_close( - HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */ -); - -void ivas_binRenderer( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ - const int16_t numTimeSlots, /* i : number of time slots to process */ - float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - float Cldfb_ImagBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] /* i : LS signals */ -); - -void ivas_binaural_add_LFE( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t output_frame, /* i : length of input frame */ - float *input_f[], /* i : transport channels */ - float *output_f[] /* o : synthesized core-coder transport channels/DirAC output */ -); - -/*----------------------------------------------------------------------------------* - * renderer prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_ism_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_ism_renderer_close( - ISM_RENDERER_HANDLE *hIsmRendererData /* i/o: ISM renderer handle */ -); - -void ivas_ism_render_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: core-coder transport channels/object output */ - const int16_t n_samples_to_render /* i : output frame length per channel */ -); - - -void ivas_mc2sba( - IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ - float *in_buffer_td[], /* i : MC signals (on input) and the HOA3 (on output) */ - float *buffer_td[], /* o : MC signals (on input) and the HOA3 (on output) */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t sba_order, /* i : SBA order */ - const float gain_lfe /* i : gain for LFE, 0=ignore LFE */ -); - -void ivas_param_mc_mc2sba_cldfb( - IVAS_OUTPUT_SETUP hTransSetup, /* i : transported MC Format */ - float *hoa_encoder, /* i : HOA3 encoder for the transported MC format */ - const int16_t slot_idx, /* i : current slot in the subframe */ - float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ - float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ - const int16_t nBands, /* i : number of synth CLDFB bands */ - const float gain_lfe /* i : gain applied to LFE */ -); - - -/*----------------------------------------------------------------------------------* - * Amplitude Panning VBAP prototypes - *----------------------------------------------------------------------------------*/ - -void panning_wrap_angles( - const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ - const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ - float *azi_wrapped, /* o : wrapped azimuth component */ - float *ele_wrapped /* o : wrapped elevation component */ -); - -/*----------------------------------------------------------------------------------* - * LS Renderer prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_ls_setup_conversion_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_ls_setup_conversion_close( - LSSETUP_CONVERSION_HANDLE *hLsSetUpConversion /* i/o: LS converter handle */ -); - - -void ivas_ls_setup_conversion( - Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ - const int16_t input_chans, /* i : number of input channels to the renderer */ - const int16_t output_frame, /* i : frame length */ - float *input[], /* i : LS input/output synthesis signal */ - float *output[] /* i/o: LS input/output synthesis signal */ -); - -void ivas_ls_setup_conversion_process_mdct( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[] /* i/o: output synthesis signal */ -); - -void ivas_ls_setup_conversion_process_mdct_param_mc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *x[][NB_DIV] /* i/o: output synthesis signal */ -); - -void ivas_lssetupconversion_process_param_mc( - Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ - const int16_t num_timeslots, /* i : number of time slots to process */ - float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ - float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ - int16_t channel_active[MAX_CICP_CHANNELS] /* i : bitmap indicating which output channels are active */ -); - - -/*----------------------------------------------------------------------------------* - * Custom loudspeaker setup prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_ls_custom_open( - LSSETUP_CUSTOM_HANDLE *hLsSetupCustom /* o : Custom loudspeaker setup handle */ -); - - - -/*----------------------------------------------------------------------------------* - * McMASA prototypes - *----------------------------------------------------------------------------------*/ - - -ivas_error ivas_mcmasa_dec_reconfig( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -); - -void ivas_mcmasa_setNumTransportChannels( - int16_t* nchan_transport, /* o : Pointer to number of transport channels to be set */ - int16_t* element_mode, /* o : Pointer to element mode to be set */ - const int32_t ivas_total_brate /* i : Total bitrate of IVAS */ -); - -void ivas_mcmasa_set_separate_channel_mode( - uint8_t *separateChannelEnabled, /* o : Pointer to separate channel toggle */ - int16_t *separateChannelIndex, /* o : Pointer to separate channel index */ - const int32_t ivas_total_brate /* i : Total bitrate of IVAS */ -); - -void ivas_mcmasa_split_brate( - const uint8_t separateChannelEnabled, /* i : Transport running in "separate channel" mode */ - const int32_t ivas_total_brate, /* i : Total bitrate available to be split */ - const int16_t nSCE, /* i : Number of SCEs in use (0 or 1) */ - const int16_t nCPE, /* i : Number of CPEs in use (0 or 1) */ - int32_t *brate_sce, /* o : Pointer to SCE element bitrate */ - int32_t *brate_cpe /* o : Pointer to CPE element bitrate */ -); - - -void ivas_mcmasa_dmx_modify_fx( - const Word16 n_samples, /* i : input frame length in samples */ - Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/ - Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/ - const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */ - const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/ -); - -ivas_error ivas_mono_dmx_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - -void ivas_mono_dmx_renderer_close( - MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ -); - -void ivas_mono_downmix_render_passive( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: synthesized core-coder transport channels/mono output */ - const int16_t output_frame /* i : output frame length */ -); - - -/*----------------------------------------------------------------------------------* - * LFE encoder low pass filter prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_create_lfe_lpf_enc( - ivas_filters_process_state_t **hLfeLpf, /* o : LFE LPF handle */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void ivas_lfe_lpf_enc_close_fx( - ivas_filters_process_state_t **hLfeLpf /* i/o: LFE LPF handle */ -); - -void ivas_lfe_lpf_enc_apply( - ivas_filters_process_state_t *hLfeLpf, /* i/o: LFE LPF handle */ - float data_lfe_ch[], /* i/o: LFE signal */ - const int16_t input_frame /* i : input frame length per channel */ -); - - -/*----------------------------------------------------------------------------------* - * LFE Coding prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_create_lfe_enc_fx( - LFE_ENC_HANDLE *hLFE, /* o : IVAS LFE encoder structure */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void ivas_lfe_enc_close_fx( - LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */ -); - -void ivas_lfe_enc( - LFE_ENC_HANDLE hLFE, /* i/o: LFE encoder handle */ - float data_lfe_ch[], /* i : input LFE signal */ - const int16_t input_frame, /* i : input frame length per channel */ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ -); - -void ivas_lfe_tdplc( - LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ - float *prevsynth, /* i : previous frame synthesis */ - float *ytda, /* o : output time-domain buffer */ - const int16_t output_frame /* i : output frame length */ -); -void ivas_lfe_window_init( - LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle */ - const int32_t sampling_rate, /* i : sampling rate */ - const int16_t frame_len /* i : frame length in samples */ -); - -void ivas_lfe_lpf_select_filt_coeff( - const int32_t sampling_rate, /* i : sampling rate */ - const int16_t order, /* i : filter order */ - const float **ppFilt_coeff /* o : filter coefficients */ -); - -void ivas_filters_init( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - const float *filt_coeff, /* i : filter coefficients */ - const int16_t order /* i : filter order */ -); - -void ivas_filters_init_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - const Word32 *filt_coeff_fx, /* i : filter coefficients Q31- *filt_coeff_e */ - const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */ - const Word16 order ) ; - -void ivas_filter_process( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - float *pIn_Out, /* i : signal subject to filtering */ - const int16_t length /* i : filter order */ -); - -void ivas_filter_process_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ - const Word16 length, /* i : filter order */ - Word16 q_factor ); - -/*----------------------------------------------------------------------------------* - * OSBA prototypes - *----------------------------------------------------------------------------------*/ -ivas_error ivas_osba_enc_reconfig( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); -ivas_error ivas_osba_data_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -); - -ivas_error ivas_osba_dirac_td_binaural_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - - -void ivas_osba_data_close( - SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ -); - - -/*----------------------------------------------------------------------------------* -* OMASA prototypes -*---------------------------------------------------------------------------------*/ - -ivas_error ivas_omasa_enc_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -void ivas_omasa_enc_close( - OMASA_ENC_HANDLE *hOMasa /* i/o: encoder OMASA handle */ -); - - -ivas_error ivas_omasa_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : output synthesis signal */ -); - - - - -void ivas_set_surplus_brate_enc( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -#ifdef DEBUG_MODE_INFO - , - const int16_t *nb_bits_metadata /* i : number of metadata bits */ -#endif -); - -void ivas_set_surplus_brate_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int32_t *ism_total_brate /* i : ISM total bitrate */ -); - - -void ivas_set_ism_importance_interformat( - const int32_t ism_total_brate, /* i/o: ISms total bitrate */ - const int16_t nchan_transport, /* i : number of transported channels */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - SCE_ENC_HANDLE hSCE[], /* i/o: SCE encoder handles */ - const float lp_noise_CPE, /* i : LP filtered total noise estimation */ - int16_t ism_imp[] /* o : ISM importance flags */ -); - - -/*! r: adjusted bitrate */ -int32_t ivas_interformat_brate( - const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t nchan_ism, /* i : number of ISM channels */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t ism_imp, /* i : ISM importance flag */ - const int16_t limit_flag /* i : flag to limit the bitrate increase */ -); - -void ivas_combined_format_brate_sanity( - const int32_t element_brate, /* i : element bitrate */ - const int16_t core, /* i : core */ - const int32_t total_brate, /* i : total bitrate */ - int32_t *core_brate, /* i/o: core bitrate */ - int16_t *inactive_coder_type_flag, /* o : inactive coder_type flag */ - int16_t *diff_nBits /* o : number of differential bits */ -); - -ISM_MODE ivas_omasa_ism_mode_select( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nchan_ism /* i : number of input ISM's */ -); - -void ivas_set_omasa_TC( - const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t nchan_ism, /* i : number of input ISMs */ - int16_t *nSCE, /* o : number of SCEs */ - int16_t *nCPE /* o : number of CPEs */ -); - -void ivas_merge_masa_transports( - float data_in_f1[][L_FRAME48k], /* i : Transport audio signals 1 */ - float *data_in_f2[], /* i : Transport audio signals 2 */ - float *data_out_f[], /* o : Merged transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t num_transport_channels /* i : Number of transport audio signals */ -); - - -ivas_error ivas_omasa_ism_metadata_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int32_t ism_total_brate, /* i : ISM total bitrate */ - int16_t *nchan_ism, /* o : number of ISM separated channels */ - int16_t *nchan_transport_ism, /* o : number of ISM TCs */ - const int16_t dirac_bs_md_write_idx, /* i : DirAC bitstream write index */ - int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ -); - -void ivas_omasa_preProcessStereoTransportsForMovedObjects( - Decoder_Struct *st_ivas, - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - const int16_t nBins, - const int16_t subframe -); - -ivas_error ivas_omasa_separate_object_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_omasa_separate_object_renderer_close( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_omasa_separate_object_render_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesRendered, /* i : number of samples rendered */ - float input_f[][L_FRAME48k], /* i : separated object signal */ - float *output_f[], /* o : rendered time signal */ - const int16_t subframes_rendered, /* i : number of subframes rendered */ - const int16_t slots_rendered /* i : number of CLDFB slots rendered */ -); - -void ivas_omasa_encode_masa_to_total( - float masa_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], - BSTR_ENC_HANDLE hMetaData, - const int16_t low_bitrate_mode, - const int16_t nbands, - const int16_t nblocks -); - -void ivas_omasa_decode_masa_to_total( - uint16_t *bit_stream, - int16_t *index, - float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], - const int16_t nbands, - const int16_t nblocks -); - -void ivas_omasa_modify_masa_energy_ratios( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_MAXIMUM_CODING_SUBBANDS] -); - - -/*----------------------------------------------------------------------------------* - * TD Binaural Object renderer - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_td_binaural_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame /* i : output frame length */ -); - -ivas_error ivas_td_binaural_renderer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ -); - -/*----------------------------------------------------------------------------------* - * Filter-bank (FB) Mixer - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_fb_set_cfg( - IVAS_FB_CFG **pFb_cfg_out, /* o : FB config. handle */ - const int16_t ivas_format, /* i : IVAS format */ - const int16_t num_in_chans, /* i : number of FB input channels */ - const int16_t num_out_chans, /* i : number of FB output channels */ - const int16_t active_w_mixing, /* i : active_w_mixing flag */ - const int32_t sampling_Fs, /* i : sampling rate */ - const int16_t nachan_dirac_ana /* i : number of DirAR analysis channels */ -); - -void ivas_fb_mixer_pcm_ingest( - IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ - float *pcm_in[], /* i : input audio channels */ - float **ppOut_pcm, /* o : output audio channels */ - const int16_t frame_length, /* i : frame length */ - const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] -); - -void ivas_fb_mixer_update_prior_input( - IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ - float *pcm_in[], /* i : input audio channels */ - const int16_t length, /* i : length of time slot */ - const int16_t nchan_fb_in /* i : number of analysis channels */ -); - -void ivas_fb_mixer_get_windowed_fr( - IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ - float *pcm_in[], /* i : input audio channels */ - float *frame_f_real[], /* o : real freq domain values */ - float *frame_f_imag[], /* o : imag freq domain values */ - const int16_t length, /* i : number of new samples in time slot */ - const int16_t mdft_len, /* i : MDFT frame length */ - const int16_t nchan_fb_in /* i : number of analysis channels */ -); - -/*! r: number of spectral bands */ - -/* clang-format on */ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 8527e6703..85fefadbc 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "cnst.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 422622552..7c7d49381 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -36,7 +36,7 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 1ab797ded..292721723 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -35,7 +35,7 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 643874a82..44b7a0bec 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 3aed4d3b1..24e61c5f3 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -34,7 +34,7 @@ #include #include #include "options.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 7cd93affa..2535eb6ee 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -35,7 +35,7 @@ #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" #include "rom_com.h" diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 210425b88..fdf18e705 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -37,7 +37,7 @@ #include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 384865a1a..dec4d3465 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -35,7 +35,7 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 697ae6345..ff895755d 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -37,7 +37,7 @@ #include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" @@ -1656,7 +1656,7 @@ void ivas_param_mc_dec_digest_tc_fx( test(); IF( is_next_band && skip_next_band ) { - continue; + CONTINUE; } IF( is_next_band ) { @@ -1697,7 +1697,7 @@ void ivas_param_mc_dec_digest_tc_fx( test(); IF( is_next_band && skip_next_band ) { - continue; + CONTINUE; } /* Cx for transport channels */ IF( is_next_band ) @@ -1794,7 +1794,7 @@ void ivas_param_mc_dec_digest_tc_fx( test(); IF( is_next_band && skip_next_band ) { - continue; + CONTINUE; } IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 3c2ba7587..762b350d1 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -36,7 +36,7 @@ #include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_mcmasa_dec_fx.c b/lib_dec/ivas_mcmasa_dec_fx.c index 1b1715c21..d12b190c6 100644 --- a/lib_dec/ivas_mcmasa_dec_fx.c +++ b/lib_dec/ivas_mcmasa_dec_fx.c @@ -33,7 +33,7 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index fe39fd8e3..b42eb534b 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -88,9 +88,9 @@ void ivas_mct_side_bits_fx( FOR( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - if ( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } mdct_read_IGF_bits_fx( st, st0 ); @@ -231,7 +231,7 @@ void ivas_mct_core_dec( { IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } i = add( i, 1 ); } @@ -258,15 +258,15 @@ void ivas_mct_core_dec( { st = sts[ch]; - if ( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) /*indicates LFE */ + IF( EQ_32( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) /*indicates LFE */ { - continue; + CONTINUE; } test(); - if ( bfi && EQ_16( st->core, ACELP_CORE ) ) /*no igf processing needed*/ + IF( bfi && EQ_16( st->core, ACELP_CORE ) ) /*no igf processing needed*/ { - continue; + CONTINUE; } IF( EQ_16( st->core, TCX_10_CORE ) ) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 884a44c9e..abf735b5a 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -38,7 +38,7 @@ #include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 35d38d03a..151ba7d1e 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1549,7 +1549,7 @@ void ivas_mdct_core_tns_ns_fx( } /* nothing to do for missing LFE */ - continue; + CONTINUE; } FOR( k = 0; k < nSubframes[ch]; k++ ) diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index b88b68915..79683e402 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index afa604684..9975493fb 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -35,7 +35,7 @@ #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 6f1a233c9..b048470d4 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -34,7 +34,7 @@ #include #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 84b6fe46d..c7bf0655d 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -35,7 +35,7 @@ #include #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index f04350366..eb2a40ecb 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -36,7 +36,7 @@ #include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index 8748342ed..bbe63e965 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include @@ -319,7 +319,7 @@ Word16 ivas_sba_remapTCs_fx( Copy32( sba_data_fx[2], sba_data_fx[3], output_frame ); /*Q11*/ } } - IF( GT_16( st_ivas->nchan_transport, 3 ) ) + IF( GE_16( st_ivas->nchan_transport, 3 ) ) { Word16 i = 0; move16(); diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index fd25e7ea7..3bc6d337e 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -372,7 +372,7 @@ void dequantize_sns_fx( IF( zero_side_flag[k] ) { set32_fx( snsQ_fx, 0, M ); - continue; + CONTINUE; } nStages = SNS_MSVQ_NSTAGES_SIDE; diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index 34a194898..c6c7565a9 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -37,7 +37,7 @@ #include "ivas_stat_dec.h" #include "prot_fx.h" #include "string.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index ef3baee3c..dc06ddc5a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -35,7 +35,7 @@ #include #include #include "ivas_cnst.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 7c28c3309..e6fc25e36 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -5401,7 +5401,7 @@ void TNSAnalysisStereo_fx( st = sts[ch]; IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } hTcxEnc = st->hTcxEnc; diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 6623cfd45..9256be408 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -476,7 +476,7 @@ void ivas_ism_coh_estim_dtx_enc_fx( { hISMDTX->coh_fx[sce_id] = 32767; /* 1 in Q15 */ move16(); - continue; + CONTINUE; } st = hSCE[sce_id]->hCoreCoder[0]; diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 3272768e9..9027b2669 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -2543,7 +2543,7 @@ void ivas_mdct_quant_coder_fx( { ignore_chan[ch] = 1; move16(); - continue; + CONTINUE; } IF( EQ_16( st->hTcxEnc->tcxMode, TCX_20 ) ) @@ -2615,7 +2615,7 @@ void ivas_mdct_quant_coder_fx( IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } FOR( n = 0; n < nSubframes; n++ ) @@ -2646,7 +2646,7 @@ void ivas_mdct_quant_coder_fx( IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } FOR( n = 0; n < nSubframes; n++ ) @@ -2730,9 +2730,9 @@ void ivas_mdct_quant_coder_fx( * Generate Bitstream *---------------------------------------------------------------*/ - if ( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + IF( EQ_16( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - continue; + CONTINUE; } nbits_start = st->hBstr->nb_bits_tot; move16(); diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index 93ee56461..dfd207c3e 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -680,7 +680,7 @@ Word16 quantize_sns_fx( IF( zero_side_flag[k] ) { set32_fx( snsQ_fx, 0, M ); - continue; + CONTINUE; } nStages = SNS_MSVQ_NSTAGES_SIDE; diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index b1a3f2f20..44f415dc7 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -586,7 +586,7 @@ void swb_bwe_enc_ivas_fx( IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { SWB_BWE_encoding_ivas_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32, - SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_exp, Q_synth ); + SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_exp, new_input_fx_exp ); } ELSE { @@ -3456,11 +3456,12 @@ static Word16 SWB_BWE_encoding_ivas_fx( global_gain_fx = L_shr( global_gain_fx, 1 ); /*2*Q_shb */ - Copy_Scale_sig32_16( yos_fx, yos_fx_16, inner_frame, 0 ); - mode = FD_BWE_class_fx( yos_fx_16, global_gain_fx, tilt_nb_fx, sub( Q_synth, Q16 ), Q_shb, st_fx ); + scale = s_min( L_norm_arr( yos_fx, inner_frame ), sub( Q27, Q_synth ) /* To accomodate 10 in Q_synth*/ ); + Copy_Scale_sig32_16( yos_fx, yos_fx_16, inner_frame, scale ); + mode = FD_BWE_class_fx( yos_fx_16, global_gain_fx, tilt_nb_fx, sub( add( Q_synth, scale ), Q16 ), Q_shb, st_fx ); push_indice( hBstr, IND_SWB_CLASS, mode, 2 ); - energy_control_ivas_fx( st_fx, ACELP_CORE, mode, -1, yos_fx_16, st_offset, energy_factor_fx, sub( Q_synth_lf, Q16 ) ); + energy_control_ivas_fx( st_fx, ACELP_CORE, mode, -1, yos_fx_16, st_offset, energy_factor_fx, sub( add( Q_synth_lf, scale ), Q16 ) ); FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) { diff --git a/lib_rend/ivas_allrad_dec_fx.c b/lib_rend/ivas_allrad_dec_fx.c index 770b62764..5023bee34 100644 --- a/lib_rend/ivas_allrad_dec_fx.c +++ b/lib_rend/ivas_allrad_dec_fx.c @@ -36,7 +36,7 @@ #include #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index e50ad32e1..36d18f859 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -34,7 +34,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "ivas_rom_binaural_crend_head.h" diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 1a5013059..8124c4967 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -33,7 +33,7 @@ #include "options.h" #include #include "ivas_cnst.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 0deb14c9b..65a68889a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -35,7 +35,7 @@ #include #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_binauralRenderer.h" #include "ivas_rom_binaural_crend_head.h" diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index b8b3c3ac7..1ffe0da74 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -36,7 +36,7 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_dirac_onsets_dec_fx.c b/lib_rend/ivas_dirac_onsets_dec_fx.c index e9af8483a..80adebfdd 100644 --- a/lib_rend/ivas_dirac_onsets_dec_fx.c +++ b/lib_rend/ivas_dirac_onsets_dec_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 40ed0ad58..6cf11887e 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -36,7 +36,7 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 35fedfc81..031a39855 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -36,7 +36,7 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 7a74e62da..543decbdd 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -36,7 +36,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index e3965fbff..93f9fbd83 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_error.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_limiter_fx.c b/lib_rend/ivas_limiter_fx.c index b66127e09..b212e5445 100644 --- a/lib_rend/ivas_limiter_fx.c +++ b/lib_rend/ivas_limiter_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "wmc_auto.h" #include diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index c74477365..fd20a9fab 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "lib_rend.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index e17b2f9f6..f3b4d1755 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -35,7 +35,7 @@ #include #include "ivas_cnst.h" #include "options.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "ivas_stat_rend.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 7b1e1fe91..1b5bc0d1b 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -34,7 +34,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index a7f46b2a4..01e35efe1 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include "prot_fx.h" #include -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index 7ee6c828b..0e61282d4 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_TdBinauralRenderer.h" #include "ivas_error.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index 971e2c2d1..210706d5b 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 307d38351..5787ded3f 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_objectRenderer_vec_fx.c b/lib_rend/ivas_objectRenderer_vec_fx.c index 4d259a68e..0d8c11aab 100644 --- a/lib_rend/ivas_objectRenderer_vec_fx.c +++ b/lib_rend/ivas_objectRenderer_vec_fx.c @@ -34,7 +34,7 @@ #include "options.h" #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" @@ -87,28 +87,6 @@ Word32 TDREND_SPATIAL_VecNorm_fx( return tmp; } - -/*-------------------------------------------------------------------* - * TDREND_SPATIAL_VecNormalize() - * - * Normalize vector to unit norm - *-------------------------------------------------------------------*/ - -void TDREND_SPATIAL_VecNormalize( - const float *Vec_p, /* i : Input vector */ - float *VecNorm_p /* o : Output vector */ -) -{ - float scaler; - - scaler = inv_sqrt( Vec_p[0] * Vec_p[0] + Vec_p[1] * Vec_p[1] + Vec_p[2] * Vec_p[2] ); - VecNorm_p[0] = scaler * Vec_p[0]; - VecNorm_p[1] = scaler * Vec_p[1]; - VecNorm_p[2] = scaler * Vec_p[2]; - - return; -} - void TDREND_SPATIAL_VecNormalize_fx( const Word32 *Vec_p_fx, /* i : Input vector q */ Word16 q, /* i : Input vector Q-factor */ @@ -172,25 +150,6 @@ void TDREND_SPATIAL_VecMapToNewCoordSystem_fx( return; } -void TDREND_SPATIAL_VecMapToNewCoordSystem( - const float *Vec_p, /* i : Input vector */ - const float *TranslVec_p, /* i : Translation vector */ - const float *DirVec_p, /* i : Direction vector */ - const float *UpVec_p, /* i : Up vector */ - const float *RightVec_p, /* i : Right vector */ - float *MappedVec_p, /* o : Transformed vector */ - float *LisRelPosAbs /* o : Transformed vector ignoring orientation */ -) -{ - v_sub( Vec_p, TranslVec_p, LisRelPosAbs, 3 ); - /* Evalute the relative Vec in the coordinates of the Orientation vectors, */ - /* which form an orthonormal basis */ - MappedVec_p[0] = dotp( LisRelPosAbs, DirVec_p, 3 ); - MappedVec_p[1] = dotp( LisRelPosAbs, RightVec_p, 3 ); - MappedVec_p[2] = dotp( LisRelPosAbs, UpVec_p, 3 ); - return; -} - /*-------------------------------------------------------------------* * TDREND_SPATIAL_EvalOrthonormOrient() * diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 5e175fae5..ba632c6ba 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -34,7 +34,7 @@ #include #include #include "ivas_cnst.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_stat_rend.h" diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index a124bf4bd..a25a8db53 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -33,7 +33,7 @@ #include "common_api_types.h" #include #include "options.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include #include diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 6fba496d5..9945d630e 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -34,7 +34,7 @@ #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 74be74497..8beb5a0ec 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -1,6 +1,6 @@ #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #ifdef FIX_DISCLAIMER #include #endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend_fx.h similarity index 69% rename from lib_rend/ivas_prot_rend.h rename to lib_rend/ivas_prot_rend_fx.h index b642e05d7..04afce118 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -93,25 +93,6 @@ ivas_error get_channel_config( * Limiter prototypes *----------------------------------------------------------------------------------*/ - -ivas_error ivas_limiter_open( - IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ - const int16_t num_channels, /* i : number of I/O channels */ - const int32_t sampling_rate /* i : sampling rate for processing */ -); - -void ivas_limiter_close( - IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */ -); - -void ivas_limiter_dec -( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ - const int16_t num_channels, /* i : number of channels to be processed */ - const int16_t output_frame, /* i : number of samples per channel in the buffer */ - const int16_t BER_detect /* i : BER detect flag */ -); void ivas_limiter_dec_fx( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ @@ -120,13 +101,7 @@ void ivas_limiter_dec_fx( const Word16 BER_detect, /* i : BER detect flag */ Word16 q_factor /* i : Q factor of the output samples */ ); -void limiter_process( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ - const float threshold, /* i : signal amplitude above which limiting starts to be applied */ - const int16_t BER_detect, /* i : BER detect flag */ - int16_t *strong_saturation_cnt /* i/o: counter of strong saturations (can be NULL) */ -); + void limiter_process_fx( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ const Word16 output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ @@ -140,9 +115,9 @@ void limiter_process_fx( *----------------------------------------------------------------------------------*/ ivas_error ivas_td_decorr_dec_open_fx( ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t nchan_internal, /* i : number of internal channels */ - const int16_t ducking_flag /* i : ducking flag */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 nchan_internal, /* i : number of internal channels */ + const Word16 ducking_flag /* i : ducking flag */ ); void ivas_td_decorr_dec_close( ivas_td_decorr_state_t **hTdDecorr /* i/o: TD decorrelator handle */ @@ -179,9 +154,6 @@ ivas_error efap_init_data_fx( const Word16 num_speaker_nodes, /* i : number of speaker nodes in the set */ const Word16 efap_mode /* i : indicates whether EFAP or EFIP is used */ ); -void efap_free_data( - EFAP_HANDLE *hEFAPdata /* i/o: EFAP handle to be freed */ -); void efap_determine_gains_fx( EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ @@ -224,14 +196,7 @@ void ivas_sba_prototype_renderer_fx( Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ Word16 q_cldfb[6][CLDFB_SLOTS_PER_SUBFRAME], - const int16_t subframe /* i : Subframe to render */ -); - -void ivas_sba_prototype_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ - const int16_t subframe /* i : Subframe to render */ + const Word16 subframe /* i : Subframe to render */ ); ivas_error ivas_sba_get_hoa_dec_matrix_fx( @@ -244,11 +209,7 @@ void ivas_dirac_dec_binaural_sba_gain_fx( const Word16 nchan_remapped, /* i : num channels after remapping of TCs */ const Word16 output_frame /* i : output frame length */ ); -void ivas_dirac_dec_binaural_sba_gain( - float *output[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ - const int16_t output_frame /* i : output frame length */ -); + void ivas_dirac_dec_binaural_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ @@ -274,11 +235,6 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs_fx( HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ ); -ivas_error ivas_dirac_dec_binaural_copy_hrtfs( - HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ -); - - ivas_error ivas_dirac_alloc_mem_fx( DIRAC_REND_HANDLE hDirACRend, const RENDERER_TYPE renderer_type, @@ -286,20 +242,6 @@ ivas_error ivas_dirac_alloc_mem_fx( DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem, const Word16 hodirac_flag); -void ivas_dirac_free_mem( - DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem -); - -void initDiffuseResponses( - float *diffuse_response_function, - const int16_t num_channels, - const AUDIO_CONFIG output_config, - const IVAS_OUTPUT_SETUP hOutSetup, - const int16_t ambisonics_order, - const IVAS_FORMAT ivas_format, - int16_t *num_ele_spk_no_diffuse_rendering, - const AUDIO_CONFIG transport_config -); void ivas_dirac_free_mem_fx( DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem ); @@ -341,18 +283,6 @@ void protoSignalComputation_shd_fx( Word32 *p_Rmat_fx, /* Q30 */ Word16 q_cldfb ); -void protoSignalComputation_shd( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float *proto_direct_buffer_f, - float *proto_diffuse_buffer_f, - float *reference_power, - const int16_t slot_index, - const int16_t num_inputs, - const int16_t num_outputs_diff, - const int16_t num_freq_bands, - float *p_Rmat -); void protoSignalComputation1_fx( Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ @@ -370,17 +300,6 @@ void protoSignalComputation1_fx( const Word16 num_freq_bands, Word16 q_cldfb ); -void protoSignalComputation1( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float *proto_frame_f, - float *proto_direct_buffer_f, - float *reference_power, - float *proto_power_smooth, - const int16_t slot_index, - const int16_t num_outputs_diff, - const int16_t num_freq_bands -); void protoSignalComputation2_fx( Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ @@ -399,18 +318,6 @@ void protoSignalComputation2_fx( MASA_STEREO_TYPE_DETECT *stereo_type_detect, Word16 q_cldfb ); -void protoSignalComputation2( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - float *proto_frame_f, - float *proto_direct_buffer_f, - float *reference_power, - float *proto_power_smooth, - const int16_t isloudspeaker, - const int16_t slot_index, - const int16_t num_freq_bands, - MASA_STEREO_TYPE_DETECT *stereo_type_detect -); void protoSignalComputation4_fx( Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ @@ -432,11 +339,6 @@ void protoSignalComputation4_fx( Word16 q_cldfb ); -void ivas_dirac_dec_compute_diffuse_proto( - DIRAC_REND_HANDLE hDirACRend, - const int16_t num_freq_bands, - const int16_t slot_idx -); void ivas_dirac_dec_compute_diffuse_proto_fx( DIRAC_REND_HANDLE hDirACRend, const Word16 num_freq_bands, @@ -453,10 +355,6 @@ void computeDirectionAngles_fx( Word16 *elevation ); -void ivas_masa_init_stereotype_detection( - MASA_STEREO_TYPE_DETECT *stereo_type_detect -); - void ivas_masa_init_stereotype_detection_fx( MASA_STEREO_TYPE_DETECT *stereo_type_detect ); @@ -464,9 +362,6 @@ void ivas_masa_init_stereotype_detection_fx( void ivas_masa_stereotype_detection_fx( MASA_STEREO_TYPE_DETECT *stereo_type_detect ); -void ivas_masa_stereotype_detection( - MASA_STEREO_TYPE_DETECT *stereo_type_detect -); void ivas_lfe_synth_with_cldfb_fx( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, @@ -487,21 +382,6 @@ void rotateAziEle_DirAC_fx( const Word16 band2, /* i : bands to work on (upper bound) */ const Word32 *p_Rmat_fx /* i : pointer to real-space rotation matrix q30*/ ); -void rotateAziEle_DirAC( - int16_t *azi, - int16_t *ele, - const int16_t band1, - const int16_t band2, - const float *p_Rmat -); - -ivas_error ivas_dirac_dec_onset_detection_open( - const int16_t num_channels, - const int16_t num_freq_bands, - const int16_t max_band_decorr, - DIRAC_ONSET_DETECTION_PARAMS *ph_dirac_onset_detection_params, - DIRAC_ONSET_DETECTION_STATE *ph_dirac_onset_detection_state -); ivas_error ivas_dirac_dec_onset_detection_open_fx( const Word16 num_protos_diff, //Q0 @@ -522,14 +402,6 @@ ivas_error ivas_dirac_dec_decorr_open_fx( const Word32 output_Fs /* i : output sampling rate */ ); -void ivas_dirac_dec_onset_detection_process( - const float *input_power_f, - float *onset_filter, - const int16_t num_protos_diff, - DIRAC_ONSET_DETECTION_PARAMS h_dirac_onset_detection_params, - DIRAC_ONSET_DETECTION_STATE h_dirac_onset_detection_state -); - void ivas_dirac_dec_onset_detection_process_fx( const Word32 *input_power_f, /* Q(0) */ Word32 *onset_filter, /* Q(0) */ @@ -538,33 +410,6 @@ void ivas_dirac_dec_onset_detection_process_fx( DIRAC_ONSET_DETECTION_STATE h_dirac_onset_detection_state ); -ivas_error ivas_dirac_dec_decorr_open( - DIRAC_DECORR_PARAMS **ph_freq_domain_decorr_ap_params, - DIRAC_DECORR_STATE **ph_freq_domain_decorr_ap_state, - const int16_t num_freq_bands, - int16_t num_outputs_diff, - const int16_t num_protos_diff, - const DIRAC_SYNTHESIS_CONFIG synthesisConf, - float *frequency_axis, - const int16_t nchan_transport, /* i : number of transport channels */ - const int32_t output_Fs /* i : output sampling rate */ -); - -void ivas_dirac_dec_decorr_process( - const int16_t num_freq_bands, - int16_t num_channels, - const int16_t num_protos_diff, - const DIRAC_SYNTHESIS_CONFIG synthesisConf, - const int16_t nchan_transport, /* i : number of transport channels */ - const float *input_frame_f, - const int16_t num_protos_dir, - const int16_t *proto_index_dir, - float *frame_dec_f, - float *onset_filter, - HANDLE_DIRAC_DECORR_PARAMS h_freq_domain_decorr_ap_params, - HANDLE_DIRAC_DECORR_STATE h_freq_domain_decorr_ap_state -); - void ivas_dirac_dec_decorr_process_fx( const Word16 num_freq_bands, Word16 num_channels, @@ -582,32 +427,11 @@ void ivas_dirac_dec_decorr_process_fx( HANDLE_DIRAC_DECORR_STATE h_freq_domain_decorr_ap_state ); -void ivas_dirac_dec_decorr_close( - HANDLE_DIRAC_DECORR_PARAMS *ph_dirac_decorr_params, - HANDLE_DIRAC_DECORR_STATE *ph_dirac_decorr_state -); void ivas_dirac_dec_decorr_close_fx( HANDLE_DIRAC_DECORR_PARAMS *ph_dirac_decorr_params, HANDLE_DIRAC_DECORR_STATE *ph_dirac_decorr_state ); - -ivas_error ivas_dirac_dec_output_synthesis_open( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const RENDERER_TYPE renderer_type, /* i : renderer type */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - -void ivas_dirac_dec_output_synthesis_init( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const int16_t nchan_out_woLFE, /* i : number of output audio channels without LFE */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - ivas_error ivas_dirac_dec_output_synthesis_open_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ @@ -627,9 +451,7 @@ void ivas_dirac_dec_output_synthesis_init_fx( void ivas_dirac_dec_output_synthesis_close_fx( DIRAC_REND_HANDLE hDirACRend /* i/o: DirAC handle */ ); -void ivas_dirac_dec_output_synthesis_close( - DIRAC_REND_HANDLE hDirACRend /* i/o: DirAC handle */ -); + void ivas_dirac_dec_output_synthesis_process_slot_fx( const Word32 *reference_power, /* i : Estimated power */ const Word16 q_reference_power, /* i : Estimated power */ @@ -648,23 +470,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( const Word16 md_idx, const Word16 hodirac_flag, /* i : flag to indicate HO-DirAC mode */ const Word16 dec_param_estim); -void ivas_dirac_dec_output_synthesis_process_slot( - const float *reference_power, /* i : Estimated power */ - const float *onset, /* i : onset filter */ - const int16_t *azimuth, - const int16_t *elevation, - const float *diffuseness, - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const int16_t sh_rot_max_order, - const float *p_Rmat, /* i : rotation matrix */ - const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ - const IVAS_OUTPUT_SETUP hOutSetup, /* i : output setup structure */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t ind_slot, /* i : index of the slot to be added to the input covariance */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - const int16_t dec_param_estim /* i : flag to indicate parameter estimation mode */ -); void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Word32 RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ @@ -681,19 +486,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Word16 *q_cy_auto_diff_smooth_prev ); -void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nbslots, /* i : number of slots to process */ - const float *onset_filter, - float *diffuseness, - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - const int16_t dec_param_estim /* i : flag to indicate parameter estimation mode */ -); - void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Word32 RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ Word32 ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ @@ -708,25 +500,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Word16 *q_Cldfb ); -void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const int16_t nbslots, /* i : number of slots to process */ - float *diffuseness_vector, /* i : diffuseness (needed for direction smoothing)*/ - float *reference_power_smooth, - float qualityBasedSmFactor, - const int16_t enc_param_start_band -); - -void compute_hoa_encoder_mtx( - const float *azimuth, - const float *elevation, - float *response, - const int16_t num_responses, - const int16_t ambisonics_order ); - void compute_hoa_encoder_mtx_fx( const Word32 *azimuth, /*q22*/ const Word32 *elevation, /*q22*/ @@ -751,21 +524,6 @@ void ivas_dirac_dec_compute_power_factors_fx( Word32 *diffuse_power_factor ); -void ivas_dirac_dec_compute_directional_responses( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ - const int16_t *masa_band_mapping, /* i : Band mapping for MASA, NULL assumes not using MASA in any form */ - MASA_ISM_DATA_HANDLE hMasaIsm, /* i : MASA_ISM data structure */ - const int16_t *azimuth, - const int16_t *elevation, - const int16_t md_idx, - const float *surCohRatio, - const int16_t shd_rot_max_order, /* i : split-order rotation method */ - const float *p_Rmat, /* i : rotation matrix */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - void ivas_dirac_dec_compute_directional_responses_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ @@ -782,36 +540,6 @@ void ivas_dirac_dec_compute_directional_responses_fx( const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */ ); -void ivas_dirac_dec_get_frequency_axis( - float *frequency_axis, /* o : array of center frequencies of a real filter bank */ - const int32_t output_Fs, /* i : sampling frequency */ - const int16_t num_freq_bands /* i : number of frequency bands */ -); - -ivas_error ivas_spat_hSpatParamRendCom_config( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, - const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ - const int16_t dec_param_estim_flag, - const IVAS_FORMAT ivas_format, - const MC_MODE mc_mode, - const int32_t output_Fs, - const int16_t hodirac_flag, - const int16_t masa_ext_rend_flag -); - -void ivas_spat_hSpatParamRendCom_close( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out -); - -void ivas_dirac_rend_close( - DIRAC_REND_HANDLE *hDirACRend_out -); - -ivas_error ivas_dirac_allocate_parameters( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ -); - void ivas_dirac_rend_close_fx( DIRAC_REND_HANDLE *hDirACRend_out ); @@ -833,18 +561,14 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( ivas_error ivas_dirac_allocate_parameters_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ + const Word16 params_flag /* i : set of parameters flag */ ); void ivas_dirac_deallocate_parameters_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ + const Word16 params_flag /* i : set of parameters flag */ ); -void ivas_dirac_deallocate_parameters( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ -); void ivas_masa_ext_dirac_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ Word32 *output_f[], /* i/o: input/output signals in time domain q11*/ @@ -862,11 +586,6 @@ void ivas_HRTF_binary_close_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ ); -ivas_error ivas_HRTF_fastconv_binary_open( - HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ -); - - ivas_error ivas_HRTF_fastconv_binary_open_fx( HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ ); @@ -910,33 +629,6 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( const Word16 num_subframes /* i : number of subframes to render */ ); -ivas_error ivas_td_binaural_renderer_unwrap( - const REVERB_HANDLE hReverb, /* i : Reverberator handle */ - const AUDIO_CONFIG transport_config, /* i : Transport configuration */ - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD binaural object renderer handle */ - const int16_t num_src, /* i : number of sources to render */ - const int16_t lfe_idx, /* i : LFE channel index */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - ISM_METADATA_HANDLE *hIsmMetaData, /* i : ISM metadata handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientaton data handle */ - const int16_t ism_md_subframe_update, - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame, /* i : output frame length */ - const int16_t num_subframes /* i : number of subframes to render */ -); - -ivas_error ivas_td_binaural_renderer_ext( - const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ - const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ - const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ - const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData,/* i : Combined head and external orientations */ - const IVAS_ISM_METADATA *currentPos, /* i : Object position */ - const REVERB_HANDLE hReverb, /* i : Reverberator handle */ - const int16_t ism_md_subframe_update_ext, /* i : Metadata Delay in subframes to sync with audio delay */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t output_frame, /* i : output frame length */ - float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ -); ivas_error ivas_td_binaural_renderer_ext_fx( const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ @@ -964,24 +656,12 @@ ivas_error ivas_td_binaural_open_unwrap_fx( Word16 *SrcInd ); -ivas_error ivas_td_binaural_open_unwrap( - TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HR filter model (from file or NULL) */ - const int32_t output_Fs, /* i : Output sampling rate */ - const int16_t nchan_transport, /* i : Number of channels */ - const IVAS_FORMAT ivas_format, /* i : IVAS format (ISM/MC) */ - const AUDIO_CONFIG transport_config, /* i : Transport configuration */ - const float *directivity, /* i : Directivity pattern (used for ISM) */ - const IVAS_OUTPUT_SETUP hTransSetup, /* i : Loudspeaker layout */ - BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, /* o : TD renderer handle */ - int32_t *binaural_latency_ns /* i : Binauralization delay */ -); - ivas_error ivas_td_binaural_open_ext_fx( TDREND_WRAPPER *pTDRend, const AUDIO_CONFIG inConfig, RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ LSSETUP_CUSTOM_STRUCT *customLsInput, - const int32_t output_Fs, + const Word32 output_Fs, Word16 *SrcInd, Word16 *num_src ); @@ -990,17 +670,6 @@ void ivas_td_binaural_close_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd /* i/o: TD binaural object renderer handle */ ); -void ivas_td_binaural_close( - BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd /* i/o: TD binaural object renderer handle */ -); - -ivas_error TDREND_GetMix( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - float *output[], /* i/o: ISM object synth/rendered output in 0,1 */ - const int16_t subframe_length, /* i/o: subframe length */ - const int16_t subframe_idx, /* i : Subframe index to 5 ms subframe */ - const int16_t ism_md_subframe_update /* i : Number of subframes to delay metadata to sync with audio */ -); ivas_error TDREND_GetMix_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ Word32 *output[], /* i/o: ISM object synth / rendered output in 0,1 */ @@ -1009,13 +678,6 @@ ivas_error TDREND_GetMix_fx( const Word16 ism_md_subframe_update /* i : Number of subframes to delay ism metadata to sync with audio */ ); - -ivas_error TDREND_Update_object_positions( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ - const int16_t num_src, /* i : number of sources to render */ - const IVAS_FORMAT in_format, /* i : Format of input sources */ - const ISM_METADATA_HANDLE *hIsmMetaData /* i : Input metadata for ISM objects */ -); void BSplineModelEvalDealloc_fx( ModelParams_t *model, /* i : Model parameters */ ModelEval_t *modelEval /* i : Model evaluation structure */ @@ -1057,16 +719,7 @@ ivas_error TDREND_MIX_SRC_SetPos_fx( const Word16 SrcInd, /* i : Source index */ const Word32 *Vec_p /* i : Position vector */ ); -ivas_error TDREND_MIX_SRC_SetPos( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float *Vec_p /* i : Position vector */ -); -ivas_error TDREND_MIX_SRC_SetDir( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float *Vec_p /* i : Direction vector */ -); + ivas_error TDREND_MIX_SRC_SetDir_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const Word16 SrcInd, /* i : Source index */ @@ -1116,19 +769,8 @@ void TDREND_SRC_Init_fx( TDREND_SRC_t *Src_p, /* i/o: Source to initialize */ const TDREND_PosType_t PosType /* i : Position type specifier */ ); -void TDREND_SRC_Init( - TDREND_SRC_t *Src_p, /* i/o: Source to initialize */ - const TDREND_PosType_t PosType /* i : Position type specifier */ -); /* ----- Object renderer - vec ----- */ - -void TDREND_SPATIAL_VecInit( - float *Pos_p, /* o : Output vector */ - const float PosX, /* i : X value */ - const float PosY, /* i : Y value */ - const float PosZ /* i : Z value */ -); void TDREND_SPATIAL_VecInit_fx( Word32 *Pos_p, /* o : Output vector */ const Word32 PosX, /* i : X value */ @@ -1144,21 +786,6 @@ void TDREND_SPATIAL_VecNormalize_fx( Word32 *VecNorm_p_fx /* o : Normalised output vector Q30 */ ); -void TDREND_SPATIAL_VecNormalize( - const float *Vec_p, /* i : Input vector */ - float *VecNorm_p /* o : Output vector */ -); - -void TDREND_SPATIAL_VecMapToNewCoordSystem( - const float *Vec_p, /* i : Input vector */ - const float *TranslVec_p, /* i : Translation vector */ - const float *DirVec_p, /* i : Direction vector */ - const float *UpVec_p, /* i : Up vector */ - const float *RightVec_p, /* i : Right vector */ - float *MappedVec_p, /* o : Transformed vector */ - float *LisRelPosAbs /* o : Transformed vector ignoring orientation */ -); - Word16 TDREND_SPATIAL_EvalOrthonormOrient_fx( Word32 *FrontVecON_p_fx, /* i/o: Normalized front vector Q30 */ Word32 *UpVecON_p_fx, /* i/o: Normalized up vector Q30 */ @@ -1167,14 +794,6 @@ Word16 TDREND_SPATIAL_EvalOrthonormOrient_fx( const Word32 *UpVec_p_fx, /* i : Input up vector orient_q */ const Word16 orient_q /* i : Input up Q-factor */ ); -/*! r: Flag if the orientation has been updated */ -int16_t TDREND_SPATIAL_EvalOrthonormOrient( - float *FrontVecON_p, /* o : Normalized front vector */ - float *UpVecON_p, /* o : Normalized up vector */ - float *RightVecON_p, /* o : Normalized right vector */ - const float *FrontVec_p, /* i : Input front vector */ - const float *UpVec_p /* i : Input up vector */ -); /* ----- Object renderer - mix ----- */ @@ -1183,11 +802,6 @@ ivas_error TDREND_MIX_AddSrc_fx( Word16 *SrcInd, /* o : Source index */ const TDREND_PosType_t PosType /* i : Position type (absolute/relative) */ ); -ivas_error TDREND_MIX_AddSrc( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - int16_t *SrcInd, /* o : Source index */ - const TDREND_PosType_t PosType /* i : Position type (absolute/relative) */ -); ivas_error TDREND_MIX_SetDistAttenModel( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ @@ -1198,35 +812,15 @@ void TDREND_MIX_Dealloc_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd /* i/o: TD renderer handle */ ); -void TDREND_MIX_Dealloc( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd /* i/o: TD renderer handle */ -); - ivas_error TDREND_MIX_Init_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HRTF data (initialized in case of NULL) */ const TDREND_MixSpatSpec_t *MixSpatSpec_p, /* i : Mixer spatial specification */ const Word32 output_Fs /* i : Output sampling rate */ ); -ivas_error TDREND_MIX_Init( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HRTF data (initialized in case of NULL) */ - const TDREND_MixSpatSpec_t *MixSpatSpec_p, /* i : Mixer spatial specification */ - const int32_t output_Fs /* i : Output sampling rate */ -); /* ----- Object renderer - sfx ----- */ -void TDREND_Apply_ITD( - float *input, /* i : Input SCE subframe to be time adjusted */ - float *out_left, /* o : Output left channels with ITD applied */ - float *out_right, /* o : Output right channels with ITD applied */ - int16_t *previtd, /* i/o: Previous ITD value */ - const int16_t itd, /* i : Current subframe ITD value */ - float *mem_itd, /* i/o: ITD buffer memory */ - const int16_t length /* i : Subframe length */ -); - void TDREND_Apply_ITD_fx( Word32 *input_fx, /* i : Input subframe to be time adjusted Qx */ Word32 *out_left_fx, /* o : Output left channel with ITD applied Qx */ @@ -1319,10 +913,10 @@ ivas_error ivas_binaural_reverb_open_fastconv_fx( ivas_error ivas_binaural_reverb_open_parambin( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ - const int16_t numBins, /* i : number of CLDFB bins Q0 */ - const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame Q0 */ + const Word16 numBins, /* i : number of CLDFB bins Q0 */ + const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame Q0 */ IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const int32_t sampling_rate, /* i : sampling rate Q0 */ + const Word32 sampling_rate, /* i : sampling rate Q0 */ const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ ); @@ -1333,16 +927,6 @@ void ivas_binaural_reverb_close( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ ); -void ivas_binaural_reverb_processSubframe( - REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ - const int16_t numInChannels, /* i : num input channels to be processed*/ - const int16_t numSlots, /* i : number of slots to be processed */ - float inReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real */ - float inImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */ - float outReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ - float outImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* o : output CLDFB data imag */ -); - void ivas_binaural_reverb_processSubframe_fx( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const Word16 numInChannels, /* i : num inputs to be processed */ @@ -1373,14 +957,7 @@ ivas_error ivas_reverb_process_fx( Word32 *pcm_out[], /* o : the PCM audio with reverb applied */ const Word16 i_ts /* i : (Q0) subframe index */ ); -ivas_error ivas_reverb_process( - const REVERB_HANDLE hReverb, /* i : Reverberator handle */ - const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ - const int16_t mix_signals, /* i : add reverb to output signal */ - float *pcm_in[], /* i : the PCM audio to apply reverb on */ - float *pcm_out[], /* o : the PCM audio with reverb applied */ - const int16_t i_ts /* i : subframe index */ -); + void ivas_rev_delay_line_init( ivas_rev_delay_line_t *pDelay, /* o : the delay line to initialize */ Word32 *memory_buffer, /* i : the memory buffer to use for the delay line Q11 */ @@ -1410,7 +987,7 @@ void ivas_rev_delay_line_feed_sample_blk_fx( ); void ivas_reverb_iir_filt_init( ivas_rev_iir_filter_t *iirFilter, /* o : IIR filter */ - const uint16_t maxTaps /* i : maximum number of filter taps */ + const UWord16 maxTaps /* i : maximum number of filter taps */ ); @@ -1469,17 +1046,6 @@ void ivas_reverb_fft_filter_CrossMix_fx( const Word16 fft_size ); -void ivas_reverb_fft_filter_CrossMix( - float *buffer0, - float *buffer1, - const int16_t fft_size -); - -void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( - rv_fftwf_type_complex *spectrum, - float *fft_real, - const int16_t fft_size -); void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR_fx( rv_fftwf_type_complex_fx *spectrum, // i: Qx Word32 *fft_real, // o: Qx @@ -1620,47 +1186,21 @@ void ivas_headTrack_close_fx( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ); -void Euler2Quat( - const float yaw, /* i : yaw (x) */ - const float pitch, /* i : pitch (y) */ - const float roll, /* i : roll (z) */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ -); void Euler2Quat_fx( const Word32 yaw, /* i : yaw (x) Q22 */ const Word32 pitch, /* i : pitch (y) Q22 */ const Word32 roll, /* i : roll (z) Q22 */ IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ ); -float deg2rad( - float degrees -); Word32 deg2rad_fx( Word32 degrees ); -float rad2deg( - float radians -); Word32 rad2deg_fx( Word32 radians ); -void QuatToRotMat( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ -); - - -void rotateAziEle( - float azi_in, /* i : output elevation */ - float ele_in, /* i : input elevation */ - int16_t *azi, /* o : rotated azimuth */ - int16_t *ele, /* o : rotated elevation */ - float Rmat[3][3], /* i : real-space rotation matrix */ - const int16_t isPlanar /* i : is roation planar and elevation meaningless? */ -); void rotateAziEle_fx( Word16 azi_in, /* i : output elevation */ Word16 ele_in, /* i : input elevation */ @@ -1734,21 +1274,21 @@ void rotateFrame_sd_cldfb_fixed( Word32 Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ const IVAS_OUTPUT_SETUP_HANDLE hOutputSetup, /* i : output format setup number of channels */ const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ - const int16_t numTimeSlots, /* i : number of time slots to process */ - const int16_t nb_band /* i : number of CLDFB bands to process */ + const Word16 numTimeSlots, /* i : number of time slots to process */ + const Word16 nb_band /* i : number of CLDFB bands to process */ ); ivas_error ivas_external_orientation_open( EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData, /* o : external orientation handle */ - const int16_t num_subframes /* i : number of subframes */ + const Word16 num_subframes /* i : number of subframes */ ); void ivas_external_orientation_close_fx( EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData /* i/o: external orientation handle */ ); ivas_error ivas_combined_orientation_open( COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* o : combined orientation handle */ - const int32_t fs, /* i : sampling rate */ - const int16_t num_subframes /* i : number of subframes */ + const Word32 fs, /* i : sampling rate */ + const Word16 num_subframes /* i : number of subframes */ ); void ivas_combined_orientation_close_fx( COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* i/o: combined orientation handle */ @@ -1808,34 +1348,6 @@ void QuaternionSlerp_fx( * Orientation tracking *----------------------------------------------------------------------------------*/ -ivas_error ivas_orient_trk_Init( - ivas_orient_trk_state_t *pOTR /* i/o: orientation tracker handle */ -); - -ivas_error ivas_orient_trk_SetTrackingType( - ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ - const IVAS_HEAD_ORIENT_TRK_T orientation_tracking /* i : orientation tracking type */ -); - -ivas_error ivas_orient_trk_SetReferenceRotation( - ivas_orient_trk_state_t *pOTR, /* i/o: orientatoin trakcer handle */ - const IVAS_QUATERNION refRot /* i : reference rotation */ -); - - -ivas_error ivas_orient_trk_GetTrackedRotation( - ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ - IVAS_QUATERNION *pRotation /* i/o: processed rotation */ -); - -ivas_error ivas_orient_trk_Process( - ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ - IVAS_QUATERNION absRot, /* i : absolute head rotation */ - float updateRate, /* i : rotation update rate [Hz] */ - IVAS_QUATERNION *pTrkRot /* o : tracked rotation */ -); - - ivas_error ivas_orient_trk_Init_fx( ivas_orient_trk_state_t *pOTR /* i/o: orientation tracker handle */ ); @@ -1880,7 +1392,7 @@ ivas_error ivas_orient_trk_Process_fx( ivas_error ivas_mcmasa_ana_open( MCMASA_ANA_HANDLE *hMcMasaPtr, /* i/o: McMASA data handle pointer */ const AUDIO_CONFIG inConfig, /* i : Input config */ - int32_t input_Fs /* i : Sampling frequency */ + Word32 input_Fs /* i : Sampling frequency */ ); void ivas_mcmasa_ana_fx( MCMASA_ANA_HANDLE hMcMasa, /* i/o: McMASA encoder handle */ @@ -1901,14 +1413,6 @@ ivas_error ivas_omasa_ana_open( UWord16 total_num_objects /* i : Number of objects */ ); -void ivas_omasa_ana( - OMASA_ANA_HANDLE hOMasa, /* i/o: OMASA analysis handle */ - float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t nchan_transport, /* i : Number of transport channels */ - const int16_t nchan_ism /* i : Number of objects for parameter analysis*/ -); - void ivas_omasa_ana_fx( OMASA_ANA_HANDLE hOMasa, /* i/o: OMASA analysis handle */ Word32 data_in_f_fx[][L_FRAME48k], /* i/o: Input / transport audio signals */ @@ -1928,13 +1432,7 @@ void computeIntensityVector_ana_fx( const Word16 num_frequency_bands, /* i : Number of frequency bands */ Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity vector 2 * Qx -31 */ ); -void computeIntensityVector_ana( - const int16_t *band_grouping, /* i : Band grouping for estimation */ - float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ - float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ - const int16_t num_frequency_bands, /* i : Number of frequency bands */ - float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity vector */ -); + void computeReferencePower_ana_fx( const Word16 *band_grouping, /* i : Band grouping for estimation */ Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal input_q */ @@ -1942,13 +1440,6 @@ void computeReferencePower_ana_fx( Word32 *reference_power, /* o : Estimated power */ const Word16 num_freq_bands /* i : Number of frequency bands 2 * input_q - 31 */ ); -void computeReferencePower_ana( - const int16_t *band_grouping, /* i : Band grouping for estimation */ - float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ - float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ - float *reference_power, /* o : Estimated power */ - const int16_t num_freq_bands /* i : Number of frequency bands */ -); void ivas_create_masa_out_meta_fx( MASA_DECODER_EXT_OUT_META_HANDLE extOutMeta, /* i/o: MASA metadata handle */ @@ -1964,17 +1455,6 @@ void ivas_create_masa_out_meta_fx( Word16 surroundingCoherence_q ); -void ivas_create_masa_out_meta( - MASA_DECODER_EXT_OUT_META_HANDLE extOutMeta, /* i/o: MASA metadata handle */ - SPHERICAL_GRID_DATA *Sph_Grid16, /* i : Spherical grid */ - const int16_t nchan_transport, /* i : Number of transport channels */ - float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated elevation */ - float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated azimuth */ - float energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated direct-to-total ratio */ - float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated spread coherence */ - float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : Estimated surround coherence */ -); - ivas_error ivas_dirac_ana_open_fx( DIRAC_ANA_HANDLE *hDirACPtr, /* i/o: DIRAC data handle pointer */ Word32 input_Fs @@ -2003,11 +1483,6 @@ void ivas_prerend_merge_masa_metadata_fx( Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */ ); -void copy_masa_descriptive_meta( - MASA_DECRIPTIVE_META *outMeta, /* o : metadata to be written */ - MASA_DECRIPTIVE_META *inMeta /* i : input metadata */ -); - ivas_error masaPrerendOpen_fx( MASA_PREREND_HANDLE *hMasaPrerendPtr, /* o : handle to the opened prerenderer */ Word16 numTransports, /* i : number of transport channels */ diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c index d6e397234..310bc77e4 100644 --- a/lib_rend/ivas_reflections_fx.c +++ b/lib_rend/ivas_reflections_fx.c @@ -36,7 +36,7 @@ #include "prot_fx.h" #include "rom_dec.h" #include "lib_rend.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index b730b1510..056ae1651 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "ivas_rom_TdBinauralRenderer.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_reverb_delay_line_fx.c b/lib_rend/ivas_reverb_delay_line_fx.c index ab41b43c2..d2a6a0c44 100644 --- a/lib_rend/ivas_reverb_delay_line_fx.c +++ b/lib_rend/ivas_reverb_delay_line_fx.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "wmc_auto.h" #include "debug.h" diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c index 2d0722ceb..bbe077f8b 100644 --- a/lib_rend/ivas_reverb_fft_filter_fx.c +++ b/lib_rend/ivas_reverb_fft_filter_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include #include "wmc_auto.h" #include "debug.h" diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index 45e492fc8..62c97f88f 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include #include #include diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index c8e6aa12f..870f8795d 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "math.h" #include "ivas_rom_rend.h" diff --git a/lib_rend/ivas_reverb_iir_filter_fx.c b/lib_rend/ivas_reverb_iir_filter_fx.c index 98b66e0c7..e09ec7005 100644 --- a/lib_rend/ivas_reverb_iir_filter_fx.c +++ b/lib_rend/ivas_reverb_iir_filter_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "wmc_auto.h" #include "debug.h" #define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index ee2bada9d..b3e1e72fa 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include #include "wmc_auto.h" diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 8b352218b..aebb80a54 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -38,7 +38,7 @@ #include #include "cnst.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "wmc_auto.h" #include #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c index d544acd13..5e097ab2b 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -33,7 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include diff --git a/lib_rend/ivas_shoebox_fx.c b/lib_rend/ivas_shoebox_fx.c index 7c930104a..1a4496085 100644 --- a/lib_rend/ivas_shoebox_fx.c +++ b/lib_rend/ivas_shoebox_fx.c @@ -33,7 +33,7 @@ #include "options.h" #include #include -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" #include "prot_fx.h" diff --git a/lib_rend/ivas_td_decorr_fx.c b/lib_rend/ivas_td_decorr_fx.c index 0fc5c21df..0c842e5bd 100644 --- a/lib_rend/ivas_td_decorr_fx.c +++ b/lib_rend/ivas_td_decorr_fx.c @@ -35,7 +35,7 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "math.h" #include "wmc_auto.h" #ifdef DEBUGGING diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c index b90b3a456..7495953e3 100644 --- a/lib_rend/ivas_vbap_fx.c +++ b/lib_rend/ivas_vbap_fx.c @@ -35,7 +35,7 @@ #include #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 129f72388..3ea159d7f 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -34,7 +34,7 @@ #include "lib_rend.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_com_fx.h" diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 0316d8b30..e667dcfe5 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -33,7 +33,7 @@ #include "hrtf_file_reader.h" #include #include "prot_fx.h" -#include "ivas_prot_rend.h" +#include "ivas_prot_rend_fx.h" #include "ivas_prot_fx.h" /*---------------------------------------------------------------------* -- GitLab From abd4aa4c51a795cf555d675ef976e4e369abef02 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 13 Mar 2025 09:53:26 +0530 Subject: [PATCH 80/97] Fix for 3GPP issue 1371: Energy burst in MDCT-Stereo coded item at 48kbps Link #1371 Restricting the Q-factor of spectrum and mdst_spectrum to Q-factor 9 before enc_ste_pre_mdct to avoid truncation of the spectrums resolved the issue --- lib_enc/ivas_mdct_core_enc_fx.c | 34 ++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 9027b2669..9f674473e 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -1556,27 +1556,30 @@ void ivas_mdct_core_whitening_enc_fx( } IF( EQ_16( hTcxEnc0->transform_type[n], TCX_5 ) ) { - Word16 length; + Word16 length, len_sbfr; const Word16 tcx5SizeFB = sts[1]->hTcxCfg->tcx5SizeFB; move16(); /* length = max(nSampCore / (2 * NB_DIV), L_subframeTCX / (2 * NB_DIV), NB_DIV = 2 */ length = shr( s_max( nSampCore, L_subframeTCX ), 2 ); + len_sbfr = shr( hTcxEnc0->L_frameTCX, shift ); + assert( hTcxEnc0->L_frameTCX == hTcxEnc1->L_frameTCX ); exp_max = s_max( hTcxEnc0->spectrum_e[n], hTcxEnc1->spectrum_e[n] ); exp_max = s_max( exp_max, mdst_spectrum_e[0][n] ); exp_max = s_max( exp_max, mdst_spectrum_e[1][n] ); // calculate the headroom available - exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], length ), L_norm_arr( hTcxEnc0->spectrum_fx[n], length ) ); - exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], length ) ); - exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], length ) ); + exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], len_sbfr ), L_norm_arr( hTcxEnc0->spectrum_fx[n], len_sbfr ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], len_sbfr ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], len_sbfr ) ); q_com = sub( s_min( Q31, add( sub( Q31, exp_max ), exp_com ) ), 6 ); // 6 guarded bits + q_com = s_max( q_com, 9 ); // Keep the Q-factor at least 9 to avoid precision loss inside enc_ste_pre_mdct. exp_com = sub( Q31, q_com ); - Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( hTcxEnc0->spectrum_e[n], exp_com ) ); // hTcxEnc0->spectrum_e - Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( hTcxEnc1->spectrum_e[n], exp_com ) ); // hTcxEnc1->spectrum_e - Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[0][n], exp_com ) ); // mdst_spectrum_e - Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[1][n], exp_com ) ); // mdst_spectrum_e + scale_sig32( hTcxEnc0->spectrum_fx[n], len_sbfr /* hTcxEnc0->L_frameTCX/nSubframes */, sub( hTcxEnc0->spectrum_e[n], exp_com ) ); // hTcxEnc0->spectrum_e + scale_sig32( hTcxEnc1->spectrum_fx[n], len_sbfr /* hTcxEnc1->L_frameTCX/nSubframes */, sub( hTcxEnc1->spectrum_e[n], exp_com ) ); // hTcxEnc1->spectrum_e + scale_sig32( mdst_spectrum_fx[0][n], len_sbfr /* hTcxEnc0->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[0][n], exp_com ) ); // mdst_spectrum_e + scale_sig32( mdst_spectrum_fx[1][n], len_sbfr /* hTcxEnc1->L_frameTCX/nSubframes */, sub( mdst_spectrum_e[1][n], exp_com ) ); // mdst_spectrum_e Word16 q_com_orig = q_com; move16(); @@ -1600,17 +1603,18 @@ void ivas_mdct_core_whitening_enc_fx( exp_max = sub( Q31, q_com ); move16(); - exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */ ), L_norm_arr( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); - exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); - exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( L_norm_arr( hTcxEnc1->spectrum_fx[n], len_sbfr /* hTcxEnc1->L_frameTCX/nSubframes */ ), L_norm_arr( hTcxEnc0->spectrum_fx[n], len_sbfr /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[0][n], len_sbfr /* hTcxEnc0->L_frameTCX/nSubframes */ ) ); + exp_com = s_min( exp_com, L_norm_arr( mdst_spectrum_fx[1][n], len_sbfr /* hTcxEnc1->L_frameTCX/nSubframes */ ) ); q_com = sub( s_min( Q31, add( q_com, exp_com ) ), 6 ); + q_com = s_max( q_com, 9 ); // Keep the Q-factor at least 9 to avoid precision loss inside enc_ste_pre_mdct. exp_com = sub( Q31, q_com ); - Scale_sig32( hTcxEnc0->spectrum_fx[n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max - Scale_sig32( hTcxEnc1->spectrum_fx[n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max - Scale_sig32( mdst_spectrum_fx[0][n], shr( hTcxEnc0->L_frameTCX, shift ) /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max - Scale_sig32( mdst_spectrum_fx[1][n], shr( hTcxEnc1->L_frameTCX, shift ) /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max + scale_sig32( hTcxEnc0->spectrum_fx[n], len_sbfr /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max + scale_sig32( hTcxEnc1->spectrum_fx[n], len_sbfr /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max + scale_sig32( mdst_spectrum_fx[0][n], len_sbfr /* hTcxEnc0->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max + scale_sig32( mdst_spectrum_fx[1][n], len_sbfr /* hTcxEnc1->L_frameTCX/nSubframes */, sub( exp_max, exp_com ) ); // exp_max q_com_orig = q_com; move16(); -- GitLab From 5d1c2b1c1706aaed8cc43bd85e1bc92a907ac963 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 13 Mar 2025 10:27:26 +0530 Subject: [PATCH 81/97] Fix for 3GPP issue 1343: read_indices_fx() variants Link #1343 --- lib_com/bitstream.c | 196 ++++++++----- lib_com/bitstream_fx.c | 357 +---------------------- lib_com/prot_fx.h | 24 +- lib_dec/lib_dec_fx.c | 2 +- lib_enc/acelp_core_switch_enc_fx.c | 13 - lib_enc/dtx_fx.c | 8 +- lib_enc/enc_ppp_fx.c | 12 +- lib_enc/eval_pit_contr_fx.c | 8 - lib_enc/fd_cng_enc_fx.c | 4 +- lib_enc/init_enc_fx.c | 15 - lib_enc/ivas_core_enc_fx.c | 2 +- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 8 +- lib_enc/ivas_init_enc_fx.c | 2 +- lib_enc/ivas_ism_dtx_enc_fx.c | 2 +- lib_enc/ivas_ism_metadata_enc_fx.c | 2 +- lib_enc/ivas_omasa_enc_fx.c | 4 +- lib_enc/ivas_qmetadata_enc_fx.c | 2 +- lib_enc/ivas_sce_enc_fx.c | 2 +- lib_enc/ivas_spar_md_enc_fx.c | 2 +- lib_enc/ivas_stereo_td_enc_fx.c | 2 +- lib_enc/tcx_utils_enc_fx.c | 11 - 21 files changed, 149 insertions(+), 529 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 90b49f8c2..79a659eb0 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -1318,33 +1318,6 @@ UWord16 get_indice_st( } #define WMC_TOOL_SKIP -/*-------------------------------------------------------------------* - * reset_indices_enc() - * - * Reset the buffer of encoder indices - *-------------------------------------------------------------------*/ - -void reset_indices_enc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 max_num_indices /* i : max number of indices */ -) -{ - Word16 i; - - hBstr->nb_bits_tot = 0; - move16(); - hBstr->nb_ind_tot = 0; - move16(); - - FOR( i = 0; i < max_num_indices; i++ ) - { - hBstr->ind_list[i].nb_bits = -1; - move16(); - } - - return; -} - /*-------------------------------------------------------------------* * reset_indices_dec() * @@ -1533,21 +1506,21 @@ static ivas_error write_indices_element_fx( { IF( st_ivas->hSCE[element_id]->hMetaData != NULL ) { - reset_indices_enc( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot ); + reset_indices_enc_fx( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot ); } - reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); } ELSE { IF( st_ivas->hCPE[element_id]->hMetaData != NULL ) { - reset_indices_enc( st_ivas->hCPE[element_id]->hMetaData, st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot ); + reset_indices_enc_fx( st_ivas->hCPE[element_id]->hMetaData, st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot ); } FOR( n = 0; n < n_channels; n++ ) { - reset_indices_enc( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot ); } } @@ -2059,67 +2032,84 @@ void ivas_set_bitstream_pointers( *-------------------------------------------------------------------*/ /*! r: 1 = reading OK, 0 = problem */ -ivas_error read_indices( +ivas_error read_indices_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t bit_stream[], /* i : bitstream buffer */ + UWord16 bit_stream[], /* i : bitstream buffer */ UWord16 num_bits, /* i : number of bits in bitstream */ - int16_t *prev_ft_speech, - int16_t *CNG, - int16_t bfi /* i : bad frame indicator */ + Word16 *prev_ft_speech, + Word16 *CNG, + Word16 bfi /* i : bad frame indicator */ ) { - int16_t k; + Word16 k; Decoder_State **sts; - int32_t total_brate = 0; - int16_t curr_ft_good_sp, curr_ft_bad_sp; - int16_t g192_sid_first, sid_upd_bad, sid_update; - int16_t speech_bad, speech_lost; - int16_t n; + Word32 total_brate = 0; + move32(); + Word16 curr_ft_good_sp, curr_ft_bad_sp; + Word16 g192_sid_first, sid_upd_bad, sid_update; + Word16 speech_bad, speech_lost; + Word16 n; ivas_error error; error = IVAS_ERR_OK; + move32(); st_ivas->BER_detect = 0; + move16(); st_ivas->num_bits = num_bits; + move16(); sts = reset_elements( st_ivas ); st_ivas->bfi = bfi; + move16(); /* convert the frame length to total bitrate */ - total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC ); + total_brate = imult3216( num_bits, FRAMES_PER_SEC ); + move32(); /* verify that a valid num bits value is present in the G.192 file */ /* only AMRWB, EVS or IVAS bitrates or 0(NO DATA) are allowed in G.192 file frame reading */ - if ( st_ivas->ivas_format != MONO_FORMAT ) + IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) ) { k = 0; - while ( k < SIZE_IVAS_BRATE_TBL && total_brate != ivas_brate_tbl[k] ) + move16(); + + test(); + WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( total_brate, ivas_brate_tbl[k] ) ) { - k++; + k = add( k, 1 ); } - if ( st_ivas->ivas_format == ISM_FORMAT && ( k < SIZE_IVAS_BRATE_TBL || total_brate <= SID_2k40 ) ) + test(); + test(); + test(); + test(); + IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && ( LT_16( k, SIZE_IVAS_BRATE_TBL ) || LE_32( total_brate, SID_2k40 ) ) ) { st_ivas->element_mode_init = IVAS_SCE; + move16(); } - else if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) && ( total_brate <= SID_2k40 ) ) + ELSE IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) && LE_32( total_brate, SID_2k40 ) ) { st_ivas->element_mode_init = IVAS_SCE; + move16(); } - else if ( k == SIZE_IVAS_BRATE_TBL ) + ELSE IF( EQ_16( k, SIZE_IVAS_BRATE_TBL ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the G.192 frame ! Exiting ! \n", total_brate ); } - else + ELSE { st_ivas->element_mode_init = -1; + move16(); } } - else /* AMRWB or EVS */ + ELSE /* AMRWB or EVS */ { st_ivas->element_mode_init = EVS_MONO; + move16(); - if ( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ + IF( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the G.192 frame ! Exiting ! \n", total_brate ); } @@ -2129,47 +2119,58 @@ ivas_error read_indices( /* handle SID_FIRST, SID_BAD, SPEECH_LOST, NO_DATA as properly as possible for the ITU-T G.192 format */ /* (total_brate, bfi , st_CNG) = rx_handler(received frame type, [previous frame type], past CNG state, past core) */ curr_ft_good_sp = 0; + move16(); curr_ft_bad_sp = 0; + move16(); - if ( is_DTXrate( total_brate ) == 0 ) + IF( is_DTXrate( total_brate ) == 0 ) { - if ( st_ivas->bfi == 0 ) + IF( st_ivas->bfi == 0 ) { curr_ft_good_sp = 1; + move16(); } - else + ELSE { curr_ft_bad_sp = 1; + move16(); } } sid_update = 0; + move16(); sid_upd_bad = 0; - if ( is_SIDrate( total_brate ) == 1 ) + move16(); + IF( EQ_16( is_SIDrate( total_brate ), 1 ) ) { - if ( st_ivas->bfi == 0 ) + IF( st_ivas->bfi == 0 ) { sid_update = 1; + move16(); } - else + ELSE { sid_upd_bad = 1; /* this frame type may happen in ETSI/3GPP CS cases, a corrupt SID frames */ + move16(); } } /* all zero indices/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain */ /* all zero indices/bits may be a result of CS bit errors and/or erroneously injected by gateways or by a bad dejitter handlers */ - if ( total_brate == SID_1k75 && sid_update == 1 ) + test(); + IF( EQ_32( total_brate, SID_1k75 ) && EQ_16( sid_update, 1 ) ) { /* valid sid_update received, check for very risky but formally valid content */ - int16_t sum = 0; - for ( k = 0; k < num_bits; ++k ) + Word16 sum = 0; + move16(); + FOR( k = 0; k < num_bits; ++k ) { - sum += ( bit_stream[k] == 1 ); /* check of 35 zeroes */ + sum = add( sum, extract_l( EQ_32( bit_stream[k], 1 ) ) ); /* check of 35 zeroes */ } if ( sum == 0 ) { /* all zeros */ sid_upd_bad = 1; /* initial signal as corrupt (BER likely) */ + move16(); } } @@ -2180,14 +2181,22 @@ ivas_error read_indices( Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR . */ - if ( sid_upd_bad ) + IF( sid_upd_bad ) { sid_upd_bad = 0; + move16(); total_brate = FRAME_NO_DATA; /* treat SID_BAD as a stolen signaling frame --> SPEECH LOST */ + move32(); } g192_sid_first = 0; - if ( st_ivas->ivas_format == MONO_FORMAT && sts[0]->core == AMR_WB_CORE && *prev_ft_speech && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 ) + move16(); + + test(); + test(); + test(); + test(); + if ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) && EQ_16( sts[0]->core, AMR_WB_CORE ) && *prev_ft_speech && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 ) { g192_sid_first = 1; /* SID_FIRST detected for previous AMRWB/AMRWBIO active frames only */ /* It is not possible to perfectly simulate rate switching conditions EVS->AMRWBIO where: @@ -2195,104 +2204,135 @@ ivas_error read_indices( and a good length 0 "SID_FIRST"(NO_DATA) frame is sent in AMRWBIO, due to the one frame state memory in the AMRWB legacy G.192 SID_FIRST encoding */ + move16(); } speech_bad = 0; + move16(); + + test(); if ( st_ivas->bfi != 0 && ( is_DTXrate( total_brate ) == 0 ) ) { speech_bad = 1; /* initial ft assumption, CNG_state decides what to do */ + move16(); } speech_lost = 0; + move16(); + + test(); if ( total_brate == FRAME_NO_DATA && st_ivas->bfi != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */ { speech_lost = 1; /* initial ft assumption, CNG_state decides what to do */ + move16(); } /* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame as this frame was never transmitted, one can not know it is good and has a a length of zero ) */ - if ( *CNG != 0 ) + IF( *CNG != 0 ) { /* We were in CNG synthesis */ if ( curr_ft_good_sp != 0 ) { /* only a good speech frame makes you leave CNG synthesis */ *CNG = 0; + move16(); } } - else + ELSE { /* We were in SPEECH synthesis */ /* only a received/detected SID frame can make the decoder enter into CNG synthsis */ + test(); + test(); if ( g192_sid_first || sid_update || sid_upd_bad ) { *CNG = 1; + move16(); } } /* set bfi, total_brate pair for proper decoding */ /* handle the G.192 _simulated_ untransmitted NO_DATA frame, setting for decoder SPEECH synthesis */ + test(); + test(); if ( *CNG == 0 && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 ) { st_ivas->bfi = 1; /* SPEECH PLC code will now become active as in a real system */ /* total_brate= 0 */ + move16(); } /* handle bad/lost speech frame(and CS bad SID frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ - if ( ( - bfi != FRAMEMODE_FUTURE && - ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ - ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ + test(); + test(); + test(); + test(); + IF( ( + NE_16( bfi, FRAMEMODE_FUTURE ) && + ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ + ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ { st_ivas->bfi = 0; /* bfi=0 needed to activate CNG code */ + move16(); total_brate = FRAME_NO_DATA; + move32(); } /* update for next frame's G.192 file format's odd SID_FIRST detection (primarily for AMRWBIO) */ + test(); *prev_ft_speech = ( ( curr_ft_good_sp != 0 ) || ( curr_ft_bad_sp != 0 ) ); + move16(); /* st->total brate= total_brate; updated in a good frame below */ - for ( k = 0; k < st_ivas->nCPE; k++ ) + FOR( k = 0; k < st_ivas->nCPE; k++ ) { sts = st_ivas->hCPE[k]->hCoreCoder; - for ( n = 0; n < CPE_CHANNELS; n++ ) + FOR( n = 0; n < CPE_CHANNELS; n++ ) { sts[n]->bfi = st_ivas->bfi; + move16(); } } - for ( k = 0; k < st_ivas->nSCE; k++ ) + FOR( k = 0; k < st_ivas->nSCE; k++ ) { sts = st_ivas->hSCE[k]->hCoreCoder; sts[0]->bfi = st_ivas->bfi; + move16(); } - if ( st_ivas->bfi == 0 ) + IF( st_ivas->bfi == 0 ) { /* select Mode 1 or Mode 2 */ - if ( st_ivas->ivas_format == MONO_FORMAT ) /* EVS mono */ + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) /* EVS mono */ { decoder_selectCodec( sts[0], total_brate, bit_stream[0] ); st_ivas->hDecoderConfig->Opt_AMR_WB = sts[0]->Opt_AMR_WB; + move16(); } - else /* IVAS */ + ELSE /* IVAS */ { st_ivas->codec_mode = MODE1; + move16(); st_ivas->hDecoderConfig->Opt_AMR_WB = 0; + move16(); } } /* GOOD frame */ - if ( st_ivas->bfi == 0 || st_ivas->bfi == FRAMEMODE_FUTURE ) + test(); + if ( st_ivas->bfi == 0 || EQ_16( st_ivas->bfi, FRAMEMODE_FUTURE ) ) { /* GOOD frame - convert ITU-T G.192 words to short values */ st_ivas->hDecoderConfig->ivas_total_brate = total_brate; + move32(); } st_ivas->bit_stream = bit_stream; - if ( st_ivas->ivas_format == MONO_FORMAT ) + IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) { ivas_set_bitstream_pointers( st_ivas ); } diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 6163fc4ff..d4938f399 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -543,7 +543,8 @@ UWord16 get_indice_1_fx( /* o : value of the indice */ *-------------------------------------------------------------------*/ void reset_indices_enc_fx( - BSTR_ENC_HANDLE hBstr /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ + const Word16 max_num_indices /* i : max number of indices */ ) { Word16 i; @@ -559,7 +560,7 @@ void reset_indices_enc_fx( hBstr->last_ind_fx = -1; move16(); - FOR( i = 0; i < MAX_NUM_INDICES; i++ ) + FOR( i = 0; i < max_num_indices; i++ ) { hBstr->ind_list[i].nb_bits = -1; move16(); @@ -1547,358 +1548,6 @@ Word32 BIT_ALLOC_IDX_16KHZ_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 t return L_temp; } - -/*-------------------------------------------------------------------* - * read_indices_fx() - * - * Read indices from an ITU-T G.192 bitstream to the buffer - * Simulate packet losses by inserting frame erasures - *-------------------------------------------------------------------*/ - -Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem */ - Decoder_State *st, /* i/o: decoder state structure */ - FILE *file, /* i : bitstream file */ - Word16 rew_flag /* i : rewind flag (rewind file after reading)*/ -) -{ - Word16 k; - UWord16 utmp, stream[2 + MAX_BITS_PER_FRAME], *pt_stream, *bit_stream_ptr; - Word16 num_bits; - Word32 total_brate; - Word32 L_tmp; - Word16 curr_ft_good_sp, curr_ft_bad_sp; - Word16 g192_sid_first, sid_upd_bad, sid_update; - Word16 speech_bad, speech_lost; - Word16 num_bits_read; - - st->bfi = 0; - move16(); - st->BER_detect = 0; - move16(); - st->mdct_sw_enable = 0; - move16(); - st->mdct_sw = 0; - move16(); - reset_indices_dec_fx( st ); - - /* read the Sync Header field from the bitstream */ - /* in case rew_flag is set, read until first good frame is encountered */ - test(); - test(); - DO - { - /* read the Sync header */ - IF( NE_32( fread( &utmp, sizeof( unsigned short ), 1, file ), 1 ) ) - { - IF( ferror( file ) ) - { - /* error during reading */ - fprintf( stderr, "\nError reading the bitstream !" ); - exit( -1 ); - } - ELSE - { - /* end of file reached */ - return 0; - } - } - - /* set the BFI indicator according the value of Sync Header */ - IF( EQ_16( utmp, SYNC_BAD_FRAME ) ) - { - st->bfi = 1; - move16(); - } - ELSE - { - st->bfi = 0; - move16(); - } - - /* read the Frame Length field from the bitstream */ - IF( NE_32( fread( &num_bits, sizeof( unsigned short ), 1, file ), 1 ) ) - { - IF( ferror( file ) ) - { - /* error during reading */ - fprintf( stderr, "\nError reading the bitstream !" ); - exit( -1 ); - } - ELSE - { - /* end of file reached */ - return 0; - } - } - /* convert the frame length to total bitrate */ - total_brate = L_mult0( num_bits, 50 ); - - /* read ITU-T G.192 serial stream of indices from file to the local buffer */ - /* Validate that the G.192 length is within the defined bit rate range - to not allow writing past the end of the "stream" buffer */ - IF( GT_16( num_bits, MAX_BITS_PER_FRAME ) ) - { - fprintf( stderr, "\nError, too large G.192 frame (size(%d))! Exiting ! \n", num_bits ); - exit( -1 ); - } - - /* verify that a valid num bits value is present in the G.192 file */ - /* only AMRWB or EVS bit rates or 0(NO DATA) are allowed in G.192 file frame reading */ - IF( rate2EVSmode( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ - { - fprintf( stderr, "\nError, illegal bit rate (%d) in the G.192 frame ! Exiting ! \n", total_brate ); - exit( -1 ); - } - pt_stream = stream; - - num_bits_read = (Word16) fread( pt_stream, sizeof( unsigned short ), num_bits, file ); - move16(); - - IF( NE_16( num_bits_read, num_bits ) ) - { - fprintf( stderr, "\nError, invalid number of bits read ! Exiting ! \n" ); - exit( -1 ); - } - } - WHILE( rew_flag && ( st->bfi || ( total_brate < 2800 ) ) ); - - /* G.192 RX DTX handler*/ - IF( !rew_flag ) - { - /* handle SID_FIRST, SID_BAD, SPEECH_LOST, NO_DATA as properly as possible for the ITU-T G.192 format */ - - /* (total_brate, bfi , st_CNG) = rx_handler(received frame type, [previous frame type], past CNG state, past core) */ - curr_ft_good_sp = 0; - move16(); - curr_ft_bad_sp = 0; - move16(); - - IF( GT_32( total_brate, SID_2k40 ) ) - { - IF( st->bfi == 0 ) - { - curr_ft_good_sp = 1; - move16(); - } - ELSE - { - curr_ft_bad_sp = 1; - move16(); - } - } - sid_update = 0; - move16(); - sid_upd_bad = 0; - move16(); - - test(); - IF( total_brate == SID_1k75 || total_brate == SID_2k40 ) - { - IF( st->bfi == 0 ) - { - sid_update = 1; - move16(); - } - ELSE - { - sid_upd_bad = 1; /* may happen in CS , corrupt but detected sid frame */ - move16(); - } - } - - /* all zero indeces/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain */ - /* all zero indeces/bits may be a result of CS bit errors and/or erroneously injected by gateways or by a bad dejitter handlers */ - test(); - IF( EQ_32( total_brate, SID_1k75 ) && EQ_16( sid_update, 1 ) ) - { - /* valid sid_update received, check for very risky but formally valid content */ - Word16 sum = 0; - move16(); - FOR( k = 0; k < num_bits; ++k ) - { - sum = add( sum, extract_l( EQ_16( pt_stream[k], G192_BIN1 ) ) ); /* check of 35 zeroes, 35 ones */ - } - if ( sum == 0 ) - { /* all zeros */ - sid_upd_bad = 1; /* initial signal as corrupt (BER likley) */ - move16(); - } - } - - /* AMRWB 26.173 G.192 file reader (read_serial) does not declare/use SID_BAD ft, - it declares every bad synch marked frame initially as a lost_speech frame, - and then the RXDTX handler CNG state decides the decoding mode CNG/SPEECH. - While In the AMRWB ETSI/3GPP format eid a CRC error in a detected SID_UPDATE frame triggers SID_UPD_BAD. - - Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR . - */ - IF( sid_upd_bad ) - { - sid_upd_bad = 0; - move16(); - total_brate = FRAME_NO_DATA; /* treat SID_BAD as a stolen signaling frame --> SPEECH LOST */ - move32(); - } - - g192_sid_first = 0; - move16(); - - test(); - test(); - test(); - if ( EQ_16( st->core, AMR_WB_CORE ) && st->prev_ft_speech_fx && total_brate == FRAME_NO_DATA && st->bfi == 0 ) - { - g192_sid_first = 1; /* SID_FIRST detected for previous AMRWB/AMRWBIO active frames only */ - /* - It is not possible to perfectly simulate rate switching conditions EVS->AMRWBIO where: - the very first SID_FIRST detection is based on a past EVS active frame - and a good length 0 "SID_FIRST"(NO_DATA) frame is sent in AMRWBIO, - , due to the one frame state memory in the AMRWB legacy G.192 SID_FIRST encoding - */ - move16(); - } - - speech_bad = 0; - move16(); - - test(); - if ( GT_32( total_brate, SID_2k40 ) && st->bfi != 0 ) /* CS-type of CRC failure frame */ - { - speech_bad = 1; /* initial assumption, CNG_state decides what to do */ - move16(); - } - - speech_lost = 0; - move16(); - - test(); - if ( total_brate == 0 && st->bfi != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */ - { - speech_lost = 1; /* initial assumption, CNG_state decides what to do */ - move16(); - } - - /* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame - as this frame was never transmitted, one can not know it is good and has a a length of zero ) */ - - IF( st->CNG_fx != 0 ) - { - /* We were in CNG synthesis */ - if ( curr_ft_good_sp != 0 ) - { - /* only a good speech frame makes you leave CNG synthesis */ - st->CNG_fx = 0; - move16(); - } - } - ELSE - { - /* We were in SPEECH synthesis */ - /* only a received SID frame can make the decoder enter into CNG synthsis */ - test(); - test(); - if ( g192_sid_first || sid_update || sid_upd_bad ) - { - st->CNG_fx = 1; - move16(); - } - } - - /* handle the g.192 _simulated_ untransmitted frame, setting for decoder SPEECH synthesis */ - test(); - test(); - if ( ( st->CNG_fx == 0 ) && ( total_brate == 0 && st->bfi == 0 ) ) - { - st->bfi = 1; - move16(); /* SPEECH PLC code will now become active as in a real system */ - /* total_brate= 0 */ - } - - /* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ - test(); - test(); - test(); - IF( ( ( st->CNG_fx != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ - ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ - { - st->bfi = 0; - move16(); - total_brate = 0; - move32(); - } - /* update for next frame's G.192 file format's SID_FIRST detection (primarily for AMRWBIO) */ - test(); - st->prev_ft_speech_fx = ( ( curr_ft_good_sp != 0 ) || ( curr_ft_bad_sp != 0 ) ); - move16(); - - /* st->total brate= total_brate ; updated in a good frame below */ - } /* rew_flag */ - - /* get total bit-rate */ -#ifdef DEBUGGING - st->bfi |= file_read_FECpattern(); -#endif - test(); - IF( st->bfi == 0 && !rew_flag ) - { - /* select MODE1 or MODE2 */ - decoder_selectCodec( st, total_brate, *pt_stream ); - } - - Mpy_32_16_ss( total_brate, 5243, &L_tmp, &utmp ); /* 5243 is 1/50 in Q18. (0+18-15=3) */ - st->total_num_bits = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */ - move16(); - - /* in case rew_flag is set, rewind the file and return */ - /* (used in io_enc() to print out info about technologies and to initialize the codec) */ - IF( rew_flag ) - { - rewind( file ); - st->total_brate = total_brate; - move32(); - return 1; - } - - /* GOOD frame */ - IF( st->bfi == 0 ) - { - /* GOOD frame - convert ITU-T G.192 words to short values */ - bit_stream_ptr = st->bit_stream; - - FOR( k = 0; k < num_bits; ++k ) - { - *bit_stream_ptr++ = (UWord16) EQ_32( *pt_stream++, G192_BIN1 ); - move16(); - } - - /*add two zero bytes for arithmetic coder flush*/ - FOR( k = 0; k < 2 * 8; ++k ) - { - *bit_stream_ptr++ = 0; - move16(); - } - /*a change of the total bitrate should not be - known to the decoder, if the received frame was lost*/ - st->total_brate = total_brate; - move32(); - - mdct_switching_dec( st ); - } -#ifdef DEBUGGING - else - { - bit_stream_ptr = st->bit_stream; - - for ( k = 0; k < num_bits + 2 * 8; ++k ) - { - *bit_stream_ptr++ = 0; - } - } -#endif - return 1; -} - - /*-------------------------------------------------------------------* * read_indices_mime_handle_dtx() * diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9fe14b5bd..1bd007e64 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1323,7 +1323,8 @@ UWord16 get_indice_1_fx( /* o : value of the indice */ ); void reset_indices_enc_fx( - BSTR_ENC_HANDLE hBstr /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ + const Word16 max_num_indices /* i : max number of indices */ ); void reset_indices_dec_fx( @@ -1367,12 +1368,6 @@ Word16 BRATE2IDX16k_fx( Word32 brate ); Word32 BIT_ALLOC_IDX_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc ); Word32 BIT_ALLOC_IDX_16KHZ_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc ); -Word16 read_indices_fx( /* o : 1 = OK, 0 = something wrong */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - FILE *file, /* i : bitstream file */ - Word16 rew_flag /* i : rewind flag (rewind file after reading) */ -); - Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem */ Decoder_State *st, /* i/o: decoder state structure */ FILE *file, /* i : bitstream file */ @@ -11544,11 +11539,6 @@ uint16_t get_indice( int16_t nb_bits /* i : number of bits that were used to quantize the indice */ ); -void reset_indices_enc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t max_num_indices /* i : max number of indices */ -); - void reset_indices_dec( Decoder_State *st /* i/o: decoder state structure */ ); @@ -11560,13 +11550,13 @@ Word16 rate2EVSmode_float( /*! r: 1 = OK, 0 = something wrong */ -ivas_error read_indices( +ivas_error read_indices_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t bit_stream[], /* i : bitstream buffer */ + UWord16 bit_stream[], /* i : bitstream buffer */ UWord16 num_bits, /* i : number of bits in bitstream */ - int16_t *prev_ft_speech, - int16_t *CNG, - int16_t bfi /* i : bad frame indicator */ + Word16 *prev_ft_speech, + Word16 *CNG, + Word16 bfi /* i : bad frame indicator */ ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index dc06ddc5a..56ffe3924 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -923,7 +923,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } } - IF( NE_32( ( error = read_indices( hIvasDec->st_ivas, serial, num_bits, &hIvasDec->prev_ft_speech, &hIvasDec->CNG, bfi ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = read_indices_fx( hIvasDec->st_ivas, serial, num_bits, &hIvasDec->prev_ft_speech, &hIvasDec->CNG, bfi ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 90768aca1..d88e1523e 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -160,18 +160,6 @@ void acelp_core_switch_enc_fx( /*----------------------------------------------------------------* * bit-stream: modify the layer of sub frame CELP *----------------------------------------------------------------*/ -#ifdef IVAS_CODE_BITSTREAM - i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits ); -#ifdef DEBUGGING - assert( i >= 0 && "Internal error in ACELP core switching - unable to find ACELP subframe indices!" ); -#endif - while ( hBstr->ind_list[i].id == TAG_ACELP_SUBFR_LOOP_START ) - { - push_indice( hBstr, IND_CORE_SWITCHING_CELP_SUBFRAME, hBstr->ind_list[i].value, hBstr->ind_list[i].nb_bits ); - i++; - } - delete_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START ); -#else FOR( i = 0; i < 20; i++ ) { hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].value = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].value; /* Q0 */ @@ -181,7 +169,6 @@ void acelp_core_switch_enc_fx( hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1; /* Q0 */ move16(); } -#endif /*----------------------------------------------------------------* * BWE encoding *----------------------------------------------------------------*/ diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 6e4d2a043..154b43c12 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -349,7 +349,7 @@ void dtx_ivas_fx( IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) { - reset_indices_enc( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); + reset_indices_enc_fx( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); } } #ifdef NONBE_1211_DTX_BR_SWITCHING @@ -863,11 +863,7 @@ void dtx_fx( /* reset the bitstream (IVAS format signalling was already written) */ IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) { -#ifndef IVAS_CODE_BITSTREAM - reset_indices_enc_fx( st_fx->hBstr ); -#else - reset_indices_enc( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); -#endif + reset_indices_enc_fx( st_fx->hBstr, MAX_NUM_INDICES ); } } diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index f1a87d2d2..c2aeaa7ca 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -189,11 +189,7 @@ ivas_error encod_ppp_fx( /* We write signalling indices again only in case of bump_up */ /* delete previous indices */ -#ifndef IVAS_CODE_BITSTREAM - reset_indices_enc_fx( hBstr ); -#else - reset_indices_enc_fx( hBstr, hBstr->nb_ind_tot ); -#endif + reset_indices_enc_fx( hBstr, MAX_NUM_INDICES ); /* signalling matrix (writing of signalling bits) */ signalling_enc_fx( st_fx ); @@ -377,11 +373,7 @@ ivas_error encod_ppp_ivas_fx( /* We write signalling indices again only in case of bump_up */ /* delete previous indices */ -#ifndef IVAS_CODE_BITSTREAM - reset_indices_enc_fx( hBstr ); -#else - reset_indices_enc_fx( hBstr, hBstr->nb_ind_tot ); -#endif + reset_indices_enc_fx( hBstr, MAX_NUM_INDICES ); /* signalling matrix (writing of signalling bits) */ signalling_enc_fx( st_fx ); diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index 75e82409e..d5f832f8c 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -381,19 +381,14 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit /* pitch contribution useless - delete all previously written indices belonging to pitch contribution */ FOR( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) { -#ifndef IVAS_CODE_BITSTREAM IF( hBstr->ind_list[i].nb_bits != -1 ) { hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[i].nb_bits ); /* Q0 */ hBstr->ind_list[i].nb_bits = -1; move16(); } -#else - delete_indice( hBstr, i ); -#endif } -#ifndef IVAS_CODE_BITSTREAM IF( hBstr->ind_list[IND_ES_PRED].nb_bits != -1 ) { hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_ES_PRED].nb_bits ); /* Q0 */ @@ -401,9 +396,6 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit hBstr->ind_list[IND_ES_PRED].nb_bits = -1; move16(); } -#else - delete_indice( hBstr, i ); -#endif } IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) ) { diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 2db8b956b..757a69518 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -2695,9 +2695,9 @@ void stereoFdCngCoherence_fx( ELSE IF( LE_32( sts[0]->core_brate, SID_2k40 ) && LE_32( sts[1]->core_brate, SID_2k40 ) ) { /* case: no VAD for both channels -> INACTIVE FRAME */ - reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); - reset_indices_enc( sts[1]->hBstr, sts[1]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( sts[1]->hBstr, sts[1]->hBstr->nb_ind_tot ); /* synchronize SID sending for variable SID rate */ IF( EQ_32( sts[0]->core_brate, sts[1]->core_brate ) ) diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index cd5db5377..ebfd9c4a2 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -136,18 +136,6 @@ ivas_error init_encoder_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Bitstream structure\n" ) ); } -#ifdef IVAS_CODE_BITSTREAM - - /* set pointer to the buffer of indices */ - st->hBstr->ind_list = st_ivas->ind_list; - st->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; - st->hBstr->ivas_max_num_indices = &st_ivas->ivas_max_num_indices; - st->hBstr->nb_ind_tot = 0; - move16(); - st->hBstr->nb_bits_tot = 0; - move16(); - st->hBstr->st_ivas = st_ivas; -#endif } ELSE { @@ -910,9 +898,6 @@ ivas_error init_encoder_fx( NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ), &st_fx->transientDetection ); - // reset_indices_enc_fx( st_fx->hBstr); - - st_fx->Q_syn2 = 0; move16(); st_fx->Q_syn = 0; diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index f88288ea1..cacbcabd3 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -309,7 +309,7 @@ ivas_error ivas_core_enc_fx( st->hBstr->nb_ind_tot = add( st->hBstr->nb_ind_tot, hStereoTD->tdm_hBstr_tmp.nb_ind_tot ); /* Q0 */ st->hBstr->nb_bits_tot = add( st->hBstr->nb_bits_tot, hStereoTD->tdm_hBstr_tmp.nb_bits_tot ); /* Q0 */ - reset_indices_enc( &hStereoTD->tdm_hBstr_tmp, MAX_IND_TDM_TMP ); + reset_indices_enc_fx( &hStereoTD->tdm_hBstr_tmp, MAX_IND_TDM_TMP ); } /*---------------------------------------------------------------------* diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index f21c8e262..a1f2196fb 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -405,7 +405,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( /* only reset indices if it is not the first index list, this already contains the IVAS format bits */ IF( sce_id > 0 || EQ_16( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) { - reset_indices_enc( st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr, st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr, st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->nb_ind_tot ); } } @@ -449,7 +449,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( ( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->nSCE > 0 ) || ( EQ_16( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) && st_ivas->nSCE > 0 ) ) { - reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); } } } @@ -487,7 +487,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( test(); IF( add( i_mult( cpe_id, CPE_CHANNELS ), n ) > 0 || ( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->nSCE > 0 ) ) { - reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); } IF( hEncoderConfig->Opt_DTX_ON ) @@ -667,7 +667,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( } } - reset_indices_enc( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData, st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->nb_ind_tot ); + reset_indices_enc_fx( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData, st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->nb_ind_tot ); FOR( cpe_id = 0; cpe_id < st_ivas->nCPE - 1; cpe_id++ ) { diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index b49fc9716..57858b03e 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -2151,7 +2151,7 @@ ivas_error ivas_initialize_MD_bstr_enc_fx( hMetaData->ivas_max_num_indices = &st_ivas->ivas_max_num_indices_metadata; /* Q0 */ hMetaData->st_ivas = st_ivas; - reset_indices_enc( hMetaData, st_ivas->ivas_max_num_indices_metadata ); + reset_indices_enc_fx( hMetaData, st_ivas->ivas_max_num_indices_metadata ); *hMetaData_out = hMetaData; diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 9256be408..6aba283be 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -191,7 +191,7 @@ Word16 ivas_ism_dtx_enc_fx( IF( dtx_flag ) { /* reset the bitstream (IVAS format signaling was already written) */ - reset_indices_enc( hSCE[0]->hCoreCoder[0]->hBstr, hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot ); + reset_indices_enc_fx( hSCE[0]->hCoreCoder[0]->hBstr, hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot ); } /*------------------------------------------------------------------* diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index 6a2e54db6..8e6e0c93f 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -873,7 +873,7 @@ ivas_error ivas_ism_metadata_enc_fx( /* write metadata only in active frames */ IF( GT_32( hSCE[0]->hCoreCoder[0]->core_brate, SID_2k40 ) ) { - reset_indices_enc( hSCE[ch]->hMetaData, hSCE[ch]->hMetaData->nb_ind_tot ); + reset_indices_enc_fx( hSCE[ch]->hMetaData, hSCE[ch]->hMetaData->nb_ind_tot ); } } diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index b5258712b..d31e6d53d 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -336,11 +336,11 @@ ivas_error ivas_omasa_enc_config_fx( /* re-write IVAS format signalling - actual 'ism_mode' was not known before */ IF( st_ivas->nSCE > 0 ) { - reset_indices_enc( st_ivas->hSCE[0]->hCoreCoder[0]->hBstr, st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_bits_tot ); + reset_indices_enc_fx( st_ivas->hSCE[0]->hCoreCoder[0]->hBstr, st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_bits_tot ); } ELSE { - reset_indices_enc( st_ivas->hCPE[0]->hCoreCoder[0]->hBstr, st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->nb_bits_tot ); + reset_indices_enc_fx( st_ivas->hCPE[0]->hCoreCoder[0]->hBstr, st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->nb_bits_tot ); } ivas_write_format_fx( st_ivas ); diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 2d6080995..7de54c482 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -1209,7 +1209,7 @@ void reset_metadata_spatial_fx( ELSE { /*Reset metadata*/ - reset_indices_enc( hMetaData, hMetaData->nb_ind_tot ); + reset_indices_enc_fx( hMetaData, hMetaData->nb_ind_tot ); } *total_brate = element_brate; diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index 2983ea2f0..35b65e4c1 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -608,7 +608,7 @@ ivas_error create_evs_sce_enc_fx( } st_fx->hBstr->ind_list = ind_list; // st_fx->hBstr->ind_list_fx = st->hBstr->ind_list; - reset_indices_enc_fx( st_fx->hBstr ); + reset_indices_enc_fx( st_fx->hBstr, MAX_NUM_INDICES ); hSCE->hCoreCoder[0] = st_fx; st_ivas->hSCE[sce_id] = hSCE; diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index 997581476..9c4fcc937 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -849,7 +849,7 @@ ivas_error ivas_spar_md_enc_process_fx( move16(); IF( NE_16( strat, NO_STRAT ) ) { - reset_indices_enc( &hMetaData_tmp, md_indices_allocated ); + reset_indices_enc_fx( &hMetaData_tmp, md_indices_allocated ); ivas_write_spar_md_bitstream_fx( hMdEnc, num_bands, bands_bw, &hMetaData_tmp, hEncoderConfig->ivas_total_brate, strat, qsi ); diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index 1544aab76..378068827 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -195,7 +195,7 @@ void stereo_td_init_enc_fx( move32(); hStereoTD->tdm_hBstr_tmp.ivas_max_num_indices = &hStereoTD->max_ind_tdm_tmp; hStereoTD->tdm_hBstr_tmp.st_ivas = NULL; - reset_indices_enc( &hStereoTD->tdm_hBstr_tmp, MAX_IND_TDM_TMP ); + reset_indices_enc_fx( &hStereoTD->tdm_hBstr_tmp, MAX_IND_TDM_TMP ); return; } diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 7247b6446..ce7f0e6a6 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -3734,7 +3734,6 @@ void ProcessIGF_fx( } } - // IVAS_CODE_BITSTREAM bsStart = hBstr->next_ind_fx; move16(); @@ -3749,21 +3748,11 @@ void ProcessIGF_fx( IGFEncWriteBitstream_fx( hInstance, st->hBstr, &hInstance->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); } -#ifndef IVAS_CODE_BITSTREAM bsBits = sub( hBstr->next_ind_fx, bsStart ); IF( !isTCX20 ) { IGFEncConcatenateBitstream_fx( hInstance, bsBits, &hBstr->next_ind_fx, &hBstr->nb_bits_tot, hBstr->ind_list ); } -#else - PMT( "New bit stream implementation to be checked" ) - bsBits = sub( hBstr->next_ind_fx, bsStart ); - IF( !isTCX20 ) - { - IGFEncConcatenateBitstream_fx( hInstance, bsBits, &hBstr->next_ind_fx, &hBstr->nb_bits_tot_fx, hBstr->ind_list_fx ); - } - -#endif } void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) -- GitLab From 213f62ced4428c1b26300d0b0e37c9f43480d6eb Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 13 Mar 2025 13:54:21 +0100 Subject: [PATCH 82/97] add missing defines not ported from ivas_prot.h to ivas_prot_fx.h into isar_prot.h --- lib_isar/isar_prot.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 82fbe631d..4f0967f14 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -445,6 +445,29 @@ void ivas_calculate_abs_fx( Word32 re_fx, Word16 exp_re, Word32 im_fx, Word16 ex void ivas_calculate_rabs_fx( Word32 re_fx, Word16 exp_re, Word32 *out_fx, Word16 *exp_out ); +#define IVAS_CMULT_FLOAT( in1_re, in1_im, in2_re, in2_im, out1_re, out1_im ) \ + out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); \ + out1_im = ( in1_re * in2_im ) + ( in2_re * in1_im ); + +#define IVAS_CALCULATE_ABS( re, im, out ) \ + out = sqrtf( ( re * re ) + ( im * im ) ); + +#define IVAS_CALCULATE_RABS( re, out ) \ + out = sqrtf( re * re ); + +#define IVAS_CALCULATE_SQ_ABS( re, im, out ) \ + out = (float) ( ( re * re ) + ( im * im ) ); + +#define IVAS_RMULT_DOUBLE( in1_re, in2_re, out1_re ) \ + out1_re = ( in1_re * in2_re ); \ + +#define IVAS_CALCULATE_SQ_ABS_N( re, out ) \ + out = (float) ( re * re ); + +#define IVAS_RMULT_FLOAT( in1_re, in2_re, out1_re ) \ + out1_re = ( in1_re * in2_re ); + + /* clang-format on */ #endif /* IVAS_PROT_REND_H */ -- GitLab From a046f76786bbe1e6756e3925b0825a7a41096ee6 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 13 Mar 2025 13:55:13 +0100 Subject: [PATCH 83/97] clang-format --- lib_dec/ivas_init_dec.c | 2 +- lib_isar/isar_prot.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 22a593746..cef1e45e9 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -148,7 +148,7 @@ static ivas_error ivas_dec_reconfig_split_rend( FOR( ch = 0; ch < num_ch; ch++ ) { - IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS , DEC) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); } diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 4f0967f14..90a9d2763 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -446,26 +446,26 @@ void ivas_calculate_abs_fx( Word32 re_fx, Word16 exp_re, Word32 im_fx, Word16 ex void ivas_calculate_rabs_fx( Word32 re_fx, Word16 exp_re, Word32 *out_fx, Word16 *exp_out ); #define IVAS_CMULT_FLOAT( in1_re, in1_im, in2_re, in2_im, out1_re, out1_im ) \ - out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); \ - out1_im = ( in1_re * in2_im ) + ( in2_re * in1_im ); + out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); \ + out1_im = ( in1_re * in2_im ) + ( in2_re * in1_im ); #define IVAS_CALCULATE_ABS( re, im, out ) \ - out = sqrtf( ( re * re ) + ( im * im ) ); + out = sqrtf( ( re * re ) + ( im * im ) ); #define IVAS_CALCULATE_RABS( re, out ) \ out = sqrtf( re * re ); #define IVAS_CALCULATE_SQ_ABS( re, im, out ) \ - out = (float) ( ( re * re ) + ( im * im ) ); + out = (float) ( ( re * re ) + ( im * im ) ); #define IVAS_RMULT_DOUBLE( in1_re, in2_re, out1_re ) \ - out1_re = ( in1_re * in2_re ); \ + out1_re = ( in1_re * in2_re ); #define IVAS_CALCULATE_SQ_ABS_N( re, out ) \ out = (float) ( re * re ); #define IVAS_RMULT_FLOAT( in1_re, in2_re, out1_re ) \ - out1_re = ( in1_re * in2_re ); + out1_re = ( in1_re * in2_re ); /* clang-format on */ -- GitLab From 07b7b2db45859778ef0d6da3d1f6d455f9659b36 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 13 Mar 2025 18:20:10 +0100 Subject: [PATCH 84/97] add git fetch before checking for float ref branch --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 886fa96f1..069131722 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1063,6 +1063,7 @@ check-naming-of-branch-for-main-pc-merges: script: - *update-scripts-repo - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then + - git fetch - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -- GitLab From 1cf8c8882344da44d548c74d190b5c9a35669bca Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 08:15:53 +0100 Subject: [PATCH 85/97] increase timeout for split rendering comp test --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 069131722..c0a7d37b5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1340,8 +1340,7 @@ split-rendering-pytest-on-merge-request: - .test-job-linux-needs-testv-dir - .rules-merge-request needs: ["build-codec-linux-make"] - # TODO: set reasonable timeout, will most likely take less - timeout: "30 minutes" + timeout: "45 minutes" stage: compare script: - *print-common-info -- GitLab From b23e6918ae00b6a51699c577faba9e72d3398243 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 14 Mar 2025 09:45:41 +0100 Subject: [PATCH 86/97] update --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0c5f94a40..109e81094 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -180,9 +180,9 @@ #define SPLIT_REND_POSE_CORRECTION_UNUSED_BITS #define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ #endif +#define NONBE_FIX_855_JBM_FLUSH_OFFSET /* FhG: issue #855: add missing switch here for the code in JBM flushing */ #define FIX_923_EXTERNAL_REND_COMMAND_LINE /* VA: issue 923: enable external renderer command-line options in UPPER case letters */ -#define NONBE_FIX_855_JBM_FLUSH_OFFSET /* FhG: issue #855: add missing switch here for the code in JBM flushing */ /* #################### End BASOP porting switches ############################ */ -- GitLab From e5067a7b89c47c7ccdd35eb75a56293e721887a4 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 13:47:59 +0100 Subject: [PATCH 87/97] move switch to correct section --- lib_com/options.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 348e4bc24..b2dd1e3e7 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,7 +79,6 @@ #define FIX_QMETADATA_PENALTY /* Nokia: transform penalty calculation in qmetadata into integer operations */ #define FIX_1013_CRASH_HQ_CORE_DEC /* Ittiam: Saturation added on the lines of EVS */ #define NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS /* DLB: adjust prerendering and mixing gain in OSBA encoder. This is fix to float codes*/ -#define NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA /* FhG: issue 926: crash in OSBA decoding with planar FOA */ #define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */ #define FIX_ISSUE_1062_AND_1068_TON_ENE_EST_FX #define FIX_ISSUE_987 @@ -184,7 +183,7 @@ #define NONBE_FIX_855_JBM_FLUSH_OFFSET /* FhG: issue #855: add missing switch here for the code in JBM flushing */ #define FIX_923_EXTERNAL_REND_COMMAND_LINE /* VA: issue 923: enable external renderer command-line options in UPPER case letters */ #define FIX_921_OMASA_DELAY_PRINTOUT /* VA: issue 921: correct OMASA decoder delay printout */ - +#define NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA /* FhG: issue 926: crash in OSBA decoding with planar FOA */ /* #################### End BASOP porting switches ############################ */ -- GitLab From 847c923ffd563692dad77bd8e0833ebd05dfef11 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 13:57:29 +0100 Subject: [PATCH 88/97] add debug output in CI job --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c0a7d37b5..95f7c9959 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1062,6 +1062,7 @@ check-naming-of-branch-for-main-pc-merges: - ivas-basop-linux script: - *update-scripts-repo + - git branch --list - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - git fetch - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME -- GitLab From a3a3f515ece52eeaa9184292fa8a68ac7e78b68f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:02:16 +0100 Subject: [PATCH 89/97] apply clang-format --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 8cee8c26d..95d9fb03e 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -3401,7 +3401,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( test(); test(); -#ifdef NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA +#ifdef NONBE_FIX_926_OSBA_DECODER_CRASH_PLANAR_SBA if ( EQ_16( num_tc, 3 ) ) #else if ( ( st_ivas->sba_planar && GE_16( num_tc, 3 ) ) || EQ_16( num_tc, 3 ) ) -- GitLab From c796ec69f3dcbf2fe7604c1f48877359de1ffe65 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:03:22 +0100 Subject: [PATCH 90/97] add further debug printout --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 95f7c9959..e6801b2c5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1065,6 +1065,7 @@ check-naming-of-branch-for-main-pc-merges: - git branch --list - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - git fetch + - git branch --list - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -- GitLab From 4455a51b8bdc2180cca085182bb0264801caa0cc Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:07:08 +0100 Subject: [PATCH 91/97] use -av arg for git branch command --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e6801b2c5..d549fceab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1062,10 +1062,10 @@ check-naming-of-branch-for-main-pc-merges: - ivas-basop-linux script: - *update-scripts-repo - - git branch --list + - git branch -av - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - git fetch - - git branch --list + - git branch -av - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -- GitLab From a3e33d36e9483f0e92a6db81fa879e75536574da Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:33:48 +0100 Subject: [PATCH 92/97] dummy commit to trigger CI -- GitLab From 8583d6677d115474e6978a801aff307bfc41cabd Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:38:24 +0100 Subject: [PATCH 93/97] more debug printout... --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d549fceab..d313d639d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1064,8 +1064,9 @@ check-naming-of-branch-for-main-pc-merges: - *update-scripts-repo - git branch -av - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - - git fetch - - git branch -av + - float_ref_branchname="${branchname/basop/ref}" + - git_result=$(git branch -av --list "$float_ref_branchname") + - echo "$git_result" - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -- GitLab From d9721934c1922732da8dbef49a7cec346d6b97e6 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:40:00 +0100 Subject: [PATCH 94/97] fix last commit --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d313d639d..ddd665f8f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1064,6 +1064,7 @@ check-naming-of-branch-for-main-pc-merges: - *update-scripts-repo - git branch -av - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then + - branchname="$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" - float_ref_branchname="${branchname/basop/ref}" - git_result=$(git branch -av --list "$float_ref_branchname") - echo "$git_result" -- GitLab From 4c39492de6c619da105ceda2c4b7769f6c951b0f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:46:05 +0100 Subject: [PATCH 95/97] more debugging --- .gitlab-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ddd665f8f..59a7a99fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1062,12 +1062,17 @@ check-naming-of-branch-for-main-pc-merges: - ivas-basop-linux script: - *update-scripts-repo - - git branch -av - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then + - set -euxo - branchname="$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" - float_ref_branchname="${branchname/basop/ref}" + - git branch -av + - git branch -av --list || true + - git branch -av --list $branchname + - git branch -av --list "$float_ref_branchname" - git_result=$(git branch -av --list "$float_ref_branchname") - echo "$git_result" + - set +euxo - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -- GitLab From 2cf229b2d2e23183de25644cefb1a8d1f24c2343 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 14:54:31 +0100 Subject: [PATCH 96/97] try with different script branch from flaot repo --- .gitlab-ci.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 59a7a99fc..00b954ca6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ variables: MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" + BASOP_CI_BRANCH_PC_REPO: "basop-ci/fix-get-float-ref-script" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 @@ -1063,16 +1063,6 @@ check-naming-of-branch-for-main-pc-merges: script: - *update-scripts-repo - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - - set -euxo - - branchname="$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" - - float_ref_branchname="${branchname/basop/ref}" - - git branch -av - - git branch -av --list || true - - git branch -av --list $branchname - - git branch -av --list "$float_ref_branchname" - - git_result=$(git branch -av --list "$float_ref_branchname") - - echo "$git_result" - - set +euxo - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -- GitLab From 49de6d513ed5c6430389bfda073ab7ee8e0c188b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 14 Mar 2025 15:21:22 +0100 Subject: [PATCH 97/97] change scripts branch back --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 00b954ca6..57ae48287 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ variables: MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "basop-ci/fix-get-float-ref-script" + BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 -- GitLab