Commit f789945a authored by Mohammadreza Naghibzadeh's avatar Mohammadreza Naghibzadeh
Browse files

Merge remote-tracking branch 'origin/main' into 1962_fix_format_conv_spectral_diff

# Conflicts:
#	lib_com/options.h
parents 765c1a05 01b6b99d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1739,7 +1739,7 @@ int main(
            int16_t numFramesToTargetOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
            for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ )
            {
                if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &quatBuffer[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK )
                if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &quatBuffer[sf_idx], &enableHeadRotation[sf_idx], &enableExternalOrientation[sf_idx], &enableRotationInterpolation[sf_idx], &numFramesToTargetOrientation[sf_idx] ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError in External Orientation File Reading: %s\n", ivas_error_to_string( error ) );
                    goto cleanup;
+2 −3
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@
#define FIX_1979_SAT_MISSING_IN_LSF_ENC                      /* VA: Proposal to fix 1979, saturation in lsf_enc, NOkia to review */
#define FIX_1946_CRASH_JBM_PROCESSING                        /* FhG: Increased guard bits of DFT_fx */
#define FIX_1980_CRASH_FDCNG_ENCODESID                       /* FhG: Add one bit of headroom in e_fx calculation in FdCng_encodeSID_ivas_fx() */
#define FIX_1987_CRASH_OMASA_ENERGY                          /* FhG: Replace cldfbAnalysis_ts_fx_fix_q() with cldfbAnalysis_ts_fx_var_q() to avoid assertion error */
#define FIX_1962_FORMAT_CONV_SPECTRAL_DIFF                   /* FhG: Improved precision of targetEnergy in ivas_ls_setup_conversion_process_mdct_fx() */
/* #################### Start BASOP porting switches ############################ */

@@ -90,9 +91,7 @@
#define NONBE_1302_FIX_OMASA_JBM_FLUSH                  /* VA: issue 1302: fix OMASA JBM bitrate switching flush in binaural output */
#define NONBE_1328_FIX_NON_LINEARITY                    /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0, float issue 1328  */
#define FIX_1319_STACK_SBA_DECODER                      /* VA: issue 1319: Optimize the definition of buffer lengths in the SBA decoder */
//de-activate FIX_1320_STACK_CPE_DECODER due to sanitizer issues in #1986; also review needed for patch within FIX_1946_CRASH_JBM_PROCESSING, which gets partially disabled
//#define FIX_1320_STACK_CPE_DECODER                      /* VA: issue 1320: Optimize the stack memory consumption in the CPE decoder */

#define FIX_1320_STACK_CPE_DECODER                      /* VA: issue 1320: Optimize the stack memory consumption in the CPE decoder */
#define FIX_1984_SAT_IN_PSYCHAD                         /* VA: Issue 1984: proposal to fix an assert */

/* #################### End BASOP porting switches ############################ */
+29 −10
Original line number Diff line number Diff line
@@ -77,8 +77,8 @@ ivas_error ivas_core_dec_fx(

    Word16 tmps, incr;
#ifdef FIX_1320_STACK_CPE_DECODER
    Word16 flag_bwe_bws, flaf_swb_tbe;
    Word32 *bwe_exc_extended_fx[CPE_CHANNELS] = { NULL, NULL };
    Word16 flag_bwe_bws;
#else
    Word32 bwe_exc_extended_fx[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET];
#endif
@@ -981,6 +981,24 @@ ivas_error ivas_core_dec_fx(
        Word16 Q_input, Q_hb_synth_fx, Q_synth_fx;
        Word16 Q_syn_hb, sf;

#ifdef FIX_1320_STACK_CPE_DECODER
        flaf_swb_tbe = 0;
        move16();
        test();
        test();
        test();
        test();
        test();
        test();
        test();
        test();
        if ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) || ( NE_16( st->coder_type, AUDIO ) && NE_16( st->coder_type, INACTIVE ) && GE_32( st->core_brate, SID_2k40 ) && EQ_16( st->core, ACELP_CORE ) && !st->con_tcx && GE_32( output_Fs, 32000 ) && GT_16( st->bwidth, NB ) && st->bws_cnt > 0 ) )
        {
            flaf_swb_tbe = 1;
            move16();
        }
#endif

        sf = getScaleFactor32( output_32_fx[n], L_FRAME48k );

        Q_input = 0;
@@ -1005,7 +1023,6 @@ ivas_error ivas_core_dec_fx(
        IF( EQ_16( st->extl, WB_TBE ) )
        {
            /* WB TBE decoder */

            ivas_wb_tbe_dec_fx( st, st->coder_type, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], hb_synth_16_fx[n], &Q_hb_synth_fx );
        }
        ELSE IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( n, 1 ) && !tdm_LRTD_flag && NE_16( st->extl, -1 ) && st->bws_cnt == 0 && st->extl_brate == 0 )
