Commit 50fabd3d authored by Arthur Tritthart's avatar Arthur Tritthart
Browse files

changed format of spar cldfb weights from Q22 to Q31, fixing overflow issue for weights[55+][11]

parent 487ba7ca
Loading
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1098,8 +1098,16 @@ static Word16 ivas_calculate_abs_fr_fx(

            Word16 exp_diff = 0;
            move16();
#ifndef FIX_1101_IVAS_SPAR_DEC_SATURATE_WEIGHTS_IN_Q31
            Word16 tmp = BASOP_Util_Divide3232_Scale( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i], sum_over_spar_bands_fx, &exp_diff );
            pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22
            pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] = L_min(0x003FFFFF, L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ) ); // Q22
#else
            /* Note: 16-bit division result has bad accuracy for num=denom */
            Word32 L_tmp = BASOP_Util_Divide3232_Scale_cadence( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i], sum_over_spar_bands_fx, &exp_diff ); // Q31
            if (exp_diff != 0)
               L_tmp = L_shl_sat(L_tmp, exp_diff); /* convert to Q31 with saturation */
            pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] = L_tmp;  // Q31
#endif
            move32();
        }
        pFb->fb_bin_to_band.p_spar_start_bands[j] = spar_start;
+2 −1
Original line number Diff line number Diff line
@@ -120,7 +120,8 @@
/* Note: each compile switch (FIX_1101_...) is independent from the other ones */
#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_MADD_ADD_WEIGHTS  /* FhG: Defines 1.0f-weight variables, uses Madd operation instead of L_add_sat */
#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SPLIT_LOOPS           /* FhG: Splits single loop with IF-statements into two low-complex loops */
#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SATURATE_WEIGHTS      /* FhG: BUGFIX: Saturate weight parameters during reformatting, fixes overflow in extract_l */
#define FIX_1101_IVAS_SPAR_DEC_SATURATE_WEIGHTS_IN_Q31          /* FhG: BUGFIX2: +ivas_fb_mixer.c: Saturate weight parameters during reformatting in Q31, BUGFIX1 is obsolete */
#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SATURATE_WEIGHTS      /* FhG: BUGFIX1: Saturate weight parameters during reformatting in Q22, fixes overflow in extract_l */
#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_HQ_CONSTANTS          /* FhG: IMPROVE PRECISION: Uses 1/6 and 1/20 in full-precise Q31 constants instead of Q15 */
#define FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_USE_UNIQUE_SHL        /* FhG: Uses unique shift amount in each loop iteration */
#define FIX_11_1_IVAS_SPAR_DEC_UPMIXER_SF_RND_COEFFS            /* FhG  ivas_spar_com.c: Zeroes very small negative coeffs via L_shr_r (was L_shr) */
+8 −0
Original line number Diff line number Diff line
@@ -1925,6 +1925,7 @@ void ivas_spar_dec_upmixer_sf_fx(
                            FOR( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ )
                            {
                                /* accumulate contributions from all SPAR bands */
#ifndef FIX_1101_IVAS_SPAR_DEC_SATURATE_WEIGHTS_IN_Q31
#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SATURATE_WEIGHTS
                                Word16 tmp = extract_l( L_shr( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 7 ) ); /*Q15*/
                                cldfb_par_fx = L_add_sat( cldfb_par_fx, Mpy_32_16_1( mixer_mat_fx[out_ch][in_ch][spar_band], tmp ) );     /*q1*/
@@ -1932,6 +1933,9 @@ void ivas_spar_dec_upmixer_sf_fx(
                                Word32 tmp = L_shl_sat( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 9 );    /*Q22 -> Q31(sat)*/
                                cldfb_par_fx = L_add_sat( cldfb_par_fx, Mpy_32_32( mixer_mat_fx[out_ch][in_ch][spar_band], tmp ) ); /*q1*/
#endif
#else
                                cldfb_par_fx = L_add_sat( cldfb_par_fx, Mpy_32_32(mixer_mat_fx[out_ch][in_ch][spar_band], bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band] ) ); /*q1*/
#endif /* FIX_1101_IVAS_SPAR_DEC_SATURATE_WEIGHTS_IN_Q31 */
                            }
                        }

@@ -2025,6 +2029,7 @@ void ivas_spar_dec_upmixer_sf_fx(
                        FOR( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ )
                        {
                            /* accumulate contributions from all SPAR bands */
#ifndef FIX_1101_IVAS_SPAR_DEC_SATURATE_WEIGHTS_IN_Q31
#ifndef FIX_1101_IVAS_SPAR_DEC_UPMIXER_SF_SATURATE_WEIGHTS
                            Word16 tmp = extract_l( L_shr( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 7 ) ); /*Q15*/
                            cldfb_par_fx = L_add_sat( cldfb_par_fx, Mpy_32_16_1( mixer_mat_fx[out_ch][in_ch][spar_band], tmp ) );     /*q1*/
@@ -2032,6 +2037,9 @@ void ivas_spar_dec_upmixer_sf_fx(
                            Word32 tmp = L_shl_sat( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 9 );    /*Q22 -> Q31(sat)*/
                            cldfb_par_fx = L_add_sat( cldfb_par_fx, Mpy_32_32( mixer_mat_fx[out_ch][in_ch][spar_band], tmp ) ); /*q1*/
#endif
#else
                            cldfb_par_fx = L_add_sat( cldfb_par_fx, Mpy_32_32(mixer_mat_fx[out_ch][in_ch][spar_band], bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band] ) ); /*q1*/
#endif /* FIX_1101_IVAS_SPAR_DEC_SATURATE_WEIGHTS_IN_Q31 */
                        }
                        Out_re_fx = Madd_32_32( Out_re_fx, cldfb_in_ts_re_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); /*q1-25*/
                        Out_im_fx = Madd_32_32( Out_im_fx, cldfb_in_ts_im_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); /*q1-25*/