From b88eae79d9c829965cda32a8f0919ff0015d2123 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 23 Oct 2025 17:45:36 +0300 Subject: [PATCH 1/6] Adds missing pieces of port 408 for BASOP main. --- lib_dec/ivas_jbm_dec_fx.c | 17 +++++++ .../ivas_dirac_dec_binaural_functions_fx.c | 48 +++++++++---------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3e171a8de..4b9194c45 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4598,6 +4598,23 @@ void ivas_dec_prepare_renderer_fx( move16(); } +#ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES + test(); + test(); + IF ( st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32(st_ivas->renderer_type, RENDERER_DIRAC) ) + { + /* Gain MASA part, if edited */ + IF ( st_ivas->hMasaIsmData->masa_gain_is_edited ) + { + FOR ( n = 0; n < CPE_CHANNELS; n++ ) + { + v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available ); + Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 + } + } + } +#endif + FOR( n = 0; n < nchan_transport_ism; n++ ) { test(); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 0539b7b85..53659db0b 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -5383,7 +5383,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } /* MASA gaining */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { IF( masaGainEdited ) { @@ -5420,7 +5420,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move16(); /* Use diagonal mixing matrix as the instant mixing matrix, to slowly fade away the editing during dtx */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { ismPreprocMtxNew[ch][ch] = ONE_IN_Q28; move32(); @@ -5462,7 +5462,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move16(); FOR( slot = 0; slot < nSlots; slot++ ) { - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { FOR( bin = bin_lo; bin < bin_hi; bin++ ) { @@ -5481,9 +5481,9 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } /* Get increment value for temporal interpolation */ - FOR( inCh = 0; inCh < 2; inCh++ ) + FOR( inCh = 0; inCh < BINAURAL_CHANNELS; inCh++ ) { - FOR( outCh = 0; outCh < 2; outCh++ ) + FOR( outCh = 0; outCh < BINAURAL_CHANNELS; outCh++ ) { temp = L_sub( ismPreprocMtxNew[outCh][inCh], hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ); // Q28 ismPreprocMtxIncrement[outCh][inCh] = L_shr( temp, 2 ); // Divide by 4 @@ -5501,11 +5501,11 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( hMasaIsmData->preprocEneTarget_fx[band_idx] = BASOP_Util_Add_Mant32Exp( hMasaIsmData->preprocEneTarget_fx[band_idx], hMasaIsmData->preprocEneTarget_e[band_idx], totalTargetEne, totalTargetEne_e, &hMasaIsmData->preprocEneTarget_e[band_idx] ); // Q = 31-preprocEneTarget_e move32(); - FOR( outCh = 0; outCh < 2; outCh++ ) + FOR( outCh = 0; outCh < BINAURAL_CHANNELS; outCh++ ) { FOR( slot = 0; slot < nSlots; slot++ ) { - FOR( inCh = 0; inCh < 2; inCh++ ) + FOR( inCh = 0; inCh < BINAURAL_CHANNELS; inCh++ ) { hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] = L_add( hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx], ismPreprocMtxIncrement[outCh][inCh] ); // Q28 @@ -5564,7 +5564,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move32(); } - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { FOR( slot = 0; slot < nSlots; slot++ ) { @@ -5666,7 +5666,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( ELSE { /* When not edited, input and output pan gains are the same */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { panGainsOut[ismDirIndex][ch] = panGainsIn[ismDirIndex][ch]; move16(); @@ -5674,7 +5674,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } /* Determine pan enes */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { panEnesOut[ismDirIndex][ch] = mult( panGainsOut[ismDirIndex][ch], panGainsOut[ismDirIndex][ch] ); // Q15 move16(); @@ -5704,14 +5704,14 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } /* Init out array */ - FOR( Word16 k = 0; k < nSlots; k++ ) + FOR( slot = 0; slot < nSlots; slot++ ) { FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - set_zero_fx( outSlotRe[ch][k], CLDFB_NO_CHANNELS_MAX ); - set_zero_fx( outSlotIm[ch][k], CLDFB_NO_CHANNELS_MAX ); + set_zero_fx( outSlotRe[ch][slot], CLDFB_NO_CHANNELS_MAX ); + set_zero_fx( outSlotIm[ch][slot], CLDFB_NO_CHANNELS_MAX ); - norm = s_min( L_norm_arr( inRe_fx[ch][k], nBins ), L_norm_arr( inIm_fx[ch][k], nBins ) ); + norm = s_min( L_norm_arr( inRe_fx[ch][slot], nBins ), L_norm_arr( inIm_fx[ch][slot], nBins ) ); shift = s_min( norm, shift ); } } @@ -5762,7 +5762,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move16(); /* Determine transport normalized energies and subframe energy */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { FOR( slot = 0; slot < nSlots; slot++ ) { @@ -5985,7 +5985,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( /* Calculate MASA target energies and add to total target energy estimation */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { /* MASA original energy per channel */ masaEneThisCh[ch] = L_max( masaEneThisCh[ch], 0 ); // Q5 @@ -6167,7 +6167,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } } - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { eneMoveThis = s_max( 0, sub( panEnesIn[ismDirIndex][ch], panEnesOut[ismDirIndex][ch] ) ); // Q15 move16(); @@ -6197,7 +6197,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( remainderNormEne = L_max( 0, temp ); // Q25 /* Normalize */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { temp = L_shr( remainderNormEne, 1 ); // Division by 2, Q25 temp = L_add( normEnes[ch], temp ); // Q25 @@ -6233,7 +6233,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( /* Temporally average energy moving and preserving, and generate the transport signal preprocessing matrix for * gaining objects and moving objects between left and right */ - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { hMasaIsmData->eneMoveIIR_fx[ch][band_idx] = Mpy_32_16_1( hMasaIsmData->eneMoveIIR_fx[ch][band_idx], STEREO_PREPROCESS_IIR_FACTOR_Q15 ); // Q = Enemove_Q + 15 + 1 -16 = Enemove_Q move32(); @@ -6320,9 +6320,9 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } /* Get increment value for temporal interpolation */ - FOR( inCh = 0; inCh < 2; inCh++ ) + FOR( inCh = 0; inCh < BINAURAL_CHANNELS; inCh++ ) { - FOR( outCh = 0; outCh < 2; outCh++ ) + FOR( outCh = 0; outCh < BINAURAL_CHANNELS; outCh++ ) { temp = L_sub( ismPreprocMtxNew[outCh][inCh], hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] ); // Q28 ismPreprocMtxIncrement[outCh][inCh] = L_shr( temp, 2 ); // Divide by 4 @@ -6340,11 +6340,11 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( hMasaIsmData->preprocEneTarget_fx[band_idx] = BASOP_Util_Add_Mant32Exp( hMasaIsmData->preprocEneTarget_fx[band_idx], hMasaIsmData->preprocEneTarget_e[band_idx], totalTargetEne, sub( Q31, subQ ), &hMasaIsmData->preprocEneTarget_e[band_idx] ); // Q = 31-preprocEneTarget_e move32(); - FOR( outCh = 0; outCh < 2; outCh++ ) + FOR( outCh = 0; outCh < BINAURAL_CHANNELS; outCh++ ) { FOR( slot = 0; slot < nSlots; slot++ ) { - FOR( inCh = 0; inCh < 2; inCh++ ) + FOR( inCh = 0; inCh < BINAURAL_CHANNELS; inCh++ ) { hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx] = L_add( hMasaIsmData->ismPreprocMatrix_fx[outCh][inCh][band_idx], ismPreprocMtxIncrement[outCh][inCh] ); // Q28 move32(); @@ -6403,7 +6403,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move32(); } - FOR( ch = 0; ch < 2; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { FOR( slot = 0; slot < nSlots; slot++ ) { -- GitLab From b72b0307f7419b393d5dc6969ac11f39836917fa Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 23 Oct 2025 18:13:03 +0300 Subject: [PATCH 2/6] Add one minor missing bit and format. --- lib_dec/ivas_jbm_dec_fx.c | 6 +++--- lib_dec/ivas_omasa_dec_fx.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 4b9194c45..b67c7478e 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4601,12 +4601,12 @@ void ivas_dec_prepare_renderer_fx( #ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES test(); test(); - IF ( st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32(st_ivas->renderer_type, RENDERER_DIRAC) ) + IF( st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) ) { /* Gain MASA part, if edited */ - IF ( st_ivas->hMasaIsmData->masa_gain_is_edited ) + IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) { - FOR ( n = 0; n < CPE_CHANNELS; n++ ) + FOR( n = 0; n < CPE_CHANNELS; n++ ) { v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available ); Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 811935a60..c562d7df6 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1114,7 +1114,7 @@ void ivas_omasa_dirac_rend_jbm_fx( /* Gain MASA part, if edited */ IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) { - FOR( n = 0; n < 2; n++ ) + FOR( n = 0; n < CPE_CHANNELS; n++ ) { v_multc_fx_16( output_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, output_fx[n], *nSamplesRendered ); // Q = 8 Scale_sig32( output_fx[n], *nSamplesRendered, Q3 ); // Q = 11 -- GitLab From fb4ba1a9aad474ba1f89cbec78ca3670ee8a837d Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 30 Oct 2025 14:23:17 +0200 Subject: [PATCH 3/6] Add switch NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES back. --- lib_com/options.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/options.h b/lib_com/options.h index 676b3d674..344f3b451 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -129,6 +129,7 @@ #define FIX_1372_OSBA_OBJECT_EDITING /* VA: issue 1372: Fix OSBA object-editing in BINAURAL_ROOM_IR */ #define FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES /* Nokia: Issue 2140, fixes three different sanitizer issues persisting in object editing code. */ #define NONBE_FIX_1172_OBJ_EDIT_JBM /* VA: issue 1172: fix OMASA object editing in JBM */ +#define NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES /* Nokia: Fix for issues 1399: obj edit broken with MC/SBA output in VOIP, and 1400: negative energy estimate used for gaining. */ /* #################### End BASOP porting switches ############################ */ -- GitLab From d433c626514059143e0ab9e527def313018e4184 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 30 Oct 2025 14:32:07 +0200 Subject: [PATCH 4/6] Revert "Add switch NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES back." This reverts commit fb4ba1a9aad474ba1f89cbec78ca3670ee8a837d. --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 344f3b451..676b3d674 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -129,7 +129,6 @@ #define FIX_1372_OSBA_OBJECT_EDITING /* VA: issue 1372: Fix OSBA object-editing in BINAURAL_ROOM_IR */ #define FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES /* Nokia: Issue 2140, fixes three different sanitizer issues persisting in object editing code. */ #define NONBE_FIX_1172_OBJ_EDIT_JBM /* VA: issue 1172: fix OMASA object editing in JBM */ -#define NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES /* Nokia: Fix for issues 1399: obj edit broken with MC/SBA output in VOIP, and 1400: negative energy estimate used for gaining. */ /* #################### End BASOP porting switches ############################ */ -- GitLab From c1597d2c9fa1079bed2231f5162e7f0a3950bac9 Mon Sep 17 00:00:00 2001 From: lintervo Date: Tue, 4 Nov 2025 12:38:01 +0200 Subject: [PATCH 5/6] Add missing changes --- lib_dec/ivas_omasa_dec_fx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 0c5f0eeef..8b455266d 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1120,10 +1120,14 @@ void ivas_omasa_dirac_rend_jbm_fx( { Copy32( &output_fx[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); +#ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) +#else #ifdef FIX_1330_JBM_MEMORY IF( !st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) #else IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) +#endif #endif { /* Gain separated object, if edited */ @@ -1145,10 +1149,14 @@ void ivas_omasa_dirac_rend_jbm_fx( Copy32( &output_fx[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); /* Gain discrete objects, if edited */ +#ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES + IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) +#else #ifdef FIX_1330_JBM_MEMORY IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) #else IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) +#endif #endif { v_multc_fx_16( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited_fx[n], data_separated_objects[n], *nSamplesRendered ); // Q = 8 @@ -1156,7 +1164,7 @@ void ivas_omasa_dirac_rend_jbm_fx( } } - /* Gain MASA part, if edited */ + /* Gain MASA part, if edited in G192. MASA gaining with VOIP is done in ivas_dec_prepare_renderer() */ #ifdef FIX_1330_JBM_MEMORY IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->masa_gain_is_edited ) #else -- GitLab From 9fc1139f35a9390b4cf2dfa776cd4ad577a4d54d Mon Sep 17 00:00:00 2001 From: lintervo Date: Wed, 5 Nov 2025 12:23:29 +0200 Subject: [PATCH 6/6] Clang format --- lib_dec/ivas_omasa_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 8b455266d..b1435fe77 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1124,7 +1124,7 @@ void ivas_omasa_dirac_rend_jbm_fx( IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) #else #ifdef FIX_1330_JBM_MEMORY - IF( !st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + IF( !st_ivas->hDecoderConfig->Opt_tsm && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) #else IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) #endif @@ -1153,7 +1153,7 @@ void ivas_omasa_dirac_rend_jbm_fx( IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) #else #ifdef FIX_1330_JBM_MEMORY - IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) + IF( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) #else IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) #endif -- GitLab