Commit eac680a1 authored by vaclav's avatar vaclav
Browse files

updt

parent 658ece77
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5775,6 +5775,7 @@ void swb_tbe_dec_fx(
    Word16 *Q_synth,
    Word16 *pitch_buf );
#ifndef HARM_BWE
void ivas_dequantizeSHBparams_fx_9_1(
    Decoder_State *st_fx,
    const Word16 extl,        /* i  : extension layer                 */
@@ -5787,7 +5788,7 @@ void ivas_dequantizeSHBparams_fx_9_1(
    Word16 *Q_shb_res_gshape, /* o  : Q14                                         */
    Word16 *Q_mixFactors,     /* o  : Q15                                         */
    Word16 *MSFlag );
#endif
void fb_tbe_dec_fx(
#ifndef HARM_BWE
    Decoder_State *st,     /* i/o: encoder state structure                 */
+57 −29
Original line number Diff line number Diff line
@@ -2,22 +2,23 @@
    EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0
  ====================================================================================*/


#include <stdlib.h>
#include "options.h"
#include "rom_com.h"
#include "prot_fx.h"
#include "rom_dec.h"
#include "stl.h"

#include "ivas_prot_fx.h"

/*-----------------------------------------------------------------*
 * Local functions
 *-----------------------------------------------------------------*/

#ifdef HARM_BWE
static void dequantizeSHBparams_fx( Decoder_State *st_fx, const Word16 extl, Word32 extl_brate, Word16 *Q_lsf, Word16 *Q_subgain, Word32 *Q_framegrain, Word16 *uv_flag, Word32 *Q_shb_ener_sf_32, Word16 *Q_shb_res_gshape, Word16 *Q_mixFactors, Word16 *MSFlag );
#else
static void dequantizeSHBparams_fx_9_1( Decoder_State *st_fx, const Word16 extl, Word32 extl_brate, Word16 *Q_lsf, Word16 *Q_subgain, Word32 *Q_framegrain, Word16 *uv_flag, Word32 *Q_shb_ener_sf_32, Word16 *Q_shb_res_gshape, Word16 *Q_mixFactors );

#endif
static void find_max_mem_dec( Decoder_State *st_fx, Word16 *n_mem, Word16 *n_mem2, Word16 *n_mem3 );
static void rescale_genSHB_mem_dec( Decoder_State *st_fx, Word16 sf );
static void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem );
@@ -27,15 +28,15 @@ static void Map_higher_LSF_fx( Word16 lsf_q[], const Word16 m, const Word16 grid
static void Dequant_mirror_point_fx( const Word16 lsf_q[], const Word16 m_idx, Word16 *m );
static Word16 dotp_loc( const Word16 x[], const Word32 y[], const Word16 n );
static void find_max_mem_dec_m3( Decoder_State *st, Word16 *n_mem3 );

/* gain shape concealment code */
static void gradientGainShape( Decoder_State *st_fx, Word16 *GainShape, Word32 *GainFrame );


/*-------------------------------------------------------------------*
 * find_max_mem_dec()
 *
 * Find norm and max in TBE memories and past buffers
 *-------------------------------------------------------------------*/

static void find_max_mem_dec(
    Decoder_State *st_fx,
    Word16 *n_mem,
@@ -219,14 +220,17 @@ static void find_max_mem_dec(
                                                       because of the Hilber transform and Q14 coeffs */
    *n_mem3 = s_max( tempQ15, 0 );
    move16();
    /* --------------------------------------------------------------*/

    return;
}


/*-------------------------------------------------------------------*
 * rescale_genSHB_mem_dec()
 *
 * Rescale genSHB memories
 *-------------------------------------------------------------------*/

static void rescale_genSHB_mem_dec(
    Decoder_State *st_fx,
    Word16 sf )
@@ -276,9 +280,13 @@ static void rescale_genSHB_mem_dec(
    move16();
    hBWE_TD->tbe_premph_fx = shl_r( hBWE_TD->tbe_premph_fx, sf );
    move16();

    return;
}

void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )
static void find_max_mem_wb(
    Decoder_State *st_fx,
    Word16 *n_mem )
{
    Word16 i;
    Word16 max = 0;
@@ -311,21 +319,18 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )

    FOR( i = 0; i < 7; i++ )
    {

        if ( GT_16( abs_s( hBWE_TD->mem_genSHBexc_filt_down_wb3_fx[i] ), max ) )
            max = abs_s( hBWE_TD->mem_genSHBexc_filt_down_wb3_fx[i] );
    }

    FOR( i = 0; i < 10; i++ )
    {

        if ( GT_16( abs_s( hBWE_TD->state_lpc_syn_fx[i] ), max ) )
            max = abs_s( hBWE_TD->state_lpc_syn_fx[i] );
    }

    FOR( i = 0; i < 5; i++ )
    {

        if ( GT_16( abs_s( hBWE_TD->state_syn_shbexc_fx[i] ), max ) )
            max = abs_s( hBWE_TD->state_syn_shbexc_fx[i] );
    }
@@ -341,10 +346,8 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )
        move16();
    }


    FOR( i = 0; i < 2; i++ )
    {

        if ( GT_32( L_abs( hBWE_TD->mem_csfilt_fx[i] ), Lmax ) )
            Lmax = L_abs( hBWE_TD->mem_csfilt_fx[i] );
    }
