From 571964853eff10781dcee652cbd6a5543109d497 Mon Sep 17 00:00:00 2001 From: rhb Date: Wed, 8 Mar 2023 16:08:54 +0100 Subject: [PATCH 01/12] first implementation of low-delay SBA-to-mono --- lib_com/ivas_prot.h | 3 + lib_com/options.h | 2 + lib_dec/ivas_cpe_dec.c | 4 + lib_dec/ivas_dec.c | 4 + lib_dec/ivas_init_dec.c | 8 ++ lib_dec/ivas_output_config.c | 10 ++- lib_dec/ivas_sba_dirac_stereo_dec.c | 121 +++++++++++++++++++++------- lib_dec/ivas_sce_dec.c | 0 lib_dec/ivas_stereo_dft_dec.c | 105 +++++++++++++++++------- 9 files changed, 197 insertions(+), 60 deletions(-) mode change 100644 => 100755 lib_com/ivas_prot.h mode change 100644 => 100755 lib_dec/ivas_cpe_dec.c mode change 100644 => 100755 lib_dec/ivas_dec.c mode change 100644 => 100755 lib_dec/ivas_init_dec.c mode change 100644 => 100755 lib_dec/ivas_output_config.c mode change 100644 => 100755 lib_dec/ivas_sba_dirac_stereo_dec.c mode change 100644 => 100755 lib_dec/ivas_sce_dec.c mode change 100644 => 100755 lib_dec/ivas_stereo_dft_dec.c diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h old mode 100644 new mode 100755 index 4335929d8c..b430846d05 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1115,6 +1115,9 @@ void stereo_dft_dec( float *input_mem, /* i/o: mem of buffer DFT analysis */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ +#ifdef SBA2MONO + const int16_t sba_mono_flag, /* i : signal mono output for SBA DirAC */ +#endif 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 */ diff --git a/lib_com/options.h b/lib_com/options.h index 25da1d2ad3..334755ac0a 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,6 +168,8 @@ #define FIX_94_VERIFY_WAV_NUM_CHANNELS /* FhG: Issue 94 - Check if number of channels in input wav file matches encoder/renderer configuration */ #define ISM_HIGHEST_BITRATE /* VA: Issue 284: Update highest bitrate limit in ISM format */ +#define SBA2MONO /* FhG: Issue 365: Adapt processing of SBA mono output to be in line with stereo output (less delay, lower complexity) */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c old mode 100644 new mode 100755 index ddd4ae363f..17d2efd516 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -405,7 +405,11 @@ ivas_error ivas_cpe_dec( } else { +#ifdef SBA2MONO + stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0 ); +#else stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0 ); +#endif } /* synthesis iFFT */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c old mode 100644 new mode 100755 index de8dde9828..ede1af7dfc --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -385,7 +385,11 @@ ivas_error ivas_dec( ivas_dirac_dec( st_ivas, output, nchan_remapped, NULL, NULL, -1 ); } } +#ifdef SBA2MONO + else if ( !st_ivas->sba_dirac_stereo_flag && nchan_out != 1 ) +#else else if ( !st_ivas->sba_dirac_stereo_flag ) +#endif { ivas_sba_upmixer_renderer( st_ivas, output, output_frame ); /* Note: ivas_sba_linear_renderer() or ivas_dirac_dec() are called internally */ } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c old mode 100644 new mode 100755 index f4764893f1..a424561f21 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -903,7 +903,11 @@ ivas_error ivas_init_decoder( ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } +#ifdef SBA2MONO + st_ivas->sba_dirac_stereo_flag = ( output_config == AUDIO_CONFIG_STEREO || ( output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) ); +#else st_ivas->sba_dirac_stereo_flag = ( output_config == AUDIO_CONFIG_STEREO ); +#endif } else /* SBA_MODE_DIRAC */ { @@ -1368,7 +1372,11 @@ ivas_error ivas_init_decoder( } /* CLDFB Interpolation weights */ +#ifdef SBA2MONO + if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 ) +#else if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR && !st_ivas->sba_dirac_stereo_flag ) +#endif { ivas_spar_get_cldfb_gains( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig ); } diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c old mode 100644 new mode 100755 index f38e810ce3..75e1a0f812 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -303,7 +303,11 @@ void ivas_renderer_select( *renderer_type = RENDERER_DIRAC; if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR && - ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM ) ) +#ifdef SBA2MONO + ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM && output_config != AUDIO_CONFIG_MONO && output_config != AUDIO_CONFIG_STEREO ) ) +#else + ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM ) ) +#endif { if ( output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_FOA ) { @@ -320,7 +324,11 @@ void ivas_renderer_select( st_ivas->renderer_type = RENDERER_SBA_LINEAR_DEC; } else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || +#ifdef SBA2MONO + ( st_ivas->ivas_format == SBA_FORMAT && ( output_config == AUDIO_CONFIG_STEREO || output_config == AUDIO_CONFIG_MONO ) ) ) +#else ( st_ivas->ivas_format == SBA_FORMAT && output_config == AUDIO_CONFIG_STEREO && st_ivas->nchan_transport == 1 ) ) +#endif { *renderer_type = RENDERER_DISABLE; } diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c old mode 100644 new mode 100755 index e184654eaa..c388675ec1 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -453,6 +453,9 @@ static void ivas_sba_dirac_stereo_upmix_hb( float hb_gain[NB_DIV], /* i : side gains for HB signal */ const int16_t output_frame, /* i : output frame length per channel */ const int16_t mcmasa, /* i : McMASA flag */ +#ifdef SBA2MONO + const int16_t sba_mono_flag, /* i : flag for mono output */ +#endif const STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i : Stereo DFT handle for mixing matrix */ ) { @@ -460,36 +463,60 @@ static void ivas_sba_dirac_stereo_upmix_hb( if ( !mcmasa ) { - for ( i = 0; i < output_frame / 2; i++ ) +#ifdef SBA2MONO + if ( sba_mono_flag ) { - float gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[1][0][8] + - hStereoDft->mixer_mat_smooth[0][0][9] + hStereoDft->mixer_mat_smooth[1][0][9] + - hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[1][0][10] + - hStereoDft->mixer_mat_smooth[0][0][11] + hStereoDft->mixer_mat_smooth[1][0][11]; - - float gm = hStereoDft->mixer_mat_smooth[0][0][8] - hStereoDft->mixer_mat_smooth[1][0][8] + - hStereoDft->mixer_mat_smooth[0][0][9] - hStereoDft->mixer_mat_smooth[1][0][9] + - hStereoDft->mixer_mat_smooth[0][0][10] - hStereoDft->mixer_mat_smooth[1][0][10] + - hStereoDft->mixer_mat_smooth[0][0][11] - hStereoDft->mixer_mat_smooth[1][0][11]; - - hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp; - hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm; + for ( i = 0; i < output_frame / 2; i++ ) + { + float gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[0][0][9] + + hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[0][0][11]; + + hb_stereo_synth[0][i] = hb_synth[i] * 0.25f * gp; + } + for ( i = output_frame / 2; i < output_frame; i++ ) + { + float gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS]; + + hb_stereo_synth[0][i] = hb_synth[i] * 0.25f * gp; + } } - for ( i = output_frame / 2; i < output_frame; i++ ) + else { - float gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; - - float gm = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; - - hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp; - hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm; +#endif + for ( i = 0; i < output_frame / 2; i++ ) + { + float gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[1][0][8] + + hStereoDft->mixer_mat_smooth[0][0][9] + hStereoDft->mixer_mat_smooth[1][0][9] + + hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[1][0][10] + + hStereoDft->mixer_mat_smooth[0][0][11] + hStereoDft->mixer_mat_smooth[1][0][11]; + + float gm = hStereoDft->mixer_mat_smooth[0][0][8] - hStereoDft->mixer_mat_smooth[1][0][8] + + hStereoDft->mixer_mat_smooth[0][0][9] - hStereoDft->mixer_mat_smooth[1][0][9] + + hStereoDft->mixer_mat_smooth[0][0][10] - hStereoDft->mixer_mat_smooth[1][0][10] + + hStereoDft->mixer_mat_smooth[0][0][11] - hStereoDft->mixer_mat_smooth[1][0][11]; + + hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp; + hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm; + } + for ( i = output_frame / 2; i < output_frame; i++ ) + { + float gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + + float gm = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + + hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp; + hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm; + } +#ifdef SBA2MONO } +#endif } else { @@ -732,6 +759,9 @@ void ivas_sba_dirac_stereo_dec( ) { int16_t dtx_flag, fd_cng_flag; +#ifdef SBA2MONO + int16_t sba_mono_flag; +#endif int16_t memOffset; float tmp_buf[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; float tmp_synth[L_FRAME16k]; @@ -756,6 +786,9 @@ void ivas_sba_dirac_stereo_dec( dtx_flag = ( hSCE->hCoreCoder[0]->core_brate <= SID_2k40 ); fd_cng_flag = ( dtx_flag && hSCE->hCoreCoder[0]->cng_type == FD_CNG ); } +#ifdef SBA2MONO + sba_mono_flag = ( st_ivas->hDecoderConfig->nchan_out == 1 ) ? 1 : 0; +#endif memOffset = NS2SA( output_frame * FRAMES_PER_SEC, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); @@ -794,20 +827,39 @@ void ivas_sba_dirac_stereo_dec( } /* DFT Stereo upmix */ +#ifdef SBA2MONO + stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, +#else stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1, /*st_ivas->sba_dirac_stereo_flag*/ +#endif ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : 0, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport ); /* DFT synthesis */ stereo_dft_dec_synthesize( hCPE, DFT, 0, output[0], output_frame ); +#ifdef SBA2MONO + if ( !sba_mono_flag ) + { + stereo_dft_dec_synthesize( hCPE, DFT, 1, output[1], output_frame ); + } +#else stereo_dft_dec_synthesize( hCPE, DFT, 1, output[1], output_frame ); +#endif synchro_synthesis( st_ivas->hDecoderConfig->ivas_total_brate, hCPE, output, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); /* output scaling */ +#ifdef SBA2MONO + if ( !sba_mono_flag ) + { + v_multc( output[0], 0.5f, output[0], output_frame ); + v_multc( output[1], 0.5f, output[1], output_frame ); + } +#else v_multc( output[0], 0.5f, output[0], output_frame ); v_multc( output[1], 0.5f, output[1], output_frame ); +#endif /* delay HB synth */ if ( st_ivas->nchan_transport == 1 ) @@ -824,15 +876,26 @@ void ivas_sba_dirac_stereo_dec( ivas_sba_dirac_stereo_compute_hb_gain( hStereoDft, hb_gain ); ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame, +#ifdef SBA2MONO + ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ), sba_mono_flag, hStereoDft ); +#else ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ), hStereoDft ); +#endif /* add HB to ACELP core */ v_add( output[0], hb_synth_stereo[0], output[0], output_frame ); - v_add( output[1], hb_synth_stereo[1], output[1], output_frame ); +#ifdef SBA2MONO + if ( !sba_mono_flag ) + { +#endif + v_add( output[1], hb_synth_stereo[1], output[1], output_frame ); - /* apply TD Stereo Filling as is done in ICBWE */ - ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, ( st_ivas->sba_mode == SBA_MODE_SPAR && !mcmasa ) ); + /* apply TD Stereo Filling as is done in ICBWE */ + ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, (st_ivas->sba_mode == SBA_MODE_SPAR && !mcmasa) ); +#ifdef SBA2MONO + } +#endif } return; diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c old mode 100644 new mode 100755 diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c old mode 100644 new mode 100755 index f1cbf180bd..0d9b079f2a --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -1126,6 +1126,9 @@ void stereo_dft_dec( float *input_mem, /* i/o: mem of buffer DFT analysis */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ +#ifdef SBA2MONO + const int16_t sba_mono_flag, /* i : signal mono output for SBA DirAC */ +#endif ivas_spar_md_dec_state_t *hMdDec, /* i : 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 */ @@ -1410,50 +1413,92 @@ void stereo_dft_dec( if ( nchan_transport == 1 ) { - if ( b == 0 ) +#ifdef SBA2MONO + if ( sba_mono_flag ) { - i = 0; + if ( b == 0 ) + { + i = 0; - DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i]; - DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i]; + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i]; + DFT_L[2 * i] = DFT_W; + DFT_R[2 * i] = 0.f; - DFT_L[2 * i] = DFT_W + DFT_Y; - DFT_R[2 * i] = DFT_W - DFT_Y; + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1]; + DFT_L[2 * i + 1] = DFT_W; + DFT_R[2 * i + 1] = 0.f; + } + for ( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) + { + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i] + (hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS]) * DFT_PRED_RES[2 * i]; + DFT_L[2 * i] = DFT_W; + DFT_R[2 * i] = 0.f; - DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1]; - DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1]; + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1] + (hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS]) * DFT_PRED_RES[2 * i + 1]; + DFT_L[2 * i + 1] = DFT_W; + DFT_R[2 * i + 1] = 0.f; + } + for ( ; i < hStereoDft->band_limits[b + 1]; i++ ) + { + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i]; + DFT_L[2 * i] = DFT_W; + DFT_R[2 * i] = 0.f; - DFT_L[2 * i + 1] = DFT_W + DFT_Y; - DFT_R[2 * i + 1] = DFT_W - DFT_Y; + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1]; + DFT_L[2 * i + 1] = DFT_W; + DFT_R[2 * i + 1] = 0.f; + } } - for ( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) + else { - DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i] + ( hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS] ) * DFT_PRED_RES[2 * i]; - DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i] + ( hStereoDft->mixer_mat_smooth[1][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][3][b + k * IVAS_MAX_NUM_BANDS] ) * DFT_PRED_RES[2 * i]; +#endif + if ( b == 0 ) + { + i = 0; - DFT_L[2 * i] = DFT_W + DFT_Y; - DFT_R[2 * i] = DFT_W - DFT_Y; + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i]; + DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i]; - DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1] + ( hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS] ) * DFT_PRED_RES[2 * i + 1]; - DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1] + ( hStereoDft->mixer_mat_smooth[1][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][3][b + k * IVAS_MAX_NUM_BANDS] ) * DFT_PRED_RES[2 * i + 1]; + DFT_L[2 * i] = DFT_W + DFT_Y; + DFT_R[2 * i] = DFT_W - DFT_Y; - DFT_L[2 * i + 1] = DFT_W + DFT_Y; - DFT_R[2 * i + 1] = DFT_W - DFT_Y; - } - for ( ; i < hStereoDft->band_limits[b + 1]; i++ ) - { - DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i]; - DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i]; + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1]; + DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1]; - DFT_L[2 * i] = DFT_W + DFT_Y; - DFT_R[2 * i] = DFT_W - DFT_Y; + DFT_L[2 * i + 1] = DFT_W + DFT_Y; + DFT_R[2 * i + 1] = DFT_W - DFT_Y; + } + for ( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) + { + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i] + (hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS]) * DFT_PRED_RES[2 * i]; + DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i] + (hStereoDft->mixer_mat_smooth[1][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][3][b + k * IVAS_MAX_NUM_BANDS]) * DFT_PRED_RES[2 * i]; - DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1]; - DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1]; + DFT_L[2 * i] = DFT_W + DFT_Y; + DFT_R[2 * i] = DFT_W - DFT_Y; - DFT_L[2 * i + 1] = DFT_W + DFT_Y; - DFT_R[2 * i + 1] = DFT_W - DFT_Y; + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1] + (hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS]) * DFT_PRED_RES[2 * i + 1]; + DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1] + (hStereoDft->mixer_mat_smooth[1][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][3][b + k * IVAS_MAX_NUM_BANDS]) * DFT_PRED_RES[2 * i + 1]; + + DFT_L[2 * i + 1] = DFT_W + DFT_Y; + DFT_R[2 * i + 1] = DFT_W - DFT_Y; + } + for ( ; i < hStereoDft->band_limits[b + 1]; i++ ) + { + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i]; + DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i]; + + DFT_L[2 * i] = DFT_W + DFT_Y; + DFT_R[2 * i] = DFT_W - DFT_Y; + + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1]; + DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1]; + + DFT_L[2 * i + 1] = DFT_W + DFT_Y; + DFT_R[2 * i + 1] = DFT_W - DFT_Y; + } +#ifdef SBA2MONO } +#endif } else if ( nchan_transport >= 2 ) { -- GitLab From a69924e44536283e20e46511b4233da3c37d6d66 Mon Sep 17 00:00:00 2001 From: rhb Date: Wed, 8 Mar 2023 17:06:50 +0100 Subject: [PATCH 02/12] some optimization for ACELP HB processing --- lib_dec/ivas_sba_dirac_stereo_dec.c | 96 +++++++++++++++++++---------- 1 file changed, 65 insertions(+), 31 deletions(-) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index c388675ec1..719bef5782 100755 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -455,66 +455,100 @@ static void ivas_sba_dirac_stereo_upmix_hb( const int16_t mcmasa, /* i : McMASA flag */ #ifdef SBA2MONO const int16_t sba_mono_flag, /* i : flag for mono output */ + const int16_t bwidth, /* i : bandwidth of signal */ #endif const STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i : Stereo DFT handle for mixing matrix */ ) { int16_t i; +#ifdef SBA2MONO + float gp, gm; + float gain_fac; +#endif if ( !mcmasa ) { #ifdef SBA2MONO + gain_fac = ( bwidth == FB ) ? 0.25f : 0.33f; /* last matrix element zero for SWB, divide by 3 instead of 4*/ if ( sba_mono_flag ) { + gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[0][0][9] + + hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[0][0][11]; for ( i = 0; i < output_frame / 2; i++ ) { - float gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[0][0][9] + - hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[0][0][11]; - - hb_stereo_synth[0][i] = hb_synth[i] * 0.25f * gp; + hb_stereo_synth[0][i] = hb_synth[i] * gain_fac * gp; } + gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS]; for ( i = output_frame / 2; i < output_frame; i++ ) { - float gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS]; - - hb_stereo_synth[0][i] = hb_synth[i] * 0.25f * gp; + hb_stereo_synth[0][i] = hb_synth[i] * gain_fac * gp; } } else { -#endif - for ( i = 0; i < output_frame / 2; i++ ) - { - float gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[1][0][8] + - hStereoDft->mixer_mat_smooth[0][0][9] + hStereoDft->mixer_mat_smooth[1][0][9] + - hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[1][0][10] + - hStereoDft->mixer_mat_smooth[0][0][11] + hStereoDft->mixer_mat_smooth[1][0][11]; + gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[1][0][8] + + hStereoDft->mixer_mat_smooth[0][0][9] + hStereoDft->mixer_mat_smooth[1][0][9] + + hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[1][0][10] + + hStereoDft->mixer_mat_smooth[0][0][11] + hStereoDft->mixer_mat_smooth[1][0][11]; - float gm = hStereoDft->mixer_mat_smooth[0][0][8] - hStereoDft->mixer_mat_smooth[1][0][8] + - hStereoDft->mixer_mat_smooth[0][0][9] - hStereoDft->mixer_mat_smooth[1][0][9] + - hStereoDft->mixer_mat_smooth[0][0][10] - hStereoDft->mixer_mat_smooth[1][0][10] + - hStereoDft->mixer_mat_smooth[0][0][11] - hStereoDft->mixer_mat_smooth[1][0][11]; + gm = hStereoDft->mixer_mat_smooth[0][0][8] - hStereoDft->mixer_mat_smooth[1][0][8] + + hStereoDft->mixer_mat_smooth[0][0][9] - hStereoDft->mixer_mat_smooth[1][0][9] + + hStereoDft->mixer_mat_smooth[0][0][10] - hStereoDft->mixer_mat_smooth[1][0][10] + + hStereoDft->mixer_mat_smooth[0][0][11] - hStereoDft->mixer_mat_smooth[1][0][11]; + for ( i = 0; i < output_frame / 2; i++ ) + { hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp; hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm; } - for ( i = output_frame / 2; i < output_frame; i++ ) - { - float gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; - float gm = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + gm = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + + for ( i = output_frame / 2; i < output_frame; i++ ) + { hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp; hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm; } -#ifdef SBA2MONO + } +#else + for ( i = 0; i < output_frame / 2; i++ ) + { + float gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[1][0][8] + + hStereoDft->mixer_mat_smooth[0][0][9] + hStereoDft->mixer_mat_smooth[1][0][9] + + hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[1][0][10] + + hStereoDft->mixer_mat_smooth[0][0][11] + hStereoDft->mixer_mat_smooth[1][0][11]; + + float gm = hStereoDft->mixer_mat_smooth[0][0][8] - hStereoDft->mixer_mat_smooth[1][0][8] + + hStereoDft->mixer_mat_smooth[0][0][9] - hStereoDft->mixer_mat_smooth[1][0][9] + + hStereoDft->mixer_mat_smooth[0][0][10] - hStereoDft->mixer_mat_smooth[1][0][10] + + hStereoDft->mixer_mat_smooth[0][0][11] - hStereoDft->mixer_mat_smooth[1][0][11]; + + hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp; + hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm; + } + for ( i = output_frame / 2; i < output_frame; i++ ) + { + float gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + + float gm = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + + hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp; + hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm; } #endif } @@ -877,7 +911,7 @@ void ivas_sba_dirac_stereo_dec( ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame, #ifdef SBA2MONO - ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ), sba_mono_flag, hStereoDft ); + ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); #else ( st_ivas->sba_mode != SBA_MODE_SPAR || mcmasa ), hStereoDft ); #endif -- GitLab From 655369fb1de135c9d64afefabe80dc925aa312bb Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 9 Mar 2023 11:35:41 +0100 Subject: [PATCH 03/12] fix crashes for 1 TC modes with DTX --- lib_dec/ivas_sce_dec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index ac948a59c4..c95701edac 100755 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -364,7 +364,11 @@ ivas_error create_sce_dec( return error; } +#ifdef SBA2MONO + if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) ) ) +#else if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) +#endif { if ( ( error = openCldfb( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) { -- GitLab From 1968f2420b166a60528ac31ab49cf291c4f45f45 Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 9 Mar 2023 12:15:30 +0100 Subject: [PATCH 04/12] fix msan error --- lib_dec/ivas_dec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index ede1af7dfc..e6683ffed1 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -308,7 +308,11 @@ ivas_error ivas_dec( nchan_remapped = st_ivas->nchan_transport; if ( st_ivas->sba_dirac_stereo_flag ) { +#ifdef SBA2MONO + nchan_remapped = nchan_out; +#else nchan_remapped = CPE_CHANNELS; +#endif if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { -- GitLab From 1a55422e5ee08742f78f39bbe7825fbdff5c0087 Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 9 Mar 2023 14:00:40 +0100 Subject: [PATCH 05/12] fix crashes in rate switching modes --- lib_dec/ivas_corecoder_dec_reconfig.c | 4 ++++ 1 file changed, 4 insertions(+) mode change 100644 => 100755 lib_dec/ivas_corecoder_dec_reconfig.c diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c old mode 100644 new mode 100755 index bb2b753181..7b91755b70 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -513,7 +513,11 @@ ivas_error ivas_cldfb_dec_reconfig( } } /* CLDFB Interpolation weights */ +#ifdef SBA2MONO + if ( st_ivas->sba_mode == SBA_MODE_SPAR && ( numCldfbAnalyses_old != numCldfbAnalyses || numCldfbSyntheses_old != numCldfbSyntheses || nchan_transport_old != st_ivas->nchan_transport ) && numCldfbAnalyses != 0 && numCldfbSyntheses != 0 ) +#else if ( st_ivas->sba_mode == SBA_MODE_SPAR && ( numCldfbAnalyses_old != numCldfbAnalyses || numCldfbSyntheses_old != numCldfbSyntheses || nchan_transport_old != st_ivas->nchan_transport ) ) +#endif { ivas_spar_get_cldfb_gains( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig ); } -- GitLab From 1de9422f4dd80c7aa0dfb31c363cf3158b92c086 Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 9 Mar 2023 17:11:36 +0100 Subject: [PATCH 06/12] more fixes for SBA-to-mono and SBA-to-stereo bitrate switching --- lib_dec/ivas_corecoder_dec_reconfig.c | 14 ++++++++++++++ lib_dec/ivas_sba_dec.c | 7 +++++++ 2 files changed, 21 insertions(+) mode change 100644 => 100755 lib_dec/ivas_sba_dec.c diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 7b91755b70..559552c230 100755 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -149,6 +149,13 @@ ivas_error ivas_corecoder_dec_reconfig( for ( cpe_id = st_ivas->nCPE; cpe_id < nCPE_old; cpe_id++ ) { +#ifdef SBA2MONO + /* don't deallocate first CPE in case of mono/stereo output of 1 TC SBA */ + if ( cpe_id == 0 && st_ivas->sba_dirac_stereo_flag ) + { + continue; + } +#endif destroy_cpe_dec( st_ivas->hCPE[cpe_id] ); st_ivas->hCPE[cpe_id] = NULL; } @@ -188,6 +195,13 @@ ivas_error ivas_corecoder_dec_reconfig( return error; } } +#ifdef SBA2MONO + if ( st_ivas->sba_dirac_stereo_flag && st_ivas->nchan_transport == 1 && nchan_transport_old > 1 ) + { + st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hSCE[0]->hCoreCoder[0]; /* don't allocate unnecessary core coder, simply point to core coder of SCE element */ + st_ivas->hCPE[0]->hCoreCoder[1] = NULL; + } +#endif for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c old mode 100644 new mode 100755 index 98fad8c094..16503f8082 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -215,11 +215,18 @@ ivas_error ivas_sba_dec_reconfigure( hSpar = st_ivas->hSpar; } + +#ifndef SBA2MONO st_ivas->sba_dirac_stereo_flag = 0; +#endif sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); +#ifdef SBA2MONO + st_ivas->sba_dirac_stereo_flag = ( hDecoderConfig->output_config == AUDIO_CONFIG_STEREO || (hDecoderConfig->output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) ); +#endif + if ( hDirAC == NULL && st_ivas->sba_mode == SBA_MODE_DIRAC ) { if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK ) -- GitLab From 8f88afc0522a9cf8ec3688c62e1ca78e9607223f Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 16 Mar 2023 17:08:09 +0100 Subject: [PATCH 07/12] fix asan error connected to CPE de-/allocation during bitrate switching --- lib_dec/ivas_corecoder_dec_reconfig.c | 40 +++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 559552c230..06ec5921b5 100755 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -90,8 +90,13 @@ ivas_error ivas_corecoder_dec_reconfig( *-----------------------------------------------------------------*/ /* remove dummy CPE element for DFT stereo-like upmix */ +#ifdef SBA2MONO + if ( ( st_ivas->ivas_format == SBA_FORMAT && sba_dirac_stereo_flag_old && nchan_transport_old == 1 && ( !st_ivas->sba_dirac_stereo_flag || st_ivas->nchan_transport > 1 ) ) || + ( st_ivas->ivas_format == MC_FORMAT && last_mc_mode == MC_MODE_MCMASA && sba_dirac_stereo_flag_old && nchan_transport_old == 1 && ( !st_ivas->sba_dirac_stereo_flag || st_ivas->nchan_transport > 1 ) ) ) +#else if ( ( st_ivas->ivas_format == SBA_FORMAT && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) || ( st_ivas->ivas_format == MC_FORMAT && last_mc_mode == MC_MODE_MCMASA && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) ) +#endif { st_ivas->hCPE[0]->hCoreCoder[0] = NULL; st_ivas->hCPE[0]->hCoreCoder[1] = NULL; @@ -150,9 +155,19 @@ ivas_error ivas_corecoder_dec_reconfig( for ( cpe_id = st_ivas->nCPE; cpe_id < nCPE_old; cpe_id++ ) { #ifdef SBA2MONO - /* don't deallocate first CPE in case of mono/stereo output of 1 TC SBA */ - if ( cpe_id == 0 && st_ivas->sba_dirac_stereo_flag ) + /* don't deallocate first CPE in case of mono/stereo output of 1 TC SBA, only deallocate core coder */ + if ( cpe_id == 0 && st_ivas->sba_dirac_stereo_flag && sba_dirac_stereo_flag_old ) { + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + if ( st_ivas->hCPE[cpe_id]->hCoreCoder[n] != NULL ) + { + destroy_core_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); + + free( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); + st_ivas->hCPE[cpe_id]->hCoreCoder[n] = NULL; + } + } continue; } #endif @@ -196,7 +211,7 @@ ivas_error ivas_corecoder_dec_reconfig( } } #ifdef SBA2MONO - if ( st_ivas->sba_dirac_stereo_flag && st_ivas->nchan_transport == 1 && nchan_transport_old > 1 ) + if ( st_ivas->sba_dirac_stereo_flag && sba_dirac_stereo_flag_old && st_ivas->nchan_transport == 1 && nSCE_old == 0 ) { st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hSCE[0]->hCoreCoder[0]; /* don't allocate unnecessary core coder, simply point to core coder of SCE element */ st_ivas->hCPE[0]->hCoreCoder[1] = NULL; @@ -280,10 +295,29 @@ ivas_error ivas_corecoder_dec_reconfig( if ( ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) ) { +#ifdef SBA2MONO + /* if at least one CPE is already available, only allocate DFT Stereo struct */ + if ( st_ivas->nCPE > 0 ) + { + if ( ( error = stereo_dft_dec_create( &(st_ivas->hCPE[0]->hStereoDft ), st_ivas->hCPE[0]->element_brate, st_ivas->hDecoderConfig->output_Fs, st_ivas->sba_dirac_stereo_flag, st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) + { + return error; + } + } + /* otherwise create extra dummy CPE */ + else + { + if ( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else if ( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) { return error; } +#endif // VE: TBV - just reset for now set_f( st_ivas->hCPE[0]->hStereoDft->buff_LBTCX_mem, 0, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ) ); -- GitLab From c95c5c6f07c9766c34fa8e280ad1833393aefc29 Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 30 Mar 2023 14:36:08 +0200 Subject: [PATCH 08/12] fix gain overshoot in ACELP HB for SWB and also apply SWB changes to stereo --- lib_dec/ivas_sba_dirac_stereo_dec.c | 50 ++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 719bef5782..464fde49c6 100755 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -469,17 +469,25 @@ static void ivas_sba_dirac_stereo_upmix_hb( if ( !mcmasa ) { #ifdef SBA2MONO - gain_fac = ( bwidth == FB ) ? 0.25f : 0.33f; /* last matrix element zero for SWB, divide by 3 instead of 4*/ + gain_fac = ( bwidth == FB ) ? 0.25f : 0.33f; /* last matrix element not used for SWB, divide by 3 instead of 4*/ if ( sba_mono_flag ) { gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[0][0][9] + - hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[0][0][11]; + hStereoDft->mixer_mat_smooth[0][0][10]; + if ( bwidth == FB ) + { + gp += hStereoDft->mixer_mat_smooth[0][0][11]; + } for ( i = 0; i < output_frame / 2; i++ ) { hb_stereo_synth[0][i] = hb_synth[i] * gain_fac * gp; } gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS]; + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS]; + if ( bwidth == FB ) + { + gp += hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS]; + } for ( i = output_frame / 2; i < output_frame; i++ ) { hb_stereo_synth[0][i] = hb_synth[i] * gain_fac * gp; @@ -489,34 +497,46 @@ static void ivas_sba_dirac_stereo_upmix_hb( { gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[1][0][8] + hStereoDft->mixer_mat_smooth[0][0][9] + hStereoDft->mixer_mat_smooth[1][0][9] + - hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[1][0][10] + - hStereoDft->mixer_mat_smooth[0][0][11] + hStereoDft->mixer_mat_smooth[1][0][11]; + hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[1][0][10]; + if ( bwidth == FB ) + { + gp += hStereoDft->mixer_mat_smooth[0][0][11] + hStereoDft->mixer_mat_smooth[1][0][11]; + } gm = hStereoDft->mixer_mat_smooth[0][0][8] - hStereoDft->mixer_mat_smooth[1][0][8] + hStereoDft->mixer_mat_smooth[0][0][9] - hStereoDft->mixer_mat_smooth[1][0][9] + - hStereoDft->mixer_mat_smooth[0][0][10] - hStereoDft->mixer_mat_smooth[1][0][10] + - hStereoDft->mixer_mat_smooth[0][0][11] - hStereoDft->mixer_mat_smooth[1][0][11]; + hStereoDft->mixer_mat_smooth[0][0][10] - hStereoDft->mixer_mat_smooth[1][0][10]; + if ( bwidth == FB ) + { + gm += hStereoDft->mixer_mat_smooth[0][0][11] - hStereoDft->mixer_mat_smooth[1][0][11]; + } for ( i = 0; i < output_frame / 2; i++ ) { - hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp; - hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm; + hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * gain_fac * gp; + hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * gain_fac * gm; } gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS]; + if ( bwidth == FB ) + { + gp += hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + } gm = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS]; + if ( bwidth == FB ) + { + gm += hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + } for ( i = output_frame / 2; i < output_frame; i++ ) { - hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp; - hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm; + hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * gain_fac * gp; + hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * gain_fac * gm; } } #else -- GitLab From 957de910adc3546ddceb5aab90b9e62a78f35815 Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 30 Mar 2023 17:53:21 +0200 Subject: [PATCH 09/12] address some minor issues --- lib_dec/ivas_dec.c | 18 ++++++++++++++++++ lib_dec/ivas_init_dec.c | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 4b2e860be8..bfe74db452 100755 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -347,6 +347,24 @@ ivas_error ivas_dec( if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { +#ifdef SBA2MONO + ivas_agc_dec_process( st_ivas->hSpar->hAgcDec, output, output, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); + + if ( st_ivas->hSpar->hPCA != NULL ) + { + int16_t num_in_ingest; + if ( st_ivas->hSpar->hMdDec->td_decorr_flag ) + { + num_in_ingest = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order );; + } + else + { + num_in_ingest = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; + } + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, num_in_ingest, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output ); + } + +#endif ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi ); } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a355f95b38..f7f6ba4173 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1033,7 +1033,11 @@ ivas_error ivas_init_decoder( } /* create CPE element for DFT Stereo like upmix */ +#ifdef SBA2MONO + if ( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 ) +#else if ( st_ivas->sba_dirac_stereo_flag && st_ivas->nchan_transport == 1 ) +#endif { if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) { -- GitLab From 678ce25c5dfecbcaeaf167f23e35a5205ffba328 Mon Sep 17 00:00:00 2001 From: rhb Date: Fri, 31 Mar 2023 17:29:31 +0200 Subject: [PATCH 10/12] add function for setting sba_dirac_stereo_flag --- lib_com/ivas_prot.h | 6 +++++ lib_dec/ivas_init_dec.c | 10 +++++++- lib_dec/ivas_mcmasa_dec.c | 4 +++ lib_dec/ivas_mct_dec.c | 4 +++ lib_dec/ivas_sba_dec.c | 6 ++++- lib_dec/ivas_sba_dirac_stereo_dec.c | 40 +++++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 2 deletions(-) mode change 100644 => 100755 lib_dec/ivas_mcmasa_dec.c mode change 100644 => 100755 lib_dec/ivas_mct_dec.c diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 54b2f50a07..c1e7cb9e2b 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3304,6 +3304,12 @@ void ivas_sba_dirac_stereo_config( STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */ ); +#ifdef SBA2MONO +int16_t ivas_get_sba_dirac_stereo_flag( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); +#endif + 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 */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index f7f6ba4173..e53218d3e7 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -984,7 +984,7 @@ ivas_error ivas_init_decoder( st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } #ifdef SBA2MONO - st_ivas->sba_dirac_stereo_flag = ( output_config == AUDIO_CONFIG_STEREO || ( output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) ); + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); #else st_ivas->sba_dirac_stereo_flag = ( output_config == AUDIO_CONFIG_STEREO ); #endif @@ -996,7 +996,11 @@ ivas_error ivas_init_decoder( return error; } +#ifdef SBA2MONO + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); +#else st_ivas->sba_dirac_stereo_flag = ( st_ivas->nchan_transport == 1 && output_config == AUDIO_CONFIG_STEREO ); +#endif } } @@ -1166,7 +1170,11 @@ ivas_error ivas_init_decoder( return error; } +#ifdef SBA2MONO + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); +#else st_ivas->sba_dirac_stereo_flag = ( st_ivas->nchan_transport == 1 && output_config == AUDIO_CONFIG_STEREO ); +#endif if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_MCMASA_MONO_STEREO ) { diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c old mode 100644 new mode 100755 index 3ef12f3094..d075bf61da --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -76,7 +76,11 @@ ivas_error ivas_mcmasa_dec_reconfig( return error; } +#ifdef SBA2MONO + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); +#else st_ivas->sba_dirac_stereo_flag = ( st_ivas->nchan_transport == 1 && st_ivas->hOutSetup.output_config == AUDIO_CONFIG_STEREO ); +#endif if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_MCMASA_MONO_STEREO ) { diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c old mode 100644 new mode 100755 index 8c53538dec..f39951e087 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -707,7 +707,11 @@ static ivas_error ivas_mc_dec_reconfig( { nchan_hp20_old = nchan_transport_old; } +#ifdef SBA2MONO + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); +#else st_ivas->sba_dirac_stereo_flag = 0; /* needs to be after getNumChanSynthesis() */ +#endif /* renderer might have changed, reselect */ renderer_type_old = st_ivas->renderer_type; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 5bc6adb5bd..bf905457e0 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -117,7 +117,11 @@ ivas_error ivas_sba_dec_reconfigure( return error; } +#ifdef SBA2MONO + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); +#else st_ivas->sba_dirac_stereo_flag = ( st_ivas->nchan_transport == 1 && hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ); +#endif } else { @@ -157,7 +161,7 @@ ivas_error ivas_sba_dec_reconfigure( hSpar = st_ivas->hSpar; #ifdef SBA2MONO - st_ivas->sba_dirac_stereo_flag = (hDecoderConfig->output_config == AUDIO_CONFIG_STEREO || (hDecoderConfig->output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1)); + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); #else st_ivas->sba_dirac_stereo_flag = 0; #endif diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 464fde49c6..fb39673e62 100755 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -45,6 +45,46 @@ #include "wmc_auto.h" +#ifdef SBA2MONO +/*-------------------------------------------------------------------* + * ivas_get_sba_dirac_stereo_flag() + * + * Set sba_dirac_stereo_flag + *-------------------------------------------------------------------*/ + +int16_t ivas_get_sba_dirac_stereo_flag( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + int16_t sba_dirac_stereo_flag; + AUDIO_CONFIG output_config; + + sba_dirac_stereo_flag = 0; + output_config = st_ivas->hDecoderConfig->output_config; + + if ( st_ivas->ivas_format == SBA_FORMAT || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) ) + { + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) + { + if ( output_config == AUDIO_CONFIG_STEREO || (output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1) ) + { + sba_dirac_stereo_flag = 1; + } + } + else + { + if ( st_ivas->nchan_transport == 1 && output_config == AUDIO_CONFIG_STEREO ) + { + sba_dirac_stereo_flag = 1; + } + } + } + + return sba_dirac_stereo_flag; +} +#endif + + /*-------------------------------------------------------------------* * ivas_sba_dirac_stereo_config() * -- GitLab From 4658aaf9bbae5d680c6dd58c8740cd0c09d8a322 Mon Sep 17 00:00:00 2001 From: rhb Date: Fri, 31 Mar 2023 17:53:05 +0200 Subject: [PATCH 11/12] clang format --- lib_dec/ivas_corecoder_dec_reconfig.c | 2 +- lib_dec/ivas_dec.c | 3 ++- lib_dec/ivas_output_config.c | 4 +-- lib_dec/ivas_sba_dirac_stereo_dec.c | 36 +++++++++++++-------------- lib_dec/ivas_stereo_dft_dec.c | 22 ++++++++-------- 5 files changed, 34 insertions(+), 33 deletions(-) mode change 100755 => 100644 lib_dec/ivas_corecoder_dec_reconfig.c mode change 100755 => 100644 lib_dec/ivas_dec.c mode change 100755 => 100644 lib_dec/ivas_output_config.c mode change 100755 => 100644 lib_dec/ivas_sba_dirac_stereo_dec.c mode change 100755 => 100644 lib_dec/ivas_stereo_dft_dec.c diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c old mode 100755 new mode 100644 index 883e97475e..62579d35d7 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -297,7 +297,7 @@ ivas_error ivas_corecoder_dec_reconfig( /* if at least one CPE is already available, only allocate DFT Stereo struct */ if ( st_ivas->nCPE > 0 ) { - if ( ( error = stereo_dft_dec_create( &(st_ivas->hCPE[0]->hStereoDft ), st_ivas->hCPE[0]->element_brate, st_ivas->hDecoderConfig->output_Fs, st_ivas->sba_dirac_stereo_flag, st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) + if ( ( error = stereo_dft_dec_create( &( st_ivas->hCPE[0]->hStereoDft ), st_ivas->hCPE[0]->element_brate, st_ivas->hDecoderConfig->output_Fs, st_ivas->sba_dirac_stereo_flag, st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c old mode 100755 new mode 100644 index bfe74db452..2185322025 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -355,7 +355,8 @@ ivas_error ivas_dec( int16_t num_in_ingest; if ( st_ivas->hSpar->hMdDec->td_decorr_flag ) { - num_in_ingest = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order );; + num_in_ingest = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); + ; } else { diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c old mode 100755 new mode 100644 index 75e1a0f812..f522a3217d --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -304,9 +304,9 @@ void ivas_renderer_select( if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR && #ifdef SBA2MONO - ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM && output_config != AUDIO_CONFIG_MONO && output_config != AUDIO_CONFIG_STEREO ) ) + ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM && output_config != AUDIO_CONFIG_MONO && output_config != AUDIO_CONFIG_STEREO ) ) #else - ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM ) ) + ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM ) ) #endif { if ( output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_FOA ) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c old mode 100755 new mode 100644 index fb39673e62..82ccaceea9 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -53,7 +53,7 @@ *-------------------------------------------------------------------*/ int16_t ivas_get_sba_dirac_stereo_flag( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { int16_t sba_dirac_stereo_flag; @@ -66,7 +66,7 @@ int16_t ivas_get_sba_dirac_stereo_flag( { if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { - if ( output_config == AUDIO_CONFIG_STEREO || (output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1) ) + if ( output_config == AUDIO_CONFIG_STEREO || ( output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) ) { sba_dirac_stereo_flag = 1; } @@ -494,10 +494,10 @@ static void ivas_sba_dirac_stereo_upmix_hb( const int16_t output_frame, /* i : output frame length per channel */ const int16_t mcmasa, /* i : McMASA flag */ #ifdef SBA2MONO - const int16_t sba_mono_flag, /* i : flag for mono output */ - const int16_t bwidth, /* i : bandwidth of signal */ + const int16_t sba_mono_flag, /* i : flag for mono output */ + const int16_t bwidth, /* i : bandwidth of signal */ #endif - const STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i : Stereo DFT handle for mixing matrix */ + const STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i : Stereo DFT handle for mixing matrix */ ) { int16_t i; @@ -583,14 +583,14 @@ static void ivas_sba_dirac_stereo_upmix_hb( for ( i = 0; i < output_frame / 2; i++ ) { float gp = hStereoDft->mixer_mat_smooth[0][0][8] + hStereoDft->mixer_mat_smooth[1][0][8] + - hStereoDft->mixer_mat_smooth[0][0][9] + hStereoDft->mixer_mat_smooth[1][0][9] + - hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[1][0][10] + - hStereoDft->mixer_mat_smooth[0][0][11] + hStereoDft->mixer_mat_smooth[1][0][11]; + hStereoDft->mixer_mat_smooth[0][0][9] + hStereoDft->mixer_mat_smooth[1][0][9] + + hStereoDft->mixer_mat_smooth[0][0][10] + hStereoDft->mixer_mat_smooth[1][0][10] + + hStereoDft->mixer_mat_smooth[0][0][11] + hStereoDft->mixer_mat_smooth[1][0][11]; float gm = hStereoDft->mixer_mat_smooth[0][0][8] - hStereoDft->mixer_mat_smooth[1][0][8] + - hStereoDft->mixer_mat_smooth[0][0][9] - hStereoDft->mixer_mat_smooth[1][0][9] + - hStereoDft->mixer_mat_smooth[0][0][10] - hStereoDft->mixer_mat_smooth[1][0][10] + - hStereoDft->mixer_mat_smooth[0][0][11] - hStereoDft->mixer_mat_smooth[1][0][11]; + hStereoDft->mixer_mat_smooth[0][0][9] - hStereoDft->mixer_mat_smooth[1][0][9] + + hStereoDft->mixer_mat_smooth[0][0][10] - hStereoDft->mixer_mat_smooth[1][0][10] + + hStereoDft->mixer_mat_smooth[0][0][11] - hStereoDft->mixer_mat_smooth[1][0][11]; hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp; hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm; @@ -598,14 +598,14 @@ static void ivas_sba_dirac_stereo_upmix_hb( for ( i = output_frame / 2; i < output_frame; i++ ) { float gp = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; float gm = hStereoDft->mixer_mat_smooth[0][0][8 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][8 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + - hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; + hStereoDft->mixer_mat_smooth[0][0][9 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][9 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][10 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][10 + IVAS_MAX_NUM_BANDS] + + hStereoDft->mixer_mat_smooth[0][0][11 + IVAS_MAX_NUM_BANDS] - hStereoDft->mixer_mat_smooth[1][0][11 + IVAS_MAX_NUM_BANDS]; hb_stereo_synth[0][i] = 0.5f * hb_synth[i] * 0.25f * gp; hb_stereo_synth[1][i] = 0.5f * hb_synth[i] * 0.25f * gm; @@ -986,7 +986,7 @@ void ivas_sba_dirac_stereo_dec( v_add( output[1], hb_synth_stereo[1], output[1], output_frame ); /* apply TD Stereo Filling as is done in ICBWE */ - ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, (st_ivas->sba_mode == SBA_MODE_SPAR && !mcmasa) ); + ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, ( st_ivas->sba_mode == SBA_MODE_SPAR && !mcmasa ) ); #ifdef SBA2MONO } #endif diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c old mode 100755 new mode 100644 index 0d9b079f2a..769f6016b4 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -1127,12 +1127,12 @@ void stereo_dft_dec( STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ #ifdef SBA2MONO - const int16_t sba_mono_flag, /* i : signal mono output for SBA DirAC */ + const int16_t sba_mono_flag, /* i : signal mono output for SBA DirAC */ #endif - ivas_spar_md_dec_state_t *hMdDec, /* i : 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 nchan_transport /* i : number of transpor channels */ + ivas_spar_md_dec_state_t *hMdDec, /* i : 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 nchan_transport /* i : number of transpor channels */ ) { int16_t i, k, b, N_div, stop; @@ -1430,11 +1430,11 @@ void stereo_dft_dec( } for ( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) { - DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i] + (hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS]) * DFT_PRED_RES[2 * i]; + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i] + ( hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS] ) * DFT_PRED_RES[2 * i]; DFT_L[2 * i] = DFT_W; DFT_R[2 * i] = 0.f; - DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1] + (hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS]) * DFT_PRED_RES[2 * i + 1]; + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1] + ( hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS] ) * DFT_PRED_RES[2 * i + 1]; DFT_L[2 * i + 1] = DFT_W; DFT_R[2 * i + 1] = 0.f; } @@ -1470,14 +1470,14 @@ void stereo_dft_dec( } for ( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) { - DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i] + (hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS]) * DFT_PRED_RES[2 * i]; - DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i] + (hStereoDft->mixer_mat_smooth[1][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][3][b + k * IVAS_MAX_NUM_BANDS]) * DFT_PRED_RES[2 * i]; + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i] + ( hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS] ) * DFT_PRED_RES[2 * i]; + DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i] + ( hStereoDft->mixer_mat_smooth[1][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][3][b + k * IVAS_MAX_NUM_BANDS] ) * DFT_PRED_RES[2 * i]; DFT_L[2 * i] = DFT_W + DFT_Y; DFT_R[2 * i] = DFT_W - DFT_Y; - DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1] + (hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS]) * DFT_PRED_RES[2 * i + 1]; - DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1] + (hStereoDft->mixer_mat_smooth[1][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][3][b + k * IVAS_MAX_NUM_BANDS]) * DFT_PRED_RES[2 * i + 1]; + DFT_W = hStereoDft->mixer_mat_smooth[0][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1] + ( hStereoDft->mixer_mat_smooth[0][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[0][3][b + k * IVAS_MAX_NUM_BANDS] ) * DFT_PRED_RES[2 * i + 1]; + DFT_Y = hStereoDft->mixer_mat_smooth[1][0][b + k * IVAS_MAX_NUM_BANDS] * pDFT_DMX[2 * i + 1] + ( hStereoDft->mixer_mat_smooth[1][1][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][2][b + k * IVAS_MAX_NUM_BANDS] + hStereoDft->mixer_mat_smooth[1][3][b + k * IVAS_MAX_NUM_BANDS] ) * DFT_PRED_RES[2 * i + 1]; DFT_L[2 * i + 1] = DFT_W + DFT_Y; DFT_R[2 * i + 1] = DFT_W - DFT_Y; -- GitLab From cea27718456a826df71ee1badd569f7e61d1b92b Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 4 Apr 2023 15:16:26 +1000 Subject: [PATCH 12/12] minor change to PCA decoder call --- lib_dec/ivas_dec.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 2185322025..f89a64bf3e 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -352,17 +352,7 @@ ivas_error ivas_dec( if ( st_ivas->hSpar->hPCA != NULL ) { - int16_t num_in_ingest; - if ( st_ivas->hSpar->hMdDec->td_decorr_flag ) - { - num_in_ingest = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order ); - ; - } - else - { - num_in_ingest = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; - } - ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, num_in_ingest, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output ); + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output ); } #endif -- GitLab