Commit 0a11fd46 authored by Manuel Jander's avatar Manuel Jander
Browse files

Resolve issue from comment from \!2445. Use fixed Q-1 for vectors documented...

Resolve issue from comment from \!2445. Use fixed Q-1 for vectors documented as st->q_inp but where st->q_inp was fixed to -1 and now is variable.
parent 932be5ec
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -699,7 +699,19 @@ ivas_error ivas_core_enc_fx(
         * SWB(FB) TBE encoding
         * SWB(FB) BWE encoding
         *---------------------------------------------------------------------*/
#ifdef NONBE_FIX_ISSUE_2206
        IF( GE_32( input_Fs, 32000 ) && st->hBWE_TD != NULL )
        {
            /* provide 1 bit of headroom. A better solution is to deal with the scale of
               hBWE_FD->old_fdbwe_speech_fx and other vectors which are fixed to Q-1 */
            st->q_inp = sub( st->q_inp, 1 );
            st->q_old_inp = sub( st->q_old_inp, 1 );
            move16();
            move16();
            Scale_sig( st->input_fx - input_frame, shl( input_frame, 1 ), -1 );
        }

#else
        Word16 q_inp_orig;
        q_inp_orig = st->q_inp;
        move16();
@@ -712,6 +724,7 @@ ivas_error ivas_core_enc_fx(
            move16();
            Scale_sig( st->input_fx - input_frame, shl( input_frame, 1 ), sub( st->q_inp, q_inp_orig ) );
        }
#endif

        new_swb_speech_fx_16 = new_swb_speech_buffer_fx_16 + STEREO_DFT_OVL_MAX;
        set16_fx( new_swb_speech_buffer_fx_16, 0, L_FRAME48k + STEREO_DFT_OVL_MAX );
@@ -804,12 +817,14 @@ ivas_error ivas_core_enc_fx(

        Scale_sig( old_syn_12k8_16k_fx[n], L_FRAME16k, sub( Q1, Q_new[n] ) ); // Q0

#ifndef NONBE_FIX_ISSUE_2206
        IF( GE_32( input_Fs, 32000 ) && st->hBWE_TD != NULL )
        {
            Scale_sig( st->input_fx, input_frame, sub( q_inp_orig, st->q_inp ) );
            st->q_inp = q_inp_orig;
            move16();
        }
#endif

        /*---------------------------------------------------------------------*
         * SWB DTX/CNG encoding
+8 −0
Original line number Diff line number Diff line
@@ -1022,11 +1022,19 @@ typedef struct fd_bwe_enc_structure
{
    Word16 new_input_hp_fx[NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS )]; // Q_new_input_hp
    Word16 Q_new_input_hp;
#ifdef NONBE_FIX_ISSUE_2206
    Word16 old_input_fx[NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS )]; // Q(-1)
#else
    Word16 old_input_fx[NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS )]; // st->q_inp
#endif
    Word16 old_input_wb_fx[NS2SA( 16000, DELAY_FD_BWE_ENC_NS )];                     /* Q(-1) */
    Word16 old_input_lp_fx[NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS )];     // st->hBWE_FD->prev_Q_input_lp
    Word16 old_syn_12k8_16k_fx[NS2SA( 16000, DELAY_FD_BWE_ENC_NS )];                 // st->Q_syn
#ifdef NONBE_FIX_ISSUE_2206
    Word16 old_fdbwe_speech_fx[L_FRAME48k];                                          // Q(-1)
#else
    Word16 old_fdbwe_speech_fx[L_FRAME48k];
#endif
    Word16 mem_deemph_old_syn_fx;
    Word16 q_mem_deemph_old_syn;
    Word16 prev_mode;
+108 −9
Original line number Diff line number Diff line
@@ -315,13 +315,18 @@ void wb_pre_proc_ivas_fx(
    }
#endif

#ifdef NONBE_FIX_ISSUE_2206
    Q_wb_sp = add( Q_wb_sp, new_inp_resamp16k_q );

    Copy_Scale_sig( new_inp_resamp16k, temp_buf, L_FRAME16k, sub( Q_wb_sp, new_inp_resamp16k_q ) );
    Scale_sig( hBWE_TD->decim_state1_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), sub( Q_wb_sp, -1 ) );
    Scale_sig( hBWE_TD->decim_state2_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), sub( Q_wb_sp, -1 ) );
    /* temp_buf, and the memory states are in Q_wb_sp */
