Commit e10e110e authored by malenov's avatar malenov
Browse files

prevent saturation when up-scaling lpc_shb_fx[]

parent c23f7811
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@
#define NONBE_FIX_1143_MASA_BRSW                        /* Nok: Fix for issue 1143: MSAN use of uninitialized value in masa decoding to binaural with dtx bitrate switching and 5 % FER */
#define NONBE_FIX_1220_OMASA_JBM_EXT_USAN               /* Nokia: fix issue 1220 OMASA EXT JBM USAN, also fix similar cases of free to avoid future problems */
#define NONBE_FIX_1376_MDCT_CONCEALMENT                 /* FhG: fix concealment artifact in MDCT Stereo with DTX, in case transition frame gets lost */
#define FIX_ISSUE_2004_LPC_SHB_SAT                      /* Dolby: Issue 2004: prevent saturation of the LPC SHB filter */

/* #################### End BASOP porting switches ############################ */

+20 −1
Original line number Diff line number Diff line
@@ -3161,7 +3161,25 @@ void swb_tbe_enc_ivas_fx(
        enerG = Enr_1_Az_fx( lpc_shb1, 2 * L_SUBFR ); /* Q3 */

        /* if the LP gain is greater than a threshold, avoid saturation */
#ifdef FIX_ISSUE_2004_LPC_SHB_SAT
        Word16 flag_sat = 0;
        Word16 lpc_shb_fx0_req_shift = sub( norm_s( lpc_shb_fx[0] ), 2);
        IF( GT_16( lpc_shb_fx0_req_shift, 0 ) )
        {
            FOR( i = 1; i <= LPC_SHB_ORDER; i++ )
            {
                IF( LT_16( norm_s( lpc_shb_fx[i] ), lpc_shb_fx0_req_shift ) )
                {
                    flag_sat = 1;
                    break;
                }
            }
        }

        IF( GT_16( enerG, 256 /* 32.0 in Q3 */ ) || flag_sat )
#else
        IF( GT_16( enerG, 256 /*32 Q3*/ ) )
#endif
        {
            set16_fx( lpc_shb_fx, 0, LPC_SHB_ORDER + 1 );
            E_LPC_lev_dur( R_h, R_l, lpc_shb_fx, LepsP, 2, NULL ); /* LPC in Q14 */
@@ -3169,7 +3187,8 @@ void swb_tbe_enc_ivas_fx(
    }

    /* this is needed as the E_LPC_lev_dur function outputs lpc in Q14 */
    scale_sig( lpc_shb_fx, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_fx[0] ), 2 ) );
    Word16 tmp_shift = sub( norm_s( lpc_shb_fx[0] ), 2 );
    scale_sig( lpc_shb_fx, LPC_SHB_ORDER + 1, tmp_shift );

    /* Expand bandwidth of the LP coeffs */
    test();