Commit 7388eeb8 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'ivas_td_stereo_bit_alloc' into 'main'

Functions in ivas_td_stereo_bit_alloc converted to fxd

See merge request !142
parents cc65aee3 b9103e24
Loading
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -2225,12 +2225,34 @@ void tdm_low_rate_dec(
    const float *lsf_new                                        /* i  : ISFs at the end of the frame            */
);

#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        */
);
#endif

void tdm_SCh_LSF_intra_pred(
    const int32_t element_brate,                                /* i  : element bitrate                         */
    const float *tdm_lsfQ_PCh,                                  /* i  : primary channel LSFs                    */
    float *pred_lsf_SCh                                         /* o  : predicted secondary channel LSFs        */
);

#ifdef IVAS_FLOAT_FIXED
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 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                             */
    Word16 *beta_index                                          /* i/o: quantization index                      */
);
#endif

void tdm_SCh_lsf_reuse(
    const int16_t enc_dec,                                      /* i  : encoder/decoder flag                    */
    const int32_t element_brate,                                /* i  : element bitrate                         */
+81 −2
Original line number Diff line number Diff line
@@ -634,7 +634,86 @@ const int16_t tdm_bit_allc_tbl[5][6] =
     { 1650,  6050, 0,  10000,  0, 10000 },  /* IVAS_32k     */
     { 1650,  6050, 0,  13000,  0, 14000 }   /* IVAS_48k     */
};
#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
/* LSFs Intra-frame prediction tables */
const float tdm_LSF_MEAN_RE_USE_OUT[M] =
{
@@ -711,7 +790,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};
+18 −1
Original line number Diff line number Diff line
@@ -106,6 +106,23 @@ extern const float tdm_den_ratio_tabl[];
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 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];
@@ -121,7 +138,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[];

+349 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#include "prot.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "prot_fx1.h"
#include "prot_fx2.h"
#endif

@@ -549,6 +550,31 @@ void td_stereo_param_updt_fx(
    return;
}
#endif

#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
 * tdm_SCh_LSF_intra_pred_zero_bits_fx()
 *
 *
 *-------------------------------------------------------------------*/

static void tdm_SCh_LSF_intra_pred_zero_bits_fx(
    const Word32 *tdm_lsfQ_PCh_fx, /* i  : primary channel LSFs             */
    Word32 *pred_lsf_SCh_fx,       /* o  : predicted secondary channel LSFs */
    const Word32 *lsf_mean_fx,     /* i  : secondary channel mean LSFs      */
    const Word32 beta_fx           /* i  : pull to average beta factor      */
)
{
    Word16 i;
    /* pulling the LSFs closer to the average */
    FOR( i = 0; i < M; i++ )
    {
        pred_lsf_SCh_fx[i] = L_add( Mpy_32_32( beta_fx, tdm_lsfQ_PCh_fx[i] ), Mpy_32_32( L_sub( ONE_IN_Q31, beta_fx ), lsf_mean_fx[i] ) );
    }

    return;
}
#else
/*-------------------------------------------------------------------*
 * tdm_SCh_LSF_intra_pred_zero_bits()
 *
@@ -572,8 +598,60 @@ static void tdm_SCh_LSF_intra_pred_zero_bits(

    return;
}
#endif
#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
 * tdm_SCh_LSF_intra_pred_tri_diag_mat_fx()
 *
 *
 *-------------------------------------------------------------------*/

