Commit 668f557d authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'evs_funcs_with_ivas_code_updated' into 'main'

Updates to IVAS commented code in EVS.

See merge request !49
parents 5e5104b8 9a5ec7cb
Loading
Loading
Loading
Loading
Loading
+405 −292

File changed.

Preview size limit exceeded, changes collapsed.

+128 −0
Original line number Diff line number Diff line
@@ -604,3 +604,131 @@ void tcx5TnsUngrouping(
}

#endif


/*-------------------------------------------------------------------*
 * tcx5SpectrumInterleaving()
 *
 *
 *-------------------------------------------------------------------*/


void tcx5SpectrumInterleaving_fx(
    const Word16 tcx5Size,
    Word32 *spectrum )
{
    Word16 i;
    Word32 interleaveBuf[N_TCX10_MAX];

    set32_fx( interleaveBuf, 0, N_TCX10_MAX );

    /* group sub-windows: interleave bins according to their frequencies */
    FOR( i = 0; i < tcx5Size; i++ )
    {
        interleaveBuf[2 * i] = spectrum[i];
        interleaveBuf[2 * i + 1] = spectrum[tcx5Size + i];
    }

    Copy32( interleaveBuf, spectrum, shl( tcx5Size, 1 ) );

    return;
}

/*-------------------------------------------------------------------*
 * tcx5SpectrumDeinterleaving()
 *
 *
 *-------------------------------------------------------------------*/

void tcx5SpectrumDeinterleaving_fx(
    const Word16 tcx5Size,
    Word32 *spectrum )
{
    Word16 i;
    Word32 interleaveBuf[N_TCX10_MAX];

    set32_fx( interleaveBuf, 0, N_TCX10_MAX );

    /* ungroup sub-windows: interleave bins according to their frequencies */
    FOR( i = 0; i < tcx5Size; i++ )
    {
        interleaveBuf[i] = spectrum[2 * i];
        interleaveBuf[tcx5Size + i] = spectrum[2 * i + 1];
    }

    Copy32( interleaveBuf, spectrum, shl( tcx5Size, 1 ) );

    return;
}

/*-------------------------------------------------------------------*
 * tcx5TnsGrouping()
 *
 *
 *-------------------------------------------------------------------*/

void tcx5TnsGrouping_fx(
    const Word16 L_frame, /* i  : frame length (TCX5)                                 */
    const Word16 L_spec,  /* i  : coded spec length (TCX5, derived from filter borders*/
    Word32 *spectrum )
{
    /* rearrange LF sub-window lines prior to TNS synthesis filtering */
    IF( LT_16( L_spec, L_frame ) )
    {
        Copy32( spectrum + 8, spectrum + 16, sub( L_spec, 8 ) );
        Copy32( spectrum + L_frame, spectrum + 8, 8 );
        Copy32( spectrum + L_frame + 8, spectrum + L_spec + 8, sub( L_spec, 8 ) );
    }
    ELSE
    {
        Word32 buff[8]; /* Buffer for the rearrangement of LF TCX5 */
        Copy32( spectrum + L_spec, buff, 8 );
        Copy32( spectrum + 8, spectrum + 16, sub( L_spec, 8 ) );
        Copy32( buff, spectrum + 8, 8 );
    }

    return;
}

/*-------------------------------------------------------------------*
 * tcx5TnsUngrouping()
 *
 *
 *-------------------------------------------------------------------*/

void tcx5TnsUngrouping_fx(
    const Word16 L_frame, /* i  : frame length (TCX5)                                 */
    const Word16 L_spec,  /* i  : coded spec length (TCX5, derived from filter borders*/
    Word32 *spectrum,
    const Word16 enc_dec /* i  : 0: encoder, else decoder                            */
)
{
    /* undo rearrangement of LF sub-window lines prior to TNS analysis */
    IF( LT_16( L_spec, L_frame ) )
    {
        Copy32( spectrum + L_spec + 8, spectrum + L_frame + 8, sub( L_spec, 8 ) );
        Copy32( spectrum + 8, spectrum + L_frame, 8 );
        Copy32( spectrum + 16, spectrum + 8, sub( L_spec, 8 ) );
        set32_fx( spectrum + L_spec, 0, sub( L_frame, L_spec ) );
        set32_fx( spectrum + L_frame + L_spec, 0, sub( L_frame, L_spec ) );
    }
    ELSE
    {
        Word32 buff[8]; /* Buffer for the rearrangement of LF TCX5 */

        Copy32( spectrum + 8, buff, 8 );

        IF( enc_dec == ENC )
        {
            Copy32( spectrum + 16, spectrum + 8, sub( L_frame, 8 ) );
            Copy32( buff, spectrum + L_frame, 8 );
        }
        ELSE
        {
            Copy32( spectrum + 16, spectrum + 8, sub( L_spec, 8 ) );
            Copy32( buff, spectrum + L_spec, 8 );
        }
    }

    return;
}
 No newline at end of file
+44 −1
Original line number Diff line number Diff line
@@ -981,6 +981,16 @@ void push_next_bits_fx(
	Word16 nb_bits      /* i  : number of bits to pack */
);

UWord16 get_indice_fx(                      /* o  : value of the indice */
    Decoder_State *st_fx,                  /* i/o: decoder state structure */
    Word16 pos,                       /* i  : absolute position in the bitstream */
    Word16 nb_bits                    /* i  : number of bits that were used to quantize the indice */
);

UWord16 get_next_indice_1_fx(               /* o  : value of the indice */
    Decoder_State *st_fx                   /* i/o: decoder state structure */
);

