Commit f0fe3dcd authored by Manuel Jander's avatar Manuel Jander
Browse files

Separate Q input values for ivas_acelp_tcx20_switching_fx to avoid rescaling....

Separate Q input values for ivas_acelp_tcx20_switching_fx to avoid rescaling. Fix scale of portions of st->buf_speech_enc_pe and st->buf_speech_enc.
parent 0a7629f7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2979,6 +2979,9 @@ Word16 ivas_acelp_tcx20_switching_fx(
    Word16 *inp_fx,                                             /* i  : new input signal                        */
    Word16 q_inp,                                               /* i  : i/p Q                                   */
    Word16 *wsp,                                                /* i  : input weighted signal                   */
#ifdef NONBE_FIX_ISSUE_2206
    Word16 q_wsp,                                               /* i  : Q of input weighted signal                   */
#endif
    Word32 non_staX,                                            /* i  : unbound non-stationarity for sp/mu clas */
    Word16 *pitch_fr,                                           /* i  : fraction pitch values                   */
    Word16 *voicing_fr,                                         /* i  : fractional voicing values               */
+7 −1
Original line number Diff line number Diff line
@@ -1619,9 +1619,10 @@ ivas_error pre_proc_front_ivas_fx(
                move16();
#ifdef NONBE_FIX_ISSUE_2206
                Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( sub( *Q_new, 1 ), Q_old_inp_12k8 ) ); /* Q_new-1 */

                smc_dec = ivas_acelp_tcx20_switching_fx( st, st->speech_enc, sub( Q15, st->exp_buf_speech_enc ), st->wspeech_enc, sub( Q15, st->exp_buf_wspeech_enc ), non_staX_fx, pitch_fr_fx, voicing_fr_fx, currFlatness_fx, lsp_mid_fx, stab_fac_fx, res_cod_SNR_M_fx, res_cod_SNR_M_fx_e, flag_16k_smc );
#else
                Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( *Q_new, Q_old_inp_12k8 ) ); /* Q_new */
#endif

                Scale_sig( st->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k, sub( 0, sub( Q15, st->exp_buf_speech_enc ) ) ); /* Q0 */
                st->exp_buf_speech_enc = Q15;
@@ -1630,15 +1631,20 @@ ivas_error pre_proc_front_ivas_fx(
                st->exp_buf_wspeech_enc = Q15;
                move16();
                smc_dec = ivas_acelp_tcx20_switching_fx( st, st->speech_enc, 0, st->wspeech_enc, non_staX_fx, pitch_fr_fx, voicing_fr_fx, currFlatness_fx, lsp_mid_fx, stab_fac_fx, res_cod_SNR_M_fx, res_cod_SNR_M_fx_e, flag_16k_smc ); /* Q0 */
#endif
            }
            ELSE
            {
#ifdef NONBE_FIX_ISSUE_2206
                smc_dec = ivas_acelp_tcx20_switching_fx( st, inp_12k8_fx, sub( *Q_new, 1 ), wsp_fx, *q_old_wsp, non_staX_fx, pitch_fr_fx, voicing_fr_fx, currFlatness_fx, lsp_mid_fx, stab_fac_fx, res_cod_SNR_M_fx, res_cod_SNR_M_fx_e, flag_16k_smc ); /* Q0 */
#else
                Scale_sig( old_wsp_fx, L_WSP, sub( *Q_new, *q_old_wsp ) ); /* Q_new */
                *q_old_wsp = *Q_new;
                move16();
                Q_wsp = *Q_new;
                move16();
                smc_dec = ivas_acelp_tcx20_switching_fx( st, inp_12k8_fx, *Q_new, wsp_fx, non_staX_fx, pitch_fr_fx, voicing_fr_fx, currFlatness_fx, lsp_mid_fx, stab_fac_fx, res_cod_SNR_M_fx, res_cod_SNR_M_fx_e, flag_16k_smc ); /* Q0 */
#endif
            }
        }
        /* Switch to ACELP for non-harmonic transient signals */
+14 −8
Original line number Diff line number Diff line
@@ -1345,8 +1345,10 @@ ivas_error ivas_compute_core_buffers_fx(

            tmp = norm_arr( new_inp_16k_fx - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k );
            tmp = s_min( tmp, norm_arr( st->buf_speech_enc_pe, L_FRAME16k - STEREO_DFT_OVL_16k ) );
            tmp = s_min( tmp, norm_arr( st->buf_speech_enc_pe + L_FRAME16k + L_FRAME16k, L_PAST_MAX_32k + L_NEXT_MAX_32k ) );
            tmp = add( s_min( sub( *Q_new, 1 ), sub( Q15, st->exp_buf_speech_enc_pe ) ), tmp );
            scale_sig( st->buf_speech_enc_pe, L_FRAME16k - STEREO_DFT_OVL_16k, sub( tmp, sub( Q15, st->exp_buf_speech_enc_pe ) ) );
            scale_sig( st->buf_speech_enc_pe + L_FRAME16k + L_FRAME16k, L_PAST_MAX_32k + L_NEXT_MAX_32k, sub( tmp, sub( Q15, st->exp_buf_speech_enc_pe ) ) );
            Copy_Scale_sig_nosat( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc_pe + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k, sub( tmp, sub( *Q_new, 1 ) ) );
            st->exp_buf_speech_enc_pe = sub( Q15, tmp );
        }
