Commit 8e7d8af3 authored by vaclav's avatar vaclav
Browse files

accept switches

parent 39895d36
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -286,7 +286,6 @@ void hp20( Word16 signal[], /* i/o: signal to filter any *
}


#ifdef HP20_FIX32_RECODING
void hp20_fx_32_opt(
    Word32 signal_fx[],
    const Word16 lg,
@@ -448,7 +447,8 @@ void hp20_fx_32_opt(

    return;
}
#endif


void hp20_fx_32(
    Word32 signal_fx[],
    const Word16 lg,
+0 −25
Original line number Diff line number Diff line
@@ -73,33 +73,8 @@

/* ################### Start FIXES switches ########################### */

#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_1985_SBA_714_HF_LOSS                             /* Dlb: Fix for issue 1985, improved dirac ref pow precision*/
#define FIX_1819_EIGENVALUE_ERROR                            /* FhG: Workaround for zero eigenvalue: replace with epsilon if det != 0*/
#define FIX_1990_SANITIZER_IN_REVERB_LOAD                    /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure. */
#define FIX_1995_REVERB_INIT                                 /* VA/Nokia: issue 1995: Fix use-of-uninitialized-value in ivas_binaural_reverb_init() */
#define FIX_1996_MASKING_NOISE                               /* Dlb: Heavy precision loss in ola buffers causing discontinuity*/
#define FIX1998_APA_EXEC_SCALING                             /* FhG: fix scaling of apa_exec_ivas_fx(); avoid continuously worse scaling with previous data */
#define FIX2007_BASSPSFILTER_OVERFLOW                        /* FhG: use saturing operator, to avoid overflow in bass_psfilter_fx() */
#define FIX_ISSUE_2004_LPC_SHB_SAT                           /* Dolby: Issue 2004: prevent saturation of the LPC SHB filter */

#define FIX_2009_HIGH_NOISE_FLOOR_FOR_FX_DEC                 /* FhG: Corrected the q_input in the input of generate_masking_noise_dirac_ivas_fx() */
#define FIX_ISSUE_2013_MDCT_STEREO_DTX_DISCONTINUITIES       /* Eri/FhG: Issue 2013 fix for dtx discontinuities */
#define FIX_ISSUE_2013_MDCT_STEREO_FER_DISCONTINUITIES       /* Eri/FhG: Issue 2013 fix for FER discontinuities */
#define FIX_2000_NON_LINEARITY_OVERSHOOT                     /* Eri: Issue 2000: SWB TBE energy overshoot in non-linearity. Aligns with float */
#define FIX_2010_PREP_TBE_EXC                                /* FhG: fix issues with varying Q-values for code_preQ_fx[] */
#define FIX_2025_FDCNG_MULT                                  /* Nokia, FhG: Fix LB FDCNG noise introduced by changing mult to i_mult */

#define FIX_1962_FORMAT_CONV_SPECTRAL_DIFF                   /* FhG: Improved precision of targetEnergy in ivas_ls_setup_conversion_process_mdct_fx() */
#define FIX_2003_CON_TCX_OVERFLOW                            /* FhG: Use a dynamic scaling factor for the synth buffer at the output of con_tcx_ivas_fx() */
#define HP20_FIX32_RECODING                                  /* FhG: optimized hp20_fx_32 calculation and applied it as hp20_fx_32_opt in decoder */
#define OPT_TCXLTP_FILTER_LOOP                               /* FhG: optimize loop in tcx_ltp_synth_filter */
#define FIX_2049_DIFF_IN_DECORR_TAIL                         /* FhG: correct scale values in ivas_dirac_dec_binaural_process_output_fx() */
#define FIX_2602_NONBE_SAT_IN_SWB_TBE_SCALE                  /* Dolby/FhG: fix for issue 2026: Saturation in SWB TBE re-scaling function preventing StereoDownmix complexity job to complete */
#define FIX_2021_BANDWIDTH_EXTENSION_PROBLEM                 /* FhG: increase cldfb buffer precision*/

#define FIX_2083_FLOATING_POINT_LEFTOVERS                    /* FhG: convert floating-point leftovers in makeCustomLsSetup()*/
#define FIX_2085_FLOATING_POINT_LEFTOVERS                    /* FhG: convert floating-point leftovers in ivas_dirac_config_fx() */
+10 −14
Original line number Diff line number Diff line
@@ -3308,9 +3308,7 @@ void prep_tbe_exc_fx(
    Word16 bwe_exc_fx[],         /* i/o: excitation for TBE                Q_exc*/
    const Word16 gain_preQ_fx,   /* i  : prequantizer excitation gain           */
    const Word16 code_preQ_fx[], /* i  : prequantizer excitation                */
#ifdef FIX_2010_PREP_TBE_EXC
    const Word16 Q_code_preQ,    /* i  : Q, prequantizer excitation             */
#endif
    const Word16 Q_exc,          /* i  : Excitation,           bwe_exc Q-factor */
    const Word16 T0,             /* i  : integer pitch variables             Q0 */
    const Word16 T0_frac,        /* i  : Fractional pitch variables           Q0*/
@@ -10488,13 +10486,11 @@ void hp20_fx_32(
    Word32 mem_fx[],
    const Word32 Fs );
#ifdef HP20_FIX32_RECODING
void hp20_fx_32_opt(
    Word32 signal_fx[],
    const Word16 lg,
    Word32 mem_fx[],
    const Word32 Fs );
#endif
void getTCXMode_ivas_fx(
    Decoder_State *st,    /* i/o: decoder memory state                */
+12 −47
Original line number Diff line number Diff line
@@ -5965,21 +5965,10 @@ void non_linearity_ivas_fx(
    }

#ifdef NONBE_1328_FIX_NON_LINEARITY
#ifdef FIX_2000_NON_LINEARITY_OVERSHOOT
    sc_factor = s_max( sub( 13, norm_s( add( j, 1 ) ) ), 0 ); /* Adapt the scaling factor allowed depending of max position  */
    sc_factor = s_max( sc_factor, 1 );                        /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */
#else
    /* sc_factor = 32; */                                                      /* Here we divide prev_scale, so 32 == 2 << (15-10)  1024.0 corresponds to 10 bits and 32 to 5 bits  */
    /* if ( element_mode > EVS_MONO ) */                                       /* element mode is not needed because the function is duplicated for IVAS */
    sc_factor = shl_sat( 1, sub( 16, max( 13 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position  */
    sc_factor = s_max( s_min( sc_factor, 16384 ), 2 * 32 );                    /* note: The thresholding is purposely different between float and BASOP implementations. */
#endif
    test();
#ifdef FIX_2000_NON_LINEARITY_OVERSHOOT
    IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */
#else
    IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) )
#endif
#else
    test();
    IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 64 ) /*Q30 -> Q31*/, scale /*Q31*/ ) )
@@ -6057,23 +6046,12 @@ void non_linearity_ivas_fx(
    }

#ifdef NONBE_1328_FIX_NON_LINEARITY
#ifdef FIX_2000_NON_LINEARITY_OVERSHOOT
    /* if ( element_mode > EVS_MONO ) */                                          /* element mode is not needed because the function is duplicated for IVAS */
    sc_factor = s_max( sub( 12, norm_s( add( sub( j, length_half ), 1 ) ) ), 0 ); /* allowed intra frame jump is smaller */
    sc_factor = s_max( sc_factor, 1 );                                            /* Note: The sc_factor is the log2 of the sc_factor in the float code to simplify condition below */
#else
    /* sc_factor = 32; */                                                      /* Here we divide prev_scale, so 32 == 2 << (15-10)  1024.0 corresponds to 10 bits and 32 to 5 bits  */
    /* if ( element_mode > EVS_MONO ) */                                       /* element mode is not needed because the function is duplicated for IVAS */
    sc_factor = shl_sat( 1, sub( 16, max( 12 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position  */
    sc_factor = s_max( s_min( sc_factor, 16384 ), 2 * 32 );                    /* note: The thresholding is purposely different between float and BASOP implementations. */
#endif

    test();
#ifdef FIX_2000_NON_LINEARITY_OVERSHOOT
    IF( prev_scale <= 0 || GT_32( L_shr( prev_scale, sub( sc_factor, 1 ) /*Q30 -> Q31*/ ), scale /*Q31*/ ) ) /* Since the sc_factor is the log2 of sc_factor in float, we apply it using L_shr */
#else
    IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) )
#endif
#else
    IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 64 ), scale ) )
