Commit c26005fe authored by PLAINSI's avatar PLAINSI
Browse files

Cleanup

parent 2ad7a310
Loading
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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
+67 −3
Original line number Diff line number Diff line
@@ -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 */
+9 −2
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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 ################################## */

+128 −4
Original line number Diff line number Diff line
@@ -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;
Loading