@@ -1356,8 +1358,10 @@ ivas_error ivas_compute_core_buffers_fx(

            tmp = norm_arr( new_inp_16k_fx - lMemRecalc_16k, L_FRAME16k + lMemRecalc_16k + L_FILT16k );
            tmp = s_min( tmp, norm_arr( st->buf_speech_enc_pe, L_FRAME16k - lMemRecalc_16k - L_FILT16k ) );
            tmp = s_min( tmp, norm_arr( st->buf_speech_enc_pe + L_FRAME16k + L_FRAME16k, L_PAST_MAX_32k + L_NEXT_MAX_32k ) );
            tmp = add( s_min( sub( *Q_new, 1 ), sub( Q15, st->exp_buf_speech_enc_pe ) ), tmp );
            scale_sig( st->buf_speech_enc_pe, L_FRAME16k - lMemRecalc_16k - L_FILT16k, sub( tmp, sub( Q15, st->exp_buf_speech_enc_pe ) ) );
            scale_sig( st->buf_speech_enc_pe + L_FRAME16k + L_FRAME16k, L_PAST_MAX_32k + L_NEXT_MAX_32k, sub( tmp, sub( Q15, st->exp_buf_speech_enc_pe ) ) );
            Copy_Scale_sig_nosat( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc_pe + L_FRAME16k - lMemRecalc_16k - L_FILT16k, L_FRAME16k + lMemRecalc_16k + L_FILT16k, sub( tmp, sub( *Q_new, 1 ) ) );
            st->exp_buf_speech_enc_pe = sub( Q15, tmp );
        }
@@ -1365,19 +1369,21 @@ ivas_error ivas_compute_core_buffers_fx(
        {
            Word16 tmp;

            tmp = norm_arr( new_inp_resamp16k_fx, L_FRAME16k );
            tmp = s_min( tmp, norm_arr( st->buf_speech_enc, L_FRAME16k ) ); // L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k
            tmp = s_min( tmp, norm_arr( st->buf_speech_enc + L_FRAME16k + L_FRAME16k, L_PAST_MAX_32k + L_NEXT_MAX_32k ) );
            tmp = add( s_min( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc ) ), tmp );
            scale_sig( st->buf_speech_enc, L_FRAME16k, sub( tmp, sub( Q15, st->exp_buf_speech_enc ) ) );
            scale_sig( st->buf_speech_enc + L_FRAME16k + L_FRAME16k, L_PAST_MAX_32k + L_NEXT_MAX_32k, sub( tmp, sub( Q15, st->exp_buf_speech_enc ) ) );
            Copy_Scale_sig_nosat( new_inp_resamp16k_fx, st->buf_speech_enc + L_FRAME16k, L_FRAME16k, sub( tmp, Q_old_inp_16k ) );
            st->exp_buf_speech_enc = sub( Q15, tmp );

            tmp = norm_arr( new_inp_16k_fx, L_FRAME16k );
            tmp = s_min( tmp, norm_arr( st->buf_speech_enc_pe, L_FRAME16k ) );
            tmp = add( s_min( sub( *Q_new, 1 ), sub( Q15, st->exp_buf_speech_enc_pe ) ), tmp );
            scale_sig( st->buf_speech_enc_pe, L_FRAME16k - STEREO_DFT_OVL_16k, sub( tmp, sub( Q15, st->exp_buf_speech_enc_pe ) ) );
            scale_sig( st->buf_speech_enc_pe, L_FRAME16k, sub( tmp, sub( Q15, st->exp_buf_speech_enc_pe ) ) );
            Copy_Scale_sig_nosat( new_inp_16k_fx, st->buf_speech_enc_pe + L_FRAME16k, L_FRAME16k, sub( tmp, sub( *Q_new, 1 ) ) );
            st->exp_buf_speech_enc_pe = sub( Q15, tmp );

            tmp = norm_arr( new_inp_resamp16k_fx, L_FRAME16k );
            tmp = s_min( tmp, norm_arr( st->buf_speech_enc, L_FRAME16k ) );
            tmp = add( s_min( Q_old_inp_16k, sub( Q15, st->exp_buf_speech_enc ) ), tmp );
            scale_sig( st->buf_speech_enc, L_FRAME16k - STEREO_DFT_OVL_16k, sub( tmp, sub( Q15, st->exp_buf_speech_enc ) ) );
            Copy_Scale_sig_nosat( new_inp_resamp16k_fx, st->buf_speech_enc + L_FRAME16k, L_FRAME16k, sub( tmp, Q_old_inp_16k ) );
            st->exp_buf_speech_enc = sub( Q15, tmp );
        }
