Commit 49bc936e authored by Fabian Bauer's avatar Fabian Bauer
Browse files

added macro and code HARMONIZE_2567_init_tcx

parent ed470042
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@
#define FIX_1585_ASAN_FORMAT_SW_ALT                     /* VA: float issue 1585: alternative fix memory leaks with format switching */
#define HARMONIZE_2567_init_acelp                       /* FhG: harmonize init_acelp derivates for evs/ivas  */
#define HARMONIZE_2567_init_tcx_cfg                     /* FhG: harmonize init_tcx_cfg derivates for evs/ivas  */

#define HARMONIZE_2567_init_tcx                         /* FhG: harmonize init_tcx derivates for evs/ivas  */
/* #################### End BE switches ################################## */

/* #################### Start NON-BE switches ############################ */
+153 −28
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@
 * Local functions
 *-----------------------------------------------------------------------*/

#ifndef HARMONIZE_2567_init_tcx
static void init_tcx_fx( Encoder_State *st, Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag );
#endif
static void init_core_sig_ana_fx( Encoder_State *st );
#ifdef HARMONIZE_2567_init_acelp
static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 shift, const Word32 last_total_brate );
@@ -28,7 +30,11 @@ static void init_acelp_fx( Encoder_State *st, Word16 L_frame_old, const Word16 s
#endif
static void init_modes_fx( Encoder_State *st, const Word32 Last_total_brate );
static void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr );
#ifdef HARMONIZE_2567_init_tcx
static void init_tcx_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag );
#else
static void init_tcx_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word32 total_brate, const Word32 last_total_brate, const Word16 MCT_flag );
#endif
static void init_core_sig_ana_ivas_fx( Encoder_State *st );
static void init_modes_ivas_fx( Encoder_State *st, const Word32 last_total_brate );
static void init_sig_buffers_ivas_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr, const Word32 last_total_brate );
@@ -288,6 +294,7 @@ void init_coder_ace_plus_fx(
    return;
}

#ifndef HARMONIZE_2567_init_tcx
static void init_tcx_fx(
    Encoder_State *st,
    Word16 L_frame_old,
@@ -447,6 +454,7 @@ static void init_tcx_fx(
    hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode );
    move16();
}
#endif

