Commit 9d347062 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

Merge branch 'main' of ssh://forge.3gpp.org:29419/sa4/audio/ivas-basop into...

Merge branch 'main' of ssh://forge.3gpp.org:29419/sa4/audio/ivas-basop into 1867-replace-overflow-basop-operators-by-overflow-free-variants-in-lib_enc
parents 181e498a ca3146eb
Loading
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@


#define FIX_1931_BIN_COHR_CROSS_MIX                    /* FhG: correct binauralCoherenceCrossmixGains_fx calculation */
#define FIX_1939_REVERB_DMX_OUT_Q                       /*Dlb: output correct q factor for the reverb dmx function*/

#define EVS_BE_REUSAGE
#ifdef EVS_BE_REUSAGE
@@ -107,7 +108,8 @@
#endif
#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW   /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */
#define FIX_1844_MISSING_FREE                   /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */

#define FIX_1942_ASSERTION_LOWSHELF             /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() */
#define FIX_1944_CRASH_FOR_STEREO                      /* FhG: improve TonalMDCTConceal_InsertNoise calculation precision */
/* #################### Start BASOP porting switches ############################ */

#define FIX_1372_ISAR_POST_REND
@@ -147,6 +149,8 @@
#define FIX_587_DEFAULT_REVERB                          /* Philips: issue 587: inconsistent default reverb parameters across renderers */
#define NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC      /* FhG: fix out-of-bound errors when switching from SID frame to active frame*/
#define NONBE_FIX_1052_SBA_EXT_FIX                      /* VA: SBA external output support fix - do not overwrite "output_config" parameter */

#define FIX_1129_EXT_REND_OUTPUT_HIGH                   /* Philips: issue 1129: External renderer BINAURAL_ROOM_REVERB format output level too high compared to internal rendering output */
#define NONBE_1289_STEREO_SW_TO_MONO                    /* VA: issue 1289: Fix glitch when stereo signal is decoded to mono n TD->DFT switching */
#define NONBE_FIX_1196_TD_HEADTRACKING_INTERPOLATION    /* Ericsson: Issue 1196, Always apply filter interpolation for each subframe */
#define NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING       /* VA: issue 1110: fix encoder crash in the stereo DTX bitrate switching condition */
@@ -168,8 +172,12 @@
#define NONBE_FIX_1337_MISSING_DIRECTIVITY_DISTATT_EXTREND /* Eri: issue 1337: Missing directivity setting and distance attenuation in external renderer IVAS_rend */
#define NONBE_1214_PLC_LSF_MEMORY                       /* VA: issue 1224: reset ACELP PLC FEC memory in case of switching from MDCT stereo to TD/DFT stereo */
#define NONBE_1293_SR_HRTF                              /* VA: issue 1293: add support of external HRTFs in split rendering */
#define FIX_1249_REMOVE_OBSOLETE_ALLRAD_MATRIX          /* VA: issue 1249: remove obsolete code around ALLRAD decoder matrix */
#define NONBE_1220_OMASA_JBM_BRATE_SW_FLUSH             /* VA: issue 1220: fix bug in renderer flush in OMASA 1ISM JBM bitrate switching */
#define NONBE_1118_EVS_LR_HQ_BITERROR                   /* VA: issue 1118: fix EVS decoder crash in LR-HQ in case of bit errors */
#define FIX_1139_REV_COLORATION_SHORT_T60               /* Nokia,FhG: Fix issue 1139, prevent sound coloration artefacts at very low reverberation times */

#define FIX_1959_assert_in_gain_enc_mless_fx            /* VA: Fix saturation introduced by the usage of the non-EVS basop operators =, the saturation was expected */
/* #################### End BASOP porting switches ############################ */

#endif
+23 −0
Original line number Diff line number Diff line
@@ -629,10 +629,33 @@ void hq_lr_dec_fx(

            IF( GE_16( i, highband ) )
            {

#ifdef NONBE_1118_EVS_LR_HQ_BITERROR
                /* safety check in case of bit errors */
                IF( GT_32( Ep_fx[i], 536788991 /* max(Q30) */ ) )
                {
                    st_fx->BER_detect = 1;
                    move16();
                    set32_fx( L_yout, 0, inner_frame );
                    return;
                }

#endif
                enerH_fx = L_add_sat( enerH_fx, L_shl_sat( Ep_fx[i], 2 ) ); /*Q0 */
            }
            ELSE IF( GE_16( i, lowband ) )
            {
#ifdef NONBE_1118_EVS_LR_HQ_BITERROR
                /* safety check in case of bit errors */
                IF( GT_32( Ep_fx[i], 536788991 /* max(Q30) */ ) )
                {
                    st_fx->BER_detect = 1;
                    move16();
                    set32_fx( L_yout, 0, inner_frame );
                    return;
                }

#endif
                enerL_fx = L_add_sat( enerL_fx, L_shl_sat( Ep_fx[i], 2 ) ); /*Q0 */
            }
        }