#else
    Copy_Scale_sig( new_inp_resamp16k, temp_buf, L_FRAME16k, Q_wb_sp );
    Scale_sig( hBWE_TD->decim_state1_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), Q_wb_sp );
    Scale_sig( hBWE_TD->decim_state2_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), Q_wb_sp );
    /* temp_buf, and the memory states are in Q_wb_sp */

#ifdef NONBE_FIX_ISSUE_2206
    Q_wb_sp = add( Q_wb_sp, new_inp_resamp16k_q );
#endif

    test();
@@ -492,10 +497,10 @@ void wb_pre_proc_ivas_fx(
            }

#ifdef NONBE_FIX_ISSUE_2206
            /* rescale the hb_speech and memories back to new_inp_resamp16k_q to keep the downstream BWE coding unaffected */
            /* rescale the hb_speech and memories back to -1 */
            Scale_sig( hb_speech, L_FRAME16k / 4, sub( new_inp_resamp16k_q, Q_wb_sp ) );
            Scale_sig( hBWE_TD->decim_state1_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), sub( new_inp_resamp16k_q, Q_wb_sp ) );
            Scale_sig( hBWE_TD->decim_state2_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), sub( new_inp_resamp16k_q, Q_wb_sp ) );
            Scale_sig( hBWE_TD->decim_state1_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), sub( -1, Q_wb_sp ) );
            Scale_sig( hBWE_TD->decim_state2_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), sub( -1, Q_wb_sp ) );
            if ( st_fx->element_mode == EVS_MONO )
            {
                Q_wb_sp = new_inp_resamp16k_q;
@@ -515,7 +520,11 @@ void wb_pre_proc_ivas_fx(

                highband_new_speech = highband_old_speech + Sample_Delay_WB_BWE;
                Copy( hb_speech, highband_new_speech, L_FRAME16k / 4 );
#ifdef NONBE_FIX_ISSUE_2206
                Copy_Scale_sig( highband_old_speech + L_FRAME16k / 4, hBWE_TD->old_speech_wb_fx, Sample_Delay_WB_BWE, s_max( -15, sub( -1, new_inp_resamp16k_q ) ) );
#else
                Copy( highband_old_speech + L_FRAME16k / 4, hBWE_TD->old_speech_wb_fx, Sample_Delay_WB_BWE );
#endif
            }
        }
    }
@@ -552,7 +561,11 @@ void wb_pre_proc_ivas_fx(
#ifdef NONBE_FIX_ISSUE_2206
        Copy_Scale_sig_nosat( new_inp_resamp16k, &old_input[Sample_Delay_WB_BWE], L_FRAME16k, sub( Q_wb_sp, new_inp_resamp16k_q ) );
        Copy_Scale_sig( hBWE_FD->old_input_wb_fx, old_input, Sample_Delay_WB_BWE, sub( Q_wb_sp, -1 ) );
        IF( LT_16( sub( -1, new_inp_resamp16k_q ), -15 ) ) {
            set16_zero_fx( hBWE_FD->old_input_wb_fx, Sample_Delay_WB_BWE );
        } ELSE {
            Copy_Scale_sig_nosat( new_inp_resamp16k + L_FRAME16k - Sample_Delay_WB_BWE, hBWE_FD->old_input_wb_fx, Sample_Delay_WB_BWE, sub( -1, new_inp_resamp16k_q ) );
        }
#else
        Copy( new_inp_resamp16k, &old_input[Sample_Delay_WB_BWE], L_FRAME16k );
        Copy( hBWE_FD->old_input_wb_fx, old_input, Sample_Delay_WB_BWE );
@@ -953,10 +966,20 @@ void swb_pre_proc_ivas_fx(
                Sample_Delay_SWB_BWE = NS2SA( 32000, DELAY_FD_BWE_ENC_16k_NS );
            }

#ifdef NONBE_FIX_ISSUE_2206
            Copy_Scale_sig_nosat( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE, sub( -1, st->q_inp ) );
            Copy_Scale_sig_nosat( st->input_fx - L_FRAME32k, hBWE_FD->old_fdbwe_speech_fx, L_FRAME32k, sub( -1, st->q_inp ) );
#else
            Copy( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE );
            Copy( st->input_fx - L_FRAME32k, hBWE_FD->old_fdbwe_speech_fx, L_FRAME32k );
#endif

#ifndef NONBE_FIX_ISSUE_2206
#ifdef NONBE_FIX_ISSUE_2206
            Word16 tmp = s_min( st->q_inp, st->Q_old_wtda );
            scale_sig( hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( tmp, st->Q_old_wtda ) ); // st->Q_old_wtda -> tmp
            st->Q_old_wtda = tmp;                                                            //    st->Q_old_wtda = tmp;
            move16();
#else
            scale_sig( hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( st->q_inp, st->Q_old_wtda ) ); // st->Q_old_wtda -> st->q_inp
            st->Q_old_wtda = st->q_inp;                                                            //    st->Q_old_wtda = st->q_inp;
            move16();
@@ -966,11 +989,19 @@ void swb_pre_proc_ivas_fx(
            test();
            IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && GE_16( st->bwidth, SWB ) )
            {
#ifdef NONBE_FIX_ISSUE_2206
                Copy_Scale_sig_nosat( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( st->Q_old_wtda, st->q_inp ) );
#else
                Copy( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ) );
#endif
            }
            ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && GE_16( st->bwidth, SWB ) )
            {
#ifdef NONBE_FIX_ISSUE_2206
                Copy_Scale_sig_nosat( st->input_fx - hCPE->hStereoDft->dft_ovl, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( hCPE->hStereoDft->dft_ovl, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoDft->dft_ovl, Sample_Delay_SWB_BWE ), sub( st->Q_old_wtda, st->q_inp ) );
#else
                Copy( st->input_fx - hCPE->hStereoDft->dft_ovl, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( hCPE->hStereoDft->dft_ovl, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoDft->dft_ovl, Sample_Delay_SWB_BWE ) );
#endif
            }
        }