void init_sig_buffers_fx( Encoder_State *st, const Word16 L_frame_old, const Word16 L_subfr )
{
@@ -1093,7 +1101,11 @@ void init_coder_ace_plus_ivas_fx(
    /* Initialize TCX */
    IF( hTcxEnc != NULL )
    {
#ifdef HARMONIZE_2567_init_tcx
        init_tcx_fx( st, L_frame_old, st->total_brate, last_total_brate, MCT_flag );
#else
        init_tcx_ivas_fx( st, L_frame_old, st->total_brate, last_total_brate, MCT_flag );
#endif
    }

    /* Initialize Signal Buffers */
@@ -1215,7 +1227,11 @@ void init_coder_ace_plus_ivas_fx(
 *-----------------------------------------------------------------------*/


#ifdef HARMONIZE_2567_init_tcx
static void init_tcx_fx(
#else
static void init_tcx_ivas_fx(
#endif
    Encoder_State *st,
    const Word16 L_frame_old,
    const Word32 total_brate,
@@ -1223,7 +1239,40 @@ static void init_tcx_ivas_fx(
    const Word16 MCT_flag )
{
    TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
#ifdef HARMONIZE_2567_init_tcx
    Word16 i;
    Word16 fscaleFB;

    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        fscaleFB = div_l( L_shl( st->input_Fs, LD_FSCALE_DENOM + 1 ), 12800 );

        init_TCX_config( st->hTcxCfg, st->L_frame, st->fscale, hTcxEnc->L_frameTCX, fscaleFB );

        st->hTcxCfg->tcx_mdct_window_length_old = st->hTcxCfg->tcx_mdct_window_length;
        move16();

        /* TCX Offset */
        st->hTcxCfg->tcx_offset = shr( st->hTcxCfg->tcx_mdct_window_delay, 1 );
        move16();
        st->hTcxCfg->tcx_offsetFB = shr( st->hTcxCfg->tcx_mdct_window_delayFB, 1 );
        move16();

        /*<0 rectangular transition with optimized window size = L_frame+L_frame/4*/
        st->hTcxCfg->lfacNext = sub( st->hTcxCfg->tcx_offset, shr( st->L_frame, 2 ) );
        move16();
        st->hTcxCfg->lfacNextFB = sub( st->hTcxCfg->tcx_offsetFB, shr( hTcxEnc->L_frameTCX, 2 ) );
        move16();
        IF( st->ini_frame == 0 )
        {
            st->hTcxCfg->tcx_curr_overlap_mode = st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW;
            move16();
            move16();
        }
    }
    ELSE
#endif
    {
        /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */
        hTcxEnc->spectrum_fx[0] = hTcxEnc->spectrum_long_fx;
        hTcxEnc->spectrum_fx[1] = hTcxEnc->spectrum_long_fx + N_TCX10_MAX;
@@ -1239,6 +1288,7 @@ static void init_tcx_ivas_fx(
                              st->fscale, st->preemph_fac, st->tcxonly, st->rf_mode, st->igf,
                              st->hIGFEnc != NULL ? st->hIGFEnc->infoStopFrequency : 0, st->element_mode, st->ini_frame, MCT_flag );
#endif
    }

    /* Init TCX target bits correction factor */
    hTcxEnc->tcx_target_bits_fac = 0x4000; /*1.0f in 1Q14*/
@@ -1249,9 +1299,59 @@ static void init_tcx_ivas_fx(
    move16();
    hTcxEnc->noiseLevelMemory_cnt = 0;
    move16();
#ifdef HARMONIZE_2567_init_tcx
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        /*SQ deadzone & memory quantization*/

        /*0.375f: deadzone of 1.25->rounding=1-1.25/2 (No deadzone=0.5)*/
        st->hTcxCfg->sq_rounding = 12288 /*0.375f Q15*/;
        move16();

        FOR( i = 0; i < L_FRAME_PLUS; i++ )
        {
            hTcxEnc->memQuantZeros[i] = 0;
            move16();
        }

        /* TCX rate loop */
        st->hTcxCfg->tcxRateLoopOpt = 0;
        move16();

        if ( st->tcxonly != 0 )
        {
            st->hTcxCfg->tcxRateLoopOpt = 2;
            move16();
        }

        /* TCX bandwidth */
        move16();
        st->hTcxCfg->bandwidth = getTcxBandwidth( st->bwidth );


        /* set number of coded lines */
        st->hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( st->bwidth );

        /* TNS in TCX */
        move16();
        move16();
        st->hTcxCfg->fIsTNSAllowed = (Word8) getTnsAllowed( st->total_brate, st->igf, st->element_mode );

        st->hTcxCfg->pCurrentTnsConfig = NULL;

        IF( st->hTcxCfg->fIsTNSAllowed != 0 )
        {
            InitTnsConfigs_fx( st->bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFEnc->infoStopFrequency, st->total_brate, st->element_mode, 0 /*is_mct*/ );
        }
    }
    ELSE
    {
#endif
        set16_fx( hTcxEnc->ltpGainMemory_fx, 0, N_LTP_GAIN_MEMS );
        set8_fx( hTcxEnc->memQuantZeros, 0, L_FRAME_PLUS );
#ifdef HARMONIZE_2567_init_tcx
    }
#endif

    /* TCX-LTP */
    hTcxEnc->tcxltp = getTcxLtp( st->sr_core );
@@ -1267,6 +1367,11 @@ static void init_tcx_ivas_fx(
        hTcxEnc->tcxltp_pitch_fr_past = 0;
        hTcxEnc->tcxltp_gain_past = 0;
        hTcxEnc->tcxltp_norm_corr_past = 0;
        move16();
#ifdef HARMONIZE_2567_init_tcx
        IF( GT_16( st->element_mode, EVS_MONO ) )
        {
#endif
            hTcxEnc->tcxltp_norm_corr_mem = 0;
            hTcxEnc->kernel_switch_corr_past = 0;
            hTcxEnc->kernel_symmetry_past = 0; /* MDCT_IV & 1 */
@@ -1281,7 +1386,9 @@ static void init_tcx_ivas_fx(
            move16();
            move16();
            move16();
        move16();
#ifdef HARMONIZE_2567_init_tcx
        }
#endif
        move16();
    }
    ELSE IF( NE_16( st->L_frame, L_frame_old ) && !( ( GE_32( total_brate, ACELP_16k40 ) && LE_32( total_brate, ACELP_24k40 ) ) &&
@@ -1320,6 +1427,24 @@ static void init_tcx_ivas_fx(
        move16();
    }

#ifdef HARMONIZE_2567_init_tcx
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        /* Residual Coding*/
        st->hTcxCfg->resq = getResq( st->total_brate );
        move16();

        test();
        if ( st->hTcxCfg->resq != 0 && st->tcxonly == 0 )
        {
            st->hTcxCfg->tcxRateLoopOpt = 1;
            move16();
        }

        st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, st->total_brate, st->rf_mode );
        move16();
    }
#endif
    hTcxEnc->tcx_lpc_shaped_ari = getTcxLpcShapedAri( st->total_brate, st->rf_mode, st->element_mode );
    move16();