static void tdm_SCh_LSF_intra_pred_tri_diag_mat_fx(
    Word32 *lsf_SCh_fx,            /* i/o: secondary channel LSFs               */
    const Word32 *lsf_mean_in_fx,  /* i  : secondary channel mean LSFs (in)     */
    const Word32 *lsf_mean_out_fx, /* i  : secondary channel mean LSFs (out)    */
    const Word32 *prd_diag_3_fx    /* i  : secondary channel mean LSFs          */
)
{
    Word16 i;
    Word32 lsf_tmp_fx[M];
    const Word32 *prd_ptr_fx;
    Word32 *lsf_tmp_ptr1_fx;
    Word32 *lsf_tmp_ptr2_fx;
    Word32 *lsf_SCh_ptr_fx;

    prd_ptr_fx = prd_diag_3_fx;

    v_sub_32( lsf_SCh_fx, lsf_mean_in_fx, lsf_tmp_fx, M );

    lsf_tmp_ptr1_fx = lsf_tmp_fx;
    lsf_SCh_ptr_fx = lsf_SCh_fx;

    lsf_tmp_ptr2_fx = lsf_tmp_ptr1_fx;

    *lsf_SCh_ptr_fx = Mpy_32_32( *lsf_tmp_ptr1_fx++, *prd_ptr_fx++ );
    *lsf_SCh_ptr_fx = L_add( *lsf_SCh_ptr_fx, Mpy_32_32( *lsf_tmp_ptr1_fx++, *prd_ptr_fx++ ) );
    lsf_SCh_ptr_fx++;

    FOR( i = 1; i < M - 1; i++ )
    {
        lsf_tmp_ptr1_fx = lsf_tmp_ptr2_fx;
        *lsf_SCh_ptr_fx = Mpy_32_32( *lsf_tmp_ptr1_fx++, *prd_ptr_fx++ );
        lsf_tmp_ptr2_fx = lsf_tmp_ptr1_fx;
        *lsf_SCh_ptr_fx = L_add( *lsf_SCh_ptr_fx, Mpy_32_32( ( *lsf_tmp_ptr1_fx++ ), ( *prd_ptr_fx++ ) ) );
        ( *lsf_SCh_ptr_fx ) = L_add( *lsf_SCh_ptr_fx, Mpy_32_32( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx++ ) ) );
        lsf_SCh_ptr_fx++;
    }

    lsf_tmp_ptr1_fx = lsf_tmp_ptr2_fx;

    *lsf_SCh_ptr_fx = L_add( Mpy_32_32( ( *lsf_tmp_ptr1_fx++ ), ( *prd_ptr_fx++ ) ), Mpy_32_32( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx ) ) );

    v_add_32( lsf_SCh_fx, lsf_mean_out_fx, lsf_SCh_fx, M );

    return;
}
#else
/*-------------------------------------------------------------------*
 * tdm_SCh_LSF_intra_pred_tri_diag_mat()
 *
@@ -622,7 +700,50 @@ static void tdm_SCh_LSF_intra_pred_tri_diag_mat(

    return;
}
#endif
#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
 * tdm_SCh_LSF_intra_pred_fx()
 *
 *
 *-------------------------------------------------------------------*/

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 */
)
{
    Word32 fixed_beta;

    IF( element_brate <= IVAS_13k2 )
    {
        fixed_beta = 1868310773; // 0.87f in Q31
    }
    ELSE IF( element_brate <= IVAS_16k4 )
    {
        fixed_beta = 2018634629; // 0.94f in Q31
    }
    ELSE IF( element_brate <= IVAS_24k4 )
    {
        fixed_beta = 1954210119; // 0.91f in Q31
    }
    ELSE IF( element_brate <= IVAS_32k )
    {
        fixed_beta = 1975684956; // 0.92f in Q31
    }
    ELSE
    {
        fixed_beta = 1954210119; // 0.91f in Q31
    }

    tdm_SCh_LSF_intra_pred_zero_bits_fx( tdm_lsfQ_PCh_fx, pred_lsf_SCh_fx, tdm_LSF_MEAN_PRED_QNT_fx, fixed_beta );

    tdm_SCh_LSF_intra_pred_tri_diag_mat_fx( pred_lsf_SCh_fx, tdm_LSF_MEAN_PRED_QNT_IN_fx, tdm_LSF_MEAN_PRED_QNT_OUT_fx, tdm_PRED_QNT_fixed_beta_prd_diag_3_fx );

    return;
}
#endif

