Commit faf66e6a authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'enc_funcs_fxd_3' into 'main'

Core coder functions converted to fixed point

See merge request !609
parents 97d53234 107850fc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1549,6 +1549,7 @@ enum
#define SHB_GAIN_QDELTA_1k75                0.08f                   /* SHB gain scalar quantizer stepsize */
#define SHB_GAIN_QLOW_1k75_FX                  0                    /* SHB gain lowest scalar quantizer value */
#define SHB_GAIN_QDELTA_1k75_FX                10486                   /* SHB gain scalar quantizer stepsize Q17 */
#define SHB_GAIN_QDELTA_1k75_FX_15             2622                   /* SHB gain scalar quantizer stepsize */
#define SHB_GAIN_QLOW_FX                      -262144              /* Q18*/   /* SHB gain lowest scalar quantizer value */
#define SHB_GAIN_QLOW_FX_16                   -65536               /* SHB gain lowest scalar quantizer value */
#define SHB_GAIN_QDELTA_FX_15                 4915                 /* SHB gain scalar quantizer step size */
+7 −0
Original line number Diff line number Diff line
@@ -78,6 +78,13 @@ void floatToFixed_arr32( float *f, Word32 *i, Word16 Q, Word16 l )
    }
}

float fixedToFloat_16( Word16 i, Word16 Q )
{
    if ( Q < 0 )
        return ( i * (float) ( ( (unsigned) 1 ) << ( -Q ) ) );
    else
        return (float) ( i ) / (float) ( (unsigned int) 1 << Q );
}
float fixedToFloat_32( Word32 number, Word16 Q )
{
    float val = 0.0f;
+79 −0
Original line number Diff line number Diff line
@@ -314,3 +314,82 @@ void int_lsp4_fx(

    return;
}

void int_lsp4_ivas_fx(
    const Word16 L_frame,        /* i  : length of the frame                   */
    const Word16 lsp_old[],      /* i  : LSPs from past frame               Q15*/
    const Word16 lsp_mid[],      /* i  : LSPs from mid-frame				  Q15*/
    const Word16 lsp_new[],      /* i  : LSPs from present frame            Q15*/
    Word16 *Aq,                  /* o  : LP coefficients in both subframes  Q12*/
    const Word16 m,              /* i  : order of LP filter                    */
    Word16 relax_prev_lsf_interp /* i  : relax prev frame lsf interp after erasure */
)
{
    Word16 lsp[M16k];
    Word16 i, j, k;
    Word32 L_tmp;
    const Word16 *pt_int_coeffs;

    IF( EQ_16( L_frame, L_FRAME ) )
    {
        IF( EQ_16( relax_prev_lsf_interp, 1 ) )
        {
            pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx;
        }
        ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) )
        {
            pt_int_coeffs = interpol_frac_mid_FEC_fx;
        }
        ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) )
        {
            pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx;
        }
        ELSE IF( EQ_16( relax_prev_lsf_interp, -2 ) )
        {
            pt_int_coeffs = interpol_frac2_mid_fx;
        }
        ELSE
        {
            pt_int_coeffs = interpol_frac_mid_fx;
        }
    }
    ELSE /* L_frame == L_FRAME16k */
    {
        IF( EQ_16( relax_prev_lsf_interp, 1 ) )
        {
            pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx;
        }
        ELSE IF( EQ_16( relax_prev_lsf_interp, 2 ) )
        {
            pt_int_coeffs = interpol_frac_mid_16k_FEC_fx;
        }
        ELSE IF( EQ_16( relax_prev_lsf_interp, -1 ) )
        {
            pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx;
        }
        ELSE
        {
            pt_int_coeffs = interpol_frac_mid_16k_fx;
        }
    }
    k = sub( shr( L_frame, 6 ), 1 );
    FOR( j = 0; j < k; j++ )
    {
        FOR( i = 0; i < m; i++ )
        {
            L_tmp = L_mult( lsp_old[i], *pt_int_coeffs );               /*Q31 */
            L_tmp = L_mac( L_tmp, lsp_mid[i], *( pt_int_coeffs + 1 ) ); /*Q31 */
            lsp[i] = mac_r( L_tmp, lsp_new[i], *( pt_int_coeffs + 2 ) );
            move16();
        }
        pt_int_coeffs += 3;

        E_LPC_f_lsp_a_conversion( lsp, Aq, m );
        Aq += add( m, 1 );
    }

    /* Last subframe */
    E_LPC_f_lsp_a_conversion( lsp_new, Aq, m );

    return;
}
+0 −8
Original line number Diff line number Diff line
@@ -4122,14 +4122,6 @@ void ivas_mdct_quant_coder(
    const int16_t MCT_flag                                      /* i  : hMCT handle allocated (1) or not (0)    */
);

