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

decod_gen_2sbfr converted to fixed point

parent 2faa7594
Loading
Loading
Loading
Loading
Loading
+101 −0
Original line number Diff line number Diff line
@@ -92,6 +92,107 @@ Word16 est_tilt_fx( /* o : tilt of the code Q15 *

    return tilt_code;
}

#ifdef IVAS_FLOAT_FIXED
/*======================================================================*/
/* FUNCTION : est_tilt_ivas_fx()												*/
/*-----------------------------------------------------------------------*/
/* PURPOSE :  Estimate spectral tilt based on the relative E of adaptive */
/* and innovative excitations                                            */
/*                                                                       */
/*-----------------------------------------------------------------------*/
/*  INPUT ARGUMENTS :													 */
/* _ (Word16 *) exc :  adaptive excitation vector      Q0                */
/* _ (Word16) gain_pit : adaptive gain                 Q14               */
/* _ (Word16 *) code : algebraic exctitation vector    Q12               */
/* _ (Word32) gain_code :  algebraic code gain         Q16               */
/* _ (Word16) Q_exc : Scaling factor of excitation     Q0                */
/*-----------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS :                                                    */
/* _ (Word16 *) voice_fac :   voicing factor          Q15                */
/*-----------------------------------------------------------------------*/
/* INPUT OUTPUT ARGUMENTS                                                */
/*-----------------------------------------------------------------------*/

/*-----------------------------------------------------------------------*/
/* RETURN ARGUMENTS :                                                    */
/* _ (Word16) tolt_code :  tilt of the code           Q15                */
/*=======================================================================*/
Word16 est_tilt_ivas_fx(             /* o  : tilt of the code              Q15      */
    const Word16 *exc,          /* i  : adaptive excitation vector      Qx  */
    const Word16 gain_pit,      /* i  : adaptive gain                   Q14 */
    const Word16 *code,         /* i  : algebraic excitation vector    Q9  */
    const Word32 gain_code,     /* i  : algebraic code gain             Q16 */
    Word16 *voice_fac,          /* o  : voicing factor                  Q15 */
    const Word16 Q_exc          /* i  : Scaling factor of excitation    Q0  */
#if 1//def ADD_LRTD
    , const Word16 L_subfr,        /* i  : Sub frame length                    */
    const Word16 flag_tilt /* i  : flag for special tilt        */
#endif
)
{
    Word16 i, tmp, exp, ener1, exp1, ener2, exp2;
    Word32 L_tmp;
    Word16 tilt_code;
#ifdef ADD_LRTD
    PMT("FIX POINT NEED to be adapted for 16 kHz frame length ")
#endif
        ener1 = extract_h(Dot_product12(exc, exc, L_subfr, &exp1));
    exp1 = sub(exp1, add(Q_exc, Q_exc));
    L_tmp = L_mult(gain_pit, gain_pit); /* energy of pitch excitation */
    exp = norm_l(L_tmp);
    tmp = extract_h(L_shl(L_tmp, exp));
    ener1 = mult(ener1, tmp);
    exp1 = sub(sub(exp1, exp), 10);     /* 10 -> gain_pit Q14 to Q9   */

    ener2 = extract_h(Dot_product12(code, code, L_subfr, &exp2));

    exp = norm_l(gain_code);
    tmp = extract_h(L_shl(gain_code, exp));
    tmp = mult(tmp, tmp);               /* energy of innovative code excitation */
    ener2 = mult(ener2, tmp);
    exp2 = sub(exp2, add(exp, exp));

    i = sub(exp1, exp2);
    BASOP_SATURATE_WARNING_OFF_EVS
        ener1 = shr(ener1, sub(1, s_min(i, 0)));
    ener2 = shr(ener2, add(s_max(0, i), 1));
    BASOP_SATURATE_WARNING_ON_EVS
        tmp = sub(ener1, ener2);
    ener1 = add(add(ener1, ener2), 1);

    /* find voice factor (1=voiced, -1=unvoiced) */
    exp = div_s(abs_s(tmp), ener1);
    IF( LT_16( tmp, 0 ) )
    {
        exp = negate(exp);
    }
    *voice_fac = exp;
    move16();

    IF(flag_tilt == 0) {
        /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */

        /* tilt_code = (float)(0.25*(1.0 + *voice_fac)) */
        tilt_code = mac_r(8192L * 65536 - 0x8000, *voice_fac, 8192); /*Q15 */
    }
    ELSE IF(flag_tilt == 1)
    {
        /*Between 0.25 (=unvoiced) and 0.5 (=voiced)*/
        //tilt_code = (float)(0.25f + (*voice_fac + 1.0f) * 0.125f);
        tilt_code = mac_r(12288L * 65536 - 0x8000, *voice_fac, 4096); /*Q15 */
    }
    ELSE
    {
        /*Between 0.28 (=unvoiced) and 0.56 (=voiced)*/
        //tilt_code = (float)(0.28f + (*voice_fac + 1.0f) * 0.14f);
        tilt_code = mac_r(13763L * 65536 - 0x8000, *voice_fac, 4588); /*Q15 */
    }

    return tilt_code;
}
#endif

/*-------------------------------------------------------------------*
 * Est_tilt2:
 *
+17 −0
Original line number Diff line number Diff line
@@ -506,6 +506,23 @@ void decod_gen_2sbfr(
    const float tdm_Pri_pitch_buf[]                             /* i  : pitch values for primary channel        */
);