@@ -363,9 +366,14 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem )
    move16();
    *n_mem = s_max( *n_mem, 0 );
    move16();

    return;
}

void rescale_genWB_mem( Decoder_State *st_fx, Word16 sf )

static void rescale_genWB_mem(
    Decoder_State *st_fx,
    Word16 sf )
{
    Word16 i;
    TD_BWE_DEC_HANDLE hBWE_TD;
@@ -640,8 +648,10 @@ void ivas_wb_tbe_dec_fx(
    Word16 f, inc;
    Word64 W_tmp;
    TD_BWE_DEC_HANDLE hBWE_TD;

    hBWE_TD = st_fx->hBWE_TD;
    set32_fx( &dummy2[0], 0, HILBERT_MEM_SIZE );

    IF( st_fx->bws_cnt == 0 )
    {
        /* Initialization */
@@ -756,17 +766,13 @@ void ivas_wb_tbe_dec_fx(
            ELSE
            {
#ifdef HARM_BWE
                IF( st_fx->element_mode == EVS_MONO )
                {
                    dequantizeSHBparams_fx_9_1( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0 );
                }
                ELSE
                {
#endif
                /* de-quantization */
                dequantizeSHBparams_fx( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0, &j /*temp*/ );
#else
                /* de-quantization */
                Word16 ignore;
                ivas_dequantizeSHBparams_fx_9_1( st_fx, st_fx->extl, st_fx->extl_brate, lsf_wb, GainShape, &GainFrame, &uv_flag, 0, 0, 0, &ignore );
                }
#endif
            }
        }
        ELSE
@@ -2328,10 +2334,14 @@ void swb_tbe_dec_fx(
            }
            ELSE
            {

                /* de-quantization */
#ifdef HARM_BWE
                dequantizeSHBparams_fx( st_fx, st_fx->extl, st_fx->extl_brate, lsf_shb, GainShape, &GainFrame, &stemp,
                                        &shb_ener_sf_32, shb_res_gshape, &mixFactors, &j /*temp*/ );
#else
                dequantizeSHBparams_fx_9_1( st_fx, st_fx->extl, st_fx->extl_brate, lsf_shb, GainShape, &GainFrame, &stemp,
                                            &shb_ener_sf_32, shb_res_gshape, &mixFactors );
#endif
                Q_shb = 0;
                move16();
                /* o: shb_ener_sf_32 in (2*Q_shb) */
@@ -3985,6 +3995,7 @@ static Word16 dotp_loc(
    Word16 i;
    Word32 suma;
    Word16 guarded_bits = find_guarded_bits_fx( n );

    suma = L_shr( Mpy_32_16_1( y[0], x[0] ), guarded_bits ); /*Qx + Qy - guarded_bits*/

    FOR( i = 1; i < n; i++ )
@@ -3996,7 +4007,18 @@ static Word16 dotp_loc(
    return extract_h( suma ); /*Qx + Qy - 16*/
}


/*-------------------------------------------------------------------*
 * dequantizeSHBparams()
 *
 * Dequantize super highband spectral envolope, temporal gains and frame gain
 *-------------------------------------------------------------------*/

#ifdef HARM_BWE
static void dequantizeSHBparams_fx(
#else
void ivas_dequantizeSHBparams_fx_9_1(
#endif
    Decoder_State *st_fx,
    const Word16 extl,        /* i  : extension layer                             */
    Word32 extl_brate,        /* i  : extensiuon layer bitrate                    */
@@ -4428,7 +4450,7 @@ void ivas_dequantizeSHBparams_fx_9_1(
    return;
}


#ifndef HARM_BWE
/*==========================================================================*/
/* FUNCTION      : static void dequantizeSHBparams_fx_9_1 ()        */
/*--------------------------------------------------------------------------*/
@@ -4747,6 +4769,7 @@ static void dequantizeSHBparams_fx_9_1(

    return;
}
#endif

/*-------------------------------------------------------------------*
 * fb_tbe_dec()
@@ -5935,8 +5958,13 @@ void ivas_swb_tbe_dec_fx(
            ELSE
            {
                /* de-quantization */
#ifdef HARM_BWE
                dequantizeSHBparams_fx( st, st->extl, st->extl_brate, lsf_shb_fx, GainShape_fx, &GainFrame_fx, &stemp,
                                        &shb_ener_sf_32, shb_res_gshape_fx, &mixFactors_fx, &MSFlag );
#else
                ivas_dequantizeSHBparams_fx_9_1( st, st->extl, st->extl_brate, lsf_shb_fx, GainShape_fx, &GainFrame_fx, &stemp,
                                                 &shb_ener_sf_32, shb_res_gshape_fx, &mixFactors_fx, &MSFlag );
#endif
                if ( hStereoICBWE != NULL )
                {
                    hStereoICBWE->MSFlag = MSFlag;
+14 −9
Original line number Diff line number Diff line
@@ -79,9 +79,6 @@ ivas_error evs_enc_fx(
#endif
    ivas_error error;
    SC_VBR_ENC_HANDLE hSC_VBR = st->hSC_VBR;
    // NOISE_EST_HANDLE hNoiseEst = st->hNoiseEst;
    // VAD_HANDLE hVAD = st->hVAD;
    // DTX_ENC_HANDLE  hDtxEnc = st->hDtxEnc;
    TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc;
    LPD_state_HANDLE hLPDmem = st->hLPDmem;
    TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD;
@@ -95,7 +92,6 @@ ivas_error evs_enc_fx(
    Q_shb_spch = 0;
    move16(); /* to avoid compiler warnings */


    /*------------------------------------------------------------------*
     * Initializiation
     *-----------------------------------------------------------------*/
@@ -176,19 +172,19 @@ ivas_error evs_enc_fx(
    /*---------------------------------------------------------------------*
     * Pre-processing
     *---------------------------------------------------------------------*/

#ifdef FIX_I4_OL_PITCH
    pre_proc( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, A, Aw, epsP, lsp_new, lsp_mid, &vad_hover_flag, &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &hq_core_type );
    pre_proc_fx( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener, A, Aw, epsP_h, epsP_l, epsP, lsp_new, lsp_mid, &vad_hover_flag,
                 &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &cldfbScale, hLPDmem->old_exc, &hq_core_type, &Q_new, &shift, Q_r );
#else
    pre_proc_fx( st, input_frame, old_inp_12k8, old_inp_16k, &inp, fr_bands, &Etot, &ener,
                 pitch_orig, A, Aw, epsP_h, epsP_l, epsP, lsp_new, lsp_mid, &vad_hover_flag,
                 &attack_flag, new_inp_resamp16k, &Voicing_flag, realBuffer, imagBuffer, &cldfbScale, hLPDmem->old_exc,
                 &hq_core_type, &Q_new, &shift, Q_r );
#endif
    // st->sharpFlag = sharpFlag;

    IF( EQ_16( st->mdct_sw, MODE2 ) )
    {

        Mpy_32_16_ss( st->total_brate, 5243, &L_tmp, &lsb );     /* 5243 is 1/50 in Q18. (0+18-15=3) */
        st->bits_frame_nominal = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */

@@ -271,6 +267,7 @@ ivas_error evs_enc_fx(
            acelp_core_enc_fx( st, inp, ener, A, Aw, epsP_h, epsP_l, lsp_new, lsp_mid, vad_hover_flag,
                               attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, Q_new, shift );
        }

        /*---------------------------------------------------------------------*
         * HQ core encoding
         *---------------------------------------------------------------------*/
@@ -283,6 +280,7 @@ ivas_error evs_enc_fx(
        /*---------------------------------------------------------------------*
         * Postprocessing for ACELP/HQ core switching
         *---------------------------------------------------------------------*/

        core_switching_post_enc_fx( st, old_inp_12k8, old_inp_16k, A, shift, Q_new, st->Q_syn2, &Q_synth );
#ifndef FIX_I4_OL_PITCH
        IF( EQ_16( st->core, HQ_CORE ) )
@@ -447,6 +445,7 @@ ivas_error evs_enc_fx(
     * SWB(FB) TBE encoding
     * SWB BWE encoding
     *---------------------------------------------------------------------*/

    test();
    IF( !st->Opt_SC_VBR && GE_32( st->input_Fs, 32000 ) )
    {
@@ -476,7 +475,11 @@ ivas_error evs_enc_fx(
            IF( EQ_16( st->extl, FB_TBE ) )
            {
                /* FB TBE encoder */
#ifdef HARM_BWE
                fb_tbe_enc_fx( st, st->input_fx, fb_exc, Q_fb_exc, 0 );
#else
                fb_tbe_enc_fx( st, st->input_fx, fb_exc, Q_fb_exc );
#endif
            }

            IF( EQ_16( st->codec_mode, MODE2 ) )
@@ -649,9 +652,11 @@ static void initFrameHeader_loc( Encoder_State *st )
 *
 * Write MODE2 frame header
 *-------------------------------------------------------------------*/
static void writeFrameHeader_loc( Encoder_State *st )
{

static void writeFrameHeader_loc(
    Encoder_State *st /* i/o: encoder state structure   */
)
{
    BSTR_ENC_HANDLE hBstr = st->hBstr;

    IF( NE_32( st->core_brate, FRAME_NO_DATA ) )
+4 −0
Original line number Diff line number Diff line
@@ -786,7 +786,11 @@ ivas_error ivas_core_enc_fx(
                IF( EQ_16( st->extl, FB_TBE ) )
                {
                    /* FB TBE encoder */
#ifdef HARM_BWE
                    fb_tbe_enc_fx( st, st->input_fx, fb_exc_fx, Q_fb_exc, st->q_inp );
#else
                    fb_tbe_enc_ivas_fx( st, st->input_fx, fb_exc_fx, Q_fb_exc, st->q_inp );
#endif
                }
            }
        }
+5 −3
Original line number Diff line number Diff line
@@ -159,12 +159,14 @@ Word16 dtx_hangover_addition_fx(
    Word16 *rem_dtx_ho );

void fb_tbe_enc_fx(
#ifndef HARM_BWE
    Encoder_State *st,        /* i/o: encoder state structure               */
    const Word16 new_input[], /* i  : i   speech at 48 kHz sample rate      */
    const Word16 fb_exc[],    /* i  : FB excitation from the SWB part       */
    const Word16 Q_fb_exc );

void fb_tbe_enc_ivas_fx(
#endif
    Encoder_State *st,        /* i/o: encoder state structure                         */
    const Word16 new_input[], /* i  : i   speech at 48 kHz sample rate     Q_new_input*/
    const Word16 fb_exc[],    /* i  : FB excitation from the SWB part         Q_fb_exc*/
Loading