/*-------------------------------------------------------------------*
 * tdm_SCh_LSF_intra_pred()
@@ -636,6 +757,47 @@ void tdm_SCh_LSF_intra_pred(
    float *pred_lsf_SCh          /* o  : predicted secondary channel LSFs */
)
{
#ifdef IVAS_FLOAT_FIXED
    Word32 fixed_beta;

    IF( element_brate <= IVAS_13k2 )
    {
        fixed_beta = 1868310773; // 0.87f in Q31
    }
    ELSE IF( element_brate <= IVAS_16k4 )
    {
        fixed_beta = 2018634629; // 0.94f in Q31
    }
    ELSE IF( element_brate <= IVAS_24k4 )
    {
        fixed_beta = 1954210119; // 0.91f in Q31
    }
    ELSE IF( element_brate <= IVAS_32k )
    {
        fixed_beta = 1975684956; // 0.92f in Q31
    }
    ELSE
    {
        fixed_beta = 1954210119; // 0.91f in Q31
    }

    Word32 pred_lsf_SCh_fx[M];
    Word32 tdm_lsfQ_PCh_fx[M];

    FOR( Word16 i = 0; i < M; i++ )
    {
        tdm_lsfQ_PCh_fx[i] = (Word32) ( tdm_lsfQ_PCh[i] * ( 1 << 18 ) );
    }

    tdm_SCh_LSF_intra_pred_zero_bits_fx( tdm_lsfQ_PCh_fx, pred_lsf_SCh_fx, tdm_LSF_MEAN_PRED_QNT_fx, fixed_beta );

    tdm_SCh_LSF_intra_pred_tri_diag_mat_fx( pred_lsf_SCh_fx, tdm_LSF_MEAN_PRED_QNT_IN_fx, tdm_LSF_MEAN_PRED_QNT_OUT_fx, tdm_PRED_QNT_fixed_beta_prd_diag_3_fx );

    FOR( Word16 i = 0; i < M; i++ )
    {
        pred_lsf_SCh[i] = (float) pred_lsf_SCh_fx[i] / ( 1 << 18 );
    }
#else
    float fixed_beta;

    if ( element_brate <= IVAS_13k2 )
@@ -662,11 +824,39 @@ void tdm_SCh_LSF_intra_pred(
    tdm_SCh_LSF_intra_pred_zero_bits( tdm_lsfQ_PCh, pred_lsf_SCh, tdm_LSF_MEAN_PRED_QNT, fixed_beta );

    tdm_SCh_LSF_intra_pred_tri_diag_mat( pred_lsf_SCh, tdm_LSF_MEAN_PRED_QNT_IN, tdm_LSF_MEAN_PRED_QNT_OUT, tdm_PRED_QNT_fixed_beta_prd_diag_3 );

#endif
    return;
}

#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
 * tdm_SCh_LSF_intra_pred_one_bit_dec_fx()
 *
 *
 *-------------------------------------------------------------------*/

static void tdm_SCh_LSF_intra_pred_one_bit_dec_fx(
    const Word32 *tdm_lsfQ_PCh_fx, /* i  : primary channel LSFs                             */
    Word32 *pred_lsf_SCh_fx,       /* o  : predicted secondary channel LSFs                 */
    const Word32 *lsf_mean_fx,     /* i  : secondary channel mean LSFs                      */
    const Word32 *Beta_Q_x_fx,     /* i  : beta quantization values                         */
    const Word16 beta_index_fx     /* i  : the quantization bits for beta (-1 if beta fixed)*/
)
{
    Word16 i;
    Word32 beta_fx;

    beta_fx = Beta_Q_x_fx[beta_index_fx]; // Q31

    /* pulling the LSFs closer to the avergae */
    for ( i = 0; i < M; i++ )
    {
        pred_lsf_SCh_fx[i] = Madd_32_32( Mpy_32_32( beta_fx, tdm_lsfQ_PCh_fx[i] ), L_sub( ONE_IN_Q31, beta_fx ), lsf_mean_fx[i] );
    }

    return;
}
#else
/*-------------------------------------------------------------------*
 * tdm_SCh_LSF_intra_pred_one_bit_dec()
 *
@@ -694,8 +884,56 @@ static void tdm_SCh_LSF_intra_pred_one_bit_dec(

    return;
}
#endif
#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
 * tdm_SCh_LSF_intra_pred_one_bit_enc_fx()
 *
 *
 *-------------------------------------------------------------------*/

static void tdm_SCh_LSF_intra_pred_one_bit_enc_fx(
    const Word32 *lsf_SCh_fx,      /* i  : secondary channel LSFs                              */
    const Word32 *tdm_lsfQ_PCh_fx, /* i  : primary channel LSFs                                */
    Word32 *pred_lsf_SCh_fx,       /* o  : predicted secondary channel LSFs                    */
    const Word32 *lsf_mean_fx,     /* i  : secondary channel mean LSFs                         */
    const Word32 *lsf_wgts_new_fx, /* i  : Improved wgts for LSFs                              */
    const Word32 *Beta_Q_x_fx,     /* i  : beta quantization values                            */
    Word16 *beta_index             /* o  : the quantization bits for beta (-1 if beta fixed)   */
)
{
    Word16 i;

    Word32 A_temp_fx[M];
    Word32 B_temp_fx[M];
    Word32 WD_fx[2] = { 0 };

    FOR( i = 0; i < M; i++ )
    {
        A_temp_fx[i] = L_sub( lsf_SCh_fx[i], lsf_mean_fx[i] );
        B_temp_fx[i] = L_sub( lsf_mean_fx[i], tdm_lsfQ_PCh_fx[i] );
    }

    FOR( i = 0; i < M; i++ )
    {
        WD_fx[0] += Mpy_32_32( lsf_wgts_new_fx[i], Mpy_32_32( A_temp_fx[i], A_temp_fx[i] ) ) + 2 * Mpy_32_32( Beta_Q_x_fx[0], Mpy_32_32( lsf_wgts_new_fx[i], Mpy_32_32( A_temp_fx[i], B_temp_fx[i] ) ) ) + Mpy_32_32( lsf_wgts_new_fx[i], Mpy_32_32( Mpy_32_32( Beta_Q_x_fx[0], Beta_Q_x_fx[0] ), Mpy_32_32( B_temp_fx[i], B_temp_fx[i] ) ) );
        WD_fx[1] += Mpy_32_32( lsf_wgts_new_fx[i], Mpy_32_32( A_temp_fx[i], A_temp_fx[i] ) ) + 2 * Mpy_32_32( Beta_Q_x_fx[1], Mpy_32_32( lsf_wgts_new_fx[i], Mpy_32_32( A_temp_fx[i], B_temp_fx[i] ) ) ) + Mpy_32_32( lsf_wgts_new_fx[i], Mpy_32_32( Mpy_32_32( Beta_Q_x_fx[1], Beta_Q_x_fx[1] ), Mpy_32_32( B_temp_fx[i], B_temp_fx[i] ) ) );
    }

    IF( WD_fx[0] < WD_fx[1] )
    {
        *beta_index = 0;
    }
    ELSE
    {
        *beta_index = 1;
    }

    tdm_SCh_LSF_intra_pred_one_bit_dec_fx( tdm_lsfQ_PCh_fx, pred_lsf_SCh_fx, tdm_LSF_MEAN_RE_USE_fx, Beta_Q_x_fx, *beta_index );

    return;
}
#else
/*-------------------------------------------------------------------*
 * tdm_SCh_LSF_intra_pred_one_bit_enc()
 *
@@ -744,7 +982,61 @@ static void tdm_SCh_LSF_intra_pred_one_bit_enc(

    return;
}
#endif
#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
 * tdm_SCh_lsf_reuse_fx()
 *
 *
 *-------------------------------------------------------------------*/

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,
    Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame        */
    Word16 lsp_new_q_fx,
    const Word32 tdm_lsfQ_PCh_fx[M], /* i  : primary channel LSFs                */
    const Word32 lsf_wgts_fx[M],     /* i  : LSF weights                         */
    Word16 *beta_index               /* i/o: quantization index                  */
)
{
    const Word32 *Beta_Q1bit_re_use_fx;

    IF( element_brate <= IVAS_13k2 )
    {
        Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_13k2_fx;
    }
    ELSE IF( element_brate <= IVAS_16k4 )
    {
        Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_16k4_fx;
    }
    ELSE IF( element_brate <= IVAS_32k )
    {
        Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_24k4_32k_fx;
    }
    ELSE
    {
        Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_48k_fx;
    }

    IF( enc_dec == ENC )
    {
        tdm_SCh_LSF_intra_pred_one_bit_enc_fx( lsf_new_fx, tdm_lsfQ_PCh_fx, lsf_new_fx, tdm_LSF_MEAN_RE_USE_fx, lsf_wgts_fx, Beta_Q1bit_re_use_fx, beta_index );
    }
    ELSE /* DEC */
    {
        tdm_SCh_LSF_intra_pred_one_bit_dec_fx( tdm_lsfQ_PCh_fx, lsf_new_fx, tdm_LSF_MEAN_RE_USE_fx, Beta_Q1bit_re_use_fx, *beta_index );
    }

    tdm_SCh_LSF_intra_pred_tri_diag_mat_fx( lsf_new_fx, tdm_LSF_MEAN_RE_USE_IN_fx, tdm_LSF_MEAN_RE_USE_OUT_fx, tdm_RE_USE_adaptive_beta_prd_diag_3_fx );

    lsf2lsp_32_fx( lsf_new_fx, lsf_new_q_fx, lsp_new_fx, &lsp_new_q_fx, M, INT_FS_12k8 );

    return;
}
#endif