+44 −10
Original line number Diff line number Diff line
@@ -902,7 +902,16 @@ static ivas_error ivas_binaural_hrtf_open_fx(
 *
 *
 *-------------------------------------------------------------------------*/

#ifdef FIX_1939_REVERB_DMX_OUT_Q
static void ivas_binaural_obtain_DMX_fx(
    const Word16 numTimeSlots,
    BINAURAL_RENDERER_HANDLE hBinRenderer,                                /* i/o: fastconv binaural renderer handle */
    Word32 RealBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i  : Contains the LS signals         Q_in_out  */
    Word32 ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i  : Contains the LS signals         Q_in_out  */
    Word32 realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],    /*Q_in_out*/
    Word32 imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],    /*Q_in_out*/
    Word16 *Q_in_out )                                                    /*i/o: input and output Q*/
#else
static void ivas_binaural_obtain_DMX_fx(
    const Word16 numTimeSlots,
    BINAURAL_RENDERER_HANDLE hBinRenderer,                                /* i/o: fastconv binaural renderer handle */
@@ -910,6 +919,7 @@ static void ivas_binaural_obtain_DMX_fx(
    Word32 ImagBuffer[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i  : Contains the LS signals         Q_in  */
    Word32 realDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],    /*Q_in-1*/
    Word32 imagDMX[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] )   /*Q_in-1*/
#endif
{
    Word16 chIdx, bandIdx, k;

@@ -948,13 +958,13 @@ static void ivas_binaural_obtain_DMX_fx(
                {
                    FOR( k = 0; k < numTimeSlots; k++ )
                    {
                        temp1_fx = Mpy_32_32( RealBuffer[chIdx][k][bandIdx], dmxConst );                  // Q_in
                        temp2_fx = Mpy_32_32( ImagBuffer[chIdx][k][bandIdx], dmxConst );                  // Q_in
                        realDMX[chOutIdx][k][bandIdx] = L_add( realDMX[chOutIdx][k][bandIdx], temp1_fx ); // Q_in
                        temp1_fx = Mpy_32_32( RealBuffer[chIdx][k][bandIdx], dmxConst );                  // Q_in_out
                        temp2_fx = Mpy_32_32( ImagBuffer[chIdx][k][bandIdx], dmxConst );                  // Q_in_out
                        realDMX[chOutIdx][k][bandIdx] = L_add( realDMX[chOutIdx][k][bandIdx], temp1_fx ); // Q_in_out
                        move32();
                        imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in
                        imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in_out
                        move32();
                        P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in
                        P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in_out
                        move32();
                    }
                }
@@ -970,7 +980,7 @@ static void ivas_binaural_obtain_DMX_fx(
                    move32();
                    temp2_fx = imagDMX[chOutIdx][k][bandIdx];
                    move32();
                    P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in
                    P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in_out
                }
                test();
                IF( ( P_in_fx[bandIdx] <= 0 ) || ( P_out_fx <= 0 ) )
@@ -994,13 +1004,16 @@ static void ivas_binaural_obtain_DMX_fx(
                factEQ_fx = L_max( L_min( factEQ_fx, 0x7fffffff ), 0x20000000 ); // Q30 , 0x7fffffff -> (1.0f in Q31)-1, 0x20000000 ->1.0f in Q29
                FOR( k = 0; k < numTimeSlots; k++ )
                {
                    realDMX[chOutIdx][k][bandIdx] = Mpy_32_32( realDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1
                    realDMX[chOutIdx][k][bandIdx] = Mpy_32_32( realDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in_out - 1
                    move32();
                    imagDMX[chOutIdx][k][bandIdx] = Mpy_32_32( imagDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in - 1
                    imagDMX[chOutIdx][k][bandIdx] = Mpy_32_32( imagDMX[chOutIdx][k][bandIdx], factEQ_fx ); // Q_in_out - 1
                    move32();
                }
            }
        }
#ifdef FIX_1939_REVERB_DMX_OUT_Q
        *Q_in_out = sub( *Q_in_out, 1 );
#endif
    }
    ELSE IF( EQ_32( hBinRenderer->ivas_format, SBA_FORMAT ) || EQ_32( hBinRenderer->ivas_format, MASA_FORMAT ) )
    {
@@ -1068,6 +1081,12 @@ static void ivas_binaural_obtain_DMX_fx(
                }
            }
        }
#ifdef FIX_1939_REVERB_DMX_OUT_Q
        IF( NE_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) )
        {
            *Q_in_out = sub( *Q_in_out, 1 );
        }
#endif
    }

    return;
@@ -1361,7 +1380,11 @@ ivas_error ivas_binRenderer_open_fx(
        {
            pRoomAcoustics = &( st_ivas->hRenderConfig->roomAcoustics );
        }
#ifdef FIX_1139_REV_COLORATION_SHORT_T60
        IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, pRoomAcoustics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx, NULL ) ), IVAS_ERR_OK ) )