@@ -991,7 +1022,15 @@ void swb_pre_proc_ivas_fx(
                Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA( 32000, DELAY_FIR_RESAMPL_NS ) );
            }

#ifdef NONBE_FIX_ISSUE_2206
            IF( st->element_mode > EVS_MONO ) {
                Copy_Scale_sig_nosat(hBWE_FD->old_fdbwe_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], L_FRAME32k, sub( st->q_inp, -1 ) );
            } ELSE {
                Copy( hBWE_FD->old_fdbwe_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], L_FRAME32k );
            }
#else
            Copy( hBWE_FD->old_fdbwe_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], L_FRAME32k );
#endif

            set16_fx( old_input_fx, 0, Sample_Delay_SWB_BWE );
            Copy( hBWE_FD->old_fdbwe_speech_fx + L_FRAME32k - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE );
@@ -1014,8 +1053,16 @@ void swb_pre_proc_ivas_fx(
        test();
        IF( NE_16( st->extl, SWB_BWE ) && NE_16( st->extl, FB_BWE ) )
        {
#ifdef NONBE_FIX_ISSUE_2206
            IF( st->element_mode > EVS_MONO ) {
                Copy_Scale_sig_nosat( st->input_fx, hBWE_FD->old_fdbwe_speech_fx, L_FRAME32k, sub( -1, st->q_inp ) );
            } ELSE {
                Copy( st->input_fx, hBWE_FD->old_fdbwe_speech_fx, L_FRAME32k );
            }
#else
            Copy( st->input_fx, hBWE_FD->old_fdbwe_speech_fx, L_FRAME32k );
#endif
        }
    }
    ELSE /* 48 kHz */
    {
@@ -1048,16 +1095,31 @@ void swb_pre_proc_ivas_fx(
                }
                ELSE IF( EQ_16( st->bwidth, FB ) )
                {
#ifdef NONBE_FIX_ISSUE_2206
                    Copy_Scale_sig_nosat( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE, sub( -1, st->q_inp ) );
#else
                    Copy( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE );
#endif
                }

#ifdef NONBE_FIX_ISSUE_2206
                Copy_Scale_sig_nosat( st->input_fx - L_FRAME48k, hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k, sub( -1, st->q_inp ) );
#else
                Copy( st->input_fx - L_FRAME48k, hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k );
#endif

                test();
                test();
#ifdef NONBE_FIX_ISSUE_2206
                Word16 tmp = s_min( st->Q_old_wtda, st->q_inp );
                scale_sig( hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( tmp, st->Q_old_wtda ) );
                st->Q_old_wtda = tmp;
                move16();
#else
                scale_sig( hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, sub( st->q_inp, st->Q_old_wtda ) ); // st->Q_old_wtda -> st->q_inp
                st->Q_old_wtda = st->q_inp;
                move16();
#endif

                IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && GE_16( st->bwidth, SWB ) )
                {
@@ -1068,13 +1130,23 @@ void swb_pre_proc_ivas_fx(
                        decimate_2_over_3_allpass_fx( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hCPE->hStereoTCA->lMemRecalc, spchTmp, hBWE_TD->dec_2_over_3_mem_fx,
                                                      allpass_poles_3_ov_2, decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx );

#ifdef NONBE_FIX_ISSUE_2206
                        Copy_Scale_sig_nosat( spchTmp, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( lMemRecalc32k, Sample_Delay_SWB_BWE32k ), sub( lMemRecalc32k, Sample_Delay_SWB_BWE32k ), sub( st->Q_old_wtda, st->q_inp ) );
                        Copy_Scale_sig_nosat( spchTmp + lMemRecalc32k - Sample_Delay_SWB_BWE32k, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE32k, sub( -1, st->q_inp ) );
#else
                        Copy( spchTmp, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - sub( lMemRecalc32k, Sample_Delay_SWB_BWE32k ), sub( lMemRecalc32k, Sample_Delay_SWB_BWE32k ) );
                        Copy( spchTmp + lMemRecalc32k - Sample_Delay_SWB_BWE32k, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE32k );
#endif
                    }
                    ELSE /* FB_BWE */
                    {
#ifdef NONBE_FIX_ISSUE_2206
                        Copy_Scale_sig_nosat( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hBWE_FD->L_old_wtda_swb_fx + L_FRAME48k - sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( st->Q_old_wtda, st->q_inp ) );
                        Copy_Scale_sig_nosat( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE, sub( -1, st->q_inp ) );
#else
                        Copy( st->input_fx - hCPE->hStereoTCA->lMemRecalc, hBWE_FD->L_old_wtda_swb_fx + L_FRAME48k - sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ), sub( hCPE->hStereoTCA->lMemRecalc, Sample_Delay_SWB_BWE ) );
                        Copy( st->input_fx - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE );
#endif
                    }
                }
                ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && GE_16( st->bwidth, SWB ) )
