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

Integration of spar decoder functions, crash fix and high MLD fix.

[x] High MLD fix in CPE dec and stereo_switching dec.
[x] spar decoder functions converted to fixed point.
[x] ivas_bw_switching_pre_proc function crash fix.
parent 58fa0557
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@
#define ONE_IN_Q29                      536870912
#define ONE_IN_Q30                      1073741824
#define ONE_IN_Q31                      0x7fffffff
#define MINUS_ONE_IN_Q31                      -2147483648

#define MAX_WORD16                      32767
#define ONE_IN_Q62                      (Word64)0x4000000000000000
+3 −0
Original line number Diff line number Diff line
@@ -1032,8 +1032,11 @@ typedef enum

/* Common SPAR metadata constants */
#define IVAS_ACTIVEW_DM_F_SCALE                 0.5f
#define IVAS_ACTIVEW_DM_F_SCALE_FX                 ONE_IN_Q30
#define IVAS_ACTIVEW_DM_F_SCALE_DTX             0.25f
#define IVAS_ACTIVEW_DM_F_SCALE_DTX_FX             ONE_IN_Q29
#define IVAS_ACTIVEW_DM_F_SCALE_VLBR            0.25f
#define IVAS_ACTIVEW_DM_F_SCALE_VLBR_FX            ONE_IN_Q29
#define IVAS_SPAR_FOA_DFLT_FREQ_PER_CHAN        24000

#define IVAS_SPAR_DYN_ACTIVEW_THRESH           (0.0039f)
+49 −1
Original line number Diff line number Diff line
@@ -3754,6 +3754,13 @@ int16_t masa_sq(
    const int16_t cb_sz                                         /* i  : codebook size                           */
);