#else
        IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, pRoomAcoustics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) )
#endif
#else
        IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) )
#endif
@@ -1846,8 +1869,16 @@ void ivas_binRenderer_fx(
        Word32 inRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
        Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
        Word16 shift_q;
#ifdef FIX_1939_REVERB_DMX_OUT_Q
        Word16 q_in_out;
        q_in_out = *Q_in;
#endif

#ifdef FIX_1939_REVERB_DMX_OUT_Q
        ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx, &q_in_out );
#else
        ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx );
#endif

        FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
        {
@@ -1859,8 +1890,11 @@ void ivas_binRenderer_fx(
        }

        ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx );

#ifdef FIX_1939_REVERB_DMX_OUT_Q
        shift_q = sub( Q6, q_in_out );
#else
        shift_q = sub( Q6, sub( *Q_in, 1 ) );
#endif
        FOR( i = 0; i < BINAURAL_CHANNELS; i++ )
        {
            FOR( j = 0; j < numTimeSlots; j++ )
+5 −1
Original line number Diff line number Diff line
@@ -751,9 +751,13 @@ ivas_error ivas_core_dec_fx(
                move16();
                sts[1]->hHQ_core->Q_old_wtda = sub( 15, sts[1]->hHQ_core->exp_old_out );
                move16();

#ifdef FIX_1944_CRASH_FOR_STEREO
                shift1 = getScaleFactor16( sts[0]->hHQ_core->old_out_fx, L_FRAME48k );
                shift2 = getScaleFactor16( sts[1]->hHQ_core->old_out_fx, L_FRAME48k );
#else
                shift1 = norm_arr( sts[0]->hHQ_core->old_out_fx, L_FRAME48k );
                shift2 = norm_arr( sts[1]->hHQ_core->old_out_fx, L_FRAME48k );
#endif
                scale_sig( sts[0]->hHQ_core->old_out_fx, L_FRAME48k, shift1 );
                scale_sig( sts[1]->hHQ_core->old_out_fx, L_FRAME48k, shift2 );
                sts[0]->hHQ_core->Q_old_wtda = add( sts[0]->hHQ_core->Q_old_wtda, shift1 );
+6 −2
Original line number Diff line number Diff line
@@ -1943,6 +1943,8 @@ ivas_error ivas_init_decoder_fx(
            return error;
        }
        set16_fx( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 0, CLDFB_NO_COL_MAX );

#ifndef FIX_1249_REMOVE_OBSOLETE_ALLRAD_MATRIX
        test();
        IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) && st_ivas->hOutSetup.is_loudspeaker_setup )
        {
@@ -1951,7 +1953,7 @@ ivas_error ivas_init_decoder_fx(
                return error;
            }
        }

#endif
        Word16 hodirac_flag = ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order );
        IF( hodirac_flag )
        {
@@ -2005,6 +2007,7 @@ ivas_error ivas_init_decoder_fx(
        }
        st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
        move16();

        FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
        {
            Word32 res_dec, res_frac;
@@ -2137,6 +2140,7 @@ ivas_error ivas_init_decoder_fx(
            return error;
        }

#ifndef FIX_1249_REMOVE_OBSOLETE_ALLRAD_MATRIX
        test();
        IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) && st_ivas->hOutSetup.is_loudspeaker_setup )
        {
@@ -2145,7 +2149,7 @@ ivas_error ivas_init_decoder_fx(
                return error;
            }
        }

#endif
        Word16 hodirac_flag = ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order );
        IF( hodirac_flag )
        {
Loading