@@ -1083,11 +1155,19 @@ void swb_pre_proc_ivas_fx(
                    {
                        lerp( st->input_fx - hCPE->hStereoDft->dft_ovl, spchTmp, dft_ovl32k - Sample_Delay_SWB_BWE32k, hCPE->hStereoDft->dft_ovl - Sample_Delay_SWB_BWE );

#ifdef NONBE_FIX_ISSUE_2206
                        Copy_Scale_sig_nosat( spchTmp, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - ( dft_ovl32k - Sample_Delay_SWB_BWE32k ), dft_ovl32k - Sample_Delay_SWB_BWE32k, sub( st->Q_old_wtda, st->q_inp ) );
#else
                        Copy( spchTmp, hBWE_FD->L_old_wtda_swb_fx + L_FRAME32k - ( dft_ovl32k - Sample_Delay_SWB_BWE32k ), dft_ovl32k - Sample_Delay_SWB_BWE32k );
#endif
                    }
                    ELSE
                    {
#ifdef NONBE_FIX_ISSUE_2206
                        Copy_Scale_sig_nosat( st->input_fx - hCPE->hStereoDft->dft_ovl, hBWE_FD->L_old_wtda_swb_fx + L_FRAME48k - ( hCPE->hStereoDft->dft_ovl - Sample_Delay_SWB_BWE ), hCPE->hStereoDft->dft_ovl - Sample_Delay_SWB_BWE, sub( st->Q_old_wtda, st->q_inp ) );
#else
                        Copy( st->input_fx - hCPE->hStereoDft->dft_ovl, hBWE_FD->L_old_wtda_swb_fx + L_FRAME48k - ( hCPE->hStereoDft->dft_ovl - Sample_Delay_SWB_BWE ), hCPE->hStereoDft->dft_ovl - Sample_Delay_SWB_BWE );
#endif
                    }
                }
            }