#else
        /* update signal buffers */
+22 −1
Original line number Diff line number Diff line
@@ -717,7 +717,12 @@ Word16 ivas_acelp_tcx20_switching_fx(
    Encoder_State *st, /* i/o: encoder state structure                          */
    Word16 *inp_fx,
    Word16 q_inp,
#ifdef NONBE_FIX_ISSUE_2206
    Word16 *wsp,         /* q_wsp i  : input weighted signal                    */
    Word16 q_wsp,        /* i  : Q of input weighted signal                     */
#else
    Word16 *wsp,         /*q_inp   i  : input weighted signal                   */
#endif
    Word32 non_staX,     /*Q20     i  : unbound non-stationarity for sp/mu clas*/
    Word16 *pitch_fr,    /*Q6 i  : fraction pitch values                        */
    Word16 *voicing_fr,  /*Q15 i  : fractional voicing values                  */
@@ -892,7 +897,11 @@ Word16 ivas_acelp_tcx20_switching_fx(
        xn_buf_fx[L_frame + i] = mult( xn_buf_fx[L_frame + i], window_fx[overlap - 1 - i] ); /* q_inp */
        move16();
    }
#ifdef NONBE_FIX_ISSUE_2206
    e_x = sub( 15, q_inp ); /*exponent for xn_buf_fx*/
#else
    e_x = sub( 16, q_inp ); /*exponent for xn_buf_fx*/
#endif
    move16();
    TCX_MDCT( xn_buf_fx, x_fx, &e_x, overlap, sub( L_frame, overlap ), overlap, st->element_mode );
    scale_A = getScaleFactor32( x_fx, L_frame );
@@ -1116,7 +1125,11 @@ Word16 ivas_acelp_tcx20_switching_fx(

        FOR( j = 0; j < L_SUBFR; j++ )
        {
#ifdef NONBE_FIX_ISSUE_2206
            tmp32 = BASOP_Util_Add_Mant32Exp( tmp32, temp32_e, L_mult0( wsp[i + j], wsp[i + j] ), sub( 31, add( q_wsp, q_wsp ) ), &temp32_e ); /* Q31-temp32_e */
#else
            tmp32 = BASOP_Util_Add_Mant32Exp( tmp32, temp32_e, L_mult0( wsp[i + j], wsp[i + j] ), sub( 31, add( q_inp, q_inp ) ), &temp32_e ); /* Q31-temp32_e */
#endif
        }
        IF( tmp32 == 0 )
        {
@@ -1188,11 +1201,19 @@ Word16 ivas_acelp_tcx20_switching_fx(
        move16();
        FOR( j = 0; j < L_SUBFR; j++ )
        {
#ifdef NONBE_FIX_ISSUE_2206
            tmp32 = Mpy_32_16_1( gain, wsp[i + j - T0] );   // Q16 + q_wsp - 15
            tmp32 = L_sub( wsp[i + j], L_shr( tmp32, 1 ) ); // q_wsp
            tmp16 = norm_l( tmp32 );
            tmp32 = L_shl( tmp32, tmp16 );                                                                                                     // q_wsp +tmp16
            noise = BASOP_Util_Add_Mant32Exp( noise, noise_e, Mpy_32_32( tmp32, tmp32 ), shl( sub( 31, add( q_wsp, tmp16 ) ), 1 ), &noise_e ); // noise_e
#else
            tmp32 = Mpy_32_16_1( gain, wsp[i + j - T0] );   // Q16 + q_inp - 15
            tmp32 = L_sub( wsp[i + j], L_shr( tmp32, 1 ) ); // q_inp
            tmp16 = norm_l( tmp32 );
            tmp32 = L_shl( tmp32, tmp16 );                                                                                                     // q_inp +tmp16
            noise = BASOP_Util_Add_Mant32Exp( noise, noise_e, Mpy_32_32( tmp32, tmp32 ), shl( sub( 31, add( q_inp, tmp16 ) ), 1 ), &noise_e ); // noise_e
#endif
        }
        test();
        IF( noise == 0 || EQ_32( noise, 1 ) )