#endif
@@ -7008,9 +6986,7 @@ void prep_tbe_exc_fx(
    Word16 bwe_exc_fx[],         /* i/o: excitation for TBE                Q_exc*/
    const Word16 gain_preQ_fx,   /* i  : prequantizer excitation gain           */
    const Word16 code_preQ_fx[], /* i  : prequantizer excitation                */
#ifdef FIX_2010_PREP_TBE_EXC
    const Word16 Q_code_preQ,    /* i  : Q, prequantizer excitation             */
#endif
    const Word16 Q_exc,          /* i  : Excitation,           bwe_exc Q-factor */
    const Word16 T0,             /* i  : integer pitch variables             Q0 */
    const Word16 T0_frac,        /* i  : Fractional pitch variables           Q0*/
@@ -7092,20 +7068,13 @@ void prep_tbe_exc_fx(
    ELSE
    {
        Word16 shift = 4;
#ifdef FIX_2010_PREP_TBE_EXC
        /* multrus 2025-09-15
           TODO:
           - leave shift = 4, since this is legacy code from EVS;
           - check with vaillancourt, whether we really have a different scaling of code_preQ_fx[] for IVAS
           - if the different scalings are confirmed, this condition could be simplified
        */
        IF( NE_16( element_mode, EVS_MONO ) )
        {
            /* shift of 4 assumes code_preQ_fx[] in Q10 - this is however not always given */
            shift = add( 2 + 1 - 1, Q_code_preQ ); /* gain_preQ_fx in Q2, code_preQ_fx[] in Q_code_preQ, 1 additional left-shift by L_mult() - factor of 2 (from "2 * gain_preQ * code_preQ[i]") */
            shift = sub( 16, shift );
        }
#endif

        move16();
        IF( gain_preQ_fx != 0 )
        {
@@ -7113,11 +7082,7 @@ void prep_tbe_exc_fx(
            {
                /*code in the encoder is Q9 and there is no <<1 with Mult_32_16 Q16 * Q9 -> Q9 */
                Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] );  /* Q16 + Q9 + 1 - 16 = Q10 */
#ifdef FIX_2010_PREP_TBE_EXC
                Ltemp2 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q_code_preQ */
#else
                Ltemp2 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /*Q2 * Q10 -> Q12  */
#endif

                Ltemp1 = L_shl_sat( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/ );                   /*Q_exc+16 */
                Ltemp2 = L_shl_sat( Ltemp2, add( Q_exc, shift ) /*Q_exc+ 2 + 6 (or) 10 - 13*/ ); /*Q_exc+16 */
+8 −90
Original line number Diff line number Diff line
@@ -484,7 +484,6 @@ static void tcx_ltp_synth_filter(
                step = negate( step );
        }

#ifdef OPT_TCXLTP_FILTER_LOOP
        IF( zir != NULL )
        {
            IF( fade != 0 )
@@ -632,57 +631,16 @@ static void tcx_ltp_synth_filter(
                }
            }
        }
#else
        FOR( j = 0; j < length; j++ )
        {
            s = L_deposit_l( 0 );
            s2 = L_deposit_l( 0 );
            k = 0;
            move16();
            FOR( i = 0; i < L; i++ )
            {
                s = L_mac_sat( L_mac_sat( s, w0[k], x0[i] ), w1[k], x1[-i] );   /* Qx */
                s2 = L_mac_sat( L_mac_sat( s2, v0[k], y0[i] ), v1[k], y1[-i] ); /* Qx */
                k = k + pitch_res;
            }

            /* s2 *= ALPHA;
               normal:      synth_ltp[j] = synth[j] - gain * s2 + gain * s;
               zir:         synth_ltp[j] = synth[j] - gain * s2 + gain * s - zir[j];
               fade-in/out: synth_ltp[j] = synth[j] - alpha * gain * s2 + alpha * gain * s; */
            i = sub_sat( round_fx_sat( s ), mult_r_sat( round_fx_sat( s2 ), ALPHA ) ); /* Qx */
            k = mult_r( gain, i );                                                     /* Qx */
            if ( fade != 0 )
                k = mult_r( k, alpha ); /* Qx */
            k = add_sat( synth[j], k ); /* Qx */
            if ( zir != NULL )
            {
                k = sub_sat( k, zir[j] ); /* Qx */
            }

            synth_ltp[j] = k; /* Qx */
            move16();

            BASOP_SATURATE_WARNING_OFF_EVS;
            if ( fade != 0 )
            {
                alpha = add_sat( alpha, step );
            }
            BASOP_SATURATE_WARNING_ON_EVS;

            x0++;
            x1++;
            y0++;
            y1++;
        }
#endif
    }
    ELSE
    {
        Copy( synth, synth_ltp, length ); /* Qx */
    }

    return;
}


static void tcx_ltp_synth_filter32(
    Word32 *synth_ltp, /* Qx */
    Word32 *synth,     /* Qx */
@@ -744,10 +702,11 @@ static void tcx_ltp_synth_filter32(
            }

            if ( fade < 0 )
            {
                step = negate( step );
            }
        }

#ifdef OPT_TCXLTP_FILTER_LOOP
        IF( fade != 0 )
        {
            IF( zir != NULL )
@@ -894,57 +853,16 @@ static void tcx_ltp_synth_filter32(
                }
            }
        }
