Commit 6b75151f authored by vaclav's avatar vaclav
Browse files

Merge branch '2081-regression-assert-in-basop-encoder-with-masa-ltv-rate-switching' into 'main'

Resolve "[regression] Assert in BASOP encoder with MASA LTV rate switching" [non-BE]

Closes #2081

See merge request !2372
parents 8dd65e04 8a313d51
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@
#define FIX_1990_SANITIZER_IN_REVERB_LOAD                    /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */
#define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK            /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/
#define OPT_IGF_GET_WHITE_SPEC_DATA                          /* FhG: optimized version of IGF_getWhiteSpectralData_ivas() */
#define FIX_2081_REVISE_H1_SCALING                           /* VA: accommodate for H1 overshoot that was causing assert in set_impule. Not BE with MASA on LTV with bitrate switching for only 2 instances */


/* #################### Start BASOP porting switches ############################ */
+30 −3
Original line number Diff line number Diff line
@@ -244,6 +244,7 @@ Word16 encod_tran_fx(
        L_tmp = L_msu( L_tmp, y1[L_SUBFR - 1], gain_pit );
        L_tmp = L_shl_sat( L_tmp, sub( 1, shift ) ); /* Q_new + 15 */
        hLPDmem->mem_w0 = round_fx_sat( L_tmp );     /*Q_new-1*/

        /*-----------------------------------------------------------------*
         * Construct adaptive part of the excitation
         * Save the non-enhanced excitation for FEC_exc
@@ -434,7 +435,11 @@ Word16 encod_tran_ivas_fx(
    Word16 tc_subfr,          /* i/o: TC subframe classification                        Q0*/
    Word16 position,          /* i  : maximum of residual signal index                  Q0*/
    Word16 *unbits,           /* i/o: number of unused bits                             Q0*/
#ifdef FIX_2081_REVISE_H1_SCALING
    const Word16 shift_r, /* i  : Scaling to get 12 bits                            */
#else
    const Word16 shift, /* i  : Scaling to get 12 bits                            */
#endif
    const Word16 Q_new /* i  : Input scaling                                     */
)
{
@@ -468,10 +473,18 @@ Word16 encod_tran_ivas_fx(
    Word16 shift_wsp;
    Word32 L_tmp;
    Word16 q_h1;
#ifdef FIX_2081_REVISE_H1_SCALING
    Word16 shift, tmp;
#endif
    BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
    SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
    LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;

#ifdef FIX_2081_REVISE_H1_SCALING
    shift = shift_r; /* for IVAS, shift_r is always 0 */
                     /* will be reusing the EVS shift strategy later on to allow of H1 overshoot */
    move16();
#endif
    L_frame_fx = st_fx->L_frame;
    move16();

@@ -480,6 +493,7 @@ Word16 encod_tran_ivas_fx(
    /*------------------------------------------------------------------*
     * Initializations
     *------------------------------------------------------------------*/

    gain_pit = 0;
    move16();
    gain_code = L_deposit_l( 0 );
@@ -521,6 +535,7 @@ Word16 encod_tran_ivas_fx(
    {
        shift_wsp = sub( shift_wsp, 1 );
    }

    /*----------------------------------------------------------------*
     * ACELP subframe loop
     *----------------------------------------------------------------*/
@@ -540,9 +555,21 @@ Word16 encod_tran_ivas_fx(
                              res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 );

        q_h1 = sub( 14, norm_s( h1[0] ) );
#ifdef FIX_2081_REVISE_H1_SCALING
        tmp = sub( 14, norm_arr( h1, L_SUBFR ) );
        shift = sub( q_h1, tmp ); /* shift is initialized to shift_r ( to 0) at the beginning of the scope, re-compute shift_wsp in case it has changed */
        shift_wsp = add( Q_new, shift );
        if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
        {
            shift_wsp = sub( shift_wsp, 1 );
        }
#endif
        Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/
#ifdef FIX_2081_REVISE_H1_SCALING
        Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) );
#else
        Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) );

#endif
        /* scaling of xn[] to limit dynamic at 12 bits */
        Scale_sig( xn, L_SUBFR, shift );