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

Merge branch 'fxd_sub_funcs_integration_2' into 'main'

Integration of fixed point sub-functions - 2.

See merge request !219
parents 60bfac4c e0d49d23
Loading
Loading
Loading
Loading
Loading
+45 −42
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
#include "prot_fx1.h"       /* Function prototypes                    */
#include "prot_fx2.h"       /* Function prototypes                    */
#include "rom_com.h"
#include "ivas_rom_com_fx.h"

/*---------------------------------------------------------------------*
 * Local constants
@@ -978,8 +979,8 @@ void cng_params_upd_ivas_fx(
    Word16 cng_exc2_buf[],   /* i/o: Excitation buffer                                  Q_exc */
    Word16 cng_Qexc_buf[],   /* i/o: Q_exc buffer                                       Q0    */
    Word32 cng_brate_buf[],  /* i/o: last_active_brate buffer                           Q0    */
    const Word32 last_active_brate,/* i  : Last active bit rate                               Q0    */
    const Word16 element_mode,     /* i  : Element mode                        */
    const Word32 last_active_brate /* i  : Last active bit rate                               Q0    */
    , const Word16 element_mode,   /* i  : Element mode                        */
    const Word16 bwidth            /* i  : Audio bandwidth                     */
)
{
@@ -993,10 +994,9 @@ void cng_params_upd_ivas_fx(
    Word32 env[NUM_ENV_CNG];
    Word16 exp1;
    Word16 CNG_mode;
    Word16 tmp;
    Word16 tmp = 0;
    Word16 temp_lo_fx, temp_hi_fx;
    Word16 exp_pow;
    Word32 att;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
@@ -1120,21 +1120,23 @@ void cng_params_upd_ivas_fx(
            tmp = add( add( Q_exc, Q_exc ), 1 );
            sp[i] = L_shr( L_tmp, sub( tmp, 6 ) );
            move32(); /* Q6 */

            ptR++;
            ptI--;
        }


        Copy32(sp,env,NUM_ENV_CNG);
        IF( element_mode == IVAS_SCE || element_mode == IVAS_CPE_DFT )
        Word16 shift = 0;
        if (element_mode == IVAS_SCE || element_mode == IVAS_CPE_DFT)
        {
            Word16 index;
            att = 0;
            index = apply_scale_ind( &att, bwidth, last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO );
            // att = powf(10, att / 10.0f);
            tmp = att_pow_tbl[index]; // Q15
            Word32 att_fx = 0;
            Word16 index = 0;
            apply_scale_ivas_fx(&att_fx, bwidth, last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO, &index);
            att_fx = pow_10_q23[index];//Q23
            tmp = extract_h(att_fx);//Q7
            shift = 8;
        }
        ELSE
        else
        {
            CNG_mode = get_cng_mode(last_active_brate);
            /* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */
@@ -1161,6 +1163,7 @@ void cng_params_upd_ivas_fx(
        /* update the circular buffer of old residual envelope */
        /* Copy32( env, &(ho_env_circ[add(shl(*ho_circ_ptr,4),shl(*ho_circ_ptr,2))]), NUM_ENV_CNG ); */
        Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG );
        scale_sig32(&(ho_env_circ[(*ho_circ_ptr)*NUM_ENV_CNG]), NUM_ENV_CNG, shift);
    }
    *ho_circ_size = add( *ho_circ_size, 1 );
    if ( GT_16( *ho_circ_size, HO_HIST_SIZE ) )
+42 −13
Original line number Diff line number Diff line
@@ -1840,6 +1840,7 @@ Word16 apply_scale_ind(
        {
            BREAK;
        }

    }

    {
@@ -1847,8 +1848,36 @@ Word16 apply_scale_ind(
    }
    return i;
}
#endif // IVAS_FLOAT_FIXED

void apply_scale_ivas_fx(
    Word32 *scale,                  /* o  : scalefactor             */
    const Word16 bwmode,            /* i  : audio bandwidth         */
    const Word32 bitrate,           /* i  : Bit rate                */
    const SCALE_SETUP* scaleTable,  /* i  : Scale table             */
    const Word16 scaleTableSize,     /* i  : Size of scale table     */
    Word16 *index
)
{
    Word16 i;
    //PMT("Verifiy if the basop ued are ok for stereo too")
    FOR(i = 0; i < scaleTableSize; i++)
    {
        cast16();
        IF(s_and((Word16)EQ_16(bwmode, (Word16)scaleTable[i].bwmode),
            s_and(L_sub(bitrate, scaleTable[i].bitrateFrom) >= 0,
                L_sub(bitrate, scaleTable[i].bitrateTo) < 0))
        )
        {
            BREAK;
        }
    }
    assert(i < scaleTableSize);

    *scale = L_add(*scale, L_deposit_h(scaleTable[i].scale));
    *index = i;

}
#endif // IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------
 * bandcombinepow()
 *
+5 −7
Original line number Diff line number Diff line
@@ -2371,8 +2371,8 @@ void tdm_low_rate_dec(
#ifdef IVAS_FLOAT_FIXED
void tdm_SCh_LSF_intra_pred_fx(
    const Word32 element_brate,                                 /* i  : element bitrate                         */
    const Word32 *tdm_lsfQ_PCh_fx,                              /* i  : primary channel LSFs                    */
    Word32 *pred_lsf_SCh_fx                                     /* o  : predicted secondary channel LSFs        */
    const Word16 *tdm_lsfQ_PCh_fx,                              /* i  : primary channel LSFs                    */
    Word16 *pred_lsf_SCh_fx                                     /* o  : predicted secondary channel LSFs        */
);
#endif

@@ -2386,12 +2386,10 @@ void tdm_SCh_LSF_intra_pred(
void tdm_SCh_lsf_reuse_fx(
    const Word16 enc_dec,                                       /* i  : encoder/decoder flag                    */
    const Word32 element_brate,                                 /* i  : element bitrate                         */
    Word32 lsf_new_fx[M],                                       /* i/o: LSFs at the end of the frame            */
    Word16 lsf_new_q_fx,                                        /* i/o: LSFs at the end of the frame            */
    Word16 lsf_new_fx[M],                                       /* i/o: LSFs at the end of the frame            */
    Word16 lsp_new_fx[M],                                       /* i/o: LSPs at the end of the frame            */
    Word16 lsp_new_q_fx,                                        /* i/o: LSPs at the end of the frame            */
    const Word32 tdm_lsfQ_PCh_fx[M],                            /* i  : primary channel LSFs                    */
    const Word32 lsf_wgts_fx[M],                                /* i  : LSF weights                             */
    const Word16 tdm_lsfQ_PCh_fx[M],                            /* i  : primary channel LSFs                    */
    const Word16 lsf_wgts_fx[M],                                /* i  : LSF weights                             */
    Word16 *beta_index                                          /* i/o: quantization index                      */
);
#endif
+52 −79
Original line number Diff line number Diff line
@@ -685,84 +685,57 @@ const int16_t tdm_bit_allc_tbl[5][6] =
};
#ifdef IVAS_FLOAT_FIXED
/* LSFs Intra-frame prediction tables */
//Q18
const Word32 tdm_LSF_MEAN_RE_USE_OUT_fx[M] =
{
   78981888, 136655664, 228279712, 351345824, 448816480, 548262656, 652351360, 744776256, 837960320, 941893888, 1037661888, 1125471744, 1234781824, 1341864320, 1454050176, 1551520000,
};
//Q18
const Word32 tdm_LSF_MEAN_RE_USE_IN_fx[M] =
{
    75081712, 136935120, 232599584, 353359904, 452356736, 551120000, 658427840, 747921216, 841828032, 946883008, 1040944704, 1134499968, 1240576256, 1351348096, 1460888960, 1563513856,
};
//Q18
const Word32 tdm_LSF_MEAN_RE_USE_fx[M] =
{
    69608200, 140188480, 241060944, 353105792, 460584864, 556547904, 670261760, 767422464,
    864841216, 966328064, 1057613056, 1151813248, 1253489536, 1351602432, 1452951424, 1553826432
};
const Word32 tdm_Beta_Q1bit_re_use_13k2_fx[2] = { 2083059138, 1610612736 };//Q31
const Word32 tdm_Beta_Q1bit_re_use_16k4_fx[2] = { 2040109465, 1524713390 };//Q31
const Word32 tdm_Beta_Q1bit_re_use_24k4_32k_fx[2] = { 1997159792, 1567663063 };//Q31
const Word32 tdm_Beta_Q1bit_re_use_48k_fx[2] = { 2083059138, 1653562408 };//Q31
//Q31
const Word32 tdm_RE_USE_adaptive_beta_prd_diag_3_fx[15 + 16 + 15] =
{
    1902455808,    442381632,
    125627792,    1770600320,    492632736,
    78383152,    1755567872,    364213216,
   -12884902,    1821710336,    442596384,
    142378160,    1929084544,    291413536,
    142592912,    1707464192,    415323328,
    200789728,    1706819968,    361851008,
    238155936,    1709396992,    392560000,
    230424992,    1682553472,    387406048,
    317612832,    1580977408,    425631264,
    286689056,    1636597248,    408021888,
    408666144,    1582480640,    368293440,
    383325824,    1549194752,    353475808,
    422410048,    1479831040,    263925744,
    438730912,    1356565376,    116608360,
    379460352,    1158782208,
};
//Q18
const Word32 tdm_LSF_MEAN_PRED_QNT_fx[M] =
{
    102580472, 159515808, 253756928, 355005792, 448190432, 545390272, 642420608, 733207808,
    837863616, 931704576, 1026299968, 1122975360, 1234068608, 1339500800, 1448725504, 1547547776
};
//Q18
const Word32 tdm_LSF_MEAN_PRED_QNT_IN_fx[M] =
{
    75639032, 140369984, 235860912, 351879296, 453702048, 552355776, 653120000, 749686720, 849157568, 950448448, 1046620416, 1142095360, 1245801600, 1351007616, 1459383680, 1565687296,
};
//Q18
const Word32 tdm_LSF_MEAN_PRED_QNT_OUT_fx[M] =
{
    75081712, 136935120, 232599584, 353359904, 452356736, 551120000, 658427840, 747921216, 841828032, 946883008, 1040944704, 1134499968, 1240576256, 1351348096, 1460888960, 1563513856,
};
//Q31
const Word32 tdm_PRED_QNT_fixed_beta_prd_diag_3_fx[15 + 16 + 15] =
{
    1511828480,    258342288,
   -240303424,    1576253056,    387191296,
    54331336,    1439243520,    408236640,
   -396640224,    1694794112,    646392576,
   -89764816,    1871746688,    394492736,
    7086696,    1484984960,    514107584,
    45741400,    1444827008,    524200768,
    151397600,    1621135360,    425846016,
    161490768,    1535880320,    466648192,
    190267056,    1323494144,    658633216,
    46600396,    1743971456,    434006432,
    340161408,    1570025344,    374950656,
    258557024,    1566804096,    424772256,
    264355232,    1611042176,    264999488,
    367004960,    1368376576,    227633264,
    256194800,    1411755776,
};
#else
//2.56
const Word16 tdm_LSF_MEAN_RE_USE_OUT_fx[M] =
{
   771,  1335,  2229,  3431,  4383,  5354,  6371,  7273,  8183,  9198,  10133,  10991,  12058,  13104,  14200,  15152
};
//2.56
const Word16 tdm_LSF_MEAN_RE_USE_IN_fx[M] =
{
    733,  1337,  2271,  3451,  4418,  5382,  6430,  7304,  8221,  9247,  10165,  11079,  12115,  13197,  14266,  15269,
};
//2.56
const Word16 tdm_LSF_MEAN_RE_USE_fx[M] =
{
    680,  1369,  2354,  3448,  4498,  5435,  6546,  7494,  8446,  9437,  10328,  11248,  12241,  13199,  14189,  15174
};
const Word16 tdm_Beta_Q1bit_re_use_13k2_fx[2] = { 31784, 24576 };//Q15
const Word16 tdm_Beta_Q1bit_re_use_16k4_fx[2] = { 31129, 23265 };//Q15
const Word16 tdm_Beta_Q1bit_re_use_24k4_32k_fx[2] = { 30474, 23920 };//Q15
const Word16 tdm_Beta_Q1bit_re_use_48k_fx[2] = { 31784, 25231 };//Q15
//Q15
const Word16 tdm_RE_USE_adaptive_beta_prd_diag_3_fx[15 + 16 + 15] =
{
    29028,  6750,  1916,  27016,  7516,  1195,  26787,  5557,  -196,  27796,  6753,  2172,  29434,  4446,  2175,  26053,  6337,  3063,  26043,  5521,  3633,  26082,
    5989,  3515,  25672,  5911,  4846,  24123,  6494,  4374,  24971,  6225,  6235,  24146,  5619,  5848,  23638,  5393,  6445,  22579,  4027,  6694,  20698,  1779,
    5789,  17681
};
//2.56
const Word16 tdm_LSF_MEAN_PRED_QNT_fx[M] =
{
    1002,  1558,  2478,  3467,  4377,  5326,  6274,  7160,  8182,  9099,  10022,  10967,  12051,  13081,  14148,  15113
};
//2.56
const Word16 tdm_LSF_MEAN_PRED_QNT_IN_fx[M] =
{
    739,  1371,  2303,  3436,  4431,  5394,  6378,  7321,  8293,  9282,  10221,  11153,  12166,  13193,  14252,  15290
};
//2.56
const Word16 tdm_LSF_MEAN_PRED_QNT_OUT_fx[M] =
{
    733,  1337,  2271,  3451,  4418,  5382,  6430,  7304,  8221,  9247,  10165,  11079,  12115,  13197,  14266,  15269
};
//Q15
const Word16 tdm_PRED_QNT_fixed_beta_prd_diag_3_fx[15 + 16 + 15] =
{
    23067,  3941,  -3666,  24050,  5907,  829,  21960,  6229,  -6052,  25859,  9862,  -1369,  28559,  6019,  108,  22658,  7844,  697,  22045,  7998,  2310,  24735,
    6497,  2464,  23434,  7120,  2903,  20194,  10049,  711,  26610,  6622,  5190,  23955,  5721,  3945,  23906,  6481,  4033,  24581,  4043,  5599,  20879,  3473,
    3909,  21541
};
#endif
/* LSFs Intra-frame prediction tables */
const float tdm_LSF_MEAN_RE_USE_OUT[M] =
{
@@ -839,7 +812,7 @@ const float tdm_PRED_QNT_fixed_beta_prd_diag_3[15 + 16 + 15] =
    0.1709f,    0.6372f,    0.1060f,
    0.1193f,    0.6574f,
};
#endif
const int16_t fast_FCB_bits_2sfr[] = {8, 14, 18, 20, 24, 128/*stop value*/};
const int16_t fast_FCB_rates_2sfr[] = {/*16*50,*/ (8+14)*50, 28*50, 32*50, 34*50, 36*50, 38*50, 40*50, 42*50, 44*50, 48*50};
+17 −17
Original line number Diff line number Diff line
@@ -112,22 +112,22 @@ extern const int16_t tdm_bit_allc_tbl[5][6];

/* LSFs Intra-frame prediction tables */
#ifdef IVAS_FLOAT_FIXED
extern const Word32 tdm_LSF_MEAN_RE_USE_OUT_fx[M];
extern const Word32 tdm_LSF_MEAN_RE_USE_IN_fx[M];
extern const Word32 tdm_LSF_MEAN_RE_USE_fx[M];

extern const Word32 tdm_Beta_Q1bit_re_use_13k2_fx[2];
extern const Word32 tdm_Beta_Q1bit_re_use_16k4_fx[2];
extern const Word32 tdm_Beta_Q1bit_re_use_24k4_32k_fx[2];
extern const Word32 tdm_Beta_Q1bit_re_use_48k_fx[2];

extern const Word32 tdm_RE_USE_adaptive_beta_prd_diag_3_fx[15 + 16 + 15];

extern const Word32 tdm_LSF_MEAN_PRED_QNT_OUT_fx[M];
extern const Word32 tdm_LSF_MEAN_PRED_QNT_IN_fx[M];
extern const Word32 tdm_LSF_MEAN_PRED_QNT_fx[M];
extern const Word32 tdm_PRED_QNT_fixed_beta_prd_diag_3_fx[15 + 16 + 15];
#else
extern const Word16 tdm_LSF_MEAN_RE_USE_OUT_fx[M];
extern const Word16 tdm_LSF_MEAN_RE_USE_IN_fx[M];
extern const Word16 tdm_LSF_MEAN_RE_USE_fx[M];

extern const Word16 tdm_Beta_Q1bit_re_use_13k2_fx[2];
extern const Word16 tdm_Beta_Q1bit_re_use_16k4_fx[2];
extern const Word16 tdm_Beta_Q1bit_re_use_24k4_32k_fx[2];
extern const Word16 tdm_Beta_Q1bit_re_use_48k_fx[2];

extern const Word16 tdm_RE_USE_adaptive_beta_prd_diag_3_fx[15 + 16 + 15];

extern const Word16 tdm_LSF_MEAN_PRED_QNT_OUT_fx[M];
extern const Word16 tdm_LSF_MEAN_PRED_QNT_IN_fx[M];
extern const Word16 tdm_LSF_MEAN_PRED_QNT_fx[M];
extern const Word16 tdm_PRED_QNT_fixed_beta_prd_diag_3_fx[15 + 16 + 15];
#endif
extern const float tdm_LSF_MEAN_RE_USE_OUT[M];
extern const float tdm_LSF_MEAN_RE_USE_IN[M];
extern const float tdm_LSF_MEAN_RE_USE[M];
@@ -143,7 +143,7 @@ extern const float tdm_LSF_MEAN_PRED_QNT_OUT[M];
extern const float tdm_LSF_MEAN_PRED_QNT_IN[M];
extern const float tdm_LSF_MEAN_PRED_QNT[M];
extern const float tdm_PRED_QNT_fixed_beta_prd_diag_3[15 + 16 + 15];
#endif

extern const int16_t fast_FCB_bits_2sfr[];
extern const int16_t fast_FCB_rates_2sfr[];

Loading