#ifdef IVAS_FLOAT_FIXED
void decod_gen_2sbfr_ivas_fx(
    Decoder_State *st,                  /* i/o: decoder static memory                     */
    const Word16 sharpFlag,            /* i  : formant sharpening flag                   */
    const Word16 *Aq,                    /* i  : LP filter coefficient                     */
    Word16 *pitch_buf,                   /* o  : floating pitch values for each subframe   */
    Word16 *voice_factors,               /* o  : voicing factors                           */
    Word16 *exc,                         /* i/o: adapt. excitation exc                     */
    Word16 *exc2,                        /* i/o: adapt. excitation/total exc               */
    Word16 *bwe_exc,                     /* o  : excitation for SWB TBE                    */
    Word16 *gain_buf,                    /* o  : floating pitch gain for each subframe     */
    const Word16 tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag          */
    const Word16 tdm_Pri_pitch_buf[],     /* i  : pitch values for primary channel          */
    Word16 Q_exc
);
#endif

void synchro_synthesis(
    const int32_t ivas_total_brate,                             /* i  : IVAS total bitrate                      */
    CPE_DEC_HANDLE hCPE,                                        /* i/o: CPE decoder structure                   */
+83 −0
Original line number Diff line number Diff line
@@ -2757,6 +2757,36 @@ void prep_tbe_exc_fx(
#endif
);

#ifdef IVAS_FLOAT_FIXED
void prep_tbe_exc_ivas_fx(
    const Word16 L_frame_fx,            /* i : length of the frame */
#if 1//def ADD_IVAS_TBE_CODE
    const Word16 L_subfr,
#endif
    const Word16 i_subfr_fx,            /* i : subframe index */
    const Word16 gain_pit_fx,           /* i : Pitch gain Q14*/
    const Word32 gain_code_fx,          /* i : algebraic codebook gain 16+Q_exc*/
    const Word16 code_fx[],             /* i : algebraic excitation Q9*/
    const Word16 voice_fac_fx,          /* i : voicing factor Q15*/
    Word16 *voice_factors_fx,           /* o : TBE voicing factor Q15*/
    Word16 bwe_exc_fx[],                /* i/o: excitation for TBE Q_exc*/
    const Word16 gain_preQ_fx,          /* i : prequantizer excitation gain */
    const Word16 code_preQ_fx[],        /* i : prequantizer excitation */
    const Word16 Q_exc,                 /* i : Excitation, bwe_exc Q-factor */
    Word16 T0,                          /* i : integer pitch variables Q0 */
    Word16 T0_frac,                     /* i : Fractional pitch variables Q0*/
    const Word16 coder_type,            /* i : coding type */
    Word32 core_brate
#if 1//def ADD_IVAS_TBE_CODE
    ,                  /* i  : core bitrate                */
    const Word16 element_mode,         /* i  : element mode                */
    const Word16 idchan,               /* i  : channel ID                  */
    const Word16 flag_TD_BWE,          /* i  : flag indicating whether hTD_BWE exists  */
    const Word16 tdm_LRTD_flag         /* i  : LRTD stereo mode flag       */
#endif
);

#endif
Word16 swb_formant_fac_fx(  /* o : Formant filter strength [0,1] */
  const Word16   lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */
  Word16*         tilt_mem /* i/o: Tilt smoothing memory */
@@ -4238,6 +4268,22 @@ Word16 est_tilt_fx( /* o : tilt of the code
  , const Word16 L_subfr                    /* i  : Sub frame lenght                    */
#endif
);

#ifdef IVAS_FLOAT_FIXED
Word16 est_tilt_ivas_fx(             /* o  : tilt of the code              Q15      */
    const Word16 *exc,          /* i  : adaptive excitation vector      Qx  */
    const Word16 gain_pit,      /* i  : adaptive gain                   Q14 */
    const Word16 *code,         /* i  : algebraic excitation vector    Q9  */
    const Word32 gain_code,     /* i  : algebraic code gain             Q16 */
    Word16 *voice_fac,          /* o  : voicing factor                  Q15 */
    const Word16 Q_exc          /* i  : Scaling factor of excitation    Q0  */
#if 1//def ADD_LRTD
    , const Word16 L_subfr,        /* i  : Sub frame length                    */
    const Word16 flag_tilt /* i  : flag for special tilt        */
#endif
);
#endif

Word16 Est_tilt2(                           /* o  : tilt of the code                    */
  const Word16 *exc,                      /* i  : adaptive excitation vector      Qx  */
  const Word16 gain_pit,                  /* i  : adaptive gain                   Q14 */
@@ -6234,6 +6280,27 @@ void init_tcx_cfg_fx(
#endif
 );

#ifdef IVAS_FLOAT_FIXED
 Word16 pit_decode_ivas_fx(                  /* o  : floating pitch value                    */
     Decoder_State *st_fx,           /* i/o: decoder state structure                 */
     const Word32 core_brate,           /* i  : core bitrate                            */
     const Word16 Opt_AMR_WB,           /* i  : flag indicating AMR-WB IO mode          */
     const Word16 L_frame,              /* i  : length of the frame                     */
     Word16 i_subfr,                    /* i  : subframe index                          */
     const Word16 coder_type,           /* i  : coding type                             */
     Word16 *limit_flag,                /* i/o: restrained(0) or extended(1) Q limits   */
     Word16 *T0,                        /* o  : close loop integer pitch                */
     Word16 *T0_frac,                   /* o  : close loop fractional part of the pitch */
     Word16 *T0_min,                    /* i/o: delta search min for sf 2 & 4           */
     Word16 *T0_max,                    /* i/o: delta search max for sf 2 & 4           */
     const Word16 L_subfr               /* i  : subframe length                         */
#if 1//def ADD_LRTD
     , const Word16 tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag                */
     const Word16 tdm_Pri_pitch_buf[]   /* i  : primary channel pitch buffer                    */
#endif
 );
#endif

 void pit_Q_dec_fx(
   const Word16 Opt_AMR_WB,   /* i  : flag indicating AMR-WB IO mode          */
   const Word16 pitch_index,  /* i  : pitch index                             */
@@ -6316,6 +6383,22 @@ void init_tcx_cfg_fx(
   , const Word16 L_subfr                /* i  : subframe length                             */
 );

#ifdef IVAS_FLOAT_FIXED
 void inov_decode_ivas_fx(
     Decoder_State *st_fx,    /* i/o: decoder state structure */
     const Word32 core_brate, /* i  : core bitrate                                */
     const Word16 Opt_AMR_WB, /* i  : flag indicating AMR-WB IO mode              */
     const Word16 L_frame,    /* i  : length of the frame                         */
     const Word16 sharpFlag,  /* i  : formant sharpening flag                     */
     const Word16 i_subfr,    /* i  : subframe index                              */
     const Word16 *p_Aq,      /* i  : LP filter coefficients Q12                  */
     const Word16 tilt_code,  /* i  : tilt of the excitation of previous subframe Q15 */
     const Word16 pt_pitch,   /* i  : pointer to current subframe fractional pitch Q6*/
     Word16 *code,            /* o  : algebraic excitation                        */
     const Word16 L_subfr     /* i  : subframe length                             */
 );
#endif

 //dec4t64_fx.c
 void dec_acelp_4t64_fx(
   Decoder_State *st_fx,                  /* i/o: decoder state structure */
+23 −0
Original line number Diff line number Diff line
@@ -1769,6 +1769,29 @@ const float inter4_2[65] =
    -0.000618f,  -0.000434f,  -0.000133f,   0.000063f,
    0.000098f,   0.000048f,   0.000007f,   0.000000f
};
const Word16 inter4_2_fx_Q15[65] =
{
    30801,
    28062, 20718, 11061, 1935,
    -4294, -6533, -5195, -1846,
    1559, 3497, 3398, 1705,
    -497, -2087, -2413, -1523,
    -32, 1252, 1741, 1312,
    305, -710, -1237, -1087,
    -426, 350, 848, 862,
    452, -119, -550, -650,
    -418, -17, 330, 462,
    349, 85, -175, -306,
    -265, -104, 76, 184,
    182, 93, -20, -98,
    -110, -66, -3, 43,
    55, 37, 8, -13,
    -20, -14, -4, 2,
    3, 1, 0, 0,
};
const Word16 inter4_2_fx[] =
{
    0,     1,      2,      1,
+1 −0
Original line number Diff line number Diff line
@@ -193,6 +193,7 @@ extern const float sincos_t_rad3[];
extern const Word16 sincos_t_rad3_fx[];
extern const int16_t fft256_read_indexes[]; /* FFT */
extern const float inter4_2[];              /* 1/4 resolution interpolation filter */
extern const Word16 inter4_2_fx_Q15[];              /* 1/4 resolution interpolation filter */
extern const Word16 inter4_2_fx[];
extern const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*1Q14*/
extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2];             /*1Q14*/
Loading