Commit b79aeaee authored by vaclav's avatar vaclav
Browse files

Merge branch 'basop-2344-align-pre_proc_ivas-between-flp-and-basop' into 'main'

Align pre_proc_ivas() between FLP and BASOP

Closes #2344

See merge request !2721
parents eadfd676 82645a05
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -5856,7 +5856,11 @@ ivas_error ivas_mct_enc_fx(
    const Word16 nb_bits_metadata                               /* i  : number of metadata bits                 */
);

#ifdef FIX_2344_ALIGN_PREPROC
void ivas_compute_core_buffers_fx(
#else
ivas_error ivas_compute_core_buffers_fx(
#endif
    Encoder_State *st,                                          /* i/o: encoder state structure                  */
    Word16 **inp16k_out_fx,                                     /* o  : ptr. to inp. signal in the current frame */
    Word16 *old_inp_16k_fx,                                     /* i/o: buffer of old input signal @ 16kHz       */
@@ -5870,7 +5874,7 @@ ivas_error ivas_compute_core_buffers_fx(
    Word32 epsP[M + 1],                                         /* i/o: LP prediction errors                     */
    Word16 lsp_new_fx[M],                                       /* i/o: LSPs at the end of the frame             */
    Word16 lsp_mid_fx[M],                                       /* i/o: LSPs in the middle of the frame          */
    Word16 Q_old_inp_16k,
    const Word16 Q_old_inp_16k,
    Word16 Q_r[2],
    Word16 *Q_new 
);
@@ -5961,7 +5965,11 @@ void ivas_mct_enc_close_fx(
    MCT_ENC_HANDLE *hMCT                                        /* i/o: MCT encoder structure                   */
);

#ifdef FIX_2344_ALIGN_PREPROC
void pre_proc_front_ivas_fx(
#else
ivas_error pre_proc_front_ivas_fx(
#endif
    SCE_ENC_HANDLE hSCE,                                           /* i/o: SCE encoder structure                                    */
    CPE_ENC_HANDLE hCPE,                                           /* i/o: CPE encoder structure                                    */
    const Word32 element_brate,                                    /* i  : SCE/CPE element bitrate                                  Q0*/
@@ -6017,7 +6025,11 @@ ivas_error pre_proc_front_ivas_fx(
    Word16 *Q_new                                                  /* i/o : Q factor of speech buffers                              */
);

#ifdef FIX_2344_ALIGN_PREPROC
void pre_proc_ivas_fx(
#else
ivas_error pre_proc_ivas_fx(
#endif
    Encoder_State *st,                                          /* i/o: encoder state structure                                */
    const Word16 last_element_mode,                             /* i  : last element mode                                    Q0*/
    const Word32 element_brate,                                 /* i  : element bitrate                                      Q0*/
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@
#define HARM_CORE_SW                                    /* VA: basop issue 2314: Remove duplicated code in the core switching */
#define HARM_PREPROC                                    /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX  */
#define HARM_NON_LINEARITY                              /* VA: basop issue 2345: Remove duplicated code in core-coder: non_linearity_fx() and LP CNG */
#define FIX_2344_ALIGN_PREPROC                          /* VA: basop issue 2344: Align pre_proc_ivas() between FLP and BASOP */

/* #################### End BE switches ################################## */

+31 −9
Original line number Diff line number Diff line
@@ -230,6 +230,20 @@ ivas_error ivas_core_enc_fx(
#endif
            Scale_sig( &Aw_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( Aw_fx[n][i * ( M + 1 )] ), 2 ) ); // scaling to Q12
        }

#ifdef FIX_2344_ALIGN_PREPROC
        Word32 last_element_brate_tmp = element_brate;
        move32();
        IF( EQ_32( ivas_format, SBA_FORMAT ) )
        {
            last_element_brate_tmp = last_element_brate;
            move32();
        }

        pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate_tmp, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
                          &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n],
                          vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] );
#else
        IF( EQ_32( ivas_format, SBA_FORMAT ) )
        {
            IF( NE_32( ( error = pre_proc_ivas_fx( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */,
@@ -250,6 +264,8 @@ ivas_error ivas_core_enc_fx(
                return error;
            }
        }
#endif

        test();
        IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) || EQ_16( st->element_mode, IVAS_SCE ) )
        {
@@ -744,6 +760,11 @@ ivas_error ivas_core_enc_fx(

        Word16 Q_shb_spch_16 = Q_shb_spch;
        move16();
#ifdef FIX_2344_ALIGN_PREPROC
        IF( st->tcxonly == 0 || hStereoICBWE != NULL || st->core == ACELP_CORE ) // temp. fix to keep BE until #1504 (FLP) is solved, then it will become:
                                                                                 // IF( st->tcxonly == 0 )
#endif
        {
            shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 );
            Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch
            Q_shb_spch = add( Q_shb_spch, shift );
@@ -755,6 +776,7 @@ ivas_error ivas_core_enc_fx(
                move16();
                Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda
            }
        }

        /* SWB TBE encoder */
        test();
+33 −5
Original line number Diff line number Diff line
@@ -76,7 +76,11 @@ static Word16 get_zero_flag( const Word32 arr[], const Word16 len )
 * (resampling, spectral analysis, LP analysis, VAD, OL pitch calculation, classification)
 *--------------------------------------------------------------------*/

#ifdef FIX_2344_ALIGN_PREPROC
void pre_proc_front_ivas_fx(
#else
ivas_error pre_proc_front_ivas_fx(
#endif
    SCE_ENC_HANDLE hSCE,                                           /* i/o: SCE encoder structure                                    */
    CPE_ENC_HANDLE hCPE,                                           /* i/o: CPE encoder structure                                    */
    const Word32 element_brate,                                    /* i  : SCE/CPE element bitrate                                  Q0*/
@@ -157,7 +161,9 @@ ivas_error pre_proc_front_ivas_fx(
    STEREO_CLASSIF_HANDLE hStereoClassif;
    Word16 old_pitch1; /* previous frame OL pitch[1] @12.8 kHz */
    Word16 LR_localVAD;
#ifndef FIX_2344_ALIGN_PREPROC
    ivas_error error;
#endif
    Word16 *signal_in_fx;
    Word32 *signal32_in_fx;
    Word16 *inp_12k8_fx, *new_inp_12k8_fx; /* pointers to current frame and new data       */
@@ -225,21 +231,30 @@ ivas_error pre_proc_front_ivas_fx(
    Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX];
    Word16 Q_inp_const = -1;
    move16();
#ifdef FIX_2344_ALIGN_PREPROC
    Word16 headroom, preemp_len, inp_max;
#else
    Word16 headroom = 0, preemp_len = 0, inp_max = 0;
    move16();
    move16();
    move16();
#endif
    Word16 *preemp_start_idx = NULL;
#ifdef FIX_2344_ALIGN_PREPROC
    Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32;
#else
    Word32 sig_out[960], max_32;
#endif

    push_wmops( "pre_proc_front" );
    /*------------------------------------------------------------------*
     * Initialization
     *------------------------------------------------------------------*/

#ifndef FIX_2344_ALIGN_PREPROC
    error = IVAS_ERR_OK;
    move32();

#endif
    cldfbScale.lb_scale = Q31;
    cldfbScale.hb_scale = Q31;
    move16();
@@ -544,12 +559,17 @@ ivas_error pre_proc_front_ivas_fx(
     * Perform fixed preemphasis (12.8 kHz signal) through 1 - g*z^-1
     *-----------------------------------------------------------------*/

#ifndef FIX_2344_ALIGN_PREPROC
    *Q_new = 0;
    move16();
    set32_fx( sig_out, 0, 960 );

#endif
    headroom = 2;
    move16();
#ifdef FIX_2344_ALIGN_PREPROC
    preemp_len = 0;
    move16();
#endif

    st->mem_preemph_fx_q_inp = shl_sat( st->mem_preemph_fx_q_inp, sub( st->q_inp, st->mem_preemph_q ) ); /*st->q_inp*/
    move16();
@@ -636,6 +656,7 @@ ivas_error pre_proc_front_ivas_fx(
        preemp_len = L_FRAME + L_FILT;
        move16();
    }

    st->mem_preemph_fx = shl_sat( st->mem_preemph_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1) saturation added as float value goes above 65536 for +10 dB test (ltv48_MC512.wav and ltv48_MC51.wav) */
    move16();
    st->mem_preemph_DFT_fx = shl_sat( st->mem_preemph_DFT_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1)*/
@@ -1329,12 +1350,11 @@ ivas_error pre_proc_front_ivas_fx(
     * 1st stage speech/music classification (GMM model)
     *----------------------------------------------------------------*/

    SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas;
    shift = getScaleFactor32( PS_fx, 128 );
    scale_sig32( PS_fx, 128, shift );
    Qfact_PS = add( Qfact_PS, shift );

    smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, extract_h( Etot_fx ), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, hSpMusClas->past_PS_Q ); /* Q0 */
    smc_dec = ivas_smc_gmm_fx( st, hStereoClassif, localVAD_HE_SAD, extract_h( Etot_fx ), lsp_new_fx, *cor_map_sum_fx /*Q8*/, epsP_fx, PS_fx, non_staX_fx, *relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, *epsP_fx_q, st->hSpMusClas->past_PS_Q ); /* Q0 */

#ifdef DEBUGGING
    if ( st->idchan == 0 )
@@ -1476,11 +1496,15 @@ ivas_error pre_proc_front_ivas_fx(
                move16();

                /* Compute core-coder buffers at internal sampling rate */
#ifdef FIX_2344_ALIGN_PREPROC
                ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new );
#else
                error = ivas_compute_core_buffers_fx( st, NULL, old_inp_16k_fx, NULL, input_frame, IVAS_SCE /*last_element_mode*/, INT_FS_16k /*sr_core_tmp*/, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, Q_new );
                IF( NE_32( error, IVAS_ERR_OK ) )
                {
                    return error;
                }
#endif

                *epsP_fx_q = add( Q_r[0], 1 );
                move16();
@@ -1571,7 +1595,11 @@ ivas_error pre_proc_front_ivas_fx(
    free( temp1F_icatdmResampBuf_fx );
#endif
    pop_wmops();
#ifdef FIX_2344_ALIGN_PREPROC
    return;
#else
    return error;
#endif
}


+142 −17
Original line number Diff line number Diff line
@@ -46,7 +46,11 @@
 * Decision matrix, Preprocessing at other Fs, core switching decision, ...)
 *--------------------------------------------------------------------*/

#ifdef FIX_2344_ALIGN_PREPROC
void pre_proc_ivas_fx(
#else
ivas_error pre_proc_ivas_fx(
#endif
    Encoder_State *st,                           /* i/o: encoder state structure                                */
    const Word16 last_element_mode,              /* i  : last element mode                                    Q0*/
    const Word32 element_brate,                  /* i  : element bitrate                                      Q0*/
@@ -82,13 +86,16 @@ ivas_error pre_proc_ivas_fx(
    Word16 *inp_16k_fx, *new_inp_12k8_fx, *inp_12k8_fx; /* pointers to current frame and new data */
    Word16 *wsp_fx;                                     /* weighted input signal buffer           */
    Word32 sr_core_tmp, total_brate_tmp;
#ifndef FIX_2344_ALIGN_PREPROC
    ivas_error error;
#endif

    push_wmops( "pre_proc" );

#ifndef FIX_2344_ALIGN_PREPROC
    error = IVAS_ERR_OK;
    move32();

#endif
    /*----------------------------------------------------------------*
     * Initialization
     *----------------------------------------------------------------*/
@@ -166,6 +173,26 @@ ivas_error pre_proc_ivas_fx(
        move16();
    }

#ifdef FIX_2344_ALIGN_PREPROC
    IF( EQ_16( st->L_frame, L_FRAME16k ) )
    {
        total_brate_tmp = ACELP_16k40;
        move16();
    }
    ELSE
    {
        total_brate_tmp = ACELP_9k60;
        move16();
    }

    test();
    test();
    test();
    IF( st->hFdCngEnc != NULL && NE_16( st->element_mode, IVAS_CPE_MDCT ) && ( ( NE_16( st->hFdCngEnc->hFdCngCom->frameSize, st->L_frame ) ) || ( NE_16( st->hFdCngEnc->hFdCngCom->CngBandwidth, st->input_bwidth ) ) ) )
    {
        configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), total_brate_tmp );
    }
#else
    test();
    test();
    test();
@@ -185,6 +212,7 @@ ivas_error pre_proc_ivas_fx(
    {
        configureFdCngEnc_ivas_fx( st->hFdCngEnc, s_max( st->input_bwidth, WB ), flag_1 );
    }
#endif

    if ( st->ini_frame == 0 )
    {
@@ -227,6 +255,7 @@ ivas_error pre_proc_ivas_fx(
     * IC frames selection
     * enforce TC frames in case of switching
     *-----------------------------------------------------------------*/

    test();
    test();
    test();
@@ -287,7 +316,6 @@ ivas_error pre_proc_ivas_fx(
        move16();
    }


    /*---------------------------------------------------------------------*
     * Decision matrix (selection of technologies)
     *---------------------------------------------------------------------*/
@@ -308,6 +336,7 @@ ivas_error pre_proc_ivas_fx(

    /* core selection */
    ivas_decision_matrix_enc_fx( st, element_brate, fft_buff_fx, enerBuffer_fx, e_enerBuffer, last_element_mode );

    test();
    test();
    if ( EQ_16( st->L_frame, L_FRAME16k ) && ( EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, UNVOICED ) ) ) /* VOICED and UNVOICED are not supported in ACELP@16k */
@@ -399,14 +428,14 @@ ivas_error pre_proc_ivas_fx(
        }
    }


    /*-----------------------------------------------------------------*
     * Update of ACELP harmonicity counter (used in ACELP transform codebook @32kbps)
     *-----------------------------------------------------------------*/

    test();
    test();
    test();
    IF( EQ_16( loc_harm, 1 ) && GT_16( cor_map_sum_fx, 50 << 8 ) && EQ_16( st->clas, VOICED_CLAS ) && EQ_16( st->coder_type, GENERIC ) )
    IF( EQ_16( loc_harm, 1 ) && GT_16( cor_map_sum_fx, 50 << Q8 ) && EQ_16( st->clas, VOICED_CLAS ) && EQ_16( st->coder_type, GENERIC ) )
    {
        st->last_harm_flag_acelp = add( st->last_harm_flag_acelp, 1 ); /* Q0 */
        move16();
@@ -474,6 +503,7 @@ ivas_error pre_proc_ivas_fx(
        }
    }

#ifndef FIX_2344_ALIGN_PREPROC
    /* channel-aware mode - due to lack of signaling bit, sharpFlag is 1 always in RF mode */
    test();
    test();
@@ -482,7 +512,7 @@ ivas_error pre_proc_ivas_fx(
        st->sharpFlag = 1;
        move16();
    }

#endif
    /* TD stereo, secondary channel - due to lack of signaling bits, sharpFlag is always 1 */
    test();
    IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) )
@@ -517,6 +547,7 @@ ivas_error pre_proc_ivas_fx(
    /*-----------------------------------------------------------------*
     * Compute core-coder buffers at internal sampling rate
     *-----------------------------------------------------------------*/

    IF( st->tcxonly == 0 )
    {
        sr_core_tmp = INT_FS_16k;
@@ -570,16 +601,29 @@ ivas_error pre_proc_ivas_fx(
    move16();
    st->exp_buf_wspeech_enc = sub( Q15, Q_old_inp_16k );
    move16();
#ifndef FIX_2344_ALIGN_PREPROC
    Word16 Q_inp_12k8 = *Q_new;
    move16();
    Word16 Q_inp_16k = *Q_new;
    move16();
#endif

    IF( !flag_16k_smc )
    {
#ifdef FIX_2344_ALIGN_PREPROC
        Word16 Q_inp_12k8 = *Q_new;
        move16();
        Word16 Q_inp_16k;

        ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx, A_fx, Aw_fx, epsP_fx, lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k );
#else
        error = ivas_compute_core_buffers_fx( st, &inp_16k_fx, old_inp_16k_fx, new_inp_resamp16k_fx, input_frame, last_element_mode, sr_core_tmp, ener_fx,
                                              A_fx, Aw_fx,
                                              epsP_fx,
                                              lsp_new_fx, lsp_mid_fx, Q_old_inp_16k, Q_r, &Q_inp_16k );

#endif

        IF( GT_16( Q_inp_16k, Q_inp_12k8 ) )
        {
            Scale_sig( old_inp_16k_fx, L_INP, sub( Q_inp_12k8, Q_inp_16k ) );
@@ -592,11 +636,12 @@ ivas_error pre_proc_ivas_fx(
        }
        move16();

#ifndef FIX_2344_ALIGN_PREPROC
        IF( error != IVAS_ERR_OK )
        {
            return error;
        }

#endif
        test();
        IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
        {
@@ -604,6 +649,7 @@ ivas_error pre_proc_ivas_fx(
            move16();
        }
    }

    test();
    IF( !( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) ) )
    {
@@ -681,15 +727,25 @@ ivas_error pre_proc_ivas_fx(
    }

    pop_wmops();
#ifdef FIX_2344_ALIGN_PREPROC
    return;
#else
    return error;
#endif
}


/*-------------------------------------------------------------------*
 * ivas_compute_core_buffers()
 *
 * Compute core-coder buffers at internal sampling rate
 *--------------------------------------------------------------------*/

#ifdef FIX_2344_ALIGN_PREPROC
void ivas_compute_core_buffers_fx(
#else
ivas_error ivas_compute_core_buffers_fx(
#endif
    Encoder_State *st,                     /* i/o: encoder state structure                  */
    Word16 **inp16k_out_fx,                /* o  : ptr. to inp. signal in the current frame Q_new-1*/
    Word16 *old_inp_16k_fx,                /* i/o: buffer of old input signal @ 16kHz       Q_new-1*/
@@ -703,7 +759,7 @@ ivas_error ivas_compute_core_buffers_fx(
    Word32 epsP_fx[M + 1],                 /* i/o: LP prediction errors                     Q_r*/
    Word16 lsp_new_fx[M],                  /* i/o: LSPs at the end of the frame             Q15*/
    Word16 lsp_mid_fx[M],                  /* i/o: LSPs in the middle of the frame          Q15*/
    Word16 Q_old_inp_16k,
    const Word16 Q_old_inp_16k,
    Word16 Q_r[2],
    Word16 *Q_new )
{
@@ -719,19 +775,28 @@ ivas_error ivas_compute_core_buffers_fx(
    Word16 Q_tmp, mem_decim16k_size, size_modified;
    Word16 epsP_h[M + 1];
    Word16 epsP_l[M + 1];

#ifdef FIX_2344_ALIGN_PREPROC
    Word16 i, shift, Q_min;
    Word16 preemp_len, inp_max;
#else
    Word16 headroom = 1, preemp_len = 0, inp_max = 0;
    move16();
    move16();
    move16();
#endif
    Word16 *preemp_start_idx = NULL;
#ifdef FIX_2344_ALIGN_PREPROC
    Word32 sig_out[STEREO_DFT_OVL_16k + L_FRAME16k /* = max( L_FRAME16k + STEREO_DFT_OVL_16k, L_FRAME16k + L_FILT16k + lMemRecalc_16k ) */], max_32;
#else
    Word32 sig_out[960], max_32;
    /*Word16 Q_exp, Q_wsp_exp*/;
#endif

#ifndef FIX_2344_ALIGN_PREPROC
    set16_fx( new_inp_resamp16k_fx, 0, L_FRAME16k );
    set16_fx( epsP_h, 0, M + 1 );
    set16_fx( epsP_l, 0, M + 1 );
    set16_fx( input_buf_fx, 0, L_FRAME48k * 2 );

#endif
    Copy_Scale_sig( st->input_fx - input_frame, input_buf_fx, input_frame, sub( -1, st->q_old_inp ) );
    Copy_Scale_sig( st->input_fx, input_buf_fx + input_frame, input_frame, sub( -1, st->q_inp ) );

@@ -757,9 +822,9 @@ ivas_error ivas_compute_core_buffers_fx(
    /*---------------------------------------------------------------*
     * Preprocessing at other sampling frequency rate (16/25.6/32kHz)
     *----------------------------------------------------------------*/

    IF( st->tcxonly == 0 )
    {

        L_frame_tmp = L_FRAME16k;
        move16();
    }
@@ -848,14 +913,23 @@ ivas_error ivas_compute_core_buffers_fx(
                Scale_sig( new_inp_16k_fx - lMemRecalc_16k - length_16k, size_modified, negate( Q_tmp ) );                                                                                                                    /* scaling back to Q_old_inp_16k */
            }

#ifdef FIX_2344_ALIGN_PREPROC
            size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - lMemRecalc_16k, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
            Scale_sig( new_inp_16k_fx - lMemRecalc_16k, size_modified, negate( Q_tmp ) );                                                                                                        /* scaling back to Q_old_inp_16k */
#else
            size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc, input_frame, input_Fs, new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size );                                                          /* Q0 */
            Scale_sig( new_inp_16k_fx - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) );                                                                                                                                                                 /* scaling back to Q_old_inp_16k */
#endif
            Copy( st->mem_decim16k_fx, mem_decim16k_dummy_fx, 2 * L_FILT_MAX );

            IF( lMemRecalc > 0 )
            {
#ifdef FIX_2344_ALIGN_PREPROC
                size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - lMemRecalc_16k, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
                Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - lMemRecalc_16k, size_modified, negate( Q_tmp ) );                                                                                                                       /* scaling back to Q_old_inp_16k */
#else
                size_modified = modify_Fs_ivas_fx( signal_in_fx - lMemRecalc + input_frame, lMemRecalc, input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */
                Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ) - ( lMemRecalc * sr_core ) / st->input_Fs, size_modified, negate( Q_tmp ) );                                                                                                                       /* scaling back to Q_old_inp_16k */
#endif
            }

            set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX );
@@ -939,6 +1013,10 @@ ivas_error ivas_compute_core_buffers_fx(
        move16();
    }

#ifdef FIX_2344_ALIGN_PREPROC
    *Q_new = 0;
    move16();
#else
    test();
    test();

@@ -951,10 +1029,22 @@ ivas_error ivas_compute_core_buffers_fx(
    {
        headroom = add( headroom, 1 );
    }

#endif

    test();
#ifdef FIX_2344_ALIGN_PREPROC
    IF( EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
#else
    test();
    IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
#endif
    {
#ifdef FIX_2344_ALIGN_PREPROC
        preemp_len = 0;
        move16();
#endif

        IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
        {
            Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, st->inp_16k_mem_stereo_sw_fx, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* update for TD/DFT stereo switching    Q(-1) */
@@ -1040,8 +1130,12 @@ ivas_error ivas_compute_core_buffers_fx(
        maximum_abs_32_fx( sig_out, preemp_len, &max_32 );
        inp_max = s_max( extract_h( max_32 ), 1 );

#ifdef FIX_2344_ALIGN_PREPROC
        shift = sub( norm_s( inp_max ), 1 /* headroom */ );
#else
        Word16 shift = sub( norm_s( inp_max ), headroom );
        Word16 Q_min, i;
#endif
        shift = s_max( shift, 0 );
        shift = s_min( shift, Q_MAX );
        minimum_fx( st->Q_max_16k, L_Q_MEM, &Q_min );
@@ -1066,8 +1160,13 @@ ivas_error ivas_compute_core_buffers_fx(
        Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, add( *Q_new, 1 ) );
        Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), *Q_new );
    }
#ifdef FIX_2344_ALIGN_PREPROC
    ELSE /* keep memory up-to-date in case of bitrate switching */
#else
    ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */
#endif
    {
#ifndef FIX_2344_ALIGN_PREPROC
        IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
        {
            st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - STEREO_DFT_OVL_16k - 1]; /* Q_new - 1 */
@@ -1078,7 +1177,9 @@ ivas_error ivas_compute_core_buffers_fx(
            st->mem_preemph16k_fx = new_inp_16k_fx[L_frame_tmp - lMemRecalc_16k - 1]; /* Q_new - 1 */
            move16();
        }
        ELSE IF( EQ_16( element_mode, IVAS_CPE_MDCT ) )
        ELSE
#endif
        IF( EQ_16( element_mode, IVAS_CPE_MDCT ) )
        {
            st->mem_preemph16k_fx = 0;
            move16();
@@ -1101,7 +1202,9 @@ ivas_error ivas_compute_core_buffers_fx(
    IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
    {
        /* update signal buffers */
#ifndef FIX_2344_ALIGN_PREPROC
        Word16 shift;
#endif
        shift = negate( *Q_new );
        move16();
        IF( EQ_16( element_mode, IVAS_CPE_DFT ) )
@@ -1137,6 +1240,14 @@ ivas_error ivas_compute_core_buffers_fx(
            analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r );
        }

#ifdef FIX_2344_ALIGN_PREPROC
        FOR( i = 0; i < M + 1; i++ )
        {
            epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] );
            move32();
        }

#endif
        /*--------------------------------------------------------------*
         * Compute Weighted Input
         *---------------------------------------------------------------*/
@@ -1151,20 +1262,30 @@ ivas_error ivas_compute_core_buffers_fx(
    /* update old input signal @16kHz buffer */
    test();
    test();
#ifndef FIX_2344_ALIGN_PREPROC
    test();
#endif
    IF( ( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) || EQ_16( element_mode, IVAS_CPE_MDCT ) )
    {
        set16_fx( st->old_inp_16k_fx, 0, L_INP_MEM );
        st->exp_old_inp_16k = 0;
        move16();
    }
#ifdef FIX_2344_ALIGN_PREPROC
    ELSE IF( EQ_32( sr_core, INT_FS_16k ) )
#else
    ELSE IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) )
#endif
    {
        Copy( &old_inp_16k_fx[L_frame_tmp], st->old_inp_16k_fx, L_INP_MEM );
        st->exp_old_inp_16k = sub( Q16, *Q_new ); //(*Q_new - 1)
        move16();
    }
#ifdef FIX_2344_ALIGN_PREPROC
    ELSE
#else
    ELSE IF( GT_32( input_Fs, 8000 ) )
#endif
    {
        lerp( st->old_inp_12k8_fx + L_INP_MEM - L_INP_MEM * 4 / 5, st->old_inp_16k_fx, L_INP_MEM, L_INP_MEM * 4 / 5 );
        Scale_sig( st->old_inp_16k_fx, L_INP_MEM, sub( -1 /* Q st->old_inp_16k_fx = -1 */, sub( 15, st->exp_old_inp_12k8 ) ) );
@@ -1181,6 +1302,8 @@ ivas_error ivas_compute_core_buffers_fx(
    {
        Copy( new_inp_resamp16k_fx, new_inp_resamp16k_out_fx, L_FRAME16k );
    }

#ifndef FIX_2344_ALIGN_PREPROC
    test();
    IF( EQ_16( st->L_frame, L_FRAME16k ) && NE_16( element_mode, IVAS_CPE_MDCT ) )
    {
@@ -1190,6 +1313,8 @@ ivas_error ivas_compute_core_buffers_fx(
            move32();
        }
    }

    return IVAS_ERR_OK;
#else
    return;
#endif
}
Loading