//UWord16 get_next_indice(                 /* o  : value of the indice */
//	Decoder_State *st_fx,                  /* i/o: decoder state structure */
//	Word16 nb_bits                    /* i  : number of bits that were used to quantize the indice */
@@ -7965,4 +7975,37 @@ void cldfbAnalysis_ts_fx(
    const Word16 samplesToProcess,          /* i  : samples to process  */
    HANDLE_CLDFB_FILTER_BANK h_cldfb 
);
// dec4t64.c
void dec_acelp_fast_fx(
    Decoder_State *st,       /* i/o: decoder state structure                 */
    const int16_t cdk_index, /* i  : codebook index                          */
    Word16 code[],           /* o  : algebraic (fixed) codebook excitation   */
    const int16_t L_subfr    /* i  : subframe length                         */
);

// codec_tcx_common.c
void tcx5SpectrumInterleaving_fx(
    const Word16 tcx5Size,
    Word32 *spectrum );

void tcx5SpectrumDeinterleaving_fx(
    const Word16 tcx5Size,
    Word32 *spectrum );

void tcx5TnsGrouping_fx(
    const Word16 L_frame,
    const Word16 L_spec,
    Word32 *spectrum );

void tcx5TnsUngrouping_fx(
    const Word16 L_frame,
    const Word16 L_spec,
    Word32 *spectrum,
    const Word16 enc_dec );

// bass_psfilter.c
void bpf_pitch_coherence_fx(
    Decoder_State *st,       /* i/o: decoder state structure             */
    const Word32 pitch_buf[] /* i  : pitch for each subframe [0,1,2,3]   */
);
#endif
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#include "cnst.h"
#include "rom_com.h"
#include "prot.h"
#include "prot_fx2.h"
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "ivas_rom_com.h"
@@ -1237,7 +1238,25 @@ ivas_error acelp_core_dec(
    }

    /* analyze pitch coherence for bass post-filter */

#ifdef IVAS_FLOAT_FIXED

    Word32 pitch_buf_fx[12];

    FOR( Word16 lp = 0; lp < 12; lp++ )
    {
        st->old_pitch_buf_fx[lp] = (Word32) ( st->old_pitch_buf[lp] * ( 1u << 20 ) );
    }
    Word16 lim = st->L_frame / 64;
    for ( Word16 lp = 0; lp < lim; lp++ )
    {
        pitch_buf_fx[lp] = (Word32) ( pitch_buf[lp] * ( 1u << 20 ) );
    }
    bpf_pitch_coherence_fx( st, pitch_buf_fx );

#else
    bpf_pitch_coherence( st, pitch_buf );
#endif

    if ( !( st->element_mode == IVAS_CPE_MDCT && st->bpf_off ) )
    {
+71 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include "options.h"
#include <math.h>
#include "prot.h"
#include "prot_fx2.h"
#include "ivas_prot.h"
#include "cnst.h"
#include "stat_dec.h"
@@ -57,6 +58,9 @@

#define K_PC_DEC -0.0357f /* <45, 17>             */
#define C_PC_DEC 1.6071f
#define K_PC_DEC_FX   -1170     /* -0.0357f in Q15            */
#define K_PC_DEC_FX32 -76665166 /* -0.0357f in Q31            */
#define C_PC_DEC_FX   6583      /*in Q8*/

/*---------------------------------------------------------------------*
 * Local function prototypes
@@ -695,3 +699,70 @@ void bpf_pitch_coherence(

    return;
}

void bpf_pitch_coherence_fx(
    Decoder_State *st,       /* i/o: decoder state structure            */
    const Word32 pitch_buf[] /* i  : pitch for every subfr [0,1,2,3]    */
)
{
    Word16 nb_subfr;
    Word32 pc, pcn1, pcn2, pcn3;

    Word32 scaled_inv_L_frame; // Q8 + Q23

    SWITCH( st->L_frame )
    {
        case 80:
            scaled_inv_L_frame = 26843545;
            BREAK;
        case 160:
            scaled_inv_L_frame = 13421773;
            BREAK;
        case 256:
            scaled_inv_L_frame = 8388608;
            BREAK;
        case 320:
            scaled_inv_L_frame = 6710886;
            BREAK;
        case 512:
            scaled_inv_L_frame = 4194304;
            BREAK;
        case 640:
            scaled_inv_L_frame = 3355443;
            BREAK;
        case 960:
            scaled_inv_L_frame = 2236962;
            BREAK;
        default:
            scaled_inv_L_frame = 0;
    }

    nb_subfr = shr( st->L_frame, 6 );

    IF( GT_16( st->clas_dec, UNVOICED_CLAS ) && NE_16( st->element_mode, EVS_MONO ) )
    {
        pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( st->old_pitch_buf_fx[nb_subfr], st->old_pitch_buf_fx[nb_subfr + 1] ) ) );
        pc = Mpy_32_32( pc, scaled_inv_L_frame );
        pcn1 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX );
        pcn1 = max( min( pcn1, 4096 ), 0 );

        pc = L_abs( L_sub( L_add( pitch_buf[nb_subfr - 1], pitch_buf[nb_subfr - 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) );
        pc = Mpy_32_32( pc, scaled_inv_L_frame );
        pcn2 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX );
        pcn2 = max( min( pcn2, 4096 ), 0 );

        pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) );
        pc = Mpy_32_32( pc, scaled_inv_L_frame );
        pcn3 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX );
        pcn3 = max( min( pcn3, 4096 ), 0 );

        IF( LT_32( L_add( pcn1, L_add( pcn2, pcn3 ) ), 10240 ) )
        {
            st->hBPF->psf_att_fx = 13107; /*Q15*/
            st->hBPF->psf_att = 0.4f;
            set16_fx( &st->hBPF->Track_on_hist[L_TRACK_HIST - nb_subfr], 1, nb_subfr );
        }
    }

    return;
}
Loading