diff --git a/lib_com/options.h b/lib_com/options.h index d222b7a6b633082d4d723d357da254ce831bdbb0..39492eb3f4515be6dadb0fc835409d5512972381 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -121,6 +121,7 @@ #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_1289_STEREO_SW_TO_MONO /* VA: issue 1289: Fix glitch when stereo signal is decoded to mono n TD->DFT switching */ #define NONBE_FIX_1196_TD_HEADTRACKING_INTERPOLATION /* Ericsson: Issue 1196, Always apply filter interpolation for each subframe */ #define NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING /* VA: issue 1110: fix encoder crash in the stereo DTX bitrate switching condition */ #define FIX_1099_JBM_MD_HANDLE_ALLOC /* VA: issue 1099: Limit the allocation of `hJbmMetadata` handle to MASA and OMASA only */ diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 182c1e16c09f6c661ba735b7c189c9758306c3a8..8801ccf604447a6383cc01f8fed4ab1a8ec3747c 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -43,11 +43,14 @@ #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" + /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ + #define DFT2TD_CORR_THRESH_FX 1932735283 + /*-------------------------------------------------------------------* * Function allocate_CoreCoder_TCX() * @@ -361,6 +364,7 @@ static void cpy_tcx_ltp_data_fx( * * Dynamically allocate/deallocate data structures depending on the actual CPE mode *-------------------------------------------------------------------*/ + ivas_error stereo_memory_dec_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ CPE_DEC_HANDLE hCPE, /* i : CPE decoder structure */ @@ -1092,6 +1096,7 @@ ivas_error stereo_memory_dec_fx( * Synchronize upmixed DFT/TD/MDCT stereo synthesis to match the overall delay of 32ms * Handling of TD stereo <-> DFT stereo transitions *-------------------------------------------------------------------*/ + void synchro_synthesis_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ @@ -1263,7 +1268,12 @@ void synchro_synthesis_fx( test(); test(); test(); +#ifdef NONBE_1289_STEREO_SW_TO_MONO + test(); + IF( ( !use_cldfb_for_last_dft && NE_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && !sba_dirac_stereo_flag && NE_16( dft_mono_brate_switch, -1 ) ) || EQ_16( dft_mono_brate_switch, 1 ) ) +#else IF( ( NE_16( hCPE->last_element_mode, IVAS_CPE_DFT ) && !sba_dirac_stereo_flag && NE_16( dft_mono_brate_switch, -1 ) ) || EQ_16( dft_mono_brate_switch, 1 ) ) +#endif { Word32 *pPrev_synth_fx; Word32 inv_fade_len_fx = 0; @@ -1679,18 +1689,22 @@ void synchro_synthesis_fx( return; } + /*-------------------------------------------------------------------* * Function stereo_switching_dec() * * Handling of memories in case of CPE modes switching *-------------------------------------------------------------------*/ -Word32 side_gain_table[32 + 1] = { -ONE_IN_Q31, -2040109440, -1932735232, -1825361152, -1717986944, - -1610612736, -1503238528, -1395864320, -1288490240, -1181115904, -1073741824, - -966367616, -858993408, -751619200, -644245120, -536870912, -429496704, - -322122496, -214748288, -107374208, 0, 107374336, 214748416, - 322122496, 429496832, 536870912, 644245248, 751619328, 858993408, - 966367744, 1073741824, 1181116160, 1288490240 }; +static Word32 side_gain_table[32 + 1] = { + -ONE_IN_Q31, -2040109440, -1932735232, -1825361152, -1717986944, + -1610612736, -1503238528, -1395864320, -1288490240, -1181115904, -1073741824, + -966367616, -858993408, -751619200, -644245120, -536870912, -429496704, + -322122496, -214748288, -107374208, 0, 107374336, 214748416, + 322122496, 429496832, 536870912, 644245248, 751619328, 858993408, + 966367744, 1073741824, 1181116160, 1288490240 +}; + void stereo_switching_dec( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ @@ -2042,11 +2056,14 @@ void stereo_switching_dec( return; } + + /*-------------------------------------------------------------------* * Function stereo_td2dft_update() * * update OLA buffers - needed for switching from TD stereo to DFT stereo *-------------------------------------------------------------------*/ + void stereo_td2dft_update_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ const Word16 n, /* i : channel number Q0*/ @@ -2190,13 +2207,16 @@ void stereo_td2dft_update_fx( return; } + + /*-------------------------------------------------------------------* * Function stereo_mdct2dft_update() * * update OLA buffers - needed for switching from MDCT stereo to DFT stereo *-------------------------------------------------------------------*/ + void stereo_mdct2dft_update_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ Word32 output0_fx[], /* i/o: synthesis @internal Fs, ch0 Q11*/ Word32 synth0_fx[] /* i/o: synthesis @output Fs, ch0 Q11*/ ) @@ -2215,6 +2235,7 @@ void stereo_mdct2dft_update_fx( fade_len = extract_l( Mpy_32_32( imult3216( st->output_Fs, STEREO_MDCT2DFT_FADE_LEN_48k ), 44740 ) ); // 1/48000 = 44740 (Q31) /* Q0 */ fade_len_LB = extract_l( Mpy_32_32( imult3216( 3 * STEREO_MDCT2DFT_FADE_LEN_48k * FRAMES_PER_SEC, st->L_frame ), 44740 ) ); // 1/48000 = 44740 (Q31) /* Q0 */ + SWITCH( st->output_Fs ) { case 16000: @@ -2230,6 +2251,7 @@ void stereo_mdct2dft_update_fx( move32(); BREAK; } + FOR( i = 0; i < fade_len; i++ ) { Word32 descen_gain; @@ -2359,6 +2381,7 @@ static Word32 ncross_corr_self_fx( quo_e = add( sub( sub( 40, q_cc ), q_prod ), quo_e ); c_c_fx_return = L_shl_sat( num, quo_e ); // Q31 } + return c_c_fx_return; }