Unverified Commit d0565f81 authored by norvell's avatar norvell
Browse files

erge branch 'main' into basop-2023-td-renderer-distance-attenuation-precision-problem

parents 5842d2c9 0470a382
Loading
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -91,9 +91,17 @@
#define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_SWB_fenv_fx2 /* FhG: Avoid overflow of SWB_fenv_fx in SWB_BWE_encoding_fx because of very small energies. */
#define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */
#define NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT_FIX_2527    /* Fix crash from issue #2527 */
#define NONBE_FIX_2507                                  /* Fix porting error in SQ_gain_estimate_fx() */
#define FIX_FLOAT_1539_G192_FORMAT_SWITCH               /* VA/Nokia: reintroduce format switching for g192 bitstreams */
#define HARMONIZE_2499_CONFIGUREFDCNGDEC                /* FhG: basop issue 2499: harmonoize configureFdCngDec */
#define FIX_BASOP_2530_IVAS_DECISION_MAT                /* VA: Fix ambiguous usage of extract_l() */
#define FIX_BASOP_2546_HARMONIZE_TCX_SCALAR             /* FhG: Fix issue 2546 Harmonize function tcx_scalar_quantization_rateloop*/
#define FIX_BASOP_2532_cx_e                             /* FhG: Fix issue 2532 about additional exponent variable*/
#define HARMONIZE_2543_SQ_gain                          /* FhG: Harmonize SQ_gain */
#define FIX_ISSUE_2533_EXTRA_CONDITION                  /* FhG: Fix issue basop 2533 removing the extra condition*/
#define HARMONIZE_2537_SetTCXModeInfo                 /* FhG: Harmonize SetTCXModeInfo  - IVAS_VERSION OBVIOUSLY NOT FITTING FOR EVS - pipes not green */
#define HARMONIZE_2537_GetTCXMaxenergyChange            /* FhG: Harmonize GetTCXMaxenergyChange */
#define HARMONIZE_2508_InitTransientDetection          /* FhG: harmonize GetAttackForTCXDecision derivates for evs/ivas  */

/* #################### End BE switches ################################## */

@@ -117,6 +125,8 @@
#define FIX_BASOP_2531_MCT_CP_BITRATE                   /* FhG: BASOP issue 2531: Fix MCT cp_bitrate calculation; affects bitrate switching only */
#define FIX_BASOP_2541_OMASA_ENC_FIXES                  /* Nokia: BASOP issue 2541: Fix function ivas_encode_masaism_metadata_fx */
#define FIX_BASOP_2545_FIX_LTV_REGRESSION_2529          /* Nokia: BASOP issue 2545: Fix LTV regression caused by issue 2529 fix */
#define FIX_FLOAT_1573_POSITION_UPDATE                  /* Eri: Float issue 1573: For static orientation and listener movement, the PoseUpdated flag is cleared and prevents 5 ms update rate. */
#define FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS         /* FhG: BASOP issue 2521: Fix wrong porting for determination of first subframe length in ivas_sba_dirac_stereo_compute_td_stefi_nrgs() */

/* ##################### End NON-BE switches ########################### */

+25 −1
Original line number Diff line number Diff line
@@ -1801,6 +1801,10 @@ void ivas_param_mc_dec_prepare_renderer(
            }
        }
        cx_e = max_e;
#ifdef FIX_BASOP_2532_cx_e
        cx_next_band_e = max_e;
        move16();
#endif
        move16();

        /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/
@@ -1815,7 +1819,11 @@ void ivas_param_mc_dec_prepare_renderer(
                Scale_sig32( cx_fx, len, -Q1 );           // add one bit head room
                Scale_sig32( cx_next_band_fx, len, -Q1 ); // add one bit head room
                cx_e = add( cx_e, Q1 );
#ifndef FIX_BASOP_2532_cx_e
                cx_next_band_e = add( cx_e, Q1 );
#else
                cx_next_band_e = add( cx_next_band_e, Q1 );
#endif // !FIX_BASOP_2532_cx_e
            }
            v_add_fx( cx_fx, cx_next_band_fx, cx_fx, len );
            Copy32( cx_fx, cx_next_band_fx, len );
@@ -1828,13 +1836,17 @@ void ivas_param_mc_dec_prepare_renderer(
            {
                CONTINUE;
            }

#ifndef FIX_ISSUE_2533_EXTRA_CONDITION
            IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) )
            {
                IF( is_next_band )
                {

#ifndef FIX_BASOP_2532_cx_e
                    ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_next_band_fx, cx_next_band_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov );
#else
                    ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_next_band_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov );
#endif
                }
                ELSE
                {
@@ -1842,6 +1854,18 @@ void ivas_param_mc_dec_prepare_renderer(
                    ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov );
                }
            }
#else
            IF( is_next_band )
            {

                ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_next_band_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov );
            }
            ELSE
            {

                ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov );
            }