#ifdef IVAS_FLOAT_FIXED
Word16 masa_sq_fx(
    const Word32 in,         /* i  : input value     */
    const Word32 *threshold, /* i  : partition       */
    const Word16 cb_sz       /* i  : codebook size   */
);
#endif
void ivas_qmetadata_azimuth_elevation_to_direction_vector(
    const float az,                                             /* i  : azimuth                                 */
    const float el,                                             /* i  : elevation                               */
@@ -4365,6 +4372,12 @@ void ivas_dirac_dec_get_response_fixed_Q(
    Word32 *response,
    const Word16 ambisonics_order,
    Word16 Q);

void ivas_dirac_dec_get_response_fx(
    const Word16 azimuth,
    const Word16 elevation,
    Word32 * response,
    const Word16 ambisonics_order);
#endif

void calculate_hodirac_sector_parameters(
@@ -5172,7 +5185,25 @@ void ivas_calc_c_p_coeffs(
    const int16_t compute_p_flag,
    const int16_t dyn_active_w_flag
);

#ifdef IVAS_FLOAT_FIXED
void ivas_get_spar_md_from_dirac_fx(
    float azi_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
    float ele_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
    float diffuseness[IVAS_MAX_NUM_BANDS],
    const int16_t n_ts,
    float ***mixer_mat,
    ivas_spar_md_t *hSpar_md,
    ivas_spar_md_com_cfg *hSpar_md_cfg,
    const int16_t start_band,
    const int16_t end_band,
    const int16_t order,
    const int16_t dtx_vad,
    float Wscale_d[IVAS_MAX_NUM_BANDS],
    const uint8_t useLowerRes,
    const int16_t active_w_vlbr,
    const int16_t  dyn_active_w_flag
);
#endif
void ivas_get_spar_md_from_dirac(
    float azi_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
    float ele_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES],
@@ -5271,6 +5302,10 @@ int16_t ivas_spar_chk_zero_coefs(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder handle                     */
);

Word16 ivas_spar_chk_zero_coefs_fx(
  Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder handle                     */
);

void ivas_spar_smooth_md_dtx(
    ivas_spar_md_dec_state_t *hMdDec,                           /* i/o: SPAR MD decoder handle                  */
    const int16_t num_bands_out,                                /* i  : number of output bands                  */
@@ -5664,6 +5699,14 @@ void ivas_quantise_real_values(
    float *quant,
    const int16_t dim
);
void ivas_quantise_real_values_fx(
  const Word32 *values_fx,
  const int16_t q_levels,
  const Word32 min_value_fx,
  const Word32 max_value_fx,
  int16_t *index,
  Word32 *quant_fx,
  const int16_t dim);

void ivas_spar_get_uniform_quant_strat(
    ivas_spar_md_com_cfg *pSpar_md_com_cfg,
@@ -5684,6 +5727,11 @@ void ivas_spar_quant_dtx_init_fx(
  Word32 *min_max
);

void ivas_spar_quant_dtx_init_fx(
  ivas_spar_md_t *spar_md,
  Word32 *min_max
);

void ivas_map_prior_coeffs_quant(
    ivas_spar_md_prev_t *pSpar_md_prior,
    ivas_spar_md_com_cfg *pSpar_md_cfg,
+24 −0
Original line number Diff line number Diff line
@@ -660,6 +660,25 @@ Word16 masa_sq_fx(
    const Word16 cb_sz       /* i  : codebook size                           */
);

void ivas_compute_spar_params_fx(
    Word32 * pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
    Word32 dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS],
    const int16_t i_ts,
    float ***mixer_mat,
    const int16_t start_band,
    const int16_t end_band,
    const int16_t dtx_vad,
    const int16_t num_ch,
    const int16_t bands_bw,
    const int16_t active_w,
    const int16_t active_w_vlbr,
    ivas_spar_md_com_cfg * hSparCfg,
    ivas_spar_md_t * hSparMd,
    float *pWscale,
    const int16_t from_dirac,
    const int16_t dyn_active_w_flag
);

ivas_error ivas_ism_metadata_dec_fx(
    const Word32 ism_total_brate,           /* i  : ISM  total bitrate                     */
    const Word16 nchan_ism,                 /* i  : number of ISM channels                 */
@@ -1883,4 +1902,9 @@ void ivas_qmetadata_close(
    IVAS_QMETADATA_HANDLE *hQMetaData /* i/o: q_metadata handle         */
);
#endif

ivas_error ivas_spar_dec_fx(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct             */
    Word16 *nb_bits_read    /* o  : number of MD bits read          */
);
#endif
+205 −0
Original line number Diff line number Diff line
@@ -1657,6 +1657,7 @@ const ivas_huff_models_t ivas_huff_decd_r_consts[TOTAL_DECD_QUANT_STRATS] =
/* DTX quantization and bitstream constants */
const float dtx_pd_real_min_max[2] = { 0, 1.6f };
const Word32 dtx_pd_real_min_max_fx[2] = { 0, 429496729 };
const int16_t dtx_pd_real_q_levels[3][3] = { { 7,7,7 },{ 7,7,0 },{ 3,0,0 } };
const int16_t dtx_pr_real_q_levels[3][3] = { { 9,9,9 },{ 9,7,9 },{ 9,5,7 } };
const int16_t pr_pr_idx_pairs[3][3][2] = { { { 0, 0 },{ 0, 0 },{ 0, 0 } },{ { 0, 0 },{ 0, 0 },{ 0, 0 } },{ { 0, 0 },{ 1, 3 },{ 0, 0 } } };
@@ -5462,6 +5463,11 @@ const Word32 dirac_gains_norm_term_int[9] = //Q30
    1073741824,  759250176,  1073741824,  438353280,  219176688,  1073741824,  309962528,  98018768,  
    40015996
};
const Word32 dirac_gains_norm_term_fx[9] = //Q31
{
    2147483647,  1518500352,  2147483647,  876706560,  438353376,  2147483647,  619925056,  196037536,  80031992
};
#endif
const float dirac_gains_Pnm[91][9] = 
{
@@ -6022,6 +6028,190 @@ const Word32 dirac_gains_trg_term_int[181][2] = //Q30
    {1073578304,  -18739382},
    {1073741824,  0}
};
const Word32 dirac_gains_trg_term_fx[181][2] = //Q31
{
    {-2147483648,187},
    {-2147156608,-37478872},
    {-2146175360,-74946000},
    {-2144540544,-112390808},
    {-2142252544,-149800880},
    {-2139311872,-187165312},
    {-2135719552,-224473248},
    {-2131476480,-261712336},
    {-2126584576,-298872160},
    {-2121044736,-335940320},
    {-2114858496,-372906880},
    {-2108028416,-409759200},
    {-2100556032,-446486752},
    {-2092443904,-483078816},
    {-2083694208,-519523328},
    {-2074309888,-555809792},
    {-2064293760,-591926784},
    {-2053648896,-627863232},
    {-2042378240,-663608960},
    {-2030485760,-699152192},
    {-2017974528,-734482816},
    {-2004848896,-769589184},
    {-1991112320,-804461312},
    {-1976769280,-839088832},
    {-1961824000,-873460224},
    {-1946281216,-907565888},
    {-1930145664,-941394752},
    {-1913421952,-974937408},
    {-1896115584,-1008182592},
    {-1878231680,-1041120448},
    {-1859775360,-1073742080},
    {-1840752768,-1106035712},
    {-1821169152,-1137993088},
    {-1801031424,-1169603328},
    {-1780344960,-1200857344},
    {-1759115776,-1231746176},
    {-1737351040,-1262259072},
    {-1715056640,-1292388096},
    {-1692240256,-1322122752},
    {-1668908160,-1351455488},
    {-1645067776,-1380375808},
    {-1620726784,-1408876032},
    {-1595891328,-1436947072},
    {-1570570112,-1464580224},
    {-1544770304,-1491767808},
    {-1518500352,-1518500352},
    {-1491767808,-1544770304},
    {-1464580224,-1570570112},
    {-1436947200,-1595891328},
    {-1408876032,-1620726784},
    {-1380375808,-1645067776},
    {-1351455104,-1668908288},
    {-1322122752,-1692240256},
    {-1292388096,-1715056640},
    {-1262259072,-1737350784},
    {-1231746176,-1759115520},
    {-1200857344,-1780344704},
    {-1169603584,-1801031424},
    {-1137993088,-1821169152},
    {-1106035712,-1840752768},
    {-1073742080,-1859775360},
    {-1041120448,-1878231552},
    {-1008182592,-1896115584},
    {-974937408,-1913421952},
    {-941394752,-1930145664},
    {-907565888,-1946281216},
    {-873460416,-1961823872},
    {-839088832,-1976769280},
    {-804461568,-1991112320},
    {-769589184,-2004848896},
    {-734482560,-2017974528},
    {-699152192,-2030485760},
    {-663608960,-2042378240},
    {-627863424,-2053648768},
    {-591926784,-2064293760},
    {-555809600,-2074309888},
    {-519523328,-2083694208},
    {-483078592,-2092443904},
    {-446486976,-2100556032},
    {-409759200,-2108028416},
    {-372906656, -2114858496},
    { -335940320,-2121044736 },
    { -298871968,-2126584576 },
    { -261712336,-2131476480 },
    { -224473248,-2135719552 },
    { -187165584,-2139311872 },
    { -149800896,-2142252544 },
    { -112390576,-2144540544 },
    { -74946016,-2146175360 },
    { -37478636,-2147156608 },
    { -93,-2147483648 },
    { 37478700,-2147156608 },
    { 74946104,-2146175360 },
    { 112390640,-2144540544 },
    { 149800960,-2142252544 },
    { 187165648,-2139311872 },
    { 224473024,-2135719552 },
    { 261712336,-2131476480 },
    { 298871968,-2126584576 },
    { 335940544,-2121044736 },
    { 372906656,-2114858496 },
    { 409759008,-2108028416 },
    { 446486976,-2100556032 },
    { 483078592,-2092443904 },
    { 519523328,-2083694208 },
    { 555809792,-2074309888 },
    { 591926784,-2064293760 },
    { 627863424,-2053648896 },
    { 663608960,-2042378240 },
    { 699152192,-2030485760 },
    { 734482816,-2017974528 },
    { 769589440,-2004848640 },
    { 804461568,-1991112320 },
    { 839088640,-1976769280 },
    { 873460224,-1961824000 },
    { 907565696,-1946281216 },
    { 941395008,-1930145664 },
    { 974937152,-1913421952 },
    { 1008182592,-1896115584 },
    { 1041120704,-1878231552 },
    { 1073741824,-1859775360 },
    { 1106035840,-1840752768 },
    { 1137993088,-1821169408 },
    { 1169603328,-1801031424 },
    { 1200857600,-1780344448 },
    { 1231746176,-1759115776 },
    { 1262259072,-1737350784 },
    { 1292387840,-1715056640 },
    { 1322123008,-1692240128 },
    { 1351455232,-1668908288 },
    { 1380375808,-1645067776 },
    { 1408876032,-1620726272 },
    { 1436947072,-1595891584 },
    { 1464580352,-1570570112 },
    { 1491767552,-1544770432 },
    { 1518500352,-1518500352 },
    { 1544770432,-1491767552 },
    { 1570570112,-1464580224 },
    { 1595891328,-1436947072 },
    { 1620726528,-1408876032 },
    { 1645067776,-1380375808 },
    { 1668908288,-1351455232 },
    { 1692240256,-1322123008 },
    { 1715056640,-1292387840 },
    { 1737350784,-1262259072 },
    { 1759115776,-1231746176 },
    { 1780344704,-1200857600 },
    { 1801031424,-1169603584 },
    { 1821169408,-1137993088 },
    { 1840752768,-1106035840 },
    { 1859775360,-1073741824 },
    { 1878231552,-1041120704 },
    { 1896115584,-1008182592 },
    { 1913421952,-974937152 },
    { 1930145664,-941395008 },
    { 1946281216,-907565888 },
    { 1961823872,-873460224 },
    { 1976769280,-839088640 },
    { 1991112320,-804461568 },
    { 2004848640,-769589184 },
    { 2017974528,-734482560 },
    { 2030485760,-699152192 },
    { 2042378240,-663608960 },
    { 2053648896,-627863424 },
    { 2064293760,-591926784 },
    { 2074309888,-555809600 },
    { 2083694208,-519523328 },
    { 2092443904,-483078592 },
    { 2100556032,-446486976 },
    { 2108028416,-409759200 },
    { 2114858496,-372906656 },
    { 2121044736,-335940544 },
    { 2126584576,-298871968 },
    { 2131476480,-261712336 },
    { 2135719552,-224473248 },
    { 2139311872,-187165520 },
    { 2142252544,-149800880 },
    { 2144540544,-112390616 },
    { 2146175360,-74946104 },
    { 2147156608,-37478764 },
    { 2147483647,0 } };
#endif
/*----------------------------------------------------------------------------------*
 * FB ROM tables
@@ -8712,4 +8902,19 @@ const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[9] =
        }
};
const Word32 one_by_q_level[64] =
{ 0, 2147483647, 1073741824, 715827904, 536870912, 429496736,
357913952, 306783392, 268435456, 238609296, 214748368,
195225792, 178956976, 165191056, 153391696, 143165584,
134217728, 126322568, 119304648, 113025456, 107374184,
102261128, 97612896, 93368856, 89478488, 85899344,
82595528, 79536432, 76695848, 74051160, 71582792,
69273664, 67108864, 65075264, 63161284, 61356676,
59652324, 58040100, 56512728, 55063684, 53687092,
52377648, 51130564, 49941480, 48806448, 47721860,
46684428, 45691140, 44739244, 43826196, 42949672,
42107524, 41297764, 40518560, 39768216, 39045156,
38347924, 37675152, 37025580, 36398028, 35791396,
35204648, 34636832, 34087044 };
/* clang-format on */
Loading