diff --git a/lib_com/options.h b/lib_com/options.h index a0932933c8027ff1ae5a16b35b290fe75b171f0a..2898dcbc9872749ef40cd2ebc6fc4a802080fca2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -203,6 +203,7 @@ #define TMP_FIX_OMASA_SR_BE // temporary fix to keep OMASA split-rendering BE #define FIX_1372_OSBA_OBJECT_EDITING /* VA: issue 1372: Fix OSBA object-editing in BINAURAL_ROOM_IR */ #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 ############################ */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 81994844110522b848771d9a23385b3bb033b50e..ae595dd31507cbdc5cc1f49ad1230944cc7f7b9e 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -3178,6 +3178,21 @@ void ivas_dec_prepare_renderer( { nchan_transport_ism = st_ivas->nchan_ism; } + +#ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES + if ( st_ivas->hDecoderConfig->Opt_tsm && st_ivas->ism_mode == ISM_MASA_MODE_DISC && 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( st_ivas->hTcBuffer->tc[n], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available ); + } + } + } +#endif + for ( n = 0; n < nchan_transport_ism; n++ ) { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 43d881dd47c486fd52c1dc4362e4d4689fb568f2..e3b2716f2bb954949e36370951a8655e288640e9 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -696,10 +696,14 @@ void ivas_omasa_dirac_rend_jbm( { mvr2r( &output_f[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); +#ifdef NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) +#else #ifdef FIX_1330_JBM_MEMORY - if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) #else if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) +#endif #endif { /* Gain separated object, if edited */ @@ -719,26 +723,30 @@ void ivas_omasa_dirac_rend_jbm( mvr2r( &output_f[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] ) + 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( data_separated_objects[n], st_ivas->hMasaIsmData->gain_ism_edited[n], data_separated_objects[n], *nSamplesRendered ); } } - /* 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 if ( st_ivas->hMasaIsmData->masa_gain_is_edited ) #endif { - for ( int16_t ch = 0; ch < 2; ch++ ) + for ( n = 0; n < CPE_CHANNELS; n++ ) { - v_multc( output_f[ch], st_ivas->hMasaIsmData->gain_masa_edited, output_f[ch], *nSamplesRendered ); + v_multc( output_f[n], st_ivas->hMasaIsmData->gain_masa_edited, output_f[n], *nSamplesRendered ); } } } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 5571d91b50dea82b769287ae9a7e7b5db02cc1dd..b0578f92c21f6c33462ec2119afdd6813d6bd1af 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -2790,7 +2790,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( } /* MASA gaining */ - for ( ch = 0; ch < 2; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { if ( masaGainEdited ) { @@ -2818,7 +2818,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( nSlotDiv = 1.0f / ( (float) nSlots ); /* 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] = 1.0f; ismPreprocMtxNew[1 - ch][ch] = 0.0f; @@ -2832,12 +2832,12 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( } /* Init out array */ - for ( int k = 0; k < nSlots; k++ ) + for ( slot = 0; slot < nSlots; slot++ ) { for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - set_zero( outSlotRe[ch][k], CLDFB_NO_CHANNELS_MAX ); - set_zero( outSlotIm[ch][k], CLDFB_NO_CHANNELS_MAX ); + set_zero( outSlotRe[ch][slot], CLDFB_NO_CHANNELS_MAX ); + set_zero( outSlotIm[ch][slot], CLDFB_NO_CHANNELS_MAX ); } } @@ -2851,7 +2851,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( totalTargetEne = 0.0f; 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++ ) { @@ -2862,9 +2862,9 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( } /* 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++ ) { ismPreprocMtxIncrement[outCh][inCh] = ( ismPreprocMtxNew[outCh][inCh] - hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] ) * nSlotDiv; } @@ -2875,11 +2875,11 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( hMasaIsmData->preprocEneRealized[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; hMasaIsmData->preprocEneTarget[band_idx] += totalTargetEne; - 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[outCh][inCh][band_idx] += ismPreprocMtxIncrement[outCh][inCh]; for ( bin = bin_lo; bin < bin_hi; bin++ ) @@ -2898,7 +2898,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( eqVal = fminf( 4.0f, sqrtf( hMasaIsmData->preprocEneTarget[band_idx] / fmaxf( 1e-12f, hMasaIsmData->preprocEneRealized[band_idx] ) ) ); - for ( ch = 0; ch < 2; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { for ( slot = 0; slot < nSlots; slot++ ) { @@ -2975,13 +2975,13 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( 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]; } } /* Determine pan enes */ - for ( ch = 0; ch < 2; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { panEnesOut[ismDirIndex][ch] = panGainsOut[ismDirIndex][ch] * panGainsOut[ismDirIndex][ch]; panEnesIn[ismDirIndex][ch] = panGainsIn[ismDirIndex][ch] * panGainsIn[ismDirIndex][ch]; @@ -3006,12 +3006,12 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( } /* Init out array */ - for ( int k = 0; k < nSlots; k++ ) + for ( slot = 0; slot < nSlots; slot++ ) { for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - set_zero( outSlotRe[ch][k], CLDFB_NO_CHANNELS_MAX ); - set_zero( outSlotIm[ch][k], CLDFB_NO_CHANNELS_MAX ); + set_zero( outSlotRe[ch][slot], CLDFB_NO_CHANNELS_MAX ); + set_zero( outSlotIm[ch][slot], CLDFB_NO_CHANNELS_MAX ); } } @@ -3041,7 +3041,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( /* Determine transport normalized energies and subframe energy */ 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++ ) { @@ -3064,7 +3064,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( ratioAccOrig += ratio; /* Calculate MASA energy as a residual of original channel energies subtracted with ISM energies */ - for ( ch = 0; ch < 2; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { masaEneThisCh[ch] -= panEnesIn[ismDirIndex][ch] * ratio * subframeEne; } @@ -3082,7 +3082,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( ratio *= gainIsmThis * gainIsmThis; /* Determine panning energies and channel target energies */ - for ( ch = 0; ch < 2; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { ismTargetEneThisCh[ch] = panEnesIn[ismDirIndex][ch] * ismTargetEneThis; /* Ism target energy per channel */ totalTargetEneCh[ch] -= panEnesIn[ismDirIndex][ch] * ismEneThis; /* Reduce original ism energy */ @@ -3123,7 +3123,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( ratio *= gainMasaPow2; /* Calculate MASA target energies and add to total target energy estimation */ - for ( ch = 0; ch < 2; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { masaEneThisCh[ch] = fmaxf( masaEneThisCh[ch], 0.0f ); /* MASA original energy per channel */ masaTargetEneThisCh[ch] = gainMasaPow2 * masaEneThisCh[ch]; /* MASA target energy per channel */ @@ -3138,7 +3138,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( /* Todo: Remove this comment with port 408 which would bring this back. * No sense to break the code with port 251. */ /* Limit target energies to non-negative values */ - for ( ch = 0; ch < 2; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { totalTargetEneCh[ch] = max( totalTargetEneCh[ch], 0.0f ); } @@ -3207,14 +3207,14 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( if ( enableCentering ) { centeringFactor = fmaxf( 0.0f, 2.0f * fabsf( panEnesIn[ismDirIndex][0] - panEnesOut[ismDirIndex][0] ) - 1.0f ); - for ( ch = 0; ch < 2; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { panEnesOut[ismDirIndex][ch] *= ( 1.0f - centeringFactor ); panEnesOut[ismDirIndex][ch] += 0.5f * centeringFactor; } } - for ( ch = 0; ch < 2; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { eneMoveThis = fmaxf( 0.0f, panEnesIn[ismDirIndex][ch] - panEnesOut[ismDirIndex][ch] ); enePreserveThis = panEnesIn[ismDirIndex][ch] - eneMoveThis; @@ -3231,7 +3231,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( remainderNormEne = fmaxf( 0.0f, ( 1.0f - ismRatioAcc ) - normEnes[0] - normEnes[1] ); /* Normalize */ - for ( ch = 0; ch < 2; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { enePreserve[ch] += fmaxf( 0.0f, normEnes[ch] + remainderNormEne / 2.0f ); normVal = 1.0f / fmaxf( EPSILON, eneMove[ch] + enePreserve[ch] ); @@ -3246,7 +3246,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( /* 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[ch][band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; hMasaIsmData->eneMoveIIR[ch][band_idx] += eneMove[ch] * totalTargetEne; @@ -3258,9 +3258,9 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( } /* 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++ ) { ismPreprocMtxIncrement[outCh][inCh] = ( ismPreprocMtxNew[outCh][inCh] - hMasaIsmData->ismPreprocMatrix[outCh][inCh][band_idx] ) * nSlotDiv; } @@ -3271,11 +3271,11 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( hMasaIsmData->preprocEneRealized[band_idx] *= STEREO_PREPROCESS_IIR_FACTOR; hMasaIsmData->preprocEneTarget[band_idx] += totalTargetEne; - 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[outCh][inCh][band_idx] += ismPreprocMtxIncrement[outCh][inCh]; for ( bin = bin_lo; bin < bin_hi; bin++ ) @@ -3294,7 +3294,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( eqVal = fminf( 4.0f, sqrtf( hMasaIsmData->preprocEneTarget[band_idx] / fmaxf( 1e-12f, hMasaIsmData->preprocEneRealized[band_idx] ) ) ); - for ( ch = 0; ch < 2; ch++ ) + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { for ( slot = 0; slot < nSlots; slot++ ) {