Commit fcb3d0eb authored by vaclav's avatar vaclav
Browse files

harmonize TD BSE

parent b6b0a12f
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -6004,13 +6004,9 @@ Word32 calc_gain_inov( /* returns innovation gain
/*              Lib_dec         */
//////////////////////////////////
// swb_tbe_dec.c
void InitSWBdecBuffer_fx(
    Decoder_State *swb_dnc_fx /* i/o: SHB decoder structure                   */
);
void ResetSHBbuffer_Dec_fx(
    Decoder_State *st_fx /* i/o: decoder state structure     */
    TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle      */
    const Word16 extl          /* i  : BWE extension layer     */
);
void wb_tbe_dec_fx(
    Decoder_State *st_fx,     /* i/o: decoder state structure                */
+4 −2
Original line number Diff line number Diff line
@@ -1717,7 +1717,7 @@ static void shb_CNG_decod_fx(
        interpolate_3_over_2_allpass_fx( shb_synth_fx, L_FRAME32k, shb_synth_fx, hTdCngDec->interpol_3_2_cng_dec_fx, allpass_poles_3_ov_2 );
    }

    ResetSHBbuffer_Dec_fx( st_fx );
    ResetSHBbuffer_Dec_fx( st_fx->hBWE_TD, st_fx->extl );

    return;
}
@@ -1994,7 +1994,9 @@ static void shb_CNG_decod_ivas_fx(
    }

    Scale_sig( shb_synth_fx, L_FRAME48k, -3 ); /* Qx - 3 */
    ResetSHBbuffer_Dec_fx( st );

    ResetSHBbuffer_Dec_fx( st->hBWE_TD, st->extl );

    return;
}

+4 −4
Original line number Diff line number Diff line
@@ -1202,7 +1202,7 @@ ivas_error core_switching_post_dec_fx(
        swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx,
                          hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) );

        set16_fx( st_fx->GainShape_Delay, 0, NUM_SHB_SUBFR / 2 );
        set16_fx( hBWE_TD->GainShape_Delay_fx, 0, NUM_SHB_SUBFR / 2 );
        swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32 );

        IF( EQ_16( output_frame, L_FRAME16k ) )
@@ -1843,11 +1843,11 @@ ivas_error core_switching_post_dec_ivas_fx(
            swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx,
                              hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) );

            set16_fx( st_fx->GainShape_Delay, 0, NUM_SHB_SUBFR / 2 );
            set16_fx( hBWE_TD->GainShape_Delay_fx, 0, NUM_SHB_SUBFR / 2 );
            swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32 );

            st_fx->hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */
            st_fx->hBWE_TD->prev_mix_factor_fx = 32767;    /* Q15 1.f */
            hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */
            hBWE_TD->prev_mix_factor_fx = 32767;    /* Q15 1.f */
            move16();
            move16();

+0 −4
Original line number Diff line number Diff line
@@ -1300,7 +1300,6 @@ typedef struct Decoder_State
    Word16 Last_GSC_noisy_speech_flag; /* AC mode (GSC) - mem of the past flag to indicate GSC osn SWB noisy speech */
    GSC_DEC_HANDLE hGSCDec;


    Word32 gc_threshold_fx;  /* Noise enhancer - threshold for gain_code Q16*/
    struct dispMem_fx dm_fx; /* Noise enhancer - phase dispersion algorithm memory */

@@ -1524,9 +1523,6 @@ typedef struct Decoder_State
    Word16 prev_fb_ener_adjust_fx;
    Word16 prev_lpc_wb_fx[LPC_SHB_ORDER_WB];

    // in FLP, the folowing one is part of TD_BWE_DEC_HANDLE
    Word16 GainShape_Delay[NUM_SHB_SUBFR / 2];

    /*----------------------------------------------------------------------------------*
     * SWB BWE structure
     *----------------------------------------------------------------------------------*/
+26 −22
Original line number Diff line number Diff line
@@ -411,10 +411,12 @@ void rescale_genWB_mem( Decoder_State *st_fx, Word16 sf )
        hBWE_TD->mem_csfilt_fx[i] = L_shl( hBWE_TD->mem_csfilt_fx[i], sf );
        move32();
    }

    return;
}


