Commit 82bbba3a authored by Manuel Jander's avatar Manuel Jander
Browse files

Add switch NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO and disable assert if...

Add switch NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO and disable assert if right shift is too large, but instead flush to zero. Fixes crash.
parent 3a808bb2
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@
#define NONBE_FIX_ISSUE_2206                            /* FhG: Calculate st->q_inp and Q_new dynamically for all data paths instead of assuming constant values */
#define NONBE_FIX_ISSUE_2206_TV1                        /* VA/FhG: Calculate st->q_inp also considering st->mem_q decimation memory to avoid saturation */
#define NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT             /* FhG: Dynamic scale of shb_speech buffers */
// #define NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO       /* FhG: Do not right shift flush to zero in Copy_Scale_sig_nosat */
#define HARM_HQ_CORE_KEEP_BE                            /* hack to keep all BE after HQ core functions harmonization; pending resolving issues #2450, #2451, #2452 */
#define FIX_BASOP_2457_HARM_GEN                         /* FhG: harmonization of function generate_comfort_noise_dec_hf_ivas_fx()*/
#define FIX_BASOP_2478_HARM_ENC_PRM_HM                  /* FhG: basop issue 2478: harmonize enc_prm_hm() and enc_prm_hm_ivas_fx() */
+14 −1
Original line number Diff line number Diff line
@@ -1266,7 +1266,9 @@ void Copy_Scale_sig_nosat(
    Word16 i;
    Word16 tmp;

#ifdef NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO
    assert( exp0 <= 15 && exp0 >= -15 );
#endif
    IF( exp0 == 0 )
    {
        FOR( i = 0; i < lg; i++ )
@@ -1276,6 +1278,17 @@ void Copy_Scale_sig_nosat(
        }
        return;
    }
#ifndef NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO
    IF( exp0 < -15 )
    {
        FOR( i = 0; i < lg; i++ )
        {
            y[i] = 0;
            move16();
        }
        return;
    }
#endif
    IF( exp0 < 0 )
    {
        tmp = shl( -32768, exp0 ); /* we use negative to correctly represent 1.0 */
@@ -1289,7 +1302,7 @@ void Copy_Scale_sig_nosat(
    FOR( i = 0; i < lg; i++ )
    {
        y[i] = shl( x[i], exp0 );
        move16(); /* saturation can occur here */
        move16();
    }

    return;
+4 −0
Original line number Diff line number Diff line
@@ -635,7 +635,11 @@ void core_signal_analysis_high_bitrate_ivas_fx(

        nexp = s_max( s_max( st->exp_buf_speech_enc, st->exp_buf_speech_enc_pe ), st->exp_mem_preemph_enc );
        scale_sig( st->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( st->exp_buf_speech_enc_pe, nexp ) );
#ifndef NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO
        Copy_Scale_sig_nosat( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame, sub( st->exp_buf_speech_enc, nexp ) );
#else
        Copy_Scale_sig_nosat( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame, s_max( -15, sub( st->exp_buf_speech_enc, nexp ) ) );
#endif
        st->mem_preemph_enc = shl( st->mem_preemph_enc, sub( st->exp_mem_preemph_enc, nexp ) );
        st->exp_mem_preemph_enc = nexp;
        move16();
+12 −0
Original line number Diff line number Diff line
@@ -394,15 +394,27 @@ void pre_proc_front_ivas_fx(

    IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
    {
#ifndef NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO
        Copy_Scale_sig_nosat( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - STEREO_DFT_OVL_12k8, sub( st->q_inp, sub( Q15, st->exp_old_inp_12k8 ) ) ); /* st->q_inp */
#else
        Copy_Scale_sig_nosat( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - STEREO_DFT_OVL_12k8, s_max( -15, sub( st->q_inp, sub( Q15, st->exp_old_inp_12k8 ) ) ) ); /* st->q_inp */
#endif
    }
    ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
    {
#ifndef NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO
        Copy_Scale_sig_nosat( st->old_inp_12k8_fx, old_inp_12k8_fx, sub( L_INP_MEM - L_FILT, lMemRecalc_12k8 ), sub( st->q_inp, sub( Q15, st->exp_old_inp_12k8 ) ) ); /* st->q_inp */
#else
        Copy_Scale_sig_nosat( st->old_inp_12k8_fx, old_inp_12k8_fx, sub( L_INP_MEM - L_FILT, lMemRecalc_12k8 ), s_max( -15, sub( st->q_inp, sub( Q15, st->exp_old_inp_12k8 ) ) ) ); /* st->q_inp */
#endif
    }
    ELSE
    {
#ifndef NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO
        Copy_Scale_sig_nosat( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - L_FILT, sub( st->q_inp, sub( Q15, st->exp_old_inp_12k8 ) ) ); /* st->q_inp */
#else
        Copy_Scale_sig_nosat( st->old_inp_12k8_fx, old_inp_12k8_fx, L_INP_MEM - L_FILT, s_max( -15, sub( st->q_inp, sub( Q15, st->exp_old_inp_12k8 ) ) ) ); /* st->q_inp */
#endif
    }

    Copy( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM ); /* exp(st->exp_old_wsp) */
+23 −3
Original line number Diff line number Diff line
@@ -690,7 +690,7 @@ void pre_proc_ivas_fx(
            tmp = s_min( Q15, tmp );
            scale_sig( st->buf_wspeech_enc, (Word16) ( st->wspeech_enc - st->buf_wspeech_enc ), sub( tmp, sub( Q15, st->exp_buf_wspeech_enc ) ) );
            scale_sig( st->wspeech_enc + L_FRAME + L_LOOK_12k8, /* L_NEXT_MAX_16k + */ 320, sub( tmp, sub( Q15, st->exp_buf_wspeech_enc ) ) );
#if 0
#ifndef NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO
            Copy_Scale_sig_nosat( wsp_fx, st->wspeech_enc, L_FRAME + L_LOOK_12k8, sub( tmp, sub( Q15, e_old_wsp ) ) );
#else
            Copy_Scale_sig_nosat( wsp_fx, st->wspeech_enc, L_FRAME + L_LOOK_12k8, s_max( -15, sub( tmp, sub( Q15, e_old_wsp ) ) ) );
@@ -873,7 +873,11 @@ void ivas_compute_core_buffers_fx(
    IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
    {
#ifdef NONBE_FIX_ISSUE_2206
#ifndef NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO
        Copy_Scale_sig( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - STEREO_DFT_OVL_16k, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ); /* Q_old_inp_16k */
#else
        Copy_Scale_sig( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - STEREO_DFT_OVL_16k, s_max( -15, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ) ); /* Q_old_inp_16k */
#endif
#else
        Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - STEREO_DFT_OVL_16k ); /* Q_new - 1 */
#endif
@@ -881,7 +885,11 @@ void ivas_compute_core_buffers_fx(
    ELSE IF( EQ_16( element_mode, IVAS_CPE_TD ) )
    {
#ifdef NONBE_FIX_ISSUE_2206
#ifndef NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO
        Copy_Scale_sig( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_MEM_RECALC_16K - L_FILT16k, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ); /* Q_old_inp_16k */
#else
        Copy_Scale_sig( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_MEM_RECALC_16K - L_FILT16k, s_max( -15, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ) ); /* Q_old_inp_16k */
#endif
#else
        Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_MEM_RECALC_16K - L_FILT16k ); /* Q_new - 1 */
#endif
@@ -889,7 +897,11 @@ void ivas_compute_core_buffers_fx(
    ELSE
    {
#ifdef NONBE_FIX_ISSUE_2206
#ifndef NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO
        Copy_Scale_sig_nosat( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_FILT16k, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ); /* Q_old_inp_16k */
#else
        Copy_Scale_sig_nosat( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_FILT16k, s_max( -15, sub( Q_old_inp_16k, sub( Q15, st->exp_old_inp_16k ) ) ) ); /* Q_old_inp_16k */
#endif
#else
        Copy( st->old_inp_16k_fx, old_inp_16k_fx, L_INP_MEM - L_FILT16k ); /* Q_new - 1 */
#endif
@@ -908,7 +920,11 @@ void ivas_compute_core_buffers_fx(
            delay = NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS );
            move16();
#ifdef NONBE_FIX_ISSUE_2206
#ifndef NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO
            Copy_Scale_sig_nosat( st->mem_decim16k_fx + delay, new_inp_16k_fx, delay, sub( Q_old_inp_16k, st->q_mem_decim16k_fx ) ); /* Q_old_inp_16k */
#else
            Copy_Scale_sig_nosat( st->mem_decim16k_fx + delay, new_inp_16k_fx, delay, s_max( -15, sub( Q_old_inp_16k, st->q_mem_decim16k_fx ) ) ); /* Q_old_inp_16k */
#endif
            Copy( signal_in_fx, new_inp_16k_fx + delay, input_frame ); /* Q_old_inp_16k */
            // Copy_Scale_sig( signal_in_fx + input_frame - shl( delay, 1 ), st->mem_decim16k_fx, shl( delay, 1 ), sub( -1, Q_old_inp_16k ) ); /* Q(-1) */
            Copy( signal_in_fx + input_frame - shl( delay, 1 ), st->mem_decim16k_fx, shl( delay, 1 ) );
@@ -958,7 +974,11 @@ void ivas_compute_core_buffers_fx(
            delay = NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS );
            move16();
#ifdef NONBE_FIX_ISSUE_2206
#ifndef NONBE_FIX_ISSUE_2206_DO_NOT_FLUSH_TO_ZERO
            Copy_Scale_sig_nosat( st->mem_decim16k_fx + delay, new_inp_16k_fx - add( lMemRecalc, sub( delay, L_FILT16k ) ), delay, sub( Q_old_inp_16k, st->q_mem_decim16k_fx ) ); /* Q_old_inp_16k */
#else
            Copy_Scale_sig_nosat( st->mem_decim16k_fx + delay, new_inp_16k_fx - add( lMemRecalc, sub( delay, L_FILT16k ) ), delay, s_max( -15, sub( Q_old_inp_16k, st->q_mem_decim16k_fx ) ) ); /* Q_old_inp_16k */
#endif
            Copy( signal_in_fx - lMemRecalc, new_inp_16k_fx - sub( lMemRecalc, L_FILT16k ), add( input_frame, lMemRecalc ) ); /* Q_old_inp_16k */
            // Copy_Scale_sig( signal_in_fx + sub( sub( input_frame, lMemRecalc ), shl( delay, 1 ) ), st->mem_decim16k_fx, shl( delay, 1 ), sub( -1, Q_old_inp_16k ) ); /* Q(-1) */
            Copy( signal_in_fx + sub( sub( input_frame, lMemRecalc ), shl( delay, 1 ) ), st->mem_decim16k_fx, shl( delay, 1 ) );
Loading