#else
        FOR( j = 0; j < length; j++ )
        {
            s = L_deposit_l( 0 );
            s2 = L_deposit_l( 0 );
            k = 0;
            move16();
            FOR( i = 0; i < L; i++ )
            {
                s = Madd_32_16_r( Madd_32_16_r( s, x0[i], w0[k] ), x1[-i], w1[k] );   /* Qx */
                s2 = Madd_32_16_r( Madd_32_16_r( s2, y0[i], v0[k] ), y1[-i], v1[k] ); /* Qx */
                k = k + pitch_res;
            }

            /* s2 *= ALPHA;
               normal:      synth_ltp[j] = synth[j] - gain * s2 + gain * s;
               zir:         synth_ltp[j] = synth[j] - gain * s2 + gain * s - zir[j];
               fade-in/out: synth_ltp[j] = synth[j] - alpha * gain * s2 + alpha * gain * s; */
            L_tmp = L_sub_sat( s, Mpy_32_16_r( s2, ALPHA ) ); /* Qx */
            L_tmp2 = Mpy_32_16_r( L_tmp, gain );              /* Qx */
            IF( fade != 0 )
            L_tmp2 = Mpy_32_16_r( L_tmp2, alpha );  /* Qx */
            L_tmp2 = L_add_sat( synth[j], L_tmp2 ); /* Qx */
            if ( zir != NULL )
            {
                L_tmp2 = L_sub_sat( L_tmp2, zir[j] ); /* Qx */
            }

            synth_ltp[j] = L_tmp2; /* Qx */
            move16();

            BASOP_SATURATE_WARNING_OFF_EVS;
            if ( fade != 0 )
            {
                alpha = add_sat( alpha, step );
            }
            BASOP_SATURATE_WARNING_ON_EVS;

            x0++;
            x1++;
            y0++;
            y1++;
        }
#endif
    }
    ELSE
    {
        Copy32( synth, synth_ltp, length ); /* Qx */
    }

    return;
}


static void tcx_ltp_synth_filter_10(
    Word16 *out,            /* Qx */
    Word16 *in,             /* Qx */
Loading