diff --git a/lib_com/options.h b/lib_com/options.h index a1ce299e394898127214eddb8f0313005081fcb8..f0e68666f41eb3e320f2ad925d9d51f62a4845e4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,6 +96,7 @@ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ #define HARMONIZE_2595_reconfig_decoder_LPD /* FhG: Harmonize reconfig_decoder_LPD with its ivas derivate */ #define HARMONIZE_2596_SetModeIndex /* FhG: Harmonize SetModeIndex with its ivas derivate */ +#define HARMONIZE_2597_ShapeSpectrum /* FhG: Harmonize ShapeSpectrum with its ivas derivate */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 8b18752079520a9850f3ebd8d38bdac149b1b89e..dd98be924c55fdb55460ef75e64db86f10699800 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -221,6 +221,7 @@ void TNSAnalysis_fx( } } +#ifndef HARMONIZE_2597_ShapeSpectrum void ShapeSpectrum_fx( TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ Word16 A[], /* input: quantized coefficients NxAz_q[M+1] Q = 14 - norm(A[0])*/ @@ -460,14 +461,20 @@ void ShapeSpectrum_fx( PsychAdaptLowFreqEmph_fx( spectrum, gainlpc, gainlpc_e ); } } +#endif + +#ifdef HARMONIZE_2597_ShapeSpectrum +void ShapeSpectrum_fx( +#else void ShapeSpectrum_ivas_fx( +#endif TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ Word16 A[], /* input: quantized coefficients NxAz_q[M+1], Q = 14 - norm(A[0]) */ Word16 gainlpc[], /* output: MDCT gains for the previous frame Q(15-gainlpc_e)*/ Word16 gainlpc_e[], /* output: MDCT gains exponents */ Word16 L_frame_glob, /* input: frame length */ Word16 L_spec, - Word32 spectrum[], /* i/o: MDCT spectrum Q(31-spectrum_e) */ + Word32 spectrum[], /* i/o: MDCT spectrum */ Word16 *spectrum_e, /* i/o: MDCT spectrum exponent */ Word8 pfUseTns, /* output: Flag indicating if TNS is used */ Encoder_State *st, @@ -724,7 +731,11 @@ void ShapeSpectrum_ivas_fx( { Word16 fac; fac = divide3232( max_low2, max_high ); +#ifdef HARMONIZE_2597_ShapeSpectrum + IF( GE_16( norm_s( fac ), max_fac_s ) || EQ_16( st->element_mode, EVS_MONO ) ) +#else IF( GE_16( norm_s( fac ), max_fac_s ) ) +#endif { fac = shl( mult_r( fac, max_fac_m ), max_fac_s ); FOR( i = 0; i < ( L_spec - L_frame ); i++ ) @@ -3793,12 +3804,23 @@ void coder_tcx_fx( ProcessIGF_fx( st, 0, spectrum, &q_spectrum, NULL, 0, powerSpec, &powerSpec_e, 1, 0, 0, 0 ); } +#ifdef HARMONIZE_2597_ShapeSpectrum + ShapeSpectrum_fx( hTcxCfg, A, gainlpc, gainlpc_e, + L_frame_glob, + L_spec, + spectrum, + 0, + hTcxEnc->fUseTns[0], + st, + 0 ); +#else ShapeSpectrum_fx( hTcxCfg, A, gainlpc, gainlpc_e, L_frame_glob, L_spec, spectrum, hTcxEnc->fUseTns[0], st ); +#endif if ( st->igf ) { nb_bits = sub( nb_bits, st->hIGFEnc->infoTotalBitsPerFrameWritten ); diff --git a/lib_enc/core_enc_2div_fx.c b/lib_enc/core_enc_2div_fx.c index 3012bb094cfe97ad8d2084676ae69eac221d4f52..1ce69cce12e158df3279b4eab11601e5a6a35343 100644 --- a/lib_enc/core_enc_2div_fx.c +++ b/lib_enc/core_enc_2div_fx.c @@ -171,6 +171,19 @@ void core_encode_twodiv_fx( } /* Shape spectrum */ +#ifdef HARMONIZE_2597_ShapeSpectrum + ShapeSpectrum_fx( st->hTcxCfg, + A_q, + gainlpc[n], + gainlpc_e[n], + shr( st->L_frame, 1 ), + shr( st->hTcxCfg->tcx_coded_lines, 1 ), + spectrum[n], + 0, + hTcxEnc->fUseTns[n], + st, + 0 ); +#else ShapeSpectrum_fx( st->hTcxCfg, A_q, gainlpc[n], @@ -180,6 +193,7 @@ void core_encode_twodiv_fx( spectrum[n], hTcxEnc->fUseTns[n], st ); +#endif st->last_core = st->core; move16(); @@ -266,7 +280,19 @@ void core_encode_twodiv_fx( E_LPC_f_lsp_a_conversion( lsp_q, A_q, M ); - +#ifdef HARMONIZE_2597_ShapeSpectrum + ShapeSpectrum_fx( st->hTcxCfg, + A_q, + gainlpc[0], + gainlpc_e[0], + st->L_frame, + st->hTcxCfg->tcx_coded_lines, + spectrum[0], + 0, + hTcxEnc->fUseTns[0], + st, + 0 ); +#else ShapeSpectrum_fx( st->hTcxCfg, A_q, gainlpc[0], @@ -276,6 +302,7 @@ void core_encode_twodiv_fx( spectrum[0], hTcxEnc->fUseTns[0], st ); +#endif /*_DIFF_FLOAT_FIX_EVS_IVAS -> The line below is present in float */ // hTcxEnc->measuredBwRatio = 0x4000; diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index bae3e6f55affe3b42b01e91c4543630fa4482801..e5e0ab31159486a592a05c4b320b104f3b2d1c88 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -2125,7 +2125,11 @@ void ivas_mdct_core_whitening_enc_fx( move16(); /* Shape spectrum */ +#ifdef HARMONIZE_2597_ShapeSpectrum + ShapeSpectrum_fx( st->hTcxCfg, A_q_fx[ch][n], NULL, NULL, L_subframe, tcx_subframe_coded_lines, st->hTcxEnc->spectrum_fx[n], &st->hTcxEnc->spectrum_e[n], st->hTcxEnc->fUseTns[n], st, scf_q_fx[ch][n] ); +#else ShapeSpectrum_ivas_fx( st->hTcxCfg, A_q_fx[ch][n], NULL, NULL, L_subframe, tcx_subframe_coded_lines, st->hTcxEnc->spectrum_fx[n], &st->hTcxEnc->spectrum_e[n], st->hTcxEnc->fUseTns[n], st, scf_q_fx[ch][n] ); +#endif Scale_sig32( st->hTcxEnc->spectrum_fx[n] + L_subframe, sub( L_subframeTCX, L_subframe ), sub( exp_tmp, st->hTcxEnc->spectrum_e[n] ) ); } @@ -2265,7 +2269,11 @@ void ivas_mdct_core_whitening_enc_fx( move16(); /* Shape spectrum */ +#ifdef HARMONIZE_2597_ShapeSpectrum + ShapeSpectrum_fx( st->hTcxCfg, A_q_fx[ch][n], NULL, NULL, L_subframe, tcx_subframe_coded_lines, mdst_spectrum_fx[ch][n], &mdst_spectrum_e[ch][n], st->hTcxEnc->fUseTns[n], st, scf_q_fx[ch][n] ); +#else ShapeSpectrum_ivas_fx( st->hTcxCfg, A_q_fx[ch][n], NULL, NULL, L_subframe, tcx_subframe_coded_lines, mdst_spectrum_fx[ch][n], &mdst_spectrum_e[ch][n], st->hTcxEnc->fUseTns[n], st, scf_q_fx[ch][n] ); +#endif Scale_sig32( mdst_spectrum_fx[ch][n] + L_subframe, sub( L_subframeTCX, L_subframe ), sub( exp_tmp, mdst_spectrum_e[ch][n] ) ); } diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 74326d7dd57231d832f5363b8cc8dbfa9c930a55..fdc43a6db8b586c1dc5a02c3778e13d0dce15f62 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -520,7 +520,11 @@ void stereo_tcx_core_enc( bitsAvailable = sub( bitsAvailable, nbits_lpc[n] ); /* Shape spectrum */ +#ifdef HARMONIZE_2597_ShapeSpectrum + ShapeSpectrum_fx( st->hTcxCfg, A_q_fx, gainlpc_fx[n], gainlpc_e[n], st->L_frame / n_subframes, st->hTcxCfg->tcx_coded_lines / n_subframes, hTcxEnc->spectrum_fx[n], &hTcxEnc->spectrum_e[n], hTcxEnc->fUseTns[n], st, NULL ); +#else ShapeSpectrum_ivas_fx( st->hTcxCfg, A_q_fx, gainlpc_fx[n], gainlpc_e[n], st->L_frame / n_subframes, st->hTcxCfg->tcx_coded_lines / n_subframes, hTcxEnc->spectrum_fx[n], &hTcxEnc->spectrum_e[n], hTcxEnc->fUseTns[n], st, NULL ); +#endif st->last_core = st->core; move16(); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 7b20bddd1f2a019ac237efbdb45e81be2b2d5d29..e40be89e7c1b0fae66ae9ba8b26b0af42e3ba110 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1976,6 +1976,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( Word16 *Q_new, Word16 *q_win ); +#ifndef HARMONIZE_2597_ShapeSpectrum void ShapeSpectrum_fx( TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ Word16 A[], /* i : quantized coefficients NxAz_q[M+1] */ @@ -1986,17 +1987,22 @@ void ShapeSpectrum_fx( Word32 spectrum[], /* i/o: MDCT spectrum */ Word8 pfUseTns, /* o : Flag indicating if TNS is used */ Encoder_State *st ); +#endif +#ifdef HARMONIZE_2597_ShapeSpectrum +void ShapeSpectrum_fx( +#else void ShapeSpectrum_ivas_fx( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word16 A[], /* i : quantized coefficients NxAz_q[M+1], Q = 14 - norm(A[0])*/ - Word16 gainlpc[], /* o : MDCT gains for the previous frame */ - Word16 gainlpc_e[], /* o : MDCT gains exponents */ - Word16 L_frame_glob, /* i : frame length */ +#endif + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + Word16 A[], /* input: quantized coefficients NxAz_q[M+1], Q = 14 - norm(A[0]) */ + Word16 gainlpc[], /* output: MDCT gains for the previous frame Q(15-gainlpc_e)*/ + Word16 gainlpc_e[], /* output: MDCT gains exponents */ + Word16 L_frame_glob, /* input: frame length */ Word16 L_spec, - Word32 spectrum[], /* i/o: MDCT spectrum */ - Word16 *spectrum_e, /* i/o: MDCT spectrum exponent */ - Word8 pfUseTns, /* output: Flag indicating if TNS is used */ + Word32 spectrum[], /* i/o: MDCT spectrum */ + Word16 *spectrum_e, /* i/o: MDCT spectrum exponent */ + Word8 pfUseTns, /* output: Flag indicating if TNS is used */ Encoder_State *st, Word32 *scf /* Q16 */ );