#endif
        }
    }

+60 −0
Original line number Diff line number Diff line
@@ -688,15 +688,60 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs(
    const Word16 q_hb_synth )
{
    Word16 i;
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    Word32 hb_nrg = EPSILON_FIX;
    Word16 q_hb_nrg_subr = Q31 + Q15 - Q6; /* in case IF( ( EQ_16( core, ACELP_CORE ) && !fd_cng_flag ) || EQ_16( hStereoDft->core_hist[1], ACELP_CORE ) ) is false, we want to end up with Q31, and we subtract Q15 - Q6 below; otherwise, we set it within this condition */
    Word16 q_hb_nrg = Q31;
    Word16 shift, shift_hb_nrg_subr;
    move32();
#else
    Word32 hb_nrg = EPSILON_FIX;
    move32();
    Word32 hb_nrg2 = EPSILON_FIX;
    move32();
#endif

#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    shift = L_norm_arr( hb_synth, output_frame );
    shift = sub( shift, shr( add( find_guarded_bits_fx( shr( output_frame, 1 ) ), 1 ), 1 ) );
#endif

    test();
    test();
    IF( ( EQ_16( core, ACELP_CORE ) && !fd_cng_flag ) || EQ_16( hStereoDft->core_hist[1], ACELP_CORE ) )
    {
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
        Word32 L_tmp;
        Word64 W_tmp;

        W_tmp = EPSILON_FIX;
        move64();

        FOR( i = 0; i < shr( output_frame, 1 ); i++ )
        {
            L_tmp = L_shl( hb_synth[i], shift );        /* q_hb_synth + shift */
            W_tmp = W_mac_32_32( W_tmp, L_tmp, L_tmp ); /* 2 * (q_hb_synth + shift) + 1 */
        }

        hStereoDft->hb_nrg_subr_fx[0] = W_round48_L( W_shr( W_tmp, 16 ) ); /* 2 * (q_hb_synth + shift) - 31 */
        move32();

        W_tmp = EPSILON_FIX;
        move64();
        FOR( ; i < output_frame; i++ )
        {
            L_tmp = L_shl( hb_synth[i], shift );        /* q_hb_synth + shift */
            W_tmp = W_mac_32_32( W_tmp, L_tmp, L_tmp ); /* 2 * (q_hb_synth + shift) + 1 */
        }

        hStereoDft->hb_nrg_subr_fx[1] = W_round48_L( W_shr( W_tmp, 16 ) ); /* 2 * (q_hb_synth + shift) - 31 */
        move32();
        q_hb_nrg_subr = sub( shl( add( q_hb_synth, shift ), 1 ), 31 );

        hb_nrg = L_add( L_shr( hStereoDft->hb_nrg_subr_fx[0], 1 ), L_shr( hStereoDft->hb_nrg_subr_fx[1], 1 ) ); /* 2 * (q_hb_synth + shift) - 16 - 1 */
        q_hb_nrg = sub( q_hb_nrg_subr, 1 );
        move16();
#else
        FOR( i = 0; i < shr( output_frame, 2 ); i++ )
        {
            hb_nrg2 = Madd_32_32( hb_nrg2, hb_synth[i], hb_synth[i] ); /*2*q_hb_synth-31*/
@@ -719,6 +764,7 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs(
        hStereoDft->hb_nrg_subr_fx[1] = hb_nrg2; /*2*q_hb_synth-31*/
        move32();
        hb_nrg = L_add( hb_nrg, hb_nrg2 );
#endif

        IF( EQ_16( hStereoDft->q_hb_stefi_sig_fx, q_hb_synth ) )
        {
@@ -747,12 +793,26 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs(
        hStereoDft->hb_nrg_subr_fx[1] = 0;
        move32();
    }
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    shift_hb_nrg_subr = s_min( norm_l( hStereoDft->hb_nrg_subr_fx[0] ), norm_l( hStereoDft->hb_nrg_subr_fx[1] ) );

    hStereoDft->hb_nrg_subr_fx[0] = ( Mpy_32_16_1( L_shl( hStereoDft->hb_nrg_subr_fx[0], shift_hb_nrg_subr ), shl( hStereoDft->NFFT, 5 ) ) ); /* shl( ., 5) is shortcut for shl( shr( hStereoDft->NFFT, 1 ), 6 ) */ /* q_hb_nrg_subr - (15 - 6) */
    move32();
    hStereoDft->hb_nrg_subr_fx[1] = ( Mpy_32_16_1( L_shl( hStereoDft->hb_nrg_subr_fx[1], shift_hb_nrg_subr ), shl( hStereoDft->NFFT, 5 ) ) ); /* shl( ., 5) is shortcut for shl( shr( hStereoDft->NFFT, 1 ), 6 ) */ /* q_hb_nrg_subr - (15 - 6) */
    move32();
    hStereoDft->q_hb_nrg_subr = sub( add( q_hb_nrg_subr, shift_hb_nrg_subr ), Q15 - Q6 );
    hStereoDft->hb_nrg_fx[0] = hb_nrg;
    move32();
    hStereoDft->q_hb_nrg[0] = q_hb_nrg;
    move16();
#else
    hStereoDft->hb_nrg_subr_fx[0] = hStereoDft->hb_nrg_subr_fx[0]; // imult3216(hStereoDft->hb_nrg_subr_fx[0] , shr(hStereoDft->NFFT, 1)); /*hStereoDft->q_hb_nrg_subr*/
    move32();
    hStereoDft->hb_nrg_subr_fx[1] = hStereoDft->hb_nrg_subr_fx[1]; // imult3216(hStereoDft->hb_nrg_subr_fx[1] , shr(hStereoDft->NFFT, 1)); /*hStereoDft->q_hb_nrg_subr*/
    move32();
    hStereoDft->hb_nrg_fx[0] = hb_nrg;
    move32();
#endif
    hStereoDft->td_gain_fx[0] = 0;
    move32();
    hStereoDft->core_hist[0] = core; /* full signal available for DTX with FD-CNG, thus apply stereo filling on full spectrum like in TCX */
+5 −0
Original line number Diff line number Diff line
@@ -199,6 +199,9 @@ typedef struct stereo_dft_dec_data_struct
    Word32 hb_nrg_fx[STEREO_DFT_CORE_HIST_MAX];                                        /* Q(q_hb_nrg) */
    Word32 hb_nrg_subr_fx[STEREO_DFT_NBDIV];                                           /* Q(q_hb_nrg_subr) */

#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    Word16 q_hb_nrg[STEREO_DFT_CORE_HIST_MAX];
#endif
    Word16 Q_nrg_subr;
    Word16 prev_Q_stefi_sig;
    Word16 q_td_gain[STEREO_DFT_CORE_HIST_MAX];
@@ -224,7 +227,9 @@ typedef struct stereo_dft_dec_data_struct
    Word32 smooth_buf_fx[SBA_DIRAC_STEREO_NUM_BANDS][SBA_DIRAC_NRG_SMOOTH_LONG + 1]; /* Q(q_smooth_buf_fx) */
    Word16 smooth_fac_fx[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS];                        /* Q15 */
    Word16 q_smooth_buf_fx;
#ifndef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    Word16 q_hb_nrg;
#endif
    Word16 q_hb_nrg_subr;
    Word16 q_res_mem;

+83 −2
Original line number Diff line number Diff line
@@ -194,6 +194,9 @@ void stereo_dft_dec_reset_fx(

    set32_fx( hStereoDft->hb_stefi_sig_fx, 0, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) );
    set32_fx( hStereoDft->hb_nrg_fx, 0, STEREO_DFT_CORE_HIST_MAX );
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    set16_fx( hStereoDft->q_hb_nrg, Q31, STEREO_DFT_CORE_HIST_MAX );
#endif
    set32_fx( hStereoDft->td_gain_fx, 0, STEREO_DFT_CORE_HIST_MAX );
    set16_fx( hStereoDft->q_td_gain, 0, STEREO_DFT_CORE_HIST_MAX );
    hStereoDft->q_dft = 0;
@@ -659,7 +662,12 @@ void stereo_dft_dec_update_fx(
    }

    Copy32( hStereoDft->hb_stefi_sig_fx + output_frame, hStereoDft->hb_stefi_sig_fx, hStereoDft->hb_stefi_delay ); /* Qx */
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    Copy32( hStereoDft->hb_nrg_fx, hStereoDft->hb_nrg_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); /* q_hb_nrg */
    Copy( hStereoDft->q_hb_nrg, hStereoDft->q_hb_nrg + 1, STEREO_DFT_CORE_HIST_MAX - 1 );
#else
    Copy32( hStereoDft->hb_nrg_fx, hStereoDft->hb_nrg_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); /* Qx */
#endif
    Copy32( hStereoDft->td_gain_fx, hStereoDft->td_gain_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); /* q_td_gain */
    Copy( hStereoDft->q_td_gain, hStereoDft->q_td_gain + 1, STEREO_DFT_CORE_HIST_MAX - 1 );

@@ -2778,6 +2786,16 @@ static void stereo_dft_compute_td_stefi_params_fx(
    move32();
    nrg_pred_DMX = hStereoDft->hb_nrg_fx[1];
    move32();
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
    IF( GT_16( hStereoDft->q_hb_nrg[0], hStereoDft->q_hb_nrg[1] ) )
    {
        nrg_DMX = L_shr( nrg_DMX, sub( hStereoDft->q_hb_nrg[0], hStereoDft->q_hb_nrg[1] ) );
    }
    ELSE
    {
        nrg_pred_DMX = L_shr( nrg_pred_DMX, sub( hStereoDft->q_hb_nrg[1], hStereoDft->q_hb_nrg[0] ) );
    }
#endif

    op1 = BASOP_Util_Divide3232_Scale( L_add( EPSILON_FIX, nrg_DMX ), L_add( EPSILON_FIX, nrg_pred_DMX ), &q_div ); /* q_div */
    q_sqrt = add( Q16, q_div );
@@ -3223,6 +3241,11 @@ void stereo_dft_generate_res_pred_fx(
        }
        ELSE IF( hStereoDft->core_hist[STEREO_DFT_STEFFI_DELAY_SHORT / 2] == ACELP_CORE )
        {
#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
            Word16 q_dmx_nrg, q_diff;
            Word16 norm_dmx_nrg;
            Word32 L_temp;
#endif
            /* ACELP -> TCX/HQ core transition */
            /* calculate high band energy only */
            dmx_nrg = EPSILON_FIX;
@@ -3232,8 +3255,66 @@ void stereo_dft_generate_res_pred_fx(
                dmx_nrg = L_add( dmx_nrg, Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) ); /* 2 * q_dft - 31 */
            }

#ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS
            norm_dmx_nrg = norm_l( dmx_nrg );
            dmx_nrg = L_shl( dmx_nrg, norm_dmx_nrg );
            q_dmx_nrg = add( sub( shl( hStereoDft->q_dft, 1 ), 31 ), norm_dmx_nrg );

            /* dmx_nrg * 2 / hStereoDft->NFFT */
            SWITCH( hStereoDft->NFFT )
            {
                case 960:
                    L_temp = Mpy_32_16_1( dmx_nrg, 17476 /* 1 / 480 in Q8 */ );
                    L_temp = L_shr( L_temp, Q1 ); /* reserve 1 bit headroom */
                    q_dmx_nrg = add( q_dmx_nrg, Q7 );
                    BREAK;
                case 640:
                    L_temp = Mpy_32_16_1( dmx_nrg, 26214 /* 1 / 320 in Q8 */ );
                    L_temp = L_shr( L_temp, Q1 ); /* reserve 1 bit headroom */
                    q_dmx_nrg = add( q_dmx_nrg, Q7 );
                    BREAK;
                case 320:
                    L_temp = Mpy_32_16_1( dmx_nrg, 26214 /* 1 / 320 in Q7 */ );
                    L_temp = L_shr( L_temp, Q1 ); /* reserve 1 bit headroom */
                    q_dmx_nrg = add( q_dmx_nrg, Q6 );
                    BREAK;
                default:
                    L_temp = 0; /* avoid compiler warnings about uninitialized variable */
                    move32();
                    assert( 0 && "Invalid hStereoDft->NFFT" );
                    /* we support only hStereoDft->NFFT == 320, 640 and 960; a more generic expression would be: */
                    /* L_temp = BASOP_Util_Divide3232_Scale_newton( dmx_nrg, shr( hStereoDft->NFFT, 1 ), &temp_e ); */
                    /* q_dmx_nrg = add( q_dmx_nrg, sub( 31, temp_e ) ); */
                    BREAK;
            }

            /* for L_temp we have at least one bit of headroom due to the division above; check also for hStereoDft->hb_nrg_fx[0] and possibly reserve one bit*/
            test();
            IF( norm_l( hStereoDft->hb_nrg_fx[0] ) == 0 && hStereoDft->hb_nrg_fx[0] != 0 )
            {
                hStereoDft->hb_nrg_fx[0] = L_shr( hStereoDft->hb_nrg_fx[0], 1 );
                hStereoDft->q_hb_nrg[0] = sub( hStereoDft->q_hb_nrg[0], 1 );
            }

            q_diff = sub( hStereoDft->q_hb_nrg[0], q_dmx_nrg );

            IF( GT_16( q_diff, 0 ) )
            {
                hStereoDft->hb_nrg_fx[0] = L_add( L_shr( hStereoDft->hb_nrg_fx[0], q_diff ), L_temp );
                move32();
                hStereoDft->q_hb_nrg[0] = sub( hStereoDft->q_hb_nrg[0], q_diff );
                move16();
            }
            ELSE
            {
                hStereoDft->hb_nrg_fx[0] = L_add( hStereoDft->hb_nrg_fx[0], L_shl( L_temp, q_diff ) );
                move32();
                /* hStereoDft->q_hb_nrg[0] stays as is */
            }
#else
            hStereoDft->hb_nrg_fx[0] = L_add( hStereoDft->hb_nrg_fx[0], div_l( dmx_nrg, shr( hStereoDft->NFFT, 2 ) ) ); /* Q15 */
            move32();
#endif
            *stop = bin0;
            move16();
        }
Loading