void InitSWBdecBuffer_fx(
static void InitSWBdecBuffer_fx(
    Decoder_State *st_fx /* i/o: SHB decoder structure */
)
{
@@ -461,15 +463,16 @@ void InitSWBdecBuffer_fx(
}


void ResetSHBbuffer_Dec_fx( Decoder_State *st_fx /* i/o: SHB encoder structure */ )
void ResetSHBbuffer_Dec_fx(
    TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle      */
    const Word16 extl          /* i  : BWE extension layer     */
)
{
    Word16 i;
    Word16 f;
    Word16 inc;
    TD_BWE_DEC_HANDLE hBWE_TD;
    hBWE_TD = st_fx->hBWE_TD;

    IF( NE_16( st_fx->extl, WB_TBE ) )
    IF( NE_16( extl, WB_TBE ) )
    {
        f = 1489;
        move16(); /* Q15 */
@@ -491,7 +494,7 @@ void ResetSHBbuffer_Dec_fx( Decoder_State *st_fx /* i/o: SHB encoder structure *
    set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD );
    set16_fx( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER );

    IF( EQ_16( st_fx->extl, FB_TBE ) )
    IF( EQ_16( extl, FB_TBE ) )
    {
        set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER );
        hBWE_TD->fb_tbe_demph_fx = 0;
@@ -514,7 +517,7 @@ void ResetSHBbuffer_Dec_fx( Decoder_State *st_fx /* i/o: SHB encoder structure *

    /* States for FEC */

    IF( NE_16( st_fx->extl, WB_TBE ) )
    IF( NE_16( extl, WB_TBE ) )
    {
        FOR( i = 0; i < LPC_SHB_ORDER; i++ )
        {
@@ -550,7 +553,7 @@ void ResetSHBbuffer_Dec_fx( Decoder_State *st_fx /* i/o: SHB encoder structure *
    set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER );
    hBWE_TD->gain_prec_swb_fx = 16384; /*Q14 =1*/
    move16();
    set16_fx( &st_fx->GainShape_Delay[0], 0, NUM_SHB_SUBFR / 2 );
    set16_fx( hBWE_TD->GainShape_Delay_fx, 0, NUM_SHB_SUBFR / 2 );
    hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */
    move32();
    hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 1.f*/
@@ -2224,7 +2227,7 @@ void swb_tbe_dec_fx(
                {
                    FOR( j = 0; j < 4; j++ )
                    {
                        GainShape[add( i * 4, j )] = mult_r( st_fx->cummulative_damping, st_fx->GainShape_Delay[4 + i] );
                        GainShape[add( i * 4, j )] = mult_r( st_fx->cummulative_damping, hBWE_TD->GainShape_Delay_fx[4 + i] );
                        move16();
                    }
                }
@@ -2329,13 +2332,13 @@ void swb_tbe_dec_fx(
    }

    /* get the gainshape delay */
    Copy( &st_fx->GainShape_Delay[4], &st_fx->GainShape_Delay[0], NUM_SHB_SUBFR / 4 );
    Copy( &hBWE_TD->GainShape_Delay_fx[4], &hBWE_TD->GainShape_Delay_fx[0], NUM_SHB_SUBFR / 4 );
    test();
    IF( ( st_fx->rf_flag != 0 ) || EQ_32( st_fx->total_brate, ACELP_9k60 ) )
    {
        FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ )
        {
            st_fx->GainShape_Delay[i + 4] = s_min( s_max( GainShape[i * 4], 3277 /*0.1f Q15*/ ), 16384 /*0.5f Q15*/ );
            hBWE_TD->GainShape_Delay_fx[i + 4] = s_min( s_max( GainShape[i * 4], 3277 /*0.1f Q15*/ ), 16384 /*0.5f Q15*/ );
            move16();
        }
    }
@@ -2343,7 +2346,7 @@ void swb_tbe_dec_fx(
    {
        FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ )
        {
            st_fx->GainShape_Delay[i + 4] = GainShape[i * 4];
            hBWE_TD->GainShape_Delay_fx[i + 4] = GainShape[i * 4];
            move16();
        }
    }
@@ -3557,9 +3560,9 @@ static void gradientGainShape(
    /* the previous frame gainshape gradient and the gainshape gradient pattern for the current frame */
    FOR( j = 0; j < 3; j++ )
    {
        GainGrad0[j] = sub( shr( st_fx->GainShape_Delay[j + 1], 1 ), shr( st_fx->GainShape_Delay[j], 1 ) );
        GainGrad0[j] = sub( shr( hBWE_TD->GainShape_Delay_fx[j + 1], 1 ), shr( hBWE_TD->GainShape_Delay_fx[j], 1 ) );
        move16(); /* Q14 */
        GainGrad1[j] = sub( shr( st_fx->GainShape_Delay[j + 5], 1 ), shr( st_fx->GainShape_Delay[j + 4], 1 ) );
        GainGrad1[j] = sub( shr( hBWE_TD->GainShape_Delay_fx[j + 5], 1 ), shr( hBWE_TD->GainShape_Delay_fx[j + 4], 1 ) );
        move16(); /* Q14 */
        GainGradFEC[j + 1] = add( mult_r( GainGrad0[j], 13107 ), mult_r( GainGrad1[j], 19660 ) );
        move16(); /* Q14 */
@@ -3588,17 +3591,17 @@ static void gradientGainShape(
    test();
    IF( ( EQ_16( st_fx->prev_coder_type, UNVOICED ) || ( st_fx->last_good == UNVOICED_CLAS ) ) && ( GainGradFEC[0] > 0 ) )
    {
        GainShapeTemp[0] = add( shr( st_fx->GainShape_Delay[7], 1 ), GainGradFEC[0] );
        GainShapeTemp[0] = add( shr( hBWE_TD->GainShape_Delay_fx[7], 1 ), GainGradFEC[0] );
        move16();
    }
    ELSE IF( GainGradFEC[0] > 0 )
    {
        GainShapeTemp[0] = add( shr( st_fx->GainShape_Delay[7], 1 ), mult_r( GainGradFEC[0], 16384 ) );
        GainShapeTemp[0] = add( shr( hBWE_TD->GainShape_Delay_fx[7], 1 ), mult_r( GainGradFEC[0], 16384 ) );
        move16(); /* Q14 */
    }
    ELSE
    {
        GainShapeTemp[0] = shr( st_fx->GainShape_Delay[7], 1 );
        GainShapeTemp[0] = shr( hBWE_TD->GainShape_Delay_fx[7], 1 );
        move16(); /* Q14 */
    }

@@ -5158,7 +5161,7 @@ void TBEreset_dec_fx(

        swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32 );

        set16_fx( st_fx->GainShape_Delay, 0, NUM_SHB_SUBFR / 2 );
        set16_fx( hBWE_TD->GainShape_Delay_fx, 0, NUM_SHB_SUBFR / 2 );
        set16_fx( hBWE_TD->int_3_over_2_tbemem_dec_fx, 0, INTERP_3_2_MEM_LEN );
        set32_fx( hBWE_TD->int_3_over_2_tbemem_dec_fx_32, 0, INTERP_3_2_MEM_LEN );
        set16_fx( hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1 );
@@ -5204,7 +5207,8 @@ void td_bwe_dec_init_fx(
    InitSWBdecBuffer_fx( st_fx );

    /* reset SHB buffers */
    ResetSHBbuffer_Dec_fx( st_fx );
    ResetSHBbuffer_Dec_fx( hBWE_TD, st_fx->extl );

    IF( EQ_32( output_Fs, 48000 ) )
    {
        set32_fx( hBWE_TD->fbbwe_hpf_mem_fx[0], 0, 4 );
@@ -5786,7 +5790,7 @@ void ivas_swb_tbe_dec_fx(
                {
                    FOR( j = 0; j < 4; j++ )
                    {
                        GainShape_fx[i * 4 + j] = mult_r( st->cummulative_damping, st->GainShape_Delay[4 + i] );
                        GainShape_fx[i * 4 + j] = mult_r( st->cummulative_damping, hBWE_TD->GainShape_Delay_fx[4 + i] );
                        move16();
                    }
                }
@@ -5883,10 +5887,10 @@ void ivas_swb_tbe_dec_fx(
    }

    /* get the gainshape delay */
    Copy( &st->GainShape_Delay[4], &st->GainShape_Delay[0], NUM_SHB_SUBFR / 4 );
    Copy( &hBWE_TD->GainShape_Delay_fx[4], &hBWE_TD->GainShape_Delay_fx[0], NUM_SHB_SUBFR / 4 );
    FOR( i = 0; i < NUM_SHB_SUBFR / 4; i++ )
    {
        st->GainShape_Delay[i + 4] = GainShape_fx[i * 4]; /*Q15*/
        hBWE_TD->GainShape_Delay_fx[i + 4] = GainShape_fx[i * 4]; /*Q15*/
        move16();
    }

Loading