@@ -1020,9 +1037,7 @@ ivas_error ivas_core_dec_fx(

        /* Memories  Re-Scaling */
#ifdef FIX_1320_STACK_CPE_DECODER
        test();
        test();
        IF( EQ_16( st->extl, WB_TBE ) || ( EQ_16( st->extl, WB_BWE ) && st->bws_cnt == 0 ) )
        IF( !flaf_swb_tbe )
        {
#endif
            Copy_Scale_sig_16_32_no_sat( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, sub( Q11, Q_hb_synth_fx ) ); // Q11
@@ -1050,6 +1065,7 @@ ivas_error ivas_core_dec_fx(
        test();
        test();
        test();
        test();
        flag_bwe_bws = ( GE_32( output_Fs, 32000 ) && st->core == ACELP_CORE && st->bwidth > NB && st->bws_cnt > 0 && st->bfi == 0 );
        move16();
#endif
@@ -1057,7 +1073,11 @@ ivas_error ivas_core_dec_fx(
        Q_white_exc = 0;
        move16();

#ifndef FIX_1320_STACK_CPE_DECODER
#ifdef FIX_1320_STACK_CPE_DECODER
        test();
        test();
        IF( flaf_swb_tbe )
#else
        test();
        test();
        test();
@@ -1065,7 +1085,6 @@ ivas_error ivas_core_dec_fx(
        test();
        test();
        test();
#endif
        test();
        test();
        test();
@@ -1077,6 +1096,7 @@ ivas_error ivas_core_dec_fx(
        test();
        test();
        IF( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, FB_TBE ) || ( NE_16( st->coder_type, AUDIO ) && NE_16( st->coder_type, INACTIVE ) && GE_32( st->core_brate, SID_2k40 ) && EQ_16( st->core, ACELP_CORE ) && !st->con_tcx && GE_32( output_Fs, 32000 ) && GT_16( st->bwidth, NB ) && st->bws_cnt > 0 ) )
#endif
        {
            /* SWB TBE decoder */
            ivas_swb_tbe_dec_fx( st, hStereoICBWE, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], old_syn_12k8_16k_fx[n], tmp_buffer_fx /*fb_exc*/, hb_synth_32_fx[n], pitch_buf_fx[n], &Q_white_exc );
@@ -1098,7 +1118,7 @@ ivas_error ivas_core_dec_fx(
            }
        }
#ifdef FIX_1320_STACK_CPE_DECODER
        ELSE IF( st->extl == SWB_BWE || st->extl == FB_BWE || flag_bwe_bws )
        ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) || flag_bwe_bws )
#else
        ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) || ( GE_32( output_Fs, 32000 ) && st->core == ACELP_CORE && st->bwidth > NB && st->bws_cnt > 0 && !st->ppp_mode_dec && !( EQ_16( st->nelp_mode_dec, 1 ) && EQ_16( st->bfi, 1 ) ) ) )
#endif
@@ -1115,11 +1135,10 @@ ivas_error ivas_core_dec_fx(
        test();
        test();
        test();
        IF( ( st->core == ACELP_CORE && ( st->extl == -1 || st->extl == SWB_CNG ) ) && flag_bwe_bws == 0 )
        IF( ( st->core == ACELP_CORE && ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) ) ) && flag_bwe_bws == 0 )
        {
            set32_fx( hb_synth_32_fx[n], 0, L_FRAME48k );
        }

#endif

        /*---------------------------------------------------------------------*
+4 −0
Original line number Diff line number Diff line
@@ -981,7 +981,11 @@ static ivas_error stereo_dft_dec_main(

    IF( NE_16( shift, 31 ) )
    {
#ifdef FIX_1946_CRASH_JBM_PROCESSING
        shift = sub( add( hCPE->hStereoDft->q_dft, shift ), Q17 ); /* Q17 for guard bits */
#else
        shift = sub( add( hCPE->hStereoDft->q_dft, shift ), Q16 ); /* Q16 for guard bits */
#endif

        IF( GT_16( shift, hCPE->hStereoDft->q_dft ) )
        {
+9 −1
Original line number Diff line number Diff line
@@ -1268,7 +1268,11 @@ void ivas_mdct_core_reconstruct_fx(

            // norm(synth_buf) >= q_syn - q_win
            // norm(synth_buf) + q_win >= q_syn
#ifdef FIX_1320_STACK_CPE_DECODER
            sf = s_min( getScaleFactor16( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS_INTERNAL ), M ) ), getScaleFactor16( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ) ) );
#else
            sf = s_min( getScaleFactor16( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ) ), getScaleFactor16( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ) ) );
#endif
            q_syn = add( sub( sf, 1 ), s_min( q_win, q_winFB ) );
            st->Q_syn = q_syn;
            move16();
@@ -1278,7 +1282,11 @@ void ivas_mdct_core_reconstruct_fx(
            sf = s_min( getScaleFactor16( st->hHQ_core->old_out_fx, L_FRAME48k ), getScaleFactor16( st->hHQ_core->old_out_LB_fx, L_FRAME32k ) );
            st->Q_syn = add( sf, s_min( q_win, q_winFB ) );

#ifdef FIX_1320_STACK_CPE_DECODER
            Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS_INTERNAL ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn
#else
            Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn
#endif
            Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn
            // Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) );
            Scale_sig( st->syn, M + 1, sub( st->Q_syn, q_win ) );
Loading