Commit bbdf1492 authored by PLAINSI's avatar PLAINSI
Browse files

Merge branch '891-paramupmix-cleanup' into 'main'

Resolve "ParamUpmix Cleanup"

See merge request !1196
parents 39336ffe 2d866e70
Loading
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -1335,34 +1335,49 @@ 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,
    BETA
} PAR_TYPE;

#ifndef FIX_891_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_891_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
+68 −2
Original line number Diff line number Diff line
@@ -2518,7 +2518,7 @@ 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
 *----------------------------------------------------------------------------------*/
@@ -2528,7 +2528,7 @@ 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
@@ -6439,6 +6439,71 @@ const int16_t sns_1st_means_32k[2][16] =
 * MC ParamUpmix 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
};
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 +6602,6 @@ const ACPL_QUANT_TABLE ivas_mc_paramupmix_beta_quant_table[2][9] =
        }
    }
};
#endif
/* clang-format on */
+8 −2
Original line number Diff line number Diff line
@@ -259,12 +259,12 @@ 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
 *----------------------------------------------------------------------------------*/

extern const int16_t ivas_param_upmx_mx_qmap[2][33];

#endif

/*----------------------------------------------------------------------------------*
 * MASA ROM tables
@@ -453,9 +453,15 @@ extern const int16_t sns_1st_means_32k[2][16];
/*----------------------------------------------------------------------*
 * MC ParamUpmix ROM tables
 *-----------------------------------------------------------------------*/
#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
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

lib_com/options.h

100644 → 100755
+3 −3
Original line number Diff line number Diff line
@@ -153,16 +153,16 @@
#define FIX_643_PCA_OPTION                              /* VA: issue 643: rename PCA bypass command-line option */
#define FIX_902_HACK_IN_CORECODER                       /* VA: issue 902: remove a hack in ivas_core_dec() */
#define FIX_881_REMOVE_LFE_ADDITION_IN_ISM              /* VA: issue 881: remove LFE addition in ISM format */

/* #################### End BE switches ################################## */
#define FIX_899_VARIABLE_SPEED_DECODING                 /* FhG: Fix variable speed decoding                                    */
#define FIX_887_ARRAY_SIZE_DFT_MDCT_STEREO              /* VA: Fix the definition of buffers/arrays in DFT and MDCT stereo to satisfy gcc v 11.4.0 */
#define FIX_891_PARAMUPMIX_CLEANUP                      /* Dlb: issue 891: remove unneeded code from ParamUpmix */

/* #################### End BE switches ################################## */

/* #################### Start NON-BE switches ############################ */
/* any switch which is non-be wrt selection floating point code */
/* all switches in this category should start with "NONBE_" */


#define NONBE_FIX_788_SBA_DTX_BR_SWITCHING                    /* VA: issue 787: fix Msan error in SBA BR switching with dtx in FOA encoding */
#define NONBE_FIX_856_TCX_LTP_SYNTH_FILTER                    /* FhG: issue 856: correct filtering length for tcx-ltp synth filtering*/
#define NONBE_UNIFIED_DECODING_PATHS                          /* FhG: unify decoding paths   */
+113 −3
Original line number Diff line number Diff line
@@ -80,6 +80,15 @@ 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, const 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,6 +96,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


/*-------------------------------------------------------------------------
@@ -141,11 +151,17 @@ void ivas_mc_paramupmix_dec_read_BS(

        for ( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ )
        {
#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] );
#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,16 +1350,37 @@ static int16_t huff_read(

static void huffman_decode(
    Decoder_State *st,
#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,
#else
    const PAR_TYPE parType,
#endif
    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 )
    {
        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 )
    {
@@ -1358,7 +1395,11 @@ static void huffman_decode(
    }

    offset = nquant - 1; /* range of df/dt [-(nquant - 1), nquant - 1] */
#endif

#ifdef FIX_891_PARAMUPMIX_CLEANUP
    st->next_bit_pos++;
#else
    if ( bNoDt )
    {
        bdt = 0;
@@ -1368,7 +1409,39 @@ static void huffman_decode(
        bdt = st->bit_stream[st->next_bit_pos];
        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 )
@@ -1421,19 +1494,31 @@ static void huffman_decode(
            vq[iv] = huff_read( st, huff_node_table ) + vq[iv - 1] - offset;
        }
    }
#endif

    return;
}


static void dequant_alpha(
#ifndef FIX_891_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_891_PARAMUPMIX_CLEANUP
    const ACPL_QUANT_TABLE *quant_table = &ivas_mc_paramupmix_alpha_quant_table;

    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 +1530,17 @@ static void dequant_alpha(
    {
        v[iv] = quant_table->data[vq[iv]];
    }

#endif
    return;
}


static void dequant_beta(
#ifndef FIX_891_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 +1548,14 @@ static void dequant_beta(
    int16_t iv;
    const ACPL_QUANT_TABLE *quant_table;

#ifdef FIX_891_PARAMUPMIX_CLEANUP
    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 +1566,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 +1574,38 @@ static void dequant_beta(
static void get_ec_data(
    Decoder_State *st,
    const PAR_TYPE parType,
#ifndef FIX_891_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_891_PARAMUPMIX_CLEANUP
    huffman_decode( st, parType, parQ );
#else
    huffman_decode( st, nParBand, parBandStart, parType, quant_type, 0, parQ );
#endif

    if ( parType == ALPHA )
    {
#ifdef FIX_891_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_891_PARAMUPMIX_CLEANUP
        dequant_beta( alphaQEnv, parQ, ab );
#else
        dequant_beta( nParBand, parBandStart, quant_type, alphaQEnv, parQ, ab );
#endif
    }

    return;
Loading