@@ -1099,7 +1179,11 @@ void swb_pre_proc_ivas_fx(
            IF( ( NE_16( st->extl, SWB_BWE ) && NE_16( st->extl, FB_BWE ) && ( st->core == ACELP_CORE ) ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && ( st->core != ACELP_CORE ) ) /*resampling not needed for MDCT cores*/ )
            {
                /* move the resampling out of the TDBWE path as new_swb_speech is not needed for TDBWE. */
#ifdef NONBE_FIX_ISSUE_2206
                Copy_Scale_sig_nosat( st->input_fx, hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k, sub( -1, st->q_inp ) );
#else
                Copy( st->input_fx, hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k );
#endif
            }
            ELSE
            {
@@ -1113,7 +1197,11 @@ void swb_pre_proc_ivas_fx(
                        move16();
                        inner_Fs = 48000;
                        move32();
#ifdef NONBE_FIX_ISSUE_2206
                        Copy_Scale_sig_nosat( hBWE_FD->old_fdbwe_speech_fx, new_swb_speech, L_FRAME48k, sub( st->q_inp, -1 ) );
#else
                        Copy( hBWE_FD->old_fdbwe_speech_fx, new_swb_speech, L_FRAME48k );
#endif
                    }
                    ELSE
                    {
@@ -1131,6 +1219,10 @@ void swb_pre_proc_ivas_fx(
                            lerp( hBWE_FD->old_fdbwe_speech_fx, new_swb_speech, inner_frame, L_FRAME48k );
                        }

#ifdef NONBE_FIX_ISSUE_2206
                        Scale_sig( new_swb_speech, L_FRAME48k, sub( st->q_inp, -1 ) );
#endif

                        test();
                        IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) && st->idchan == 0 )
                        {
@@ -1167,7 +1259,11 @@ void swb_pre_proc_ivas_fx(

                    Copy( new_swb_speech, &old_input_fx[Sample_Delay_SWB_BWE], inner_frame );
                    set16_fx( old_input_fx, 0, Sample_Delay_SWB_BWE );
#ifdef NONBE_FIX_ISSUE_2206
                    Copy_Scale_sig_nosat( new_swb_speech + inner_frame - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE, sub( -1, st->q_inp ) );
#else
                    Copy( new_swb_speech + inner_frame - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE );
#endif
                    Copy( old_input_fx, hBWE_FD->L_old_wtda_swb_fx, inner_frame );
#ifdef NONBE_FIX_ISSUE_2206
                    set16_zero_fx( hBWE_FD->L_old_wtda_swb_fx + inner_frame, sub( L_FRAME48k, inner_frame ) );
@@ -1219,6 +1315,8 @@ void swb_pre_proc_ivas_fx(
                        // Copy_Scale_sig32_16( new_swb_speech_fx - STEREO_DFT_OVL_MAX, new_swb_speech - STEREO_DFT_OVL_MAX, L_FRAME48k + STEREO_DFT_OVL_MAX, add( st->q_inp, new_swb_speech_q ) ); // st->q_inp
                        Copy_Scale_sig_32_16( new_swb_speech_fx + out_start_ind, new_swb_speech + out_start_ind, out_end_ind - out_start_ind, sub( st->q_inp, new_swb_speech_q ) ); // st->q_inp
                        Copy_Scale_sig_32_16( new_swb_speech_fx + out_end_ind, new_swb_speech + out_end_ind, L_FRAME48k - out_end_ind, sub( st->q_inp, add( q_reImBuffer, 1 ) ) );  // st->q_inp

                        Copy_Scale_sig_nosat( new_swb_speech - Sample_Delay_SWB_BWE32k, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE32k, sub( -1, st->q_inp )  ); // Q(-1) 
#else
                        Word16 out_start_ind, out_end_ind;
                        Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX];
@@ -1227,9 +1325,10 @@ void swb_pre_proc_ivas_fx(
                        new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX;
                        stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, new_swb_speech_fx, &out_start_ind, &out_end_ind, st->idchan, input_Fs, 32000, 0, NULL );
                        Copy_Scale_sig32_16( new_swb_speech_fx - STEREO_DFT_OVL_MAX, new_swb_speech - STEREO_DFT_OVL_MAX, L_FRAME48k + STEREO_DFT_OVL_MAX, add( st->q_inp, add( q_reImBuffer, 1 ) ) ); // st->q_inp
#endif

                        Copy( new_swb_speech - Sample_Delay_SWB_BWE32k, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE32k ); // st->q_inp
#endif

                    }
                }
            }