void ivas_mdct_quant_coder_fx(
    CPE_ENC_HANDLE hCPE,                   /* i/o: Encoder CPE handle                   */
    int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i  : bits needed for TNS parameters       */
    int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i  : size of TNS                          */
    int16_t p_param[CPE_CHANNELS][NB_DIV], /* i  : pointer to parameter array           */
    const int16_t MCT_flag                 /* i  : hMCT handle allocated (1) or not (0) */
);

void apply_MCT_enc(
    MCT_ENC_HANDLE hMCT,                                        /* i/o: MCT encoder structure                   */
    Encoder_State **sts,                                        /* i/o: encoder state structure                 */
+22 −8
Original line number Diff line number Diff line
@@ -835,12 +835,12 @@ void ivas_lfe_dec_close_fx(


void td_stereo_param_updt_fx(
    const Word16 lsp_old_PCh[],       /* i  : primary channel old LSPs                */
    const Word16 lsf_old_PCh[],       /* i  : primary channel old LSFs                */
    const Word16 pitch_buf_PCh[],     /* i  : primary channel pitch buffer            */
    Word16 tdm_lspQ_PCh[],            /* o  : Q LSPs for primary channel              */
    Word16 tdm_lsfQ_PCh[],            /* o  : Q LSFs for primary channel              */
    Word16 tdm_Pri_pitch_buf[],       /* o  : pitch values for primary channel        */
    const Word16 lsp_old_PCh_fx[],    /* i  : primary channel old LSPs                                     Q15 */
    const Word16 lsf_old_PCh_fx[],    /* i  : primary channel old LSFs                             Qlog2(2.56) */
    const Word16 pitch_buf_PCh_fx[],  /* i  : primary channel pitch buffer                                  Q6 */
    Word16 tdm_lspQ_PCh_fx[],         /* o  : Q LSPs for primary channel                                   Q15 */
    Word16 tdm_lsfQ_PCh_fx[],         /* o  : Q LSFs for primary channel                           Qlog2(2.56) */
    Word16 tdm_Pri_pitch_buf_fx[],    /* o  : pitch values for primary channel                              Q6 */
    const Word16 flag_ACELP16k,       /* i  : ACELP@16kHz flag                                                 */
    const Word16 tdm_use_IAWB_Ave_lpc /* i  : flag to indicate the usage of mean inactive LP coefficients      */
#ifndef FIX_798_WRONG_CPY_OF_PITCH
@@ -2725,6 +2725,20 @@ void core_switching_pre_enc_ivas_fx(
);
#endif

void ivas_mdct_quant_coder_fx(
    CPE_ENC_HANDLE hCPE,                  /* i/o: Encoder CPE handle                   */
    Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* i  : bits needed for TNS parameters       */
    Word16 tnsSize[CPE_CHANNELS][NB_DIV], /* i  : size of TNS                          */
    Word16 p_param[CPE_CHANNELS][NB_DIV], /* i  : pointer to parameter array           */
    const Word16 MCT_flag                 /* i  : hMCT handle allocated (1) or not (0) */
);

void ivas_mdct_tcx10_bit_distribution_fx(
    Word16 target_bitsTCX10[NB_DIV],   /* o  : target bit distribution */
    const Word16 nbits_tcx,            /* i  : TCX bits                */
    const Word16 nTnsBitsTCX10[NB_DIV] /* i  : TNS bits                */
);

void QuantizeSpectrum_ivas_fx(
    Encoder_State *st,           /* i/o: encoder state structure                         */
    const float A[],             /* i  : quantized coefficients NxAz_q[M+1]              */
Loading