Commit 41a83928 authored by vaclav's avatar vaclav
Browse files

Merge branch 'HARM_FD_BWE' into 'main'

Remove duplicated code: FD BWE

See merge request !2801
parents ae3fc3c5 e86d7d53
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1891,6 +1891,7 @@ void GenShapedWBExcitation_ivas_fx(
    const Word16 igf_flag 
);
#endif
#ifndef HARM_FD_BWE
/* o : Q_syn_hb*/
Word16 ivas_wb_bwe_dec_fx(
    Decoder_State *st_fx,                                       /* i/o: decoder state structure                 */
@@ -1907,7 +1908,7 @@ Word16 ivas_wb_bwe_dec_fx(
    const Word16 pitch_buf_fx[],                                /* i  : pitch buffer                         Q6 */
    Word16 *Qpost 
);

#endif
void ivas_param_ism_config_fx(
    PARAM_ISM_CONFIG_HANDLE hParamIsm,                          /* i/o: IVAS Param ISM Config Structure         */
    const Word16 nchan_obj                                      /* i  : number of ISM channels                  */
+1 −0
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@
#define FIX_2410_HARM_MODIF_FS                          /* VA: basop issue 2410: Remove duplicated modif_Fs */
#define HARM_LEV_DURBIN                                 /* VA: basop issue 2423: harmonize levinson-Durbin algorithm */
#define HARMONIZE_TBE2                                  /* VA: basop issue 2399: Remove duplicated code: TBE, step 2 */
#define HARM_FD_BWE                                     /* VA: harmonize core-coder FD BWE function duplications */

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

+36 −130
Original line number Diff line number Diff line
@@ -317,6 +317,13 @@ Word32 calc_tilt_bwe_fx(
    const Word16 N     /* i  : signal length     */
);
/* o  : Tilt in Q24       */
Word16 calc_tilt_bwe_fx_32(
    const Word32 *sp,    /* i  : i   signal        */
    const Word16 exp_sp, /* i  : Exp of inp signal */
    const Word16 N       /* i  : signal length     */
);
void calc_norm_envelop_fx(
    const Word16 SWB_signal[], /* i  : SWB spectrum            Q_syn*/
    Word32 *envelope,          /* o  : normalized envelope     Q_syn*/
@@ -325,6 +332,14 @@ void calc_norm_envelop_fx(
    const Word16 st_offset     /* i  : offset                       */
);
void calc_norm_envelop_fx_32(
    const Word32 SWB_signal_fx[], /* i  : SWB spectrum           : Q12 */
    Word32 *envelope_fx,          /* o  : normalized envelope    : Q16 */
    const Word16 L_swb_norm,      /* i  : length of envelope     : Q0  */
    const Word16 SWB_flength,     /* i  : Length of i  /output   : Q0  */
    const Word16 st_offset        /* i  : offset                 : Q0  */
);
void WB_BWE_decoding_fx(
    const Word16 *core_dec_freq, /* i  : Frequency domain core decoded signal */
    Word16 *WB_fenv,             /* i  : WB frequency envelopes               */
@@ -365,6 +380,9 @@ void SWB_BWE_decoding_fx(
);
void time_envelop_shaping_fx(
#ifdef HARM_FD_BWE
    const Word16 element_mode, /* i  : element mode                   */
#endif
    Word16 werr[],     /* i/o: SHB synthesis           Q_synth*/
    Word32 SWB_tenv[], /* i/o: frequency envelope          Q15*/
    const Word16 L,    /* i  : frame length                   */
@@ -378,14 +396,6 @@ void time_reduce_pre_echo_fx(
    Word16 Q_syn,
    Word16 Q_synth );
void calc_norm_envelop_fx_32(
    const Word32 SWB_signal_fx[], /* i  : SWB spectrum           : Q12 */
    Word32 *envelope_fx,          /* o  : normalized envelope    : Q16 */
    const Word16 L_swb_norm,      /* i  : length of envelope     : Q0  */
    const Word16 SWB_flength,     /* i  : Length of i  /output   : Q0  */
    const Word16 st_offset        /* i  : offset                 : Q0  */
);
void hq_generic_decoding_fx(
    const Word16 HQ_mode,             /* i  : HQ mode                                     */
    Word32 *coeff_out1_fx,            /* i/o: BWE i   & temporary buffer                  */
@@ -2646,83 +2656,7 @@ Word16 E_UTIL_f_preemph3_ivas_fx(
    Word16 bits      /* Q0 */
);
Word16 WB_BWE_gain_pred_fx(
    Word16 *WB_fenv,             /* o  : WB frequency envelopes               */
    const Word16 *core_dec_freq, /* i  : Frequency domain core decoded signal */
    const Word16 coder_type,     /* i  : coding type                          */
    Word16 prev_coder_type,      /* i  : coding type of last frame            */
    Word16 prev_WB_fenv,         /* i  : envelope for last frame              */
    Word16 *voice_factors,       /* i  : voicing factors        Q15           */
    const Word16 pitch_buf[],    /* i  : pitch buffer           Q6            */
    Word32 last_core_brate,      /* i  : previous frame core bitrate          */
    Word16 last_wb_bwe_ener,     /* i  : previous frame wb bwe signal energy */
    Word16 Q_syn,
    Word16 last_extl_fx,
    Word16 tilt_wb_fx );
void calc_normal_length_fx(
    const Word16 core,       /* i  : core                   */
    const Word16 *sp,        /* i  : i   signal           */
    const Word16 mode,       /* i  : i   mode             */
    const Word16 extl,       /* i  : extension layer        */
    Word16 *L_swb_norm,      /* o  : normalize length       */
    Word16 *prev_L_swb_norm, /*i/o : last normalize length  */
    Word16 Q_syn );
/* o  : Tilt in Q24       */
Word16 ivas_calc_tilt_bwe_fx(
    const Word32 *sp,    /* i  : i   signal      */
    const Word16 exp_sp, /* i  : Exp of inp signal */
    const Word16 N       /* i  : signal length     */
);
void calc_norm_envelop_fx(
    const Word16 SWB_signal[], /* i  : SWB spectrum            Q_syn*/
    Word32 *envelope,          /* o  : normalized envelope     Q_syn*/
    const Word16 L_swb_norm,   /* i  : length of envelope     Q0    */
    const Word16 SWB_flength,  /* i  : Length of i  /output       */
    const Word16 st_offset     /* i  : offset                       */
);
void WB_BWE_decoding_fx(
    const Word16 *core_dec_freq, /* i  : Frequency domain core decoded signal */
    Word16 *WB_fenv,             /* i  : WB frequency envelopes               */
    Word32 *WB_signal32,         /* o  : WB signal in MDCT domain             */
    const Word16 WB_flength,     /* i  : Length of i  /output               */
    const Word16 mode,           /* i  : classification for WB signal         */
    const Word16 last_extl,      /* i  : extl. layer for last frame           */
    Word32 *prev_Energy,         /* i/o: energy for last frame                */
    Word16 *prev_WB_fenv,        /* i/o: envelope for last frame              */
    Word16 *prev_L_wb_norm,      /* i/o: length for last frame wb norm        */
    const Word16 extl,           /* i  : extension layer                      */
    const Word16 coder_type,     /* i  : coding type                          */
    const Word32 total_brate,    /* i  : core layer bitrate                   */
    Word16 *Seed,                /* i/o: random generator seed                */
    Word16 *prev_flag,           /* i/o: attenu flag of last frame            */
    Word16 prev_coder_type,      /* i  : coding type of last frame            */
    Word16 Q_syn,
    Word16 *Q_syn_hb /*o   : Q value of WB_signal_32              */
);
void SWB_BWE_decoding_fx(
    const Word16 *core_dec_freq, /* i  : Frequency domain core decoded signal  */
    Word16 *SWB_fenv,            /* i/o: SWB frequency envelopes               */
    Word32 *SWB_signal,          /* o  : SWB signal in MDCT domain             */
    const Word16 SWB_flength,    /* i  : Length of i  /output                */
    const Word16 mode,           /* i  : classification for SWB signal         */
    Word16 *frica_flag,          /* o  : fricative signal flag                 */
    Word16 *prev_Energy,         /* i/o: energy for last frame                 */
    Word16 *prev_SWB_fenv,       /* i/o: envelope for last frame               */
    Word16 *prev_L_swb_norm,     /* i/o: length for last frame wb norm         */
    const Word16 tilt_nb,        /* i  : tilt of synthesis wb signal           */
    Word16 *Seed,                /* i/o: random generator seed                 */
    const Word16 st_offset,      /* i  : offset value due to different core    */
    Word16 *prev_weight,         /* i/o: excitation weight value of last frame */
    const Word16 extl,           /* i  : extension layer                       */
    Word16 Q_syn,
    const Word16 last_extl /* i  : extension layer of last frame         */
);
#ifndef HARM_FD_BWE
void time_envelop_shaping_fx(
    Word16 werr[],     /* i/o: SHB synthesis           Q_synth*/
    Word32 SWB_tenv[], /* i/o: frequency envelope          Q15*/
@@ -2730,55 +2664,14 @@ void time_envelop_shaping_fx(
    Word16 *Q_synth );
void time_envelop_shaping_ivas_fx(
#ifdef HARM_FD_BWE
    const Word16 element_mode, /* i  : element mode                   */
#endif
    Word16 werr[],     /* i/o: SHB synthesis           Q_synth*/
    Word32 SWB_tenv[], /* i/o: frequency envelope          Q15*/
    const Word16 L,    /* i  : frame length                   */
    Word16 *Q_synth );
void time_reduce_pre_echo_fx(
    const Word16 *synth,   /* i  : ACELP core synthesis    Q_syn*/
    Word16 *error,         /* i/o: SHB BWE synthesis          Q0*/
    Word16 prev_td_energy, /* o  : last td energy             Q0*/
    const Word16 L,        /* i  : subframe length              */
    Word16 Q_syn,
    Word16 Q_synth );
void calc_normal_length_fx_32(
    const Word16 core,      /* i  : core                   : Q0  */
    const Word32 *sp,       /* i  : i   signal           : Q12 */
    const Word16 mode,      /* i  : i   mode             : Q0  */
    const Word16 extl,      /* i  : extension layer        : Q0  */
    Word16 *L_swb_norm,     /* o  : normalize length       : Q0  */
    Word16 *prev_L_swb_norm /*i/o : last normalize length  : Q0  */
);
void calc_norm_envelop_fx_32(
    const Word32 SWB_signal_fx[], /* i  : SWB spectrum           : Q12 */
    Word32 *envelope_fx,          /* o  : normalized envelope    : Q16 */
    const Word16 L_swb_norm,      /* i  : length of envelope     : Q0  */
    const Word16 SWB_flength,     /* i  : Length of i  /output : Q0  */
    const Word16 st_offset        /* i  : offset                 : Q0  */
);
void hq_generic_decoding_fx(
    const Word16 HQ_mode,             /* i  : HQ mode                                     */
    Word32 *coeff_out1_fx,            /* i/o: BWE i   & temporary buffer                */
    const Word16 *hq_generic_fenv_fx, /* i  : SWB frequency envelopes                     */
    Word32 *coeff_out_fx,             /* o  : SWB signal in MDCT domain                   */
    const Word16 hq_generic_offset,   /* i  : frequency offset for representing hq generic*/
    Word16 *prev_L_swb_norm,          /* i/o: last normalize length                       */
    const Word16 hq_generic_exc_clas, /* i  : bwe excitation class                        */
    const Word16 *R );
void save_old_syn_fx(
    const Word16 L_frame,     /* i  : frame length                */
    const Word16 syn[],       /* i  : ACELP synthesis             */
    Word16 old_syn[],         /* o  : old synthesis buffer        */
    Word16 old_syn_mem[],     /* i/o: old synthesis buffer memory */
    const Word16 preemph_fac, /* i  : preemphasis factor          */
    Word16 *mem_deemph        /* i/o: deemphasis filter memory    */
);
#endif
void find_td_envelope_fx(
    const Word16 inp[], /* i  : input signal                            Qx */
    const Word16 len,   /* i  : length of the input signal                 */
@@ -7287,7 +7180,9 @@ Word16 WB_BWE_gain_deq_fx(
    Word16 *WB_fenv       /*Q15*/
);
/* o : Q_syn_hb*/
Word16 wb_bwe_dec_fx(
#ifndef HARM_FD_BWE
    Word16 *synth_fx,            /* i/o: ACELP core synthesis/final synthesis   Q0/Qpost */
    Word16 *hb_synth_fx,         /* o  : SHB synthesis/final synthesis          Q_syn_hb */
    const Word16 output_frame,   /* i  : frame length                            */
@@ -7295,6 +7190,17 @@ Word16 wb_bwe_dec_fx(
    const Word16 pitch_buf_fx[], /* i  : pitch buffer                      Q6      */
    Decoder_State *st_fx,        /* i/o: decoder state structure                 */
    Word16 *Qpost );
#else
    Decoder_State *st_fx,           /* i/o: decoder state structure                 */
    Word32 output_fx32[],           /* o  : synthesis @internal Fs               Q11*/
    Word16 *synth_fx,               /* i/o: ACELP core synthesis/final synthesis   Q0/Qpost */
    Word16 *hb_synth_fx,            /* o  : SHB synthesis/final synthesis          Q_syn_hb */
    const Word16 use_cldfb_for_dft, /* i  : flag to use of CLDFB for DFT Stereo     */
    const Word16 output_frame,      /* i  : frame length                            */
    Word16 *voice_factors_fx,       /* i  : voicing factors                     Q15 */
    const Word16 pitch_buf_fx[],    /* i  : pitch buffer                         Q6 */
    Word16 *Qpost );
#endif
/* o  : BWE class */
Word16 swb_bwe_gain_deq_fx(
+59 −33
Original line number Diff line number Diff line
@@ -338,16 +338,13 @@ Word16 WB_BWE_gain_pred_fx(
 *
 * calc_envelope of low frequency spectrum
 *-------------------------------------------------------------------*/

static void calc_norm_envelop_lf_fx(
    const Word32 SWB_signal[],
    /* i  : SWB spectrum                                    */ /* Q12 */
    Word32 *envelope,
    /* o  : normalized envelope                             */ /* Q12 */
    const Word32 SWB_signal[],      /* i  : SWB spectrum                                 Q12 */
    Word32 *envelope,               /* o  : normalized envelope                          Q12 */
    Word16 *L_swb_norm,             /* i/o: length of envelope                               */
    const Word16 HQ_mode,
    /* i  : HQ mode                                         */ /* Q0 */
    const Word16 hq_generic_offset,
    /* i  : frequency offset for representing hq generic    */ /* Q0 */
    const Word16 HQ_mode,           /* i  : HQ mode                                       Q0 */
    const Word16 hq_generic_offset, /* i  : frequency offset for representing hq generic  Q0 */
    Word16 *sfreq,                  /* i  : starting frequency index                         */
    Word16 *efreq                   /* i  : ending frequency index                           */
)
@@ -423,6 +420,8 @@ static void calc_norm_envelop_lf_fx(

    return;
}


/*-------------------------------------------------------------------*
 * calc_normal_length()
 *
@@ -550,13 +549,15 @@ void calc_normal_length_fx(

    return;
}

/*-------------------------------------------------------------------*
 * calc_tilt_bwe()
 *
 * calculate tilt parameter
 *-------------------------------------------------------------------*/

Word32 calc_tilt_bwe_fx(                      /* o  : Tilt in Q24                      */
/* o  : Tilt in Q24  */
Word32 calc_tilt_bwe_fx(
    const Word16 *sp,    /* i  : input signal     Q(15 - exp_sp)  */
    const Word16 exp_sp, /* i  : Exp of inp signal                */
    const Word16 N       /* i  : signal length                    */
@@ -645,7 +646,10 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24

    return L_temp;
}
Word16 ivas_calc_tilt_bwe_fx(                      /* o  : Tilt in Q24                        */


/* o  : Tilt in Q24 */
Word16 calc_tilt_bwe_fx_32(
    const Word32 *sp,    /* i  : input signal                       */
    const Word16 exp_sp, /* i  : Exp of inp signal   Q(15 - exp_sp) */
    const Word16 N       /* i  : signal length                      */
@@ -814,6 +818,7 @@ void calc_norm_envelop_fx(
/*--------------------------------------------------------------------------*/
/* CALLED FROM :                                                            */
/*==========================================================================*/

void WB_BWE_decoding_fx(
    const Word16 *core_dec_freq, /* i  : Frequency domain core decoded signal */
    Word16 *WB_fenv,             /* i  : WB frequency envelopes               */
@@ -1938,7 +1943,9 @@ return;
/* RETURN ARGUMENTS :                                                       */
/*   _ None                                                                 */
/*--------------------------------------------------------------------------*/

void time_envelop_shaping_fx(
#ifndef HARM_FD_BWE
    Word16 werr[],     /* i/o: SHB synthesis           Q_synth*/
    Word32 SWB_tenv[], /* i/o: frequency envelope          Q15*/
    const Word16 L,    /* i  : frame length                   */
@@ -2018,6 +2025,9 @@ void time_envelop_shaping_fx(
}

void time_envelop_shaping_ivas_fx(
#else
    const Word16 element_mode, /* i  : element mode                   */
#endif
    Word16 werr[],     /* i/o: SHB synthesis           Q_synth*/
    Word32 SWB_tenv[], /* i/o: frequency envelope          Q15*/
    const Word16 L,    /* i  : frame length                   */
@@ -2034,7 +2044,22 @@ void time_envelop_shaping_ivas_fx(
    pit = werr;
    exp_L = norm_s( L );
    inv_L = div_s( shl( 1, sub( 14, exp_L ) ), L ); /*Q(29-exp_L) */

    FOR( i = 0; i < SWB_TENV; i++ )
    {
#ifdef HARM_FD_BWE
        IF( element_mode == EVS_MONO )
        {
            Energy = L_deposit_l( 0 );
            FOR( j = 0; j < L / 4; j++ )
            {
                Energy = L_mac0_sat( Energy, *pit, *pit ); /*(2*Q_synth) */
                pit++;
            }
            Energy_Q = shl( ( *Q_synth ), 1 );
        }
        ELSE
#endif
        {
            Energy_64 = L_deposit_l( 0 );
            FOR( j = 0; j < L / 4; j++ )
@@ -2046,19 +2071,20 @@ void time_envelop_shaping_ivas_fx(
            Energy_64 = W_shl( Energy_64, w_tmp );
            Energy = W_extract_h( Energy_64 ); /*2*Q_synth + w_tmp -32*/
            Energy_Q = sub( add( shl( ( *Q_synth ), 1 ), w_tmp ), 32 );
        }

        Energy = Mult_32_16( Energy, inv_L ); /*Q(29-exp_L-15) -> Q(-exp_L+14+2*Q_synth+w_tmp-32) */
        Energy_16 = 0;
        move16();
        /*exp = 31-(-exp_L+14 +(2*(*Q_synth)+w_tmp-32)); */
        /*exp = 31-(-exp_L+14+Energy_Q); */
        exp = sub( 17, sub( Energy_Q, exp_L ) );

        IF( Energy != 0 )
        {
            exp = norm_l( Energy );
            frac = extract_h( L_shl( Energy, exp ) );
            /*exp = sub(exp, 30-(-exp_L+14-2+(2*(*Q_synth)+w_tmp-32)));  */
            /*exp = sub(exp, 30-(-exp_L+14-2+Energy_Q));  */
            exp = sub( exp, sub( 30, add( sub( Energy_Q, exp_L ), 14 - 2 ) ) );

            tmp = div_s( 16384, frac );
            L_tmp = L_deposit_h( tmp );
            Energy = Isqrt_lc( L_tmp, &exp );                        /*Q(31-exp) */
+4 −0
Original line number Diff line number Diff line
@@ -370,7 +370,11 @@ ivas_error evs_dec_fx(
        ELSE IF( EQ_16( st_fx->extl, WB_BWE ) && st_fx->bws_cnt == 0 )
        {
            /* WB BWE decoder */
#ifdef HARM_FD_BWE
            hb_synth_fx_exp = wb_bwe_dec_fx( st_fx, NULL, synth_fx, hb_synth_fx, 0, output_frame, voice_factors_fx, pitch_buf_fx, &Qpostd ); /*Q0*/
#else
            hb_synth_fx_exp = wb_bwe_dec_fx( synth_fx, hb_synth_fx, output_frame, voice_factors_fx, pitch_buf_fx, st_fx, &Qpostd ); /*Q0*/
#endif
        }

        /*---------------------------------------------------------------------*
Loading