+13 −7
Original line number Diff line number Diff line
@@ -595,13 +595,8 @@ void wb_tbe_enc_fx(
    Word16 n_mem, Q_bwe_exc, Q_bwe_exc_ext, exp_out, Q_cur_pow, Q_prev_pow; /* Q_hb_frame; */
    Word32 L_tmp, Lmax;
    Word16 tmp, exp, Q_out, sc;
#ifdef NONBE_FIX_ISSUE_2206
    Word16 Q_ns = q_hb_speech;
    move16();
#else
    Word16 Q_ns = -1;
    move16();
#endif

    Word16 pitBufAvg_fx, voicingBufAvg_fx;
    Word16 vf_modified_fx[NB_SUBFR16k];
@@ -621,13 +616,16 @@ void wb_tbe_enc_fx(
    hb_frame = hb_old_speech + WBTBE_LSUBFR_5_OVER_16 + WBTBE_ANA_ALIGNDELAY;

#ifdef NONBE_FIX_ISSUE_2206
    Copy_Scale_sig( hBWE_TD->old_speech_wb_fx, hb_old_speech, WBTBE_LOOK_LSUFBR_5_OVER_16, sub( Q_ns, -1 ) );
    IF( st_fx->element_mode != EVS_MONO ) {
        Q_ns = s_min( q_hb_speech, add( -1, norm_arr(hBWE_TD->old_speech_wb_fx, WBTBE_LOOK_LSUFBR_5_OVER_16 ) ) );
    }
    Copy_Scale_sig_nosat( hBWE_TD->old_speech_wb_fx, hb_old_speech, WBTBE_LOOK_LSUFBR_5_OVER_16, s_min( 15, sub( Q_ns, -1 ) ) );
#else
    Copy( hBWE_TD->old_speech_wb_fx, hb_old_speech, WBTBE_LOOK_LSUFBR_5_OVER_16 );
#endif
    Copy( hb_speech, hb_new_speech, LFRAME16K_OVER_4 );
#ifdef NONBE_FIX_ISSUE_2206
    Copy_Scale_sig( hb_old_speech + LFRAME16K_OVER_4, hBWE_TD->old_speech_wb_fx, WBTBE_LOOK_LSUFBR_5_OVER_16, sub( -1, Q_ns ) );
    Copy_Scale_sig_nosat( hb_old_speech + LFRAME16K_OVER_4, hBWE_TD->old_speech_wb_fx, WBTBE_LOOK_LSUFBR_5_OVER_16, s_max( -15, sub( -1, Q_ns ) ) );
#else
    Copy( hb_old_speech + LFRAME16K_OVER_4, hBWE_TD->old_speech_wb_fx, WBTBE_LOOK_LSUFBR_5_OVER_16 );
#endif
@@ -641,7 +639,11 @@ void wb_tbe_enc_fx(
    IF( ( NE_16( st_fx->last_extl, WB_TBE ) && NE_16( st_fx->last_extl, WB_BWE ) ) && ( st_fx->clas == UNVOICED_CLAS || ( LT_16( st_fx->voicing_fx[0], 16384 ) && LT_16( st_fx->voicing_fx[1], 16384 ) && LT_16( st_fx->voicing_fx[2], 16384 ) ) ) && !st_fx->igf )
    {
        /* In case of unvoiced signals after switching cores, back-propagate the target signal */
#ifdef NONBE_FIX_ISSUE_2206
        Copy_Scale_sig_nosat( hb_speech, hb_old_speech, WBTBE_LOOK_LSUFBR_5_OVER_16, sub( Q_ns, q_hb_speech ) );
#else
        Copy( hb_speech, hb_old_speech, WBTBE_LOOK_LSUFBR_5_OVER_16 );
#endif

        i = WBTBE_LOOK_LSUFBR_5_OVER_16;
        move16();
@@ -663,7 +665,11 @@ void wb_tbe_enc_fx(
            FOR( j = 0; j < L_SUBFR16k; j = j + 4 )
            {
                L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] );
#ifdef NONBE_FIX_ISSUE_2206
                hb_old_speech[i] = mac_r_sat( L_tmp, shl( hb_speech[k], sub( Q_ns, q_hb_speech ) ), ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] );
#else
                hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] );
#endif
                move16();
                i--;
                k++;