/*-------------------------------------------------------------------*
 * tdm_SCh_lsf_reuse()
@@ -762,6 +1054,61 @@ void tdm_SCh_lsf_reuse(
    int16_t *beta_index          /* i/o: quantization index                  */
)
{
#ifdef IVAS_FLOAT_FIXED
    ////////// to be removed ////////////////
    Word32 lsf_new_fx[M];
    Word32 tdm_lsfQ_PCh_fx[M];
    Word32 lsf_wgts_fx[M];
    Word16 lsp_new_fx[M];
    Word16 lsf_new_q_fx = 18;
    Word16 lsp_new_q_fx;
    FOR( Word16 i = 0; i < M; i++ )
    {
        lsf_new_fx[i] = (Word32) ( lsf_new[i] * ( 1 << lsf_new_q_fx ) );
        tdm_lsfQ_PCh_fx[i] = (Word32) ( tdm_lsfQ_PCh[i] * ( 1 << 18 ) );
        IF( enc_dec == ENC )
        {
            lsf_wgts_fx[i] = (Word32) ( lsf_wgts[i] * ( 1 << 26 ) );
        }
    }
    /////////////////////////////////////////
    const Word32 *Beta_Q1bit_re_use_fx;
    IF( element_brate <= IVAS_13k2 )
    {
        Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_13k2_fx;
    }
    ELSE IF( element_brate <= IVAS_16k4 )
    {
        Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_16k4_fx;
    }
    ELSE IF( element_brate <= IVAS_32k )
    {
        Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_24k4_32k_fx;
    }
    ELSE
    {
        Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_48k_fx;
    }

    IF( enc_dec == ENC )
    {
        tdm_SCh_LSF_intra_pred_one_bit_enc_fx( lsf_new_fx, tdm_lsfQ_PCh_fx, lsf_new_fx, tdm_LSF_MEAN_RE_USE_fx, lsf_wgts_fx, Beta_Q1bit_re_use_fx, beta_index );
    }
    ELSE /* DEC */
    {
        tdm_SCh_LSF_intra_pred_one_bit_dec_fx( tdm_lsfQ_PCh_fx, lsf_new_fx, tdm_LSF_MEAN_RE_USE_fx, Beta_Q1bit_re_use_fx, *beta_index );
    }

    tdm_SCh_LSF_intra_pred_tri_diag_mat_fx( lsf_new_fx, tdm_LSF_MEAN_RE_USE_IN_fx, tdm_LSF_MEAN_RE_USE_OUT_fx, tdm_RE_USE_adaptive_beta_prd_diag_3_fx );

    lsf2lsp_32_fx( lsf_new_fx, lsf_new_q_fx, lsp_new_fx, &lsp_new_q_fx, M, INT_FS_12k8 );

    FOR( Word16 i = 0; i < M; i++ )
    {
        lsf_new[i] = (float) lsf_new_fx[i] / ( 1 << lsf_new_q_fx );
        lsp_new[i] = (float) lsp_new_fx[i] / ( 1 << lsp_new_q_fx );
    }
#else
    const float *Beta_Q1bit_re_use;

    if ( element_brate <= IVAS_13k2 )
@@ -793,6 +1140,6 @@ void tdm_SCh_lsf_reuse(
    tdm_SCh_LSF_intra_pred_tri_diag_mat( lsf_new, tdm_LSF_MEAN_RE_USE_IN, tdm_LSF_MEAN_RE_USE_OUT, tdm_RE_USE_adaptive_beta_prd_diag_3 );

    lsf2lsp( lsf_new, lsp_new, M, INT_FS_12k8 );

#endif
    return;
}
+31 −0
Original line number Diff line number Diff line
@@ -1615,6 +1615,37 @@ void lsp2lsf(
    return;
}

#ifdef IVAS_FLOAT_FIXED
/*-----------------------------------------------------------------------*
 * lsf2lsp_32_fx()
 *
 * Transformation of LSFs to LSPs
 *
 * LSP are line spectral pairs in cosine domain (-1 to 1).
 * LSF are line spectral frequencies (0 to fs/2).
 *-----------------------------------------------------------------------*/

void lsf2lsp_32_fx(
    const Word32 lsf_fx[], /* i  : isf[m] normalized (range: 0<=val<=fs/2) */
    Word16 lsf_q_fx,
    Word16 lsp_fx[], /* o  : isp[m] (range: -1<=val<1)               */
    Word16 *lsp_q_fx,
    const Word16 m, /* i  : LPC order                               */
    const Word32 Fs /* i  : sampling frequency                      */
)
{
    Word16 i;

    /* convert LSFs to LSPs */
    FOR( i = 0; i < m; i++ )
    {
        lsp_fx[i] = getCosWord16R2( div_l( L_shr( lsf_fx[i], lsf_q_fx - 13 ), div_l( Fs, shl( 2, 1 ) ) ) );
    }
    *lsp_q_fx = 15;
  return;
}
#endif

/*-----------------------------------------------------------------------*
 * lsf2lsp()
 *
Loading