diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 7adb4d8065bcf1c2360c498b54198041d2d1fd96..8efa8b8961d85079b827a465ecb4585fe1f085d7 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3422,7 +3422,11 @@ void mctStereoIGF_enc_fx( Encoder_State **sts, /* i/o: encoder state structure */ Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2], /* i : MDCT spectrum for ITF */ Word16 q_origSpec, /* i : Q for MDCT spectrum */ +#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC + Word32 *powerSpec[MCT_MAX_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */ +#else Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */ +#endif Word16 q_powerSpec[MCT_MAX_CHANNELS], /* i : Q for powSpec_fx */ Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : same as powerSpec_fx but for inverse spect.*/ Word16 *q_powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV], /* i : Q for powSpecMsInv_fx */ diff --git a/lib_com/options.h b/lib_com/options.h index e666308ca10ce63d00d4cca87f4ffb11d99296b1..32c01efeb090c715b556d4d615bdf63c5b38e3a8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,6 +115,7 @@ #define FIX_1138_SBA_EXT_ERROR_PRINTOUT /* VA: issue 1138: Fix SBA EXT output call of audioCfg2channels() */ #define NONBE_FIX_981_PARAMBIN_DEFAULT_EARLY_PART /* Nokia: Set default early part energy correction to unity for BINAURAL_ROOM_REVERB */ #define NONBE_FIX_1174_MCMASA_LBR_LOOP_ERROR /* Nokia: Fix issue 1174 by removing the unnecessary inner loop causing problems. */ +#define NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC /* FhG: fix out-of-bound errors when switching from SID frame to active frame*/ #define NONBE_FIX_1052_SBA_EXT_FIX /* VA: SBA external output support fix - do not overwrite "output_config" parameter */ #define NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING /* VA: issue 1110: fix encoder crash in the stereo DTX bitrate switching condition */ #define NONBE_1894_OSBA_SCALING /* FhG: do not scale OSBA inputs by 0.5 any more */ @@ -124,6 +125,7 @@ #define NONBE_SVD_OPTIMIZATION #define NONBE_FIX_1176_OSBA_REVERB_JBM_ASAN_ERROR /* Ericsson: Issue 1176, fix in TDREND_firfilt for subframes shorter than the filter length */ + /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index 27d0a150152c83ca73119a9d62f6e4ac69dddee9..b785eb4bfa69b32b70026cb77c88fd38a81e9227 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -233,19 +233,39 @@ void ivas_mct_core_enc_fx( Word16 i, cpe_id, n, nAvailBits; Word16 nCPE; Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2]; /* Pointers to MDCT output for a short block (L/R) */ +#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC + Word32 powerSpecMsInv_long_cpe0_fx[CPE_CHANNELS][L_FRAME_PLUS]; + Word32 inv_spectrum_long_cpe0_fx[CPE_CHANNELS][L_FRAME_PLUS]; + Word32 powerSpec_long_cpe0_fx[CPE_CHANNELS][L_FRAME_PLUS]; + Word32 powerSpec_long_fx[MCT_MAX_CHANNELS - CPE_CHANNELS][L_FRAME48k]; + Word32 inv_spectrum_long_fx[MCT_MAX_CHANNELS - CPE_CHANNELS][L_FRAME48k]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */ + Word32 powerSpecMsInv_long_fx[MCT_MAX_CHANNELS - CPE_CHANNELS][L_FRAME48k]; /* MS inv power spectrum, also inverse MDST spectrum */ +#else Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k]; +#endif Word16 exp_powerSpec[MCT_MAX_CHANNELS][N_MAX + L_MDCT_OVLP_MAX]; Word32 mdst_fx; +#ifndef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC Word32 powerSpecMsInv_long_fx[MCT_MAX_CHANNELS][L_FRAME48k]; /* MS inv power spectrum, also inverse MDST spectrum */ +#endif +#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC + Word32 *powerSpec_fx[MCT_MAX_CHANNELS]; +#endif Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][2]; Word32 *inv_mdst_spectrum_fx[MCT_MAX_CHANNELS][2]; Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][2]; Word32 *mdst_spectrum_fx[MCT_MAX_CHANNELS][2] = { { NULL } }; +#ifndef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC Word32 inv_spectrum_long_fx[MCT_MAX_CHANNELS][L_FRAME48k]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */ +#endif Word16 total_side_bits; Word16 chBitRatios[MCT_MAX_CHANNELS]; Word16 q_powSpec[MCT_MAX_CHANNELS], q_spec, q_origSpec, tmp_s; +#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC + Word16 tmp_q_powSpec[L_FRAME_PLUS], tmp_q_powSpecInv[MCT_MAX_CHANNELS][L_FRAME_PLUS], *tmp_q_psi[MCT_MAX_CHANNELS][2]; +#else Word16 tmp_q_powSpec[L_FRAME48k], tmp_q_powSpecInv[MCT_MAX_CHANNELS][L_FRAME48k], *tmp_q_psi[MCT_MAX_CHANNELS][2]; +#endif Word64 W_tmp; Encoder_State *sts[MCT_MAX_CHANNELS]; Encoder_State *st; @@ -270,6 +290,62 @@ void ivas_mct_core_enc_fx( nCPE = add( nCPE, 1 ); } +#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC + /* point first CPE channels to longer buffers where switching from ACELP to TCX may occur in SBA with DTX (total memory saving)*/ + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + set32_fx( inv_spectrum_long_cpe0_fx[ch], 0, L_FRAME_PLUS ); + set32_fx( powerSpec_long_cpe0_fx[ch], 0, L_FRAME_PLUS ); // tmp_q_powSpec + set32_fx( powerSpecMsInv_long_cpe0_fx[ch], 0, L_FRAME_PLUS ); // tmp_q_powSpecInv + + inv_mdst_spectrum_fx[ch][0] = powerSpecMsInv_fx[ch][0] = powerSpecMsInv_long_cpe0_fx[ch]; + inv_mdst_spectrum_fx[ch][1] = powerSpecMsInv_fx[ch][1] = powerSpecMsInv_long_cpe0_fx[ch] + N_TCX10_MAX; + + set16_fx( tmp_q_powSpecInv[ch], 63, L_FRAME_PLUS ); + + tmp_q_psi[ch][0] = tmp_q_powSpecInv[ch]; + tmp_q_psi[ch][1] = &tmp_q_powSpecInv[ch][N_TCX10_MAX]; + + inv_spectrum_fx[ch][0] = inv_spectrum_long_cpe0_fx[ch]; + inv_spectrum_fx[ch][1] = inv_spectrum_long_cpe0_fx[ch] + N_TCX10_MAX; + powerSpec_fx[ch] = powerSpec_long_cpe0_fx[ch]; + } + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + q_powSpec[ch] = 0; + move16(); + set16_fx( exp_powerSpec[ch], 0, N_MAX + L_MDCT_OVLP_MAX ); + } + + FOR( ch = CPE_CHANNELS; ch < nChannels; ch++ ) + { + set32_fx( inv_spectrum_long_fx[ch - CPE_CHANNELS], 0, L_FRAME48k ); + set32_fx( powerSpec_long_fx[ch - CPE_CHANNELS], 0, L_FRAME48k ); // tmp_q_powSpec + set32_fx( powerSpecMsInv_long_fx[ch - CPE_CHANNELS], 0, L_FRAME48k ); // tmp_q_powSpecInv + + inv_mdst_spectrum_fx[ch][0] = powerSpecMsInv_fx[ch][0] = powerSpecMsInv_long_fx[ch - CPE_CHANNELS]; + inv_mdst_spectrum_fx[ch][1] = powerSpecMsInv_fx[ch][1] = powerSpecMsInv_long_fx[ch - CPE_CHANNELS] + N_TCX10_MAX; + + set16_fx( tmp_q_powSpecInv[ch], 63, L_FRAME48k ); + + tmp_q_psi[ch][0] = tmp_q_powSpecInv[ch]; + tmp_q_psi[ch][1] = &tmp_q_powSpecInv[ch][N_TCX10_MAX]; + + inv_spectrum_fx[ch][0] = inv_spectrum_long_fx[ch - CPE_CHANNELS]; + inv_spectrum_fx[ch][1] = inv_spectrum_long_fx[ch - CPE_CHANNELS] + N_TCX10_MAX; + powerSpec_fx[ch] = powerSpec_long_fx[ch - CPE_CHANNELS]; + } + + FOR( ch = CPE_CHANNELS; ch < MCT_MAX_CHANNELS; ch++ ) + { + set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k ); + q_powSpec[ch] = 0; + move16(); + set16_fx( exp_powerSpec[ch], 0, N_MAX + L_MDCT_OVLP_MAX ); + } + + set16_fx( tmp_q_powSpec, 63, L_FRAME_PLUS ); +#else FOR( ch = 0; ch < MCT_MAX_CHANNELS; ch++ ) { set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k ); @@ -295,6 +371,7 @@ void ivas_mct_core_enc_fx( } set16_fx( tmp_q_powSpec, 63, L_FRAME48k ); +#endif FOR( ( cpe_id = 0, i = 0 ); cpe_id < nCPE; cpe_id++ ) { diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index f28adafa428cd09ad2c0eb3fbaa74e8d0ddf4214..6403d90ada186c6984dd0e5ebd1a91c42fdd1a39 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -979,11 +979,15 @@ void write_mct_bitstream_fx( * IGF analysis of channels after MCT processing *--------------------------------------------------------------------*/ void mctStereoIGF_enc_fx( - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2], /* i : MDCT spectrum for ITF */ - Word16 q_origSpec, /* i : Q for MDCT spectrum */ - Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */ + MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ + Encoder_State **sts, /* i/o: encoder state structure */ + Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2], /* i : MDCT spectrum for ITF */ + Word16 q_origSpec, /* i : Q for MDCT spectrum */ +#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC + Word32 *powerSpec_fx[MCT_MAX_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */ +#else + Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */ +#endif Word16 q_powerSpec[MCT_MAX_CHANNELS], /* i : Q for powSpec_fx */ Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i : same as powerSpec_fx but for inverse spect.*/ Word16 *q_powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV], /* i : Q for powSpecMsInv_fx */