From 6d8749c5ba33e50af63dfcaf15db9e899851d1c5 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Thu, 11 Jan 2024 13:25:49 +0100 Subject: [PATCH 1/7] fix difference between 5/10/20 ms frames in 13.2kbps McMASA binaural rendering. switch: NONBE_FIX_951_MCMASA_5MS_RENDERING --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index ebaa43a69d..1cc56b5c11 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -160,6 +160,7 @@ #define NONBE_FIX_856_TCX_LTP_SYNTH_FILTER /* FhG: issue 856: correct filtering length for tcx-ltp synth filtering*/ #define NONBE_FIX_944_FEC_OMASA_1SEP_OBJ_MASA /* Nokia: issue 944: fix FEC error in OMASA */ +#define NONBE_FIX_951_MCMASA_5MS_RENDERING /* Nokia: issue #951: Differences for 5ms and 20ms rendering for McMASA at 13.2 kbps to BINAURAL */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 30fe1142b0..8ff1823fd4 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1372,8 +1372,11 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { int16_t offset = hSpatParamRendCom->slots_rendered * hSpatParamRendCom->slot_size; +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + nchan_remapped = st_ivas->hTcBuffer->nchan_buffer_full; +#else nchan_remapped = st_ivas->nchan_transport; - +#endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); -- GitLab From b56da9279ad0c3b575ce3b85059f2fab6f86e3bf Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Thu, 11 Jan 2024 13:53:29 +0100 Subject: [PATCH 2/7] adjust McMASA fix for BIN outputs --- lib_dec/ivas_jbm_dec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 8ff1823fd4..ffa31a96fe 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1372,13 +1372,12 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { int16_t offset = hSpatParamRendCom->slots_rendered * hSpatParamRendCom->slot_size; -#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING - nchan_remapped = st_ivas->hTcBuffer->nchan_buffer_full; -#else nchan_remapped = st_ivas->nchan_transport; -#endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + nchan_remapped = st_ivas->hTcBuffer->nchan_buffer_full; +#endif ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); } else if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) /* rendering to CICPxx and Ambisonics */ -- GitLab From 3fd1d68470a4d9e4514537b2678b43f7f4f35164 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Tue, 16 Jan 2024 08:22:59 +0100 Subject: [PATCH 3/7] adhoc change to p_output for getting same output in different rendering frame lengths --- lib_dec/ivas_jbm_dec.c | 13 +++++++++---- lib_rend/lib_rend.c | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 0963261f5c..e472eea9b2 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -950,6 +950,9 @@ ivas_error ivas_jbm_dec_render( #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t nchan_out_syn_output; #endif +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + float tmp_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; +#endif push_wmops( "ivas_dec_render" ); /*----------------------------------------------------------------* @@ -987,7 +990,12 @@ ivas_error ivas_jbm_dec_render( p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered]; } } - +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) + { + p_output[n] = tmp_output[n]; + } +#endif /*----------------------------------------------------------------* * Update combined orientation access index *----------------------------------------------------------------*/ @@ -1381,9 +1389,6 @@ ivas_error ivas_jbm_dec_render( nchan_remapped = st_ivas->nchan_transport; if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { -#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING - nchan_remapped = st_ivas->hTcBuffer->nchan_buffer_full; -#endif ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); } else if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) /* rendering to CICPxx and Ambisonics */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 947889e837..a169f9fed9 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -517,6 +517,7 @@ static void accumulate2dArrayToBuffer( * In-place saturation control for multichannel buffers with adaptive release time *-------------------------------------------------------------------*/ +#ifndef DISABLE_LIMITER /*! r: number of clipped output samples */ static int32_t limitRendererOutput( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ @@ -561,7 +562,7 @@ static int32_t limitRendererOutput( return numClipping; } - +#endif /*-------------------------------------------------------------------* * validateOutputAudioConfig() -- GitLab From 6b17a174b277db0924862d25408b67571ae2a049 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 23 Jan 2024 09:46:22 +0100 Subject: [PATCH 4/7] fix 5ms problem with low band CNA generation for the DirAC and param binaural rendering --- lib_com/ivas_prot.h | 3 ++ lib_dec/fd_cng_dec.c | 38 +++++++++++++++++++- lib_dec/ivas_dirac_dec.c | 8 +++++ lib_dec/ivas_jbm_dec.c | 10 +----- lib_dec/ivas_sba_dec.c | 4 +++ lib_rend/ivas_dirac_dec_binaural_functions.c | 16 +++++++++ 6 files changed, 69 insertions(+), 10 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2eacf811b0..c7b59b8c42 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3683,6 +3683,9 @@ void generate_masking_noise_lb_dirac( HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, +#endif const int16_t cna_flag /* i : CNA flag for LB and HB */ ); diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 69d007825c..7e4eb83500 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1805,7 +1805,10 @@ void generate_masking_noise_lb_dirac( HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ - const int16_t cna_flag /* i : CNA flag for LB and HB */ +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, +#endif + const int16_t cna_flag /* i : CNA flag for LB and HB */ ) { int16_t i; @@ -1940,8 +1943,41 @@ void generate_masking_noise_lb_dirac( n_samples_out -= hFdCngCom->frameSize; n_samples_start += hFdCngCom->frameSize; } +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + { + /* move generated noise to the 5ms subframe starts in the tc buffer according to the output sampling frequency to avoid + overwriting it with the synthesis in case of shared tc and synth channel memory, i.e. non-TSM mode */ + int16_t cur_subframe; + int16_t cur_subframe_start_outfs; + int16_t cur_subframe_start_cngfs; + int16_t slot_size_cng; + + cur_subframe_start_outfs = 0; + cur_subframe_start_cngfs = 0; + slot_size_cng = hFdCngCom->frameSize / DEFAULT_JBM_CLDFB_TIMESLOTS; + /* move start indices forward to the last subframe */ + for ( cur_subframe = 0; cur_subframe < hSpatParamRendCom->nb_subframes - 1; cur_subframe++ ) + { + cur_subframe_start_outfs += hSpatParamRendCom->subframe_nbslots[cur_subframe] * hSpatParamRendCom->slot_size; + cur_subframe_start_cngfs += hSpatParamRendCom->subframe_nbslots[cur_subframe] * slot_size_cng; + } + + /* go from the last subframe back and move the LB noise */ + for ( cur_subframe = cur_subframe < hSpatParamRendCom->nb_subframes; cur_subframe >= 0; cur_subframe-- ) + { + int16_t move_size, subframe_size_outfs; + move_size = slot_size_cng * hSpatParamRendCom->subframe_nbslots[cur_subframe]; + subframe_size_outfs = hSpatParamRendCom->subframe_nbslots[cur_subframe] * hSpatParamRendCom->slot_size; + /* move cna */ + mvr2r( tdBuffer + cur_subframe_start_cngfs, tdBuffer + cur_subframe_start_outfs, move_size ); + /* set everything else to zero */ + set_zero( tdBuffer + cur_subframe_start_outfs + move_size, subframe_size_outfs - move_size ); + } + } +#endif } + pop_wmops(); return; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 804c1e8522..b1ad6767a6 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1943,10 +1943,18 @@ void ivas_dirac_dec_render_sf( generate_masking_noise_dirac( st->hFdCngDec->hFdCngCom, st_ivas->cldfbAnaDec[1], +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + &st_ivas->hTcBuffer->tc[1][hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->slots_rendered], +#else st_ivas->hTcBuffer->tc[1], +#endif Cldfb_RealBuffer[1][0], Cldfb_ImagBuffer[1][0], +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + slot_idx, +#else index_slot, +#endif st->cna_dirac_flag && st->flag_cna, ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && st->cng_type == FD_CNG && st->cng_sba_flag ); } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index af14d23682..99878657cd 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -950,9 +950,6 @@ ivas_error ivas_jbm_dec_render( #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t nchan_out_syn_output; #endif -#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING - float tmp_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; -#endif push_wmops( "ivas_dec_render" ); /*----------------------------------------------------------------* @@ -990,12 +987,7 @@ ivas_error ivas_jbm_dec_render( p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered]; } } -#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING - for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) - { - p_output[n] = tmp_output[n]; - } -#endif + /*----------------------------------------------------------------* * Update combined orientation access index *----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 6ddcb37778..8aada05929 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -759,7 +759,11 @@ void ivas_sba_dec_digest_tc( ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st_ivas->hSpatParamRendCom, st->cna_dirac_flag && st->flag_cna ); +#else generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna ); +#endif } return; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 936d68b404..7f50ced6d0 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -669,16 +669,28 @@ static void ivas_dirac_dec_binaural_internal( if ( st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) { int16_t numCoreBands, b; +#ifndef NONBE_FIX_951_MCMASA_5MS_RENDERING int16_t slotInFrame; +#endif numCoreBands = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->numCoreBands; +#ifndef NONBE_FIX_951_MCMASA_5MS_RENDERING slotInFrame = hSpatParamRendCom->slots_rendered + slot; +#endif generate_masking_noise_dirac( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom, st_ivas->cldfbAnaDec[1], +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + &st_ivas->hTcBuffer->tc[nchan_transport][hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->slots_rendered], +#else st_ivas->hTcBuffer->tc[nchan_transport], +#endif Cldfb_RealBuffer_in[2][slot], Cldfb_ImagBuffer_in[2][slot], +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + slot, +#else slotInFrame, +#endif st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->hSCE[0]->hCoreCoder[0]->flag_cna, ( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ); @@ -686,7 +698,11 @@ static void ivas_dirac_dec_binaural_internal( st_ivas->cldfbAnaDec[1], /*nothing will be analyzed, just get cnst*/ NULL, Cldfb_RealBuffer_in[1][slot], Cldfb_ImagBuffer_in[1][slot], +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + slot, +#else slotInFrame, +#endif st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->hSCE[0]->hCoreCoder[0]->flag_cna, ( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ); -- GitLab From ebfd0a22301e07f3ae1ea8f34aa993b5e9bed7c1 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 23 Jan 2024 10:28:54 +0100 Subject: [PATCH 5/7] fix copying of cna to corresponding subframes, copy pointers were not updated correctly --- lib_dec/fd_cng_dec.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 7e4eb83500..31a8a1727d 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1952,22 +1952,20 @@ void generate_masking_noise_lb_dirac( int16_t cur_subframe_start_cngfs; int16_t slot_size_cng; - cur_subframe_start_outfs = 0; - cur_subframe_start_cngfs = 0; + slot_size_cng = hFdCngCom->frameSize / DEFAULT_JBM_CLDFB_TIMESLOTS; - /* move start indices forward to the last subframe */ - for ( cur_subframe = 0; cur_subframe < hSpatParamRendCom->nb_subframes - 1; cur_subframe++ ) - { - cur_subframe_start_outfs += hSpatParamRendCom->subframe_nbslots[cur_subframe] * hSpatParamRendCom->slot_size; - cur_subframe_start_cngfs += hSpatParamRendCom->subframe_nbslots[cur_subframe] * slot_size_cng; - } + /* move start indices forward to the end of the last subframe */ + cur_subframe_start_outfs = nCldfbTs * hSpatParamRendCom->slot_size; + cur_subframe_start_cngfs = nCldfbTs * slot_size_cng; /* go from the last subframe back and move the LB noise */ - for ( cur_subframe = cur_subframe < hSpatParamRendCom->nb_subframes; cur_subframe >= 0; cur_subframe-- ) + for ( cur_subframe = hSpatParamRendCom->nb_subframes - 1; cur_subframe >= 0; cur_subframe-- ) { int16_t move_size, subframe_size_outfs; move_size = slot_size_cng * hSpatParamRendCom->subframe_nbslots[cur_subframe]; subframe_size_outfs = hSpatParamRendCom->subframe_nbslots[cur_subframe] * hSpatParamRendCom->slot_size; + cur_subframe_start_outfs -= hSpatParamRendCom->subframe_nbslots[cur_subframe] * hSpatParamRendCom->slot_size; + cur_subframe_start_cngfs -= hSpatParamRendCom->subframe_nbslots[cur_subframe] * slot_size_cng; /* move cna */ mvr2r( tdBuffer + cur_subframe_start_cngfs, tdBuffer + cur_subframe_start_outfs, move_size ); /* set everything else to zero */ -- GitLab From b533d7eb3c08097ed58f19d213efdb5bed393e01 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 24 Jan 2024 07:12:07 +0100 Subject: [PATCH 6/7] added missing function parameter description comment --- lib_com/ivas_prot.h | 2 +- lib_dec/fd_cng_dec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c7b59b8c42..147b85092b 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3684,7 +3684,7 @@ void generate_masking_noise_lb_dirac( float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ #ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i : common spatial rendering parameters handle */ #endif const int16_t cna_flag /* i : CNA flag for LB and HB */ ); diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 31a8a1727d..06a478b3ac 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1806,7 +1806,7 @@ void generate_masking_noise_lb_dirac( float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ #ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i : common spatial rendering parameters handle */ #endif const int16_t cna_flag /* i : CNA flag for LB and HB */ ) -- GitLab From 454febfc823d616b0917d9d364c750e520bfda09 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Thu, 25 Jan 2024 08:00:14 +0100 Subject: [PATCH 7/7] remove extra inner scope from CNA buffer adjustment --- lib_dec/fd_cng_dec.c | 54 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 06a478b3ac..6d772f2a86 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1860,6 +1860,13 @@ void generate_masking_noise_lb_dirac( /* LB CLDFB - CNA from STFT: CNA applied only in channel 0*/ if ( cna_flag && tdBuffer != NULL ) { +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + int16_t cur_subframe; + int16_t cur_subframe_start_outfs; + int16_t cur_subframe_start_cngfs; + int16_t slot_size_cng; +#endif + while ( n_samples_out > 0 ) { n_samples_out_loop = min( hFdCngCom->frameSize, n_samples_out ); @@ -1943,34 +1950,27 @@ void generate_masking_noise_lb_dirac( n_samples_out -= hFdCngCom->frameSize; n_samples_start += hFdCngCom->frameSize; } -#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING - { - /* move generated noise to the 5ms subframe starts in the tc buffer according to the output sampling frequency to avoid - overwriting it with the synthesis in case of shared tc and synth channel memory, i.e. non-TSM mode */ - int16_t cur_subframe; - int16_t cur_subframe_start_outfs; - int16_t cur_subframe_start_cngfs; - int16_t slot_size_cng; - - slot_size_cng = hFdCngCom->frameSize / DEFAULT_JBM_CLDFB_TIMESLOTS; - /* move start indices forward to the end of the last subframe */ - cur_subframe_start_outfs = nCldfbTs * hSpatParamRendCom->slot_size; - cur_subframe_start_cngfs = nCldfbTs * slot_size_cng; - - /* go from the last subframe back and move the LB noise */ - for ( cur_subframe = hSpatParamRendCom->nb_subframes - 1; cur_subframe >= 0; cur_subframe-- ) - { - int16_t move_size, subframe_size_outfs; - move_size = slot_size_cng * hSpatParamRendCom->subframe_nbslots[cur_subframe]; - subframe_size_outfs = hSpatParamRendCom->subframe_nbslots[cur_subframe] * hSpatParamRendCom->slot_size; - cur_subframe_start_outfs -= hSpatParamRendCom->subframe_nbslots[cur_subframe] * hSpatParamRendCom->slot_size; - cur_subframe_start_cngfs -= hSpatParamRendCom->subframe_nbslots[cur_subframe] * slot_size_cng; - /* move cna */ - mvr2r( tdBuffer + cur_subframe_start_cngfs, tdBuffer + cur_subframe_start_outfs, move_size ); - /* set everything else to zero */ - set_zero( tdBuffer + cur_subframe_start_outfs + move_size, subframe_size_outfs - move_size ); - } +#ifdef NONBE_FIX_951_MCMASA_5MS_RENDERING + /* move generated noise to the 5ms subframe starts in the tc buffer according to the output sampling frequency to avoid + overwriting it with the synthesis in case of shared tc and synth channel memory, i.e. non-TSM mode */ + slot_size_cng = hFdCngCom->frameSize / DEFAULT_JBM_CLDFB_TIMESLOTS; + /* move start indices forward to the end of the last subframe */ + cur_subframe_start_outfs = nCldfbTs * hSpatParamRendCom->slot_size; + cur_subframe_start_cngfs = nCldfbTs * slot_size_cng; + + /* go from the last subframe back and move the LB noise */ + for ( cur_subframe = hSpatParamRendCom->nb_subframes - 1; cur_subframe >= 0; cur_subframe-- ) + { + int16_t move_size, subframe_size_outfs; + move_size = slot_size_cng * hSpatParamRendCom->subframe_nbslots[cur_subframe]; + subframe_size_outfs = hSpatParamRendCom->subframe_nbslots[cur_subframe] * hSpatParamRendCom->slot_size; + cur_subframe_start_outfs -= hSpatParamRendCom->subframe_nbslots[cur_subframe] * hSpatParamRendCom->slot_size; + cur_subframe_start_cngfs -= hSpatParamRendCom->subframe_nbslots[cur_subframe] * slot_size_cng; + /* move cna */ + mvr2r( tdBuffer + cur_subframe_start_cngfs, tdBuffer + cur_subframe_start_outfs, move_size ); + /* set everything else to zero */ + set_zero( tdBuffer + cur_subframe_start_outfs + move_size, subframe_size_outfs - move_size ); } #endif } -- GitLab