From c26005fe38977aa2c7fd4e8ae52f5215abdd68ef Mon Sep 17 00:00:00 2001 From: plains Date: Tue, 7 Nov 2023 12:57:48 +0100 Subject: [PATCH 1/6] Cleanup --- lib_com/ivas_cnst.h | 12 ++- lib_com/ivas_rom_com.c | 70 +++++++++++++++- lib_com/ivas_rom_com.h | 11 ++- lib_com/options.h | 1 + lib_dec/ivas_mc_paramupmix_dec.c | 132 ++++++++++++++++++++++++++++++- lib_dec/ivas_rom_dec.c | 32 +++++++- lib_enc/ivas_mc_paramupmix_enc.c | 128 +++++++++++++++++++++++++++++- lib_enc/ivas_rom_enc.c | 67 ++++++++++++++++ lib_enc/ivas_rom_enc.h | 10 ++- 9 files changed, 448 insertions(+), 15 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index e9173e6e93..f9e530c31a 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1346,23 +1346,31 @@ typedef enum { BETA } PAR_TYPE; +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP typedef enum { FINE, COARSE } QUANT_TYPE; +#endif typedef struct { int16_t nquant; int16_t offset; float data[35]; } ACPL_QUANT_TABLE; - +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +typedef struct +{ + const int16_t (*alpha)[2]; + const int16_t (*beta)[2]; +} HUFF_NODE_TABLE; +#else typedef struct { const int16_t (*alpha[2])[2]; const int16_t (*beta[2])[2]; } HUFF_NODE_TABLE; - +#endif /*----------------------------------------------------------------------------------* * Parametric MC Constants diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 50892fcf53..d4e5fe0ae0 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -2522,13 +2522,18 @@ const uint16_t ivas_param_mc_sym_freq_ild_delta_combined_48_16bits[2 * PARAM_MC_ /*----------------------------------------------------------------------------------* * Parametric Upmix MC ROM tables *----------------------------------------------------------------------------------*/ - +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +const int16_t ivas_param_upmx_mx_qmap[33] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0 +}; +#else const int16_t ivas_param_upmx_mx_qmap[2][33] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, { 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0 } }; - +#endif /*----------------------------------------------------------------------------------* * MASA ROM tables @@ -6438,7 +6443,66 @@ const int16_t sns_1st_means_32k[2][16] = /*----------------------------------------------------------------------* * MC ParamUpmix ROM tables *-----------------------------------------------------------------------*/ +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +const ACPL_QUANT_TABLE ivas_mc_paramupmix_alpha_quant_table = +{ + 33, /* nquant */ + 16, /* offset */ + { -2.000000e+000f, -1.809375e+000f, -1.637500e+000f, -1.484375e+000f, -1.350000e+000f, -1.234375e+000f, -1.137500e+000f, -1.059375e+000f, -1.000000e+000f, -9.406250e-001f, + -8.625000e-001f, -7.656250e-001f, -6.500000e-001f, -5.156250e-001f, -3.625000e-001f, -1.906250e-001f, +0.000000e+000f, +1.906250e-001f, +3.625000e-001f, +5.156250e-001f, + +6.500000e-001f, +7.656250e-001f, +8.625000e-001f, +9.406250e-001f, +1.000000e+000f, +1.059375e+000f, +1.137500e+000f, +1.234375e+000f, +1.350000e+000f, +1.484375e+000f, + +1.637500e+000f, +1.809375e+000f, +2.000000e+000f } /* data */ +}; +const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[9] = +{ + { + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +2.375000e-001f, +5.500000e-001f, +9.375000e-001f, +1.400000e+000f, +1.937500e+000f, +2.550000e+000f, +3.237500e+000f, +4.000000e+000f } /* data */ + }, + { /* Beta #2 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +2.035449e-001f, +4.713672e-001f, +8.034668e-001f, +1.199844e+000f, +1.660498e+000f, +2.185430e+000f, +2.774639e+000f, +3.428125e+000f } /* data */ + }, + { /* Beta #3 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +1.729297e-001f, +4.004688e-001f, +6.826172e-001f, +1.019375e+000f, +1.410742e+000f, +1.856719e+000f, +2.357305e+000f, +2.912500e+000f } /* data */ + }, + { /* Beta #4 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +1.456543e-001f, +3.373047e-001f, +5.749512e-001f, +8.585938e-001f, +1.188232e+000f, +1.563867e+000f, +1.985498e+000f, +2.453125e+000f } /* data */ + }, + { /* Beta #5 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +1.217188e-001f, +2.818750e-001f, +4.804688e-001f, +7.175000e-001f, +9.929688e-001f, +1.306875e+000f, +1.659219e+000f, +2.050000e+000f } /* data */ + }, + { /* Beta #6 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +1.011230e-001f, +2.341797e-001f, +3.991699e-001f, +5.960938e-001f, +8.249512e-001f, +1.085742e+000f, +1.378467e+000f, +1.703125e+000f } /* data */ + }, + { /* Beta #7 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +8.386719e-002f, +1.942188e-001f, +3.310547e-001f, +4.943750e-001f, +6.841797e-001f, +9.004688e-001f, +1.143242e+000f, +1.412500e+000f } /* data */ + }, + { /* Beta #8 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +6.995117e-002f, +1.619922e-001f, +2.761230e-001f, +4.123438e-001f, +5.706543e-001f, +7.510547e-001f, +9.535449e-001f, +1.178125e+000f } /* data */ + }, + { /* Beta #9 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +5.937500e-002f, +1.375000e-001f, +2.343750e-001f, +3.500000e-001f, +4.843750e-001f, +6.375000e-001f, +8.093750e-001f, +1.000000e+000f } /* data */ + } +}; +#else const ACPL_QUANT_TABLE ivas_mc_paramupmix_alpha_quant_table[] = { /* Alfa Fine */ @@ -6537,5 +6601,5 @@ const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[2][9] = } } }; - +#endif /* clang-format on */ diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index d851e2c971..b9f1c5f0d5 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -262,8 +262,11 @@ extern const uint16_t ivas_param_mc_sym_freq_icc_delta_combined_48_16bits[2 * PA /*----------------------------------------------------------------------------------* * Parametric Upmix MC ROM tables *----------------------------------------------------------------------------------*/ - +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +extern const int16_t ivas_param_upmx_mx_qmap[33]; +#else extern const int16_t ivas_param_upmx_mx_qmap[2][33]; +#endif /*----------------------------------------------------------------------------------* @@ -453,9 +456,13 @@ extern const int16_t sns_1st_means_32k[2][16]; /*----------------------------------------------------------------------* * MC ParamUpmix ROM tables *-----------------------------------------------------------------------*/ - +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +extern const ACPL_QUANT_TABLE ivas_mc_paramupmix_alpha_quant_table; +extern const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[9]; +#else extern const ACPL_QUANT_TABLE ivas_mc_paramupmix_alpha_quant_table[]; extern const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[2][9]; +#endif /* IVAS_ROM_COM_H */ #endif diff --git a/lib_com/options.h b/lib_com/options.h index 7b61ed4b4a..1b0443ea6e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,6 +156,7 @@ #define FIX_890_ARRAY_SIZE /* Nokia: issue #890: mismatch in 2D array size declaration and use */ #define BE_FIX_887_GCC_WARNING_ARRAY_SIZE /* VoiceAge: Issue 887: change array size definition to avoid warning with gcc 11.4.0 */ #define FIX_247_EXTERNAL_RENDERER_COMMAND_LINE /* VA: issue 247: harmonize command-line options names of external renderer with the decoder */ +#define FIX_DLB_PARAMUPMIX_CLEANUP /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index fe93a65ee7..395fc2fff2 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -79,7 +79,15 @@ static void ivas_param_upmix_dec_decorr_subframes( Decoder_Struct *st_ivas, cons static void paramupmix_td_decorr_process( ivas_td_decorr_state_t *hTdDecorr[], float *pcm_in[], float **pp_out_pcm, const int16_t output_frame ); static int16_t huff_read( Decoder_State *st, const int16_t ( *ht )[2] ); +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +static void huffman_decode( Decoder_State *st, PAR_TYPE parType, int32_t *vq ); +static void dequant_alpha( int32_t *vq, float *v ); + +static void dequant_beta( int32_t *aq, int32_t *bq, float *beta ); + +static void get_ec_data( Decoder_State *st, const PAR_TYPE parType, int32_t *parQ, int32_t *alphaQEnv, float ab[IVAS_MAX_NUM_BANDS] ); +#else static void huffman_decode( Decoder_State *st, const int16_t nv, const int16_t ivStart, PAR_TYPE parType, QUANT_TYPE quant_type, const int16_t bNoDt, int32_t *vq ); static void dequant_alpha( const int16_t nv, const int16_t ivStart, const QUANT_TYPE quant_type, int32_t *vq, float *v ); @@ -87,7 +95,7 @@ static void dequant_alpha( const int16_t nv, const int16_t ivStart, const QUANT_ static void dequant_beta( const int16_t nv, const int16_t ivStart, const QUANT_TYPE quant_type, int32_t *aq, int32_t *bq, float *beta ); static void get_ec_data( Decoder_State *st, const PAR_TYPE parType, const QUANT_TYPE quant_type, const int16_t nParBand, const int16_t parBandStart, int32_t *parQ, int32_t *alphaQEnv, float ab[IVAS_MAX_NUM_BANDS] ); - +#endif /*------------------------------------------------------------------------- * ivas_mc_paramupmix_dec_read_BS() @@ -141,11 +149,17 @@ void ivas_mc_paramupmix_dec_read_BS( for ( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + get_ec_data( st0, ALPHA, hMCParamUpmix->alpha_quant[i], alpha_quant, hMCParamUpmix->alphas[i] ); + + get_ec_data( st0, BETA, hMCParamUpmix->beta_quant[i], alpha_quant, hMCParamUpmix->betas[i] ); +#else get_ec_data( st0, ALPHA, FINE /*quant_type*/, IVAS_MAX_NUM_BANDS /*nParBand*/, 0 /*parBandStart*/, hMCParamUpmix->alpha_quant[i], alpha_quant, hMCParamUpmix->alphas[i] ); get_ec_data( st0, BETA, FINE /*quant_type*/, IVAS_MAX_NUM_BANDS /*nParBand*/, 0 /*parBandStart*/, hMCParamUpmix->beta_quant[i], alpha_quant, hMCParamUpmix->betas[i] ); +#endif } *nb_bits += st0->next_bit_pos; st0->bit_stream = bit_stream_orig; @@ -1334,11 +1348,16 @@ static int16_t huff_read( static void huffman_decode( Decoder_State *st, +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP const int16_t nv, const int16_t ivStart, const PAR_TYPE parType, const QUANT_TYPE quant_type, const int16_t bNoDt, + 0 +#else + const PAR_TYPE parType, +#endif int32_t *vq ) { const int16_t( *huff_node_table )[2]; @@ -1347,18 +1366,31 @@ static void huffman_decode( nquant = 0; switch ( parType ) { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + case ALPHA: + nquant = ivas_mc_paramupmix_alpha_quant_table.nquant; + break; + case BETA: + nquant = ivas_mc_paramupmix_beta_quant_table[0].nquant; + break; +#else case ALPHA: nquant = ivas_mc_paramupmix_alpha_quant_table[quant_type].nquant; break; case BETA: nquant = ivas_mc_paramupmix_beta_quant_table[quant_type][0].nquant; break; +#endif default: assert( 0 ); } offset = nquant - 1; /* range of df/dt [-(nquant - 1), nquant - 1] */ +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + bdt = st->bit_stream[st->next_bit_pos]; + st->next_bit_pos++; +#else if ( bNoDt ) { bdt = 0; @@ -1368,11 +1400,27 @@ static void huffman_decode( bdt = st->bit_stream[st->next_bit_pos]; st->next_bit_pos++; } - +#endif if ( bdt ) { /* Get dt */ switch ( parType ) { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + case ALPHA: + huff_node_table = ivas_mc_paramupmix_huff_nodes_dt.alpha; + break; + case BETA: + huff_node_table = ivas_mc_paramupmix_huff_nodes_dt.beta; + break; + default: + huff_node_table = NULL; + assert( 0 ); + } + for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) + { + vq[iv] = huff_read( st, huff_node_table ) + vq[iv] - offset; + } +#else case ALPHA: huff_node_table = ivas_mc_paramupmix_huff_nodes_dt.alpha[quant_type]; break; @@ -1387,11 +1435,42 @@ static void huffman_decode( { vq[iv] = huff_read( st, huff_node_table ) + vq[iv] - offset; } +#endif } else /* Get f0, df */ { switch ( parType ) { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + case ALPHA: + huff_node_table = ivas_mc_paramupmix_huff_nodes_df0.alpha; + break; + case BETA: + huff_node_table = ivas_mc_paramupmix_huff_nodes_df0.beta; + break; + default: + huff_node_table = NULL; + assert( 0 ); + } + vq[0] = huff_read( st, huff_node_table ); + + switch ( parType ) + { + case ALPHA: + huff_node_table = ivas_mc_paramupmix_huff_nodes_df.alpha; + break; + case BETA: + huff_node_table = ivas_mc_paramupmix_huff_nodes_df.beta; + break; + default: + assert( 0 ); + } + + for ( iv = 1; iv < IVAS_MAX_NUM_BANDS; iv++ ) + { + vq[iv] = huff_read( st, huff_node_table ) + vq[iv - 1] - offset; + } +#else case ALPHA: huff_node_table = ivas_mc_paramupmix_huff_nodes_df0.alpha[quant_type]; break; @@ -1420,6 +1499,7 @@ static void huffman_decode( { vq[iv] = huff_read( st, huff_node_table ) + vq[iv - 1] - offset; } +#endif } return; @@ -1427,13 +1507,28 @@ static void huffman_decode( static void dequant_alpha( +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP const int16_t nv, const int16_t ivStart, const QUANT_TYPE quant_type, +#endif int32_t *vq, float *v ) { int16_t iv; +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + const ACPL_QUANT_TABLE *quant_table = &ivas_mc_paramupmix_alpha_quant_table; + + for ( iv = 0; iv < 0; iv++ ) + { + v[iv] = 0; + } + + for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) + { + v[iv] = quant_table->data[vq[iv]]; + } +#else const ACPL_QUANT_TABLE *quant_table = &ivas_mc_paramupmix_alpha_quant_table[quant_type]; for ( iv = 0; iv < ivStart; iv++ ) @@ -1445,15 +1540,17 @@ static void dequant_alpha( { v[iv] = quant_table->data[vq[iv]]; } - +#endif return; } static void dequant_beta( +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP const int16_t nv, const int16_t ivStart, const QUANT_TYPE quant_type, +#endif int32_t *aq, int32_t *bq, float *beta ) @@ -1461,6 +1558,18 @@ static void dequant_beta( int16_t iv; const ACPL_QUANT_TABLE *quant_table; +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + for ( iv = 0; iv < 0; iv++ ) + { + beta[iv] = 0; + } + + for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) + { + quant_table = &ivas_mc_paramupmix_beta_quant_table[ivas_param_upmx_mx_qmap[aq[iv]]]; + beta[iv] = quant_table->data[bq[iv]]; + } +#else for ( iv = 0; iv < ivStart; iv++ ) { beta[iv] = 0; @@ -1471,7 +1580,7 @@ static void dequant_beta( quant_table = &ivas_mc_paramupmix_beta_quant_table[quant_type][ivas_param_upmx_mx_qmap[quant_type][aq[iv]]]; beta[iv] = quant_table->data[bq[iv]]; } - +#endif return; } @@ -1479,23 +1588,38 @@ static void dequant_beta( static void get_ec_data( Decoder_State *st, const PAR_TYPE parType, +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP const QUANT_TYPE quant_type, const int16_t nParBand, const int16_t parBandStart, +#endif int32_t *parQ, int32_t *alphaQEnv, float ab[IVAS_MAX_NUM_BANDS] ) { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + huffman_decode( st, parType, parQ ); +#else huffman_decode( st, nParBand, parBandStart, parType, quant_type, 0, parQ ); +#endif if ( parType == ALPHA ) { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + dequant_alpha( parQ, ab ); + mvl2l( parQ, alphaQEnv, (int16_t) IVAS_MAX_NUM_BANDS ); +#else dequant_alpha( nParBand, parBandStart, quant_type, parQ, ab ); mvl2l( parQ, alphaQEnv, (int16_t) nParBand ); +#endif } else { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + dequant_beta( alphaQEnv, parQ, ab ); +#else dequant_beta( nParBand, parBandStart, quant_type, alphaQEnv, parQ, ab ); +#endif } return; diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 1c04fb93ef..7c6e472b58 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -720,6 +720,7 @@ static const int16_t huff_nodes_first_band_alpha[32][2] = { -2, -32 } }; +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP /* Alpha Coarse Huffman table df0 */ static const int16_t huff_nodes_first_band_alpha_coarse[16][2] = { @@ -740,6 +741,7 @@ static const int16_t huff_nodes_first_band_alpha_coarse[16][2] = { -2, -16 }, { -1, -17 } }; +#endif /* Alpha Fine Huffman table df */ static const int16_t huff_nodes_alpha_1D_DF[64][2] = @@ -810,6 +812,7 @@ static const int16_t huff_nodes_alpha_1D_DF[64][2] = { -2, -62 } }; +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP /* Alpha Coarse Huffman table df */ static const int16_t huff_nodes_alpha_1D_DF_coarse[32][2] = { @@ -846,6 +849,7 @@ static const int16_t huff_nodes_alpha_1D_DF_coarse[32][2] = { -3, -4 }, { -2, -32 } }; +#endif /* Alpha Fine Huffman table dt */ static const int16_t huff_nodes_alpha_1D_DT[64][2] = @@ -916,6 +920,7 @@ static const int16_t huff_nodes_alpha_1D_DT[64][2] = { -2, -63 } }; +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP /* Alpha Coarse Huffman table dt */ static const int16_t huff_nodes_alpha_1D_DT_coarse[32][2] = { @@ -952,6 +957,7 @@ static const int16_t huff_nodes_alpha_1D_DT_coarse[32][2] = { -4, -30 }, { -2, -32 } }; +#endif /* Beta Fine Huffman table df0 */ static const int16_t huff_nodes_first_band_beta[8][2] = @@ -959,11 +965,13 @@ static const int16_t huff_nodes_first_band_beta[8][2] = { -1, 1 }, { -2, 2 }, { -3, 3 }, { -4, 4 }, { -5, 5 }, { -6, 6 }, { -7, 7 }, { -8, -9 } }; +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP /* Beta Coarse Huffman table df0 */ static const int16_t huff_nodes_first_band_beta_coarse[4][2] = { { -1, 1 }, { -2, 2 }, { -3, 3 }, { -4, -5 } }; +#endif /* Beta Fine Huffman table df */ static const int16_t huff_nodes_beta_1D_DF[16][2] = @@ -971,11 +979,13 @@ static const int16_t huff_nodes_beta_1D_DF[16][2] = { -9, 1 }, { -10, 2 }, { -8, 3 }, { -11, 4 }, { -7, 5 }, { 7, 6 }, { -6, -12 }, { 9, 8 }, { -5, -13 }, { 11, 10 }, { -4, -14 }, { -15, 12 }, { -3, 13 }, { -16, 14 }, { -2, 15 }, { -1, -17 } }; +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP /* Beta Coarse Huffman table df */ static const int16_t huff_nodes_beta_1D_DF_coarse[8][2] = { { -5, 1 }, { -6, 2 }, { -4, 3 }, { -3, 4 }, { -7, 5 }, { -2, 6 }, { -8, 7 }, { -1, -9 } }; +#endif /* Beta Fine Huffman table dt */ static const int16_t huff_nodes_beta_1D_DT[16][2] = @@ -983,18 +993,36 @@ static const int16_t huff_nodes_beta_1D_DT[16][2] = { -9, 1 }, { -10, 2 }, { -8, 3 }, { -11, 4 }, { -7, 5 }, { 7, 6 }, { -6, -12 }, { -13, 8 }, { -5, 9 }, { -14, 10 }, { -4, 11 }, { -15, 12 }, { -3, 13 }, { -16, 14 }, { -2, 15 }, { -1, -17 } }; +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP /* Beta Coarse Huffman table dt */ static const int16_t huff_nodes_beta_1D_DT_coarse[8][2] = { { -5, 1 }, { -6, 2 }, { -4, 3 }, { -7, 4 }, { -3, 5 }, { -8, 6 }, { -2, 7 }, { -1, -9 } }; +#endif +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_df0 = +{ + huff_nodes_first_band_alpha, + huff_nodes_first_band_beta +}; +const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_df = +{ + huff_nodes_alpha_1D_DF, + huff_nodes_beta_1D_DF +}; +const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_dt = +{ + huff_nodes_alpha_1D_DT, + huff_nodes_beta_1D_DT +}; +#else const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_df0 = { { huff_nodes_first_band_alpha, huff_nodes_first_band_alpha_coarse }, { huff_nodes_first_band_beta, huff_nodes_first_band_beta_coarse } }; - const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_df = { { huff_nodes_alpha_1D_DF, huff_nodes_alpha_1D_DF_coarse }, @@ -1006,5 +1034,7 @@ const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_dt = { huff_nodes_alpha_1D_DT, huff_nodes_alpha_1D_DT_coarse }, { huff_nodes_beta_1D_DT, huff_nodes_beta_1D_DT_coarse } }; +#endif + /* clang-format on */ diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index d3c431a1bd..a7037c5d8f 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -56,20 +56,32 @@ static void ivas_mc_paramupmix_dmx( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, float *data_f[], const int16_t input_frame ); static void ivas_mc_paramupmix_param_est_enc( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, float *input_frame_t[], const int16_t input_frame, float alphas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS], float betas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS] ); - +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +static void get_huff_table( const PAR_TYPE par_type, HUFF_TAB *df0, HUFF_TAB *df, HUFF_TAB *dt ); +#else static void get_huff_table( const PAR_TYPE par_type, const QUANT_TYPE quant_type, HUFF_TAB *df0, HUFF_TAB *df, HUFF_TAB *dt ); +#endif static void write_huff_bits( const int32_t value, const uint16_t length, uint16_t bit_buffer[MC_PARAMUPMIX_MAX_BITS], int16_t *bit_pos ); +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +static void huffman_encode( const int32_t *vqPrev, const int32_t *vq, const PAR_TYPE parType, const int16_t nq, uint16_t bit_buffer[MC_PARAMUPMIX_MAX_BITS], int16_t *bit_pos ); +#else static void huffman_encode( const int16_t bdfOnly, const int16_t bdtAllowed, const int16_t nv, const int16_t ivStart, const int32_t *vqPrev, const int32_t *vq, const PAR_TYPE parType, const QUANT_TYPE quant_type, const int16_t nq, uint16_t bit_buffer[MC_PARAMUPMIX_MAX_BITS], int16_t *bit_pos ); +#endif static void put_ec_data( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, const int16_t ch, const float pars[IVAS_MAX_NUM_BANDS], const float alphas[IVAS_MAX_NUM_BANDS], const PAR_TYPE parType, uint16_t bit_buffer[MC_PARAMUPMIX_MAX_BITS], int16_t *bit_pos ); +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +static void quantize_alpha( const float *alpha, int16_t *pnq, int32_t aq[IVAS_MAX_NUM_BANDS], float *adeq ); +static void quantize_pars( const float *v, const int16_t nq, const float *data, int32_t vq[IVAS_MAX_NUM_BANDS], float *vdeq ); +#else static void quantize_alpha( const int16_t nv, const float *alpha, const QUANT_TYPE quant_type, int16_t *pnq, int32_t aq[IVAS_MAX_NUM_BANDS], float *adeq ); static void quantize_pars( const int16_t nv, const float *v, const int16_t nq, const float *data, int32_t vq[IVAS_MAX_NUM_BANDS], float *vdeq ); static void quantize_pars( const int16_t nv, const float *v, const int16_t nq, const float *data, int32_t vq[IVAS_MAX_NUM_BANDS], float *vdeq ); +#endif /*------------------------------------------------------------------------- @@ -360,13 +372,33 @@ void ivas_mc_paramupmix_enc_close( static void get_huff_table( const PAR_TYPE par_type, +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP const QUANT_TYPE quant_type, +#endif HUFF_TAB *df0, HUFF_TAB *df, HUFF_TAB *dt ) { switch ( par_type ) { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + case ALPHA: + df0->value = huff_alpha_table.df0.value; + df0->length = huff_alpha_table.df0.length; + df->value = huff_alpha_table.df.value; + df->length = huff_alpha_table.df.length; + dt->value = huff_alpha_table.dt.value; + dt->length = huff_alpha_table.dt.length; + break; + case BETA: + df0->value = huff_beta_table.df0.value; + df0->length = huff_beta_table.df0.length; + df->value = huff_beta_table.df.value; + df->length = huff_beta_table.df.length; + dt->value = huff_beta_table.dt.value; + dt->length = huff_beta_table.dt.length; + break; +#else case ALPHA: df0->value = huff_alpha_table[quant_type].df0.value; df0->length = huff_alpha_table[quant_type].df0.length; @@ -383,6 +415,7 @@ static void get_huff_table( dt->value = huff_beta_table[quant_type].dt.value; dt->length = huff_beta_table[quant_type].dt.length; break; +#endif } return; @@ -407,14 +440,18 @@ static void write_huff_bits( static void huffman_encode( +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP const int16_t bdfOnly, const int16_t bdtAllowed, const int16_t nv, const int16_t ivStart, +#endif const int32_t *vqPrev, const int32_t *vq, const PAR_TYPE parType, +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP const QUANT_TYPE quant_type, +#endif const int16_t nq, uint16_t bit_buffer[MC_PARAMUPMIX_MAX_BITS], int16_t *bit_pos ) @@ -424,16 +461,28 @@ static void huffman_encode( int16_t offset; HUFF_TAB df0, df, dt; +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + get_huff_table( parType, &df0, &df, &dt ); +#else get_huff_table( parType, quant_type, &df0, &df, &dt ); +#endif offset = nq - 1; /* range [-(nquant - 1), nquant - 1] */ /* Get code length for time and freq diff coding */ ndf = 0; ndt = 0; +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) +#else for ( iv = ivStart; iv < nv; iv++ ) +#endif { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + if ( iv == 0 ) +#else if ( iv == ivStart ) +#endif { icode = vq[iv]; ndf += df0.length[icode]; @@ -448,18 +497,32 @@ static void huffman_encode( ndt += dt.length[icode]; } +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP if ( !bdtAllowed ) /* Time diff not allowed due to conformance or other reason even if bdfOnly = 0 */ { ndt = ndf + 1; } +#endif /* Write the bitstream */ +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + if ( ndf < ndt ) +#else if ( bdfOnly || ndf < ndt ) +#endif { bit_buffer[( *bit_pos )++] = (uint16_t) 0 & 1; +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) +#else for ( iv = ivStart; iv < nv; iv++ ) +#endif { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + if ( iv == 0 ) +#else if ( iv == ivStart ) +#endif { icode = vq[iv]; write_huff_bits( df0.value[icode], df0.length[icode], bit_buffer, bit_pos ); @@ -474,7 +537,11 @@ static void huffman_encode( else { bit_buffer[( *bit_pos )++] = (uint16_t) 1 & 1; +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) +#else for ( iv = ivStart; iv < nv; iv++ ) +#endif { icode = vq[iv] - vqPrev[iv] + offset; #ifdef DEBUGGING @@ -492,7 +559,9 @@ static void huffman_encode( static void quantize_pars( +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP const int16_t nv, +#endif const float *v, const int16_t nq, const float *data, @@ -501,7 +570,11 @@ static void quantize_pars( { int16_t iv, iq, iq0, iq1; +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) +#else for ( iv = 0; iv < nv; iv++ ) +#endif { iq0 = 0; iq1 = nq - 1; @@ -536,9 +609,13 @@ static void quantize_pars( static void quantize_alpha( +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP const int16_t nv, +#endif const float *alpha, +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP const QUANT_TYPE quant_type, +#endif int16_t *pnq, int32_t aq[IVAS_MAX_NUM_BANDS], float *adeq ) @@ -546,11 +623,17 @@ static void quantize_alpha( int16_t nq; const float *data; +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + nq = ivas_mc_paramupmix_alpha_quant_table.nquant; + data = ivas_mc_paramupmix_alpha_quant_table.data; + + quantize_pars( alpha, nq, data, aq, adeq ); +#else nq = ivas_mc_paramupmix_alpha_quant_table[quant_type].nquant; data = ivas_mc_paramupmix_alpha_quant_table[quant_type].data; quantize_pars( nv, alpha, nq, data, aq, adeq ); - +#endif *pnq = nq; return; @@ -558,21 +641,37 @@ static void quantize_alpha( static void quantize_beta( +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP const int16_t nv, +#endif const float *beta, const int32_t aq[IVAS_MAX_NUM_BANDS], +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP const QUANT_TYPE quant_type, +#endif int16_t *pnq, int32_t bq[IVAS_MAX_NUM_BANDS], float *bdeq ) { int16_t iv, iq, iq0, iq1; +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + const ACPL_QUANT_TABLE *tables = ivas_mc_paramupmix_beta_quant_table; +#else const ACPL_QUANT_TABLE *tables = ivas_mc_paramupmix_beta_quant_table[quant_type]; +#endif ACPL_QUANT_TABLE quant_table; +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) +#else for ( iv = 0; iv < nv; iv++ ) +#endif { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + quant_table = tables[ivas_param_upmx_mx_qmap[aq[iv]]]; +#else quant_table = tables[ivas_param_upmx_mx_qmap[quant_type][aq[iv]]]; +#endif iq0 = 0; iq1 = quant_table.nquant - 1; @@ -602,7 +701,11 @@ static void quantize_beta( } } +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + *pnq = ivas_mc_paramupmix_beta_quant_table[0].nquant; +#else *pnq = ivas_mc_paramupmix_beta_quant_table[quant_type][0].nquant; +#endif return; } @@ -617,10 +720,14 @@ static void put_ec_data( uint16_t bit_buffer[MC_PARAMUPMIX_MAX_BITS], int16_t *bit_pos ) { +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP int16_t npar = IVAS_MAX_NUM_BANDS; int16_t onlyFreq = 1; +#endif int16_t nq; +#ifndef FIX_DLB_PARAMUPMIX_CLEANUP QUANT_TYPE quant_type = FINE; +#endif int32_t alphaQuant[IVAS_MAX_NUM_BANDS]; int32_t betaQuant[IVAS_MAX_NUM_BANDS]; float alphaDequant[IVAS_MAX_NUM_BANDS]; @@ -628,12 +735,21 @@ static void put_ec_data( if ( parType == ALPHA ) { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + quantize_alpha( pars, &nq, alphaQuant, alphaDequant ); +#else quantize_alpha( npar, pars, quant_type, &nq, alphaQuant, alphaDequant ); +#endif } else { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + quantize_alpha( alphas, &nq, alphaQuant, alphaDequant ); + quantize_beta( pars, alphaQuant, &nq, betaQuant, betaDequant ); +#else quantize_alpha( npar, alphas, quant_type, &nq, alphaQuant, alphaDequant ); quantize_beta( npar, pars, alphaQuant, quant_type, &nq, betaQuant, betaDequant ); +#endif } if ( hMCParamUpmix->first_frame ) @@ -652,11 +768,19 @@ static void put_ec_data( /* Always one parameter set per frame for transient frames. Original PS framing is used internally. */ if ( parType == ALPHA ) { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + huffman_encode( hMCParamUpmix->alpha_quant_prev[ch], alphaQuant, ALPHA, nq, bit_buffer, bit_pos ); +#else huffman_encode( onlyFreq, 1, npar, 0, hMCParamUpmix->alpha_quant_prev[ch], alphaQuant, ALPHA, quant_type, nq, bit_buffer, bit_pos ); +#endif } else { +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP + huffman_encode( hMCParamUpmix->beta_quant_prev[ch], betaQuant, BETA, nq, bit_buffer, bit_pos ); +#else huffman_encode( onlyFreq, 1, npar, 0, hMCParamUpmix->beta_quant_prev[ch], betaQuant, BETA, quant_type, nq, bit_buffer, bit_pos ); +#endif } if ( parType == ALPHA ) diff --git a/lib_enc/ivas_rom_enc.c b/lib_enc/ivas_rom_enc.c index ce24de702d..653f3a4f45 100644 --- a/lib_enc/ivas_rom_enc.c +++ b/lib_enc/ivas_rom_enc.c @@ -722,7 +722,73 @@ const float Stereo_dmx_wnd_coef_48k[L_FRAME48k] = { 0.0310834963f, 0.0278123822f, 0.0245409720f, 0.0212692991f, 0.0179976355f, 0.0147257810f, 0.0114535289f, 0.00818115473f, 0.00490869302f, 0.00163617858f }; +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +const HUFF_TABLE huff_alpha_table = +{ + { /* df0 */ + { 0x0002ce, 0x000b5e, 0x0004fe, 0x0005ae, 0x00027e, 0x0002de, 0x00016a, 0x0000b2, 0x00004a, 0x00004b, + 0x0000b6, 0x00004e, 0x000024, 0x00002e, 0x00000a, 0x000006, 0x000000, 0x000007, 0x000008, 0x00002f, + 0x000026, 0x000058, 0x0000b4, 0x00009e, 0x00016e, 0x000166, 0x0002df, 0x0002cf, 0x00027c, 0x00027d, + 0x0004ff, 0x000b5f, 0x0002d6 }, + { 10, 12, 11, 11, 10, 10, 9, 8, 7, 7, + 8, 7, 6, 6, 4, 3, 1, 3, 4, 6, + 6, 7, 8, 8, 9, 9, 10, 10, 10, 10, + 11, 12, 10 } + }, + { /* df */ + { 0x0011de, 0x011ffe, 0x013dea, 0x013df6, 0x008eea, 0x013df7, 0x013dee, 0x013deb, 0x013dec, 0x008eee, + 0x008ffe, 0x009efe, 0x0047fe, 0x004f7c, 0x0023fe, 0x0011fe, 0x0013fe, 0x0008f6, 0x0009ee, 0x000476, + 0x00047a, 0x0004f6, 0x00023a, 0x00027a, 0x00027e, 0x00013e, 0x00009a, 0x00004c, 0x00004e, 0x000012, + 0x00000a, 0x000006, 0x000000, 0x000007, 0x00000b, 0x000010, 0x000022, 0x000046, 0x00009b, 0x00013c, + 0x00011c, 0x00023e, 0x00023c, 0x0004fe, 0x00047e, 0x0009fe, 0x0008fe, 0x0008f7, 0x0013ff, 0x0011df, + 0x0027bc, 0x004f7e, 0x004776, 0x009efa, 0x009ef4, 0x013dfe, 0x008eeb, 0x008ee8, 0x013dff, 0x008ee9, + 0x008eef, 0x011fff, 0x013ded, 0x013def, 0x0011dc }, + { 13, 17, 17, 17, 16, 17, 17, 17, 17, 16, + 16, 16, 15, 15, 14, 13, 13, 12, 12, 11, + 11, 11, 10, 10, 10, 9, 8, 7, 7, 5, + 4, 3, 1, 3, 4, 5, 6, 7, 8, 9, + 9, 10, 10, 11, 11, 12, 12, 12, 13, 13, + 14, 15, 15, 16, 16, 17, 16, 16, 17, 16, + 16, 17, 17, 17, 13 } + }, + { /* dt */ + { 0x00eeee, 0x03b3ee, 0x03b3f6, 0x03b3fc, 0x01d9bc, 0x01d9bd, 0x01d9b2, 0x03b3fe, 0x01d9be, 0x01d9f6, + 0x01d9fc, 0x00ecda, 0x00ecfa, 0x00eeef, 0x00766e, 0x007776, 0x003b3a, 0x003bba, 0x001d9a, 0x001ddc, + 0x001dde, 0x000eec, 0x000764, 0x000772, 0x0003b0, 0x0003b8, 0x0001da, 0x0001de, 0x000072, 0x000038, + 0x00001e, 0x000006, 0x000000, 0x000002, 0x00001f, 0x00003a, 0x000073, 0x0001df, 0x0001db, 0x0003ba, + 0x0003b1, 0x000773, 0x000765, 0x000eed, 0x000ecc, 0x001d9e, 0x001d9c, 0x003bbe, 0x003b3b, 0x00777e, + 0x00767c, 0x00eefe, 0x00ecfc, 0x00ecd8, 0x01d9fd, 0x01d9fa, 0x01d9bf, 0x01d9b6, 0x01d9b3, 0x03b3fd, + 0x01d9b7, 0x03b3ff, 0x03b3ef, 0x03b3f7, 0x00eeff }, + { 16, 18, 18, 18, 17, 17, 17, 18, 17, 17, + 17, 16, 16, 16, 15, 15, 14, 14, 13, 13, + 13, 12, 11, 11, 10, 10, 9, 9, 7, 6, + 5, 3, 1, 2, 5, 6, 7, 9, 9, 10, + 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, + 15, 16, 16, 16, 17, 17, 17, 17, 17, 18, + 17, 18, 18, 18, 16 } + } +}; +const HUFF_TABLE huff_beta_table = +{ + { /* df0 */ + { 0x000000, 0x000002, 0x000006, 0x00000e, 0x00001e, 0x00003e, 0x00007e, 0x0000fe, 0x0000ff }, + { 1, 2, 3, 4, 5, 6, 7, 8, 8 } + }, + { /* df */ + { 0x001f1e, 0x000f8e, 0x0003e2, 0x0001f2, 0x0000fa, 0x00007e, 0x00001e, 0x000006, 0x000000, 0x000002, + 0x00000e, 0x00007f, 0x0000fb, 0x0001f3, 0x0001f0, 0x0007c6, 0x001f1f }, + { 13, 12, 10, 9, 8, 7, 5, 3, 1, 2, + 4, 7, 8, 9, 9, 11, 13 } + }, + { /* dt */ + { 0x007dfe, 0x003efe, 0x000fbe, 0x0003ee, 0x0000fa, 0x00007e, 0x00001e, 0x000006, 0x000000, 0x000002, + 0x00000e, 0x00007f, 0x00007c, 0x0001f6, 0x0007de, 0x001f7e, 0x007dff }, + { 15, 14, 12, 10, 8, 7, 5, 3, 1, 2, + 4, 7, 7, 9, 11, 13, 15 } + } +}; +#else const HUFF_TABLE huff_alpha_table[2] = { { /* Alfa Fine */ @@ -834,6 +900,7 @@ const HUFF_TABLE huff_beta_table[2] = } } /* End Beta Coarse */ }; +#endif const int16_t mc_paramupmix_fb_remix_order[4] = {0, 1, 2, 3}; diff --git a/lib_enc/ivas_rom_enc.h b/lib_enc/ivas_rom_enc.h index fa45706cab..e2dce17968 100644 --- a/lib_enc/ivas_rom_enc.h +++ b/lib_enc/ivas_rom_enc.h @@ -126,10 +126,18 @@ extern const float Stereo_dmx_s_wnd_coef_48k[L_FRAME48k >> 4]; extern const float Stereo_dmx_wnd_coef_32k[L_FRAME32k]; extern const float Stereo_dmx_wnd_coef_48k[L_FRAME48k]; +#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +/*----------------------------------------------------------------------------------* + * ParamUpmix ROM tables + *----------------------------------------------------------------------------------*/ +extern const HUFF_TABLE huff_alpha_table; +extern const HUFF_TABLE huff_beta_table; +extern const int16_t mc_paramupmix_fb_remix_order[4]; +#else extern const HUFF_TABLE huff_alpha_table[2]; extern const HUFF_TABLE huff_beta_table[2]; extern const int16_t mc_paramupmix_fb_remix_order[4]; - +#endif /*----------------------------------------------------------------------------------* * ParamMC ROM tables *----------------------------------------------------------------------------------*/ -- GitLab From ce5579b783f0aefd9c5408cfb6bb2a9152f868b2 Mon Sep 17 00:00:00 2001 From: plains Date: Tue, 7 Nov 2023 14:41:11 +0100 Subject: [PATCH 2/6] Update name of define --- lib_com/ivas_cnst.h | 4 +- lib_com/ivas_rom_com.c | 4 +- lib_com/ivas_rom_com.h | 4 +- lib_com/options.h | 2 +- lib_dec/ivas_mc_paramupmix_dec.c | 31 ++++++------ lib_dec/ivas_rom_dec.c | 14 ++--- lib_enc/ivas_mc_paramupmix_enc.c | 87 ++++++++++++++++---------------- lib_enc/ivas_rom_enc.c | 2 +- lib_enc/ivas_rom_enc.h | 2 +- 9 files changed, 75 insertions(+), 75 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index f9e530c31a..78b83cf739 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1346,7 +1346,7 @@ typedef enum { BETA } PAR_TYPE; -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP typedef enum { FINE, COARSE @@ -1358,7 +1358,7 @@ typedef struct { int16_t offset; float data[35]; } ACPL_QUANT_TABLE; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP typedef struct { const int16_t (*alpha)[2]; diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index d4e5fe0ae0..a08cbbd7ad 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -2522,7 +2522,7 @@ const uint16_t ivas_param_mc_sym_freq_ild_delta_combined_48_16bits[2 * PARAM_MC_ /*----------------------------------------------------------------------------------* * Parametric Upmix MC ROM tables *----------------------------------------------------------------------------------*/ -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP const int16_t ivas_param_upmx_mx_qmap[33] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0 @@ -6443,7 +6443,7 @@ const int16_t sns_1st_means_32k[2][16] = /*----------------------------------------------------------------------* * MC ParamUpmix ROM tables *-----------------------------------------------------------------------*/ -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP const ACPL_QUANT_TABLE ivas_mc_paramupmix_alpha_quant_table = { 33, /* nquant */ diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index b9f1c5f0d5..bc6ebdf509 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -262,7 +262,7 @@ extern const uint16_t ivas_param_mc_sym_freq_icc_delta_combined_48_16bits[2 * PA /*----------------------------------------------------------------------------------* * Parametric Upmix MC ROM tables *----------------------------------------------------------------------------------*/ -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP extern const int16_t ivas_param_upmx_mx_qmap[33]; #else extern const int16_t ivas_param_upmx_mx_qmap[2][33]; @@ -456,7 +456,7 @@ extern const int16_t sns_1st_means_32k[2][16]; /*----------------------------------------------------------------------* * MC ParamUpmix ROM tables *-----------------------------------------------------------------------*/ -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP extern const ACPL_QUANT_TABLE ivas_mc_paramupmix_alpha_quant_table; extern const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[9]; #else diff --git a/lib_com/options.h b/lib_com/options.h index 1b0443ea6e..fb830e604a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,7 +156,7 @@ #define FIX_890_ARRAY_SIZE /* Nokia: issue #890: mismatch in 2D array size declaration and use */ #define BE_FIX_887_GCC_WARNING_ARRAY_SIZE /* VoiceAge: Issue 887: change array size definition to avoid warning with gcc 11.4.0 */ #define FIX_247_EXTERNAL_RENDERER_COMMAND_LINE /* VA: issue 247: harmonize command-line options names of external renderer with the decoder */ -#define FIX_DLB_PARAMUPMIX_CLEANUP +#define FIX_891_PARAMUPMIX_CLEANUP /* Dlb: issue 891: remove unneeded code from ParamUpmix */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 395fc2fff2..a2a63a6862 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -79,7 +79,7 @@ static void ivas_param_upmix_dec_decorr_subframes( Decoder_Struct *st_ivas, cons static void paramupmix_td_decorr_process( ivas_td_decorr_state_t *hTdDecorr[], float *pcm_in[], float **pp_out_pcm, const int16_t output_frame ); static int16_t huff_read( Decoder_State *st, const int16_t ( *ht )[2] ); -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP static void huffman_decode( Decoder_State *st, PAR_TYPE parType, int32_t *vq ); static void dequant_alpha( int32_t *vq, float *v ); @@ -149,7 +149,7 @@ void ivas_mc_paramupmix_dec_read_BS( for ( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP get_ec_data( st0, ALPHA, hMCParamUpmix->alpha_quant[i], alpha_quant, hMCParamUpmix->alphas[i] ); get_ec_data( st0, BETA, hMCParamUpmix->beta_quant[i], alpha_quant, hMCParamUpmix->betas[i] ); @@ -1348,13 +1348,12 @@ static int16_t huff_read( static void huffman_decode( Decoder_State *st, -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP const int16_t nv, const int16_t ivStart, const PAR_TYPE parType, const QUANT_TYPE quant_type, const int16_t bNoDt, - 0 #else const PAR_TYPE parType, #endif @@ -1366,7 +1365,7 @@ static void huffman_decode( nquant = 0; switch ( parType ) { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP case ALPHA: nquant = ivas_mc_paramupmix_alpha_quant_table.nquant; break; @@ -1387,7 +1386,7 @@ static void huffman_decode( offset = nquant - 1; /* range of df/dt [-(nquant - 1), nquant - 1] */ -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP bdt = st->bit_stream[st->next_bit_pos]; st->next_bit_pos++; #else @@ -1405,7 +1404,7 @@ static void huffman_decode( { /* Get dt */ switch ( parType ) { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP case ALPHA: huff_node_table = ivas_mc_paramupmix_huff_nodes_dt.alpha; break; @@ -1441,7 +1440,7 @@ static void huffman_decode( { switch ( parType ) { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP case ALPHA: huff_node_table = ivas_mc_paramupmix_huff_nodes_df0.alpha; break; @@ -1507,7 +1506,7 @@ static void huffman_decode( static void dequant_alpha( -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP const int16_t nv, const int16_t ivStart, const QUANT_TYPE quant_type, @@ -1516,7 +1515,7 @@ static void dequant_alpha( float *v ) { int16_t iv; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP const ACPL_QUANT_TABLE *quant_table = &ivas_mc_paramupmix_alpha_quant_table; for ( iv = 0; iv < 0; iv++ ) @@ -1546,7 +1545,7 @@ static void dequant_alpha( static void dequant_beta( -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP const int16_t nv, const int16_t ivStart, const QUANT_TYPE quant_type, @@ -1558,7 +1557,7 @@ static void dequant_beta( int16_t iv; const ACPL_QUANT_TABLE *quant_table; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP for ( iv = 0; iv < 0; iv++ ) { beta[iv] = 0; @@ -1588,7 +1587,7 @@ static void dequant_beta( static void get_ec_data( Decoder_State *st, const PAR_TYPE parType, -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP const QUANT_TYPE quant_type, const int16_t nParBand, const int16_t parBandStart, @@ -1597,7 +1596,7 @@ static void get_ec_data( int32_t *alphaQEnv, float ab[IVAS_MAX_NUM_BANDS] ) { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP huffman_decode( st, parType, parQ ); #else huffman_decode( st, nParBand, parBandStart, parType, quant_type, 0, parQ ); @@ -1605,7 +1604,7 @@ static void get_ec_data( if ( parType == ALPHA ) { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP dequant_alpha( parQ, ab ); mvl2l( parQ, alphaQEnv, (int16_t) IVAS_MAX_NUM_BANDS ); #else @@ -1615,7 +1614,7 @@ static void get_ec_data( } else { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP dequant_beta( alphaQEnv, parQ, ab ); #else dequant_beta( nParBand, parBandStart, quant_type, alphaQEnv, parQ, ab ); diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 7c6e472b58..c4216e9ba5 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -720,7 +720,7 @@ static const int16_t huff_nodes_first_band_alpha[32][2] = { -2, -32 } }; -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP /* Alpha Coarse Huffman table df0 */ static const int16_t huff_nodes_first_band_alpha_coarse[16][2] = { @@ -812,7 +812,7 @@ static const int16_t huff_nodes_alpha_1D_DF[64][2] = { -2, -62 } }; -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP /* Alpha Coarse Huffman table df */ static const int16_t huff_nodes_alpha_1D_DF_coarse[32][2] = { @@ -920,7 +920,7 @@ static const int16_t huff_nodes_alpha_1D_DT[64][2] = { -2, -63 } }; -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP /* Alpha Coarse Huffman table dt */ static const int16_t huff_nodes_alpha_1D_DT_coarse[32][2] = { @@ -965,7 +965,7 @@ static const int16_t huff_nodes_first_band_beta[8][2] = { -1, 1 }, { -2, 2 }, { -3, 3 }, { -4, 4 }, { -5, 5 }, { -6, 6 }, { -7, 7 }, { -8, -9 } }; -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP /* Beta Coarse Huffman table df0 */ static const int16_t huff_nodes_first_band_beta_coarse[4][2] = { @@ -979,7 +979,7 @@ static const int16_t huff_nodes_beta_1D_DF[16][2] = { -9, 1 }, { -10, 2 }, { -8, 3 }, { -11, 4 }, { -7, 5 }, { 7, 6 }, { -6, -12 }, { 9, 8 }, { -5, -13 }, { 11, 10 }, { -4, -14 }, { -15, 12 }, { -3, 13 }, { -16, 14 }, { -2, 15 }, { -1, -17 } }; -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP /* Beta Coarse Huffman table df */ static const int16_t huff_nodes_beta_1D_DF_coarse[8][2] = { @@ -993,7 +993,7 @@ static const int16_t huff_nodes_beta_1D_DT[16][2] = { -9, 1 }, { -10, 2 }, { -8, 3 }, { -11, 4 }, { -7, 5 }, { 7, 6 }, { -6, -12 }, { -13, 8 }, { -5, 9 }, { -14, 10 }, { -4, 11 }, { -15, 12 }, { -3, 13 }, { -16, 14 }, { -2, 15 }, { -1, -17 } }; -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP /* Beta Coarse Huffman table dt */ static const int16_t huff_nodes_beta_1D_DT_coarse[8][2] = { @@ -1001,7 +1001,7 @@ static const int16_t huff_nodes_beta_1D_DT_coarse[8][2] = }; #endif -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_df0 = { huff_nodes_first_band_alpha, diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index a7037c5d8f..9e28b0446b 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -56,7 +56,7 @@ static void ivas_mc_paramupmix_dmx( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, float *data_f[], const int16_t input_frame ); static void ivas_mc_paramupmix_param_est_enc( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, float *input_frame_t[], const int16_t input_frame, float alphas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS], float betas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS] ); -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP static void get_huff_table( const PAR_TYPE par_type, HUFF_TAB *df0, HUFF_TAB *df, HUFF_TAB *dt ); #else static void get_huff_table( const PAR_TYPE par_type, const QUANT_TYPE quant_type, HUFF_TAB *df0, HUFF_TAB *df, HUFF_TAB *dt ); @@ -64,7 +64,7 @@ static void get_huff_table( const PAR_TYPE par_type, const QUANT_TYPE quant_type static void write_huff_bits( const int32_t value, const uint16_t length, uint16_t bit_buffer[MC_PARAMUPMIX_MAX_BITS], int16_t *bit_pos ); -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP static void huffman_encode( const int32_t *vqPrev, const int32_t *vq, const PAR_TYPE parType, const int16_t nq, uint16_t bit_buffer[MC_PARAMUPMIX_MAX_BITS], int16_t *bit_pos ); #else static void huffman_encode( const int16_t bdfOnly, const int16_t bdtAllowed, const int16_t nv, const int16_t ivStart, const int32_t *vqPrev, const int32_t *vq, const PAR_TYPE parType, const QUANT_TYPE quant_type, const int16_t nq, uint16_t bit_buffer[MC_PARAMUPMIX_MAX_BITS], int16_t *bit_pos ); @@ -72,7 +72,7 @@ static void huffman_encode( const int16_t bdfOnly, const int16_t bdtAllowed, con static void put_ec_data( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, const int16_t ch, const float pars[IVAS_MAX_NUM_BANDS], const float alphas[IVAS_MAX_NUM_BANDS], const PAR_TYPE parType, uint16_t bit_buffer[MC_PARAMUPMIX_MAX_BITS], int16_t *bit_pos ); -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP static void quantize_alpha( const float *alpha, int16_t *pnq, int32_t aq[IVAS_MAX_NUM_BANDS], float *adeq ); static void quantize_pars( const float *v, const int16_t nq, const float *data, int32_t vq[IVAS_MAX_NUM_BANDS], float *vdeq ); #else @@ -372,7 +372,7 @@ void ivas_mc_paramupmix_enc_close( static void get_huff_table( const PAR_TYPE par_type, -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP const QUANT_TYPE quant_type, #endif HUFF_TAB *df0, @@ -381,7 +381,7 @@ static void get_huff_table( { switch ( par_type ) { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP case ALPHA: df0->value = huff_alpha_table.df0.value; df0->length = huff_alpha_table.df0.length; @@ -440,7 +440,7 @@ static void write_huff_bits( static void huffman_encode( -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP const int16_t bdfOnly, const int16_t bdtAllowed, const int16_t nv, @@ -449,7 +449,7 @@ static void huffman_encode( const int32_t *vqPrev, const int32_t *vq, const PAR_TYPE parType, -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP const QUANT_TYPE quant_type, #endif const int16_t nq, @@ -461,7 +461,7 @@ static void huffman_encode( int16_t offset; HUFF_TAB df0, df, dt; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP get_huff_table( parType, &df0, &df, &dt ); #else get_huff_table( parType, quant_type, &df0, &df, &dt ); @@ -472,13 +472,13 @@ static void huffman_encode( /* Get code length for time and freq diff coding */ ndf = 0; ndt = 0; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) #else for ( iv = ivStart; iv < nv; iv++ ) #endif { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP if ( iv == 0 ) #else if ( iv == ivStart ) @@ -497,7 +497,7 @@ static void huffman_encode( ndt += dt.length[icode]; } -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP if ( !bdtAllowed ) /* Time diff not allowed due to conformance or other reason even if bdfOnly = 0 */ { ndt = ndf + 1; @@ -505,24 +505,28 @@ static void huffman_encode( #endif /* Write the bitstream */ -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP - if ( ndf < ndt ) +#ifdef FIX_891_PARAMUPMIX_CLEANUP + bit_buffer[( *bit_pos )++] = (uint16_t) 0 & 1; + for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) + { + if ( iv == 0 ) + { + icode = vq[iv]; + write_huff_bits( df0.value[icode], df0.length[icode], bit_buffer, bit_pos ); + } + else + { + icode = vq[iv] - vq[iv - 1] + offset; + write_huff_bits( df.value[icode], df.length[icode], bit_buffer, bit_pos ); + } + } #else if ( bdfOnly || ndf < ndt ) -#endif { bit_buffer[( *bit_pos )++] = (uint16_t) 0 & 1; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP - for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) -#else for ( iv = ivStart; iv < nv; iv++ ) -#endif { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP - if ( iv == 0 ) -#else if ( iv == ivStart ) -#endif { icode = vq[iv]; write_huff_bits( df0.value[icode], df0.length[icode], bit_buffer, bit_pos ); @@ -537,11 +541,7 @@ static void huffman_encode( else { bit_buffer[( *bit_pos )++] = (uint16_t) 1 & 1; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP - for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) -#else for ( iv = ivStart; iv < nv; iv++ ) -#endif { icode = vq[iv] - vqPrev[iv] + offset; #ifdef DEBUGGING @@ -553,13 +553,14 @@ static void huffman_encode( write_huff_bits( dt.value[icode], dt.length[icode], bit_buffer, bit_pos ); } } +#endif return; } static void quantize_pars( -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP const int16_t nv, #endif const float *v, @@ -570,7 +571,7 @@ static void quantize_pars( { int16_t iv, iq, iq0, iq1; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) #else for ( iv = 0; iv < nv; iv++ ) @@ -609,11 +610,11 @@ static void quantize_pars( static void quantize_alpha( -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP const int16_t nv, #endif const float *alpha, -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP const QUANT_TYPE quant_type, #endif int16_t *pnq, @@ -623,7 +624,7 @@ static void quantize_alpha( int16_t nq; const float *data; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP nq = ivas_mc_paramupmix_alpha_quant_table.nquant; data = ivas_mc_paramupmix_alpha_quant_table.data; @@ -641,12 +642,12 @@ static void quantize_alpha( static void quantize_beta( -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP const int16_t nv, #endif const float *beta, const int32_t aq[IVAS_MAX_NUM_BANDS], -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP const QUANT_TYPE quant_type, #endif int16_t *pnq, @@ -654,20 +655,20 @@ static void quantize_beta( float *bdeq ) { int16_t iv, iq, iq0, iq1; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP const ACPL_QUANT_TABLE *tables = ivas_mc_paramupmix_beta_quant_table; #else const ACPL_QUANT_TABLE *tables = ivas_mc_paramupmix_beta_quant_table[quant_type]; #endif ACPL_QUANT_TABLE quant_table; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) #else for ( iv = 0; iv < nv; iv++ ) #endif { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP quant_table = tables[ivas_param_upmx_mx_qmap[aq[iv]]]; #else quant_table = tables[ivas_param_upmx_mx_qmap[quant_type][aq[iv]]]; @@ -701,7 +702,7 @@ static void quantize_beta( } } -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP *pnq = ivas_mc_paramupmix_beta_quant_table[0].nquant; #else *pnq = ivas_mc_paramupmix_beta_quant_table[quant_type][0].nquant; @@ -720,12 +721,12 @@ static void put_ec_data( uint16_t bit_buffer[MC_PARAMUPMIX_MAX_BITS], int16_t *bit_pos ) { -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP int16_t npar = IVAS_MAX_NUM_BANDS; int16_t onlyFreq = 1; #endif int16_t nq; -#ifndef FIX_DLB_PARAMUPMIX_CLEANUP +#ifndef FIX_891_PARAMUPMIX_CLEANUP QUANT_TYPE quant_type = FINE; #endif int32_t alphaQuant[IVAS_MAX_NUM_BANDS]; @@ -735,7 +736,7 @@ static void put_ec_data( if ( parType == ALPHA ) { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP quantize_alpha( pars, &nq, alphaQuant, alphaDequant ); #else quantize_alpha( npar, pars, quant_type, &nq, alphaQuant, alphaDequant ); @@ -743,7 +744,7 @@ static void put_ec_data( } else { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP quantize_alpha( alphas, &nq, alphaQuant, alphaDequant ); quantize_beta( pars, alphaQuant, &nq, betaQuant, betaDequant ); #else @@ -768,7 +769,7 @@ static void put_ec_data( /* Always one parameter set per frame for transient frames. Original PS framing is used internally. */ if ( parType == ALPHA ) { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP huffman_encode( hMCParamUpmix->alpha_quant_prev[ch], alphaQuant, ALPHA, nq, bit_buffer, bit_pos ); #else huffman_encode( onlyFreq, 1, npar, 0, hMCParamUpmix->alpha_quant_prev[ch], alphaQuant, ALPHA, quant_type, nq, bit_buffer, bit_pos ); @@ -776,7 +777,7 @@ static void put_ec_data( } else { -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP huffman_encode( hMCParamUpmix->beta_quant_prev[ch], betaQuant, BETA, nq, bit_buffer, bit_pos ); #else huffman_encode( onlyFreq, 1, npar, 0, hMCParamUpmix->beta_quant_prev[ch], betaQuant, BETA, quant_type, nq, bit_buffer, bit_pos ); diff --git a/lib_enc/ivas_rom_enc.c b/lib_enc/ivas_rom_enc.c index 653f3a4f45..d95125f1e3 100644 --- a/lib_enc/ivas_rom_enc.c +++ b/lib_enc/ivas_rom_enc.c @@ -722,7 +722,7 @@ const float Stereo_dmx_wnd_coef_48k[L_FRAME48k] = { 0.0310834963f, 0.0278123822f, 0.0245409720f, 0.0212692991f, 0.0179976355f, 0.0147257810f, 0.0114535289f, 0.00818115473f, 0.00490869302f, 0.00163617858f }; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP const HUFF_TABLE huff_alpha_table = { { /* df0 */ diff --git a/lib_enc/ivas_rom_enc.h b/lib_enc/ivas_rom_enc.h index e2dce17968..fd79f892f2 100644 --- a/lib_enc/ivas_rom_enc.h +++ b/lib_enc/ivas_rom_enc.h @@ -126,7 +126,7 @@ extern const float Stereo_dmx_s_wnd_coef_48k[L_FRAME48k >> 4]; extern const float Stereo_dmx_wnd_coef_32k[L_FRAME32k]; extern const float Stereo_dmx_wnd_coef_48k[L_FRAME48k]; -#ifdef FIX_DLB_PARAMUPMIX_CLEANUP +#ifdef FIX_891_PARAMUPMIX_CLEANUP /*----------------------------------------------------------------------------------* * ParamUpmix ROM tables *----------------------------------------------------------------------------------*/ -- GitLab From 324938bd4f225528628eb55aaf551a4d9b86892c Mon Sep 17 00:00:00 2001 From: plains Date: Tue, 7 Nov 2023 14:56:15 +0100 Subject: [PATCH 3/6] Remove more unused code --- lib_enc/ivas_mc_paramupmix_enc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index 9e28b0446b..92d1d59929 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -456,7 +456,11 @@ static void huffman_encode( uint16_t bit_buffer[MC_PARAMUPMIX_MAX_BITS], int16_t *bit_pos ) { +#ifdef FIX_891_PARAMUPMIX_CLEANUP + int16_t iv; +#else int16_t iv, ndf, ndt; +#endif int32_t icode; int16_t offset; HUFF_TAB df0, df, dt; @@ -469,9 +473,11 @@ static void huffman_encode( offset = nq - 1; /* range [-(nquant - 1), nquant - 1] */ +#ifndef FIX_891_PARAMUPMIX_CLEANUP /* Get code length for time and freq diff coding */ ndf = 0; ndt = 0; +#endif #ifdef FIX_891_PARAMUPMIX_CLEANUP for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) #else @@ -485,16 +491,22 @@ static void huffman_encode( #endif { icode = vq[iv]; +#ifndef FIX_891_PARAMUPMIX_CLEANUP ndf += df0.length[icode]; +#endif } else { icode = vq[iv] - vq[iv - 1] + offset; +#ifndef FIX_891_PARAMUPMIX_CLEANUP ndf += df.length[icode]; +#endif } icode = vq[iv] - vqPrev[iv] + offset; +#ifndef FIX_891_PARAMUPMIX_CLEANUP ndt += dt.length[icode]; +#endif } #ifndef FIX_891_PARAMUPMIX_CLEANUP -- GitLab From a87fe63f08f65fb9476a58b6d703deb9050cd557 Mon Sep 17 00:00:00 2001 From: plains Date: Wed, 8 Nov 2023 09:39:28 +0100 Subject: [PATCH 4/6] More cleanup --- lib_com/ivas_cnst.h | 7 +++ lib_dec/ivas_mc_paramupmix_dec.c | 97 +++++++++++++++----------------- lib_enc/ivas_mc_paramupmix_enc.c | 17 +++--- lib_enc/ivas_rom_enc.c | 22 -------- 4 files changed, 62 insertions(+), 81 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 78b83cf739..a2435d0f3e 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1335,11 +1335,18 @@ typedef struct { unsigned short length[81]; } HUFF_ELEMENTS; +#ifdef FIX_891_PARAMUPMIX_CLEANUP +typedef struct { + HUFF_ELEMENTS df0; + HUFF_ELEMENTS df; +} HUFF_TABLE; +#else typedef struct { HUFF_ELEMENTS df0; HUFF_ELEMENTS df; HUFF_ELEMENTS dt; } HUFF_TABLE; +#endif typedef enum { ALPHA, diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index a2a63a6862..25e3d2f6bb 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -1360,34 +1360,42 @@ static void huffman_decode( int32_t *vq ) { const int16_t( *huff_node_table )[2]; - int16_t iv, bdt, nquant, offset; +#ifdef FIX_891_PARAMUPMIX_CLEANUP + int16_t iv, nquant, offset; nquant = 0; switch ( parType ) { -#ifdef FIX_891_PARAMUPMIX_CLEANUP case ALPHA: nquant = ivas_mc_paramupmix_alpha_quant_table.nquant; break; case BETA: nquant = ivas_mc_paramupmix_beta_quant_table[0].nquant; break; + default: + assert( 0 ); + } + + offset = nquant - 1; /* range of df [-(nquant - 1), nquant - 1] */ #else + int16_t iv, bdt, nquant, offset; + nquant = 0; + switch ( parType ) + { case ALPHA: nquant = ivas_mc_paramupmix_alpha_quant_table[quant_type].nquant; break; case BETA: nquant = ivas_mc_paramupmix_beta_quant_table[quant_type][0].nquant; break; -#endif default: assert( 0 ); } offset = nquant - 1; /* range of df/dt [-(nquant - 1), nquant - 1] */ +#endif #ifdef FIX_891_PARAMUPMIX_CLEANUP - bdt = st->bit_stream[st->next_bit_pos]; st->next_bit_pos++; #else if ( bNoDt ) @@ -1400,26 +1408,42 @@ static void huffman_decode( st->next_bit_pos++; } #endif +#ifdef FIX_891_PARAMUPMIX_CLEANUP + switch ( parType ) + { + case ALPHA: + huff_node_table = ivas_mc_paramupmix_huff_nodes_df0.alpha; + break; + case BETA: + huff_node_table = ivas_mc_paramupmix_huff_nodes_df0.beta; + break; + default: + huff_node_table = NULL; + assert( 0 ); + } + vq[0] = huff_read( st, huff_node_table ); + + switch ( parType ) + { + case ALPHA: + huff_node_table = ivas_mc_paramupmix_huff_nodes_df.alpha; + break; + case BETA: + huff_node_table = ivas_mc_paramupmix_huff_nodes_df.beta; + break; + default: + assert( 0 ); + } + + for ( iv = 1; iv < IVAS_MAX_NUM_BANDS; iv++ ) + { + vq[iv] = huff_read( st, huff_node_table ) + vq[iv - 1] - offset; + } +#else if ( bdt ) { /* Get dt */ switch ( parType ) { -#ifdef FIX_891_PARAMUPMIX_CLEANUP - case ALPHA: - huff_node_table = ivas_mc_paramupmix_huff_nodes_dt.alpha; - break; - case BETA: - huff_node_table = ivas_mc_paramupmix_huff_nodes_dt.beta; - break; - default: - huff_node_table = NULL; - assert( 0 ); - } - for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) - { - vq[iv] = huff_read( st, huff_node_table ) + vq[iv] - offset; - } -#else case ALPHA: huff_node_table = ivas_mc_paramupmix_huff_nodes_dt.alpha[quant_type]; break; @@ -1434,42 +1458,11 @@ static void huffman_decode( { vq[iv] = huff_read( st, huff_node_table ) + vq[iv] - offset; } -#endif } else /* Get f0, df */ { switch ( parType ) { -#ifdef FIX_891_PARAMUPMIX_CLEANUP - case ALPHA: - huff_node_table = ivas_mc_paramupmix_huff_nodes_df0.alpha; - break; - case BETA: - huff_node_table = ivas_mc_paramupmix_huff_nodes_df0.beta; - break; - default: - huff_node_table = NULL; - assert( 0 ); - } - vq[0] = huff_read( st, huff_node_table ); - - switch ( parType ) - { - case ALPHA: - huff_node_table = ivas_mc_paramupmix_huff_nodes_df.alpha; - break; - case BETA: - huff_node_table = ivas_mc_paramupmix_huff_nodes_df.beta; - break; - default: - assert( 0 ); - } - - for ( iv = 1; iv < IVAS_MAX_NUM_BANDS; iv++ ) - { - vq[iv] = huff_read( st, huff_node_table ) + vq[iv - 1] - offset; - } -#else case ALPHA: huff_node_table = ivas_mc_paramupmix_huff_nodes_df0.alpha[quant_type]; break; @@ -1498,8 +1491,8 @@ static void huffman_decode( { vq[iv] = huff_read( st, huff_node_table ) + vq[iv - 1] - offset; } -#endif } +#endif return; } diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index 92d1d59929..a028190711 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -57,7 +57,7 @@ static void ivas_mc_paramupmix_dmx( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, floa static void ivas_mc_paramupmix_param_est_enc( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, float *input_frame_t[], const int16_t input_frame, float alphas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS], float betas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS] ); #ifdef FIX_891_PARAMUPMIX_CLEANUP -static void get_huff_table( const PAR_TYPE par_type, HUFF_TAB *df0, HUFF_TAB *df, HUFF_TAB *dt ); +static void get_huff_table( const PAR_TYPE par_type, HUFF_TAB *df0, HUFF_TAB *df ); #else static void get_huff_table( const PAR_TYPE par_type, const QUANT_TYPE quant_type, HUFF_TAB *df0, HUFF_TAB *df, HUFF_TAB *dt ); #endif @@ -374,10 +374,13 @@ static void get_huff_table( const PAR_TYPE par_type, #ifndef FIX_891_PARAMUPMIX_CLEANUP const QUANT_TYPE quant_type, -#endif HUFF_TAB *df0, HUFF_TAB *df, HUFF_TAB *dt ) +#else + HUFF_TAB *df0, + HUFF_TAB *df ) +#endif { switch ( par_type ) { @@ -387,16 +390,12 @@ static void get_huff_table( df0->length = huff_alpha_table.df0.length; df->value = huff_alpha_table.df.value; df->length = huff_alpha_table.df.length; - dt->value = huff_alpha_table.dt.value; - dt->length = huff_alpha_table.dt.length; break; case BETA: df0->value = huff_beta_table.df0.value; df0->length = huff_beta_table.df0.length; df->value = huff_beta_table.df.value; df->length = huff_beta_table.df.length; - dt->value = huff_beta_table.dt.value; - dt->length = huff_beta_table.dt.length; break; #else case ALPHA: @@ -463,10 +462,14 @@ static void huffman_encode( #endif int32_t icode; int16_t offset; +#ifdef FIX_891_PARAMUPMIX_CLEANUP + HUFF_TAB df0, df; +#else HUFF_TAB df0, df, dt; +#endif #ifdef FIX_891_PARAMUPMIX_CLEANUP - get_huff_table( parType, &df0, &df, &dt ); + get_huff_table( parType, &df0, &df ); #else get_huff_table( parType, quant_type, &df0, &df, &dt ); #endif diff --git a/lib_enc/ivas_rom_enc.c b/lib_enc/ivas_rom_enc.c index d95125f1e3..4a5329bcec 100644 --- a/lib_enc/ivas_rom_enc.c +++ b/lib_enc/ivas_rom_enc.c @@ -750,22 +750,6 @@ const HUFF_TABLE huff_alpha_table = 9, 10, 10, 11, 11, 12, 12, 12, 13, 13, 14, 15, 15, 16, 16, 17, 16, 16, 17, 16, 16, 17, 17, 17, 13 } - }, - { /* dt */ - { 0x00eeee, 0x03b3ee, 0x03b3f6, 0x03b3fc, 0x01d9bc, 0x01d9bd, 0x01d9b2, 0x03b3fe, 0x01d9be, 0x01d9f6, - 0x01d9fc, 0x00ecda, 0x00ecfa, 0x00eeef, 0x00766e, 0x007776, 0x003b3a, 0x003bba, 0x001d9a, 0x001ddc, - 0x001dde, 0x000eec, 0x000764, 0x000772, 0x0003b0, 0x0003b8, 0x0001da, 0x0001de, 0x000072, 0x000038, - 0x00001e, 0x000006, 0x000000, 0x000002, 0x00001f, 0x00003a, 0x000073, 0x0001df, 0x0001db, 0x0003ba, - 0x0003b1, 0x000773, 0x000765, 0x000eed, 0x000ecc, 0x001d9e, 0x001d9c, 0x003bbe, 0x003b3b, 0x00777e, - 0x00767c, 0x00eefe, 0x00ecfc, 0x00ecd8, 0x01d9fd, 0x01d9fa, 0x01d9bf, 0x01d9b6, 0x01d9b3, 0x03b3fd, - 0x01d9b7, 0x03b3ff, 0x03b3ef, 0x03b3f7, 0x00eeff }, - { 16, 18, 18, 18, 17, 17, 17, 18, 17, 17, - 17, 16, 16, 16, 15, 15, 14, 14, 13, 13, - 13, 12, 11, 11, 10, 10, 9, 9, 7, 6, - 5, 3, 1, 2, 5, 6, 7, 9, 9, 10, - 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, - 15, 16, 16, 16, 17, 17, 17, 17, 17, 18, - 17, 18, 18, 18, 16 } } }; @@ -780,12 +764,6 @@ const HUFF_TABLE huff_beta_table = 0x00000e, 0x00007f, 0x0000fb, 0x0001f3, 0x0001f0, 0x0007c6, 0x001f1f }, { 13, 12, 10, 9, 8, 7, 5, 3, 1, 2, 4, 7, 8, 9, 9, 11, 13 } - }, - { /* dt */ - { 0x007dfe, 0x003efe, 0x000fbe, 0x0003ee, 0x0000fa, 0x00007e, 0x00001e, 0x000006, 0x000000, 0x000002, - 0x00000e, 0x00007f, 0x00007c, 0x0001f6, 0x0007de, 0x001f7e, 0x007dff }, - { 15, 14, 12, 10, 8, 7, 5, 3, 1, 2, - 4, 7, 7, 9, 11, 13, 15 } } }; #else -- GitLab From 0dbeb47b37c8e8f96da7331390650e6adc100a21 Mon Sep 17 00:00:00 2001 From: plains Date: Thu, 16 Nov 2023 10:29:23 +0100 Subject: [PATCH 5/6] Improved spacing --- lib_com/ivas_cnst.h | 3 ++- lib_com/ivas_rom_com.c | 3 +++ lib_com/ivas_rom_com.h | 1 + lib_dec/ivas_mc_paramupmix_dec.c | 16 ++++------------ lib_enc/ivas_mc_paramupmix_enc.c | 6 ++++-- lib_enc/ivas_rom_enc.h | 3 +++ 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index a2435d0f3e..d985a04d13 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1358,14 +1358,15 @@ typedef enum { FINE, COARSE } QUANT_TYPE; -#endif +#endif typedef struct { int16_t nquant; int16_t offset; float data[35]; } ACPL_QUANT_TABLE; #ifdef FIX_891_PARAMUPMIX_CLEANUP + typedef struct { const int16_t (*alpha)[2]; diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index a08cbbd7ad..7f03c166ed 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -2522,6 +2522,7 @@ const uint16_t ivas_param_mc_sym_freq_ild_delta_combined_48_16bits[2 * PARAM_MC_ /*----------------------------------------------------------------------------------* * Parametric Upmix MC ROM tables *----------------------------------------------------------------------------------*/ + #ifdef FIX_891_PARAMUPMIX_CLEANUP const int16_t ivas_param_upmx_mx_qmap[33] = { @@ -6443,6 +6444,7 @@ const int16_t sns_1st_means_32k[2][16] = /*----------------------------------------------------------------------* * MC ParamUpmix ROM tables *-----------------------------------------------------------------------*/ + #ifdef FIX_891_PARAMUPMIX_CLEANUP const ACPL_QUANT_TABLE ivas_mc_paramupmix_alpha_quant_table = { @@ -6602,4 +6604,5 @@ const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[2][9] = } }; #endif + /* clang-format on */ diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index bc6ebdf509..5ed0ae5e84 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -457,6 +457,7 @@ extern const int16_t sns_1st_means_32k[2][16]; * MC ParamUpmix ROM tables *-----------------------------------------------------------------------*/ #ifdef FIX_891_PARAMUPMIX_CLEANUP + extern const ACPL_QUANT_TABLE ivas_mc_paramupmix_alpha_quant_table; extern const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[9]; #else diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 25e3d2f6bb..517aadfd8b 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -80,7 +80,7 @@ static void paramupmix_td_decorr_process( ivas_td_decorr_state_t *hTdDecorr[], f static int16_t huff_read( Decoder_State *st, const int16_t ( *ht )[2] ); #ifdef FIX_891_PARAMUPMIX_CLEANUP -static void huffman_decode( Decoder_State *st, PAR_TYPE parType, int32_t *vq ); +static void huffman_decode( Decoder_State *st, const PAR_TYPE parType, int32_t *vq ); static void dequant_alpha( int32_t *vq, float *v ); @@ -1360,9 +1360,9 @@ static void huffman_decode( int32_t *vq ) { const int16_t( *huff_node_table )[2]; - #ifdef FIX_891_PARAMUPMIX_CLEANUP int16_t iv, nquant, offset; + nquant = 0; switch ( parType ) { @@ -1511,15 +1511,11 @@ static void dequant_alpha( #ifdef FIX_891_PARAMUPMIX_CLEANUP const ACPL_QUANT_TABLE *quant_table = &ivas_mc_paramupmix_alpha_quant_table; - for ( iv = 0; iv < 0; iv++ ) - { - v[iv] = 0; - } - for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) { v[iv] = quant_table->data[vq[iv]]; } + #else const ACPL_QUANT_TABLE *quant_table = &ivas_mc_paramupmix_alpha_quant_table[quant_type]; @@ -1551,16 +1547,12 @@ static void dequant_beta( const ACPL_QUANT_TABLE *quant_table; #ifdef FIX_891_PARAMUPMIX_CLEANUP - for ( iv = 0; iv < 0; iv++ ) - { - beta[iv] = 0; - } - for ( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) { quant_table = &ivas_mc_paramupmix_beta_quant_table[ivas_param_upmx_mx_qmap[aq[iv]]]; beta[iv] = quant_table->data[bq[iv]]; } + #else for ( iv = 0; iv < ivStart; iv++ ) { diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index a028190711..2d1e6d37fa 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -57,6 +57,7 @@ static void ivas_mc_paramupmix_dmx( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, floa static void ivas_mc_paramupmix_param_est_enc( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, float *input_frame_t[], const int16_t input_frame, float alphas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS], float betas[MC_PARAMUPMIX_COMBINATIONS][IVAS_MAX_NUM_BANDS] ); #ifdef FIX_891_PARAMUPMIX_CLEANUP + static void get_huff_table( const PAR_TYPE par_type, HUFF_TAB *df0, HUFF_TAB *df ); #else static void get_huff_table( const PAR_TYPE par_type, const QUANT_TYPE quant_type, HUFF_TAB *df0, HUFF_TAB *df, HUFF_TAB *dt ); @@ -74,6 +75,7 @@ static void put_ec_data( MC_PARAMUPMIX_ENC_HANDLE hMCParamUpmix, const int16_t c #ifdef FIX_891_PARAMUPMIX_CLEANUP static void quantize_alpha( const float *alpha, int16_t *pnq, int32_t aq[IVAS_MAX_NUM_BANDS], float *adeq ); + static void quantize_pars( const float *v, const int16_t nq, const float *data, int32_t vq[IVAS_MAX_NUM_BANDS], float *vdeq ); #else static void quantize_alpha( const int16_t nv, const float *alpha, const QUANT_TYPE quant_type, int16_t *pnq, int32_t aq[IVAS_MAX_NUM_BANDS], float *adeq ); @@ -81,8 +83,8 @@ static void quantize_alpha( const int16_t nv, const float *alpha, const QUANT_TY static void quantize_pars( const int16_t nv, const float *v, const int16_t nq, const float *data, int32_t vq[IVAS_MAX_NUM_BANDS], float *vdeq ); static void quantize_pars( const int16_t nv, const float *v, const int16_t nq, const float *data, int32_t vq[IVAS_MAX_NUM_BANDS], float *vdeq ); -#endif +#endif /*------------------------------------------------------------------------- * ivas_mc_paramupmix_enc() @@ -517,8 +519,8 @@ static void huffman_encode( { ndt = ndf + 1; } -#endif +#endif /* Write the bitstream */ #ifdef FIX_891_PARAMUPMIX_CLEANUP bit_buffer[( *bit_pos )++] = (uint16_t) 0 & 1; diff --git a/lib_enc/ivas_rom_enc.h b/lib_enc/ivas_rom_enc.h index fd79f892f2..9e6363fb06 100644 --- a/lib_enc/ivas_rom_enc.h +++ b/lib_enc/ivas_rom_enc.h @@ -130,13 +130,16 @@ extern const float Stereo_dmx_wnd_coef_48k[L_FRAME48k]; /*----------------------------------------------------------------------------------* * ParamUpmix ROM tables *----------------------------------------------------------------------------------*/ + extern const HUFF_TABLE huff_alpha_table; extern const HUFF_TABLE huff_beta_table; extern const int16_t mc_paramupmix_fb_remix_order[4]; + #else extern const HUFF_TABLE huff_alpha_table[2]; extern const HUFF_TABLE huff_beta_table[2]; extern const int16_t mc_paramupmix_fb_remix_order[4]; + #endif /*----------------------------------------------------------------------------------* * ParamMC ROM tables -- GitLab From 75cf366d984b4331e1fca0fa67910670d4efc469 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 21 Nov 2023 09:16:03 +0100 Subject: [PATCH 6/6] formatting + put ROM tables at one common place --- lib_com/ivas_cnst.h | 1 - lib_com/ivas_rom_com.c | 13 ++++++------- lib_com/ivas_rom_com.h | 6 ++---- lib_dec/ivas_mc_paramupmix_dec.c | 2 ++ lib_dec/ivas_rom_dec.c | 12 +++++++----- lib_enc/ivas_rom_enc.c | 5 +++++ 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index d985a04d13..95008d17f5 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1366,7 +1366,6 @@ typedef struct { float data[35]; } ACPL_QUANT_TABLE; #ifdef FIX_891_PARAMUPMIX_CLEANUP - typedef struct { const int16_t (*alpha)[2]; diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 7f03c166ed..9727f39fdd 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -2518,17 +2518,11 @@ const uint16_t ivas_param_mc_sym_freq_ild_delta_combined_48_16bits[2 * PARAM_MC_ 1, 1, 1, 2, 24, 69, 122, 194, 285, 487, 690, 1173, 2255, 4709, 10599, 24635, 10862, 4709, 2204, 1059, 566, 330, 221, 150, 95, 59, 28, 2, 1, 1, 1 }; - +#ifndef FIX_891_PARAMUPMIX_CLEANUP /*----------------------------------------------------------------------------------* * Parametric Upmix MC ROM tables *----------------------------------------------------------------------------------*/ -#ifdef FIX_891_PARAMUPMIX_CLEANUP -const int16_t ivas_param_upmx_mx_qmap[33] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0 -}; -#else const int16_t ivas_param_upmx_mx_qmap[2][33] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, @@ -6446,6 +6440,11 @@ const int16_t sns_1st_means_32k[2][16] = *-----------------------------------------------------------------------*/ #ifdef FIX_891_PARAMUPMIX_CLEANUP +const int16_t ivas_param_upmx_mx_qmap[33] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 0 +}; + const ACPL_QUANT_TABLE ivas_mc_paramupmix_alpha_quant_table = { 33, /* nquant */ diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 5ed0ae5e84..89086987eb 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -259,16 +259,13 @@ extern const uint16_t ivas_param_mc_sym_freq_icc_combined_48_16bits[PARAM_MC_SZ_ extern const uint16_t ivas_param_mc_cum_freq_icc_delta_combined_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER]; extern const uint16_t ivas_param_mc_sym_freq_icc_delta_combined_48_16bits[2 * PARAM_MC_SZ_ICC_QUANTIZER - 1]; +#ifndef FIX_891_PARAMUPMIX_CLEANUP /*----------------------------------------------------------------------------------* * Parametric Upmix MC ROM tables *----------------------------------------------------------------------------------*/ -#ifdef FIX_891_PARAMUPMIX_CLEANUP -extern const int16_t ivas_param_upmx_mx_qmap[33]; -#else extern const int16_t ivas_param_upmx_mx_qmap[2][33]; #endif - /*----------------------------------------------------------------------------------* * MASA ROM tables *----------------------------------------------------------------------------------*/ @@ -458,6 +455,7 @@ extern const int16_t sns_1st_means_32k[2][16]; *-----------------------------------------------------------------------*/ #ifdef FIX_891_PARAMUPMIX_CLEANUP +extern const int16_t ivas_param_upmx_mx_qmap[33]; extern const ACPL_QUANT_TABLE ivas_mc_paramupmix_alpha_quant_table; extern const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[9]; #else diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 517aadfd8b..bfc9ca3b18 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -79,6 +79,7 @@ static void ivas_param_upmix_dec_decorr_subframes( Decoder_Struct *st_ivas, cons static void paramupmix_td_decorr_process( ivas_td_decorr_state_t *hTdDecorr[], float *pcm_in[], float **pp_out_pcm, const int16_t output_frame ); static int16_t huff_read( Decoder_State *st, const int16_t ( *ht )[2] ); + #ifdef FIX_891_PARAMUPMIX_CLEANUP static void huffman_decode( Decoder_State *st, const PAR_TYPE parType, int32_t *vq ); @@ -97,6 +98,7 @@ static void dequant_beta( const int16_t nv, const int16_t ivStart, const QUANT_T static void get_ec_data( Decoder_State *st, const PAR_TYPE parType, const QUANT_TYPE quant_type, const int16_t nParBand, const int16_t parBandStart, int32_t *parQ, int32_t *alphaQEnv, float ab[IVAS_MAX_NUM_BANDS] ); #endif + /*------------------------------------------------------------------------- * ivas_mc_paramupmix_dec_read_BS() * diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index e7ae0f42cb..4516fcff4b 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -745,8 +745,8 @@ static const int16_t huff_nodes_first_band_alpha_coarse[16][2] = { -2, -16 }, { -1, -17 } }; -#endif +#endif /* Alpha Fine Huffman table df */ static const int16_t huff_nodes_alpha_1D_DF[64][2] = { @@ -853,8 +853,8 @@ static const int16_t huff_nodes_alpha_1D_DF_coarse[32][2] = { -3, -4 }, { -2, -32 } }; -#endif +#endif /* Alpha Fine Huffman table dt */ static const int16_t huff_nodes_alpha_1D_DT[64][2] = { @@ -961,8 +961,8 @@ static const int16_t huff_nodes_alpha_1D_DT_coarse[32][2] = { -4, -30 }, { -2, -32 } }; -#endif +#endif /* Beta Fine Huffman table df0 */ static const int16_t huff_nodes_first_band_beta[8][2] = { @@ -975,8 +975,8 @@ static const int16_t huff_nodes_first_band_beta_coarse[4][2] = { { -1, 1 }, { -2, 2 }, { -3, 3 }, { -4, -5 } }; -#endif +#endif /* Beta Fine Huffman table df */ static const int16_t huff_nodes_beta_1D_DF[16][2] = { @@ -989,8 +989,8 @@ static const int16_t huff_nodes_beta_1D_DF_coarse[8][2] = { { -5, 1 }, { -6, 2 }, { -4, 3 }, { -3, 4 }, { -7, 5 }, { -2, 6 }, { -8, 7 }, { -1, -9 } }; -#endif +#endif /* Beta Fine Huffman table dt */ static const int16_t huff_nodes_beta_1D_DT[16][2] = { @@ -1011,11 +1011,13 @@ const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_df0 = huff_nodes_first_band_alpha, huff_nodes_first_band_beta }; + const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_df = { huff_nodes_alpha_1D_DF, huff_nodes_beta_1D_DF }; + const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_dt = { huff_nodes_alpha_1D_DT, diff --git a/lib_enc/ivas_rom_enc.c b/lib_enc/ivas_rom_enc.c index 4a5329bcec..2bb4efdd83 100644 --- a/lib_enc/ivas_rom_enc.c +++ b/lib_enc/ivas_rom_enc.c @@ -722,7 +722,12 @@ const float Stereo_dmx_wnd_coef_48k[L_FRAME48k] = { 0.0310834963f, 0.0278123822f, 0.0245409720f, 0.0212692991f, 0.0179976355f, 0.0147257810f, 0.0114535289f, 0.00818115473f, 0.00490869302f, 0.00163617858f }; + #ifdef FIX_891_PARAMUPMIX_CLEANUP +/*----------------------------------------------------------------------------------* + * ParamUpmix ROM tables + *----------------------------------------------------------------------------------*/ + const HUFF_TABLE huff_alpha_table = { { /* df0 */ -- GitLab