Commit 3ef7c662 authored by sagnowski's avatar sagnowski
Browse files

Merge branch 'main' into 2173-ubsan-in-jbm-pcmdsp-apa-fx-c

parents 95ab3f4b 18285010
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@
#define FIX_1330_JBM_MEMORY                             /* VA: issue 1330: memory savings in the JBM decoder */
#define FIX_1411_IGF_CRASH_BW_SWITCHING                 /* FhG: Fix for issue 1411: fixes crash that can happen for IGF with BW switching and DTX*/
#define NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG       /* FhG: Fix MDCT-Stereo comfort noise for certain noise types */
#define NONBE_1344_REND_MASA_LOW_FS                     /* Nokia: Issue 1344: Fix sanitizer errors when using IVAS_rend to render MASA with lower sampling rates */

// object-editing feature porting
#define TMP_FIX_SPLIT_REND                              // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions)
+17 −0
Original line number Diff line number Diff line
@@ -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();
+12 −4
Original line number Diff line number Diff line
@@ -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,14 +1164,14 @@ 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
        IF( st_ivas->hMasaIsmData->masa_gain_is_edited )
#endif
            {
                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
+16 −8
Original line number Diff line number Diff line
@@ -250,16 +250,24 @@ void ivas_dirac_ana_fx(
    const Word16 nchan_transport, /* i  : Number of transport channels        */
    const Word16 data_q )
{
    Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];
    /* Estimate MASA parameters from the SBA signals */
    ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, input_frame, data_q );
    /* Create MASA metadata buffer from the estimated values */
    ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, input_frame, data_q );

    ivas_create_masa_out_meta_fx( hDirAC->hMasaOut, hDirAC->sph_grid16, nchan_transport, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, Q31, Q31, Q31 );
#ifdef NONBE_1344_REND_MASA_LOW_FS
    /* Add zeros to higher bands in case of lower sampling rates */
    IF( LT_16( hDirAC->nbands, MASA_FREQUENCY_BANDS ) )
    {
        ivas_masa_zero_high_bands_fx( hDirAC->nbands, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx );
    }
#endif

    /* Create MASA metadata buffer from the estimated values */
    ivas_create_masa_out_meta_fx( hDirAC->hMasaOut, hDirAC->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 );

    /* Downmix */
    ivas_dirac_dmx_fx( data_fx, input_frame, nchan_transport ); // output Q of data_fx is same as that of input
+24 −24
Original line number Diff line number Diff line
@@ -5387,7 +5387,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx(
        }

        /* MASA gaining */
        FOR( ch = 0; ch < 2; ch++ )
        FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
        {
            IF( masaGainEdited )
            {
@@ -5424,7 +5424,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();
@@ -5466,7 +5466,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++ )
                    {
@@ -5485,9 +5485,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
@@ -5505,11 +5505,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

@@ -5568,7 +5568,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++ )
                {
@@ -5670,7 +5670,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();
@@ -5678,7 +5678,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();
@@ -5708,14 +5708,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 );
            }
        }
@@ -5766,7 +5766,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++ )
                {
@@ -5989,7 +5989,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
@@ -6171,7 +6171,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();
@@ -6201,7 +6201,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
@@ -6237,7 +6237,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();
@@ -6324,9 +6324,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
@@ -6344,11 +6344,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();
@@ -6411,7 +6411,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++ )
                {
Loading