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

Encoder functions converted to fixed point

[x] processStereoIGF functions
[x] Functions in stereo dft path
[x] LTV stereo crash fixes
[x] swb_tbe_enc functions
parent 04440bc5
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -176,6 +176,14 @@ Word32 BASOP_Util_InvLog2( Word32 x )

Word32 BASOP_Util_Log10( Word32 x, Word16 e )
{
    test();
    IF( e >= 0 && LE_16( e, 31 ) )
    {
        IF( EQ_32( x, L_shl_sat( 1, sub( 31, e ) ) ) )
        {
            return 0;
        }
    }
    Word32 res = BASOP_Util_Log2( x );
    res = L_add( Mpy_32_32( res, 646456993 /* log10(2) in Q31 */ ), Mpy_32_32( L_shl( e, 25 ), 646456993 /* log10(2) in Q31 */ ) ); // Adjusting for the exponent mismatch: multiplying first so as to avoid saturation
    return res;
+1 −1
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ static int16_t file_read_FECpattern( void )
 *
 * insert a bit into packed octet
 *-------------------------------------------------------------------*/
static void pack_bit(
void pack_bit(
    const Word16 bit, /* i:   bit to be packed */
    UWord8 **pt,      /* i/o: pointer to octet array into which bit will be placed */
    UWord8 *omask     /* i/o: output mask to indicate where in the octet the bit is to be written */
+13 −6
Original line number Diff line number Diff line
@@ -1795,6 +1795,16 @@ void stereo_dft_cng_side_gain(
    const int16_t bwidth                                        /* i  : audio band-width                    */
);

#ifdef IVAS_FLOAT_FIXED
void stereo_dft_quantize_res_gains_fx(
    const Word32 *g, //Q31
    const Word32 *r, //Q31
    Word32 *gq, //Q31
    Word32 *rq, //Q31
    Word16 *ig,
    Word16 *ir);
#endif

void stereo_dft_quantize_res_gains(
    const float *g,
    const float *r,
@@ -2239,9 +2249,9 @@ void stereo_dft_hybrid_ITD_flag(
void stereo_dft_enc_compute_itd_fx(
    CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure           */
    Word32 *DFT_L,
    Word16 DFT_L_e,
    Word16 *DFT_L_e,
    Word32 *DFT_R,
    Word16 DFT_R_e,
    Word16 *DFT_R_e,
    const Word16 k_offset,
    const Word16 input_frame,
    const Word16 vad_flag_dtx[],
@@ -4081,9 +4091,7 @@ void getChannelEnergies(
void mctStereoIGF_enc_fx(
    MCT_ENC_HANDLE hMCT,                             /* i/o: MCT encoder structure               */
    Encoder_State **sts,                             /* i/o: encoder state structure             */
#ifndef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
    Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2],       /* i  : MDCT spectrum for ITF               */
#endif
    Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k],   /* i/o: MDCT^2 + MDST^2 spectrum,or estimate*/
    Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i  : same as above but for inverse spect.*/
    Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][NB_DIV],   /* i  : inverse spectrum                    */
@@ -4095,8 +4103,7 @@ void mctStereoIGF_enc_fx(
#endif
    const Word16 sp_aud_decision0[MCT_MAX_CHANNELS] /* i  : speech audio decision               */
);
#endif // IVAS_FLOAT_FIXED

#endif
void mctStereoIGF_enc(
    MCT_ENC_HANDLE hMCT,                                        /* i/o: MCT encoder structure                   */
    Encoder_State **sts,                                        /* i/o: encoder state structure                 */
+167 −0
Original line number Diff line number Diff line
@@ -69,10 +69,12 @@ const int16_t dft_band_limits_erb8[STEREO_DFT_ERB8_BANDS] =
    1, 5, 18, 41, 84, 214, 470, 601
};
#ifndef IVAS_FLOAT_FIXED
const float dft_res_cod_alpha[STEREO_DFT_BAND_MAX] =
{
    .8f, .8f, .5f, .5f, .3f, .3f, .2f, .2f
};
#endif
const int16_t dft_band_ipd[3][4] =
{
@@ -88,6 +90,171 @@ const int16_t dft_band_res_cod[3][4] =
    {0,5,6,7}
};
const Word32 dft_res_gains_q_Q31[][2] = 
{
    /* quantization points for joint quantization of  prediction gain and residual energy  */
    /* column 1 (|ILD| = 0): */
    {0, 0 },
    {0, 251216928 },
    {0, 487459456 },
    {0, 731632640 },
    {0, 997611392 },
    {0, 1299397248 },
    {0, 1666984192 },
    {0, 2147483647 },
    /* column 2 (|ILD| = 2): */
    {246151024, 0 },
    {249475328, 247871152 },
    {258660112, 480729248 },
    {274304544, 720918848 },
    {298427200, 981720000 },
    {334663840, 1276185088 },
    {391374592, 1632160640 },
    {485919712, 2091786496 },
    /* column 3 (|ILD| = 4): */
    {485919712, 0 },
    {492224736, 238188144 },
    {509610752, 461283776 },
    {539117184, 690072384 },
    {584326016, 936189056 },
    {651608832, 1210182144 },
    {755411712, 1534299776 },
    {924504576, 1938292992 },
    /* column 4 (|ILD| = 6): */
    {713563712, 0 },
    {722237376, 223142880 },
    {746085184, 431184640 },
    {786311872, 642617280 },
    {847364864, 866812416 },
    {936938496, 1111020032 },
    {1072199936, 1390431232 },
    {1285225984, 1720430720 },
    /* column 5 (|ILD| = 8): */
    {924504576, 0 },
    {934784576, 204139792 },
    {962942400, 393358880 },
    {1010083968, 583482048 },
    {1080789888, 781462848 },
    {1182728704, 991308544 },
    {1332741248, 1221608960 },
    {1559902080, 1475937536 },
    /* column 6 (|ILD| = 10): */
    {1115604864, 0 },
    {1126709504, 182744416 },
    {1156997632, 351025536 },
    {1207276672, 517958016 },
    {1281710592, 688294272 },
    {1387005952, 863412992 },
    {1537761536, 1046870336 },
    {1757032448, 1234717184 },
    /* column 7 (|ILD| = 13): */
    {1361843968, 0 },
    {1372924928, 149366080 },
    {1402942464, 285507936 },
    {1452130560, 417893888 },
    {1523515136, 548787328 },
    {1621670144, 677135936 },
    {1756740352, 802203264 },
    {1942499840, 915633344 },
    /* column 8 (|ILD| = 16): */
    {1559902080, 0 },
    {1569913600, 117815248 },
    {1596862336, 224162928 },
    {1640492800, 325650848 },
    {1702660352, 423060736 },
    {1785997696, 514412544 },
    {1896788608, 597466432 },
    {2042241920, 664027712 },
    /* column 9 (|ILD| = 19): */
    {1714196608, 0 },
    {1722634112, 90359672 },
    {1745223424, 171238192 },
    {1781415040, 247171072 },
    {1832190080, 318199104 },
    {1898830848, 382271424 },
    {1984989952, 437025792 },
    {2094086528, 475912448 },
    /* column 10 (|ILD| = 22): */
    {1831427712, 0 },
    {1838194432, 67828272 },
    {1856228992, 128123168 },
    {1884882944, 183977072 },
    {1924581248, 235132272 },
    {1975822336, 279821408 },
    {2040659200, 316058048 },
    {2120554240, 339023232 },
    /* column 11 (|ILD| = 25): */
    {1918819584, 0 },
    {1924055168, 50102940 },
    {1937964416, 94399088 },
    {1959916032, 135003712 },
    {1990038784, 171579648 },
    {2028424960, 202728896 },
    {2076217216, 226931040 },
    {2133943808, 240762976 },
        /* column 12 (|ILD| = 30): */
    {2015827840, 0 },
    {2019068416, 29502130 },
    {2027636864, 55420112 },
    {2041056512, 78889960 },
    {2059271424, 99626064 },
    {2082150784, 116769424 },
    {2110128128, 129415952 },
    {2143192960, 135682304 },
    /* column 13 (|ILD| = 35): */
    {2072441984, 0 },
    {2074364032, 17033840 },
    {2079438464, 31939524 },
    {2087347712, 45337676 },
    {2098012032, 57039312 },
    {2111296384, 66537632 },
    {2127368192, 73321536 },
    {2146126464, 76351632 },
    /* column 14 (|ILD| = 40): */
    {2104959232, 0 },
    {2106073728, 9723806 },
    {2109011456, 18212808 },
    {2113579136, 25810606 },
    {2119712384, 32401234 },
    {2127314432, 37692632 },
    {2136458496, 41399188 },
    {2147054208, 42945376 },
    /* column 15 (|ILD| = 45): */
    {2123466240, 0 },
    {2124103936, 5514738 },
    {2125783296, 10322954 },
    {2128390400, 14615774 },
    {2131882240, 18322330 },
    {2136200832, 21283710 },
    {2141376256, 23332410 },
    {2147348352, 24150602 },
    /* column 16 (|ILD| = 50): */
    {2133943808, 0 },
    {2134306688, 3115998 },
    {2135260160, 5830418 },
    {2136737664, 8250632 },
    {2138715520, 10335839 },
    {2141157120, 11995844 },
    {2144077696, 13136157 },
    {2147440640, 13580687 }
};
const float dft_res_gains_q[][2] =
{
    /* quantization points for joint quantization of  prediction gain and residual energy  */
+2 −0
Original line number Diff line number Diff line
@@ -57,7 +57,9 @@ extern const int16_t dft_band_ipd[3][4];
extern const int16_t dft_band_res_cod[3][4];

extern const float dft_res_gains_q[][2];
#ifndef IVAS_FLOAT_FIXED
extern const float dft_res_cod_alpha[STEREO_DFT_BAND_MAX];
#endif

extern const float dft_trigo_12k8[STEREO_DFT_N_12k8_ENC / 4 + 1];
extern const float dft_trigo_32k[STEREO_DFT_N_32k_ENC / 4 + 1];
Loading