static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp,

                                unsigned int substr)

{

    SubStream *s = &m->substream[substr];

    unsigned int ch;

    int ret;



    if (s->param_presence_flags & PARAM_PRESENCE)

        if (get_bits1(gbp))

            s->param_presence_flags = get_bits(gbp, 8);



    if (s->param_presence_flags & PARAM_BLOCKSIZE)

        if (get_bits1(gbp)) {

            s->blocksize = get_bits(gbp, 9);

            if (s->blocksize < 8 || s->blocksize > m->access_unit_size) {

                av_log(m->avctx, AV_LOG_ERROR, "Invalid blocksize.\n");

                s->blocksize = 0;

                return AVERROR_INVALIDDATA;

            }

        }



    if (s->param_presence_flags & PARAM_MATRIX)

        if (get_bits1(gbp))

            if ((ret = read_matrix_params(m, substr, gbp)) < 0)

                return ret;



    if (s->param_presence_flags & PARAM_OUTSHIFT)

        if (get_bits1(gbp)) {

            for (ch = 0; ch <= s->max_matrix_channel; ch++) {

                s->output_shift[ch] = get_sbits(gbp, 4);

                if (s->output_shift[ch] < 0) {

                    avpriv_request_sample(m->avctx, "Negative output_shift");

                    s->output_shift[ch] = 0;

                }

            }

            if (substr == m->max_decoded_substream)

                m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(s->ch_assign,

                                                                       s->output_shift,

                                                                       s->max_matrix_channel,

                                                                       m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);

        }



    if (s->param_presence_flags & PARAM_QUANTSTEP)

        if (get_bits1(gbp))

            for (ch = 0; ch <= s->max_channel; ch++) {

                ChannelParams *cp = &s->channel_params[ch];



                s->quant_step_size[ch] = get_bits(gbp, 4);



                cp->sign_huff_offset = calculate_sign_huff(m, substr, ch);

            }



    for (ch = s->min_channel; ch <= s->max_channel; ch++)

        if (get_bits1(gbp))

            if ((ret = read_channel_params(m, substr, gbp, ch)) < 0)

                return ret;



    return 0;

}

static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp,

                                unsigned int substr)

{

    SubStream *s = &m->substream[substr];

    unsigned int ch;

    int ret;



    if (s->param_presence_flags & PARAM_PRESENCE)

        if (get_bits1(gbp))

            s->param_presence_flags = get_bits(gbp, 8);



    if (s->param_presence_flags & PARAM_BLOCKSIZE)

        if (get_bits1(gbp)) {

            s->blocksize = get_bits(gbp, 9);

            if (s->blocksize < 8 || s->blocksize > m->access_unit_size) {

                av_log(m->avctx, AV_LOG_ERROR, "Invalid blocksize.\n");

                s->blocksize = 0;

                return AVERROR_INVALIDDATA;

            }

        }



    if (s->param_presence_flags & PARAM_MATRIX)

        if (get_bits1(gbp))

            if ((ret = read_matrix_params(m, substr, gbp)) < 0)

                return ret;



    if (s->param_presence_flags & PARAM_OUTSHIFT)

        if (get_bits1(gbp)) {

            for (ch = 0; ch <= s->max_matrix_channel; ch++) {

                s->output_shift[ch] = get_sbits(gbp, 4);

                if (s->output_shift[ch] < 0) {

                    avpriv_request_sample(m->avctx, "Negative output_shift");

                    s->output_shift[ch] = 0;

                }

            }

            if (substr == m->max_decoded_substream)

                m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(s->ch_assign,

                                                                       s->output_shift,

                                                                       s->max_matrix_channel,

                                                                       m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);

        }



    if (s->param_presence_flags & PARAM_QUANTSTEP)

        if (get_bits1(gbp))

            for (ch = 0; ch <= s->max_channel; ch++) {

                ChannelParams *cp = &s->channel_params[ch];



                s->quant_step_size[ch] = get_bits(gbp, 4);



                cp->sign_huff_offset = calculate_sign_huff(m, substr, ch);

            }



    for (ch = s->min_channel; ch <= s->max_channel; ch++)

        if (get_bits1(gbp))

            if ((ret = read_channel_params(m, substr, gbp, ch)) < 0)

                return ret;



    return 0;

}

    int ret;                 ChannelParams *cp = &s->channel_params[ch];                 cp->sign_huff_offset = calculate_sign_huff(m, substr, ch);         if (get_bits1(gbp))                 return ret;     return 0;
static int FUNC_0(MLPDecodeContext *VAR_0, GetBitContext *VAR_1,

                                unsigned int VAR_2)

{

    SubStream *s = &VAR_0->substream[VAR_2];

    unsigned int VAR_3;

    int VAR_4;



    if (s->param_presence_flags & PARAM_PRESENCE)

        if (get_bits1(VAR_1))

            s->param_presence_flags = get_bits(VAR_1, 8);



    if (s->param_presence_flags & PARAM_BLOCKSIZE)

        if (get_bits1(VAR_1)) {

            s->blocksize = get_bits(VAR_1, 9);

            if (s->blocksize < 8 || s->blocksize > VAR_0->access_unit_size) {

                av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid blocksize.\n");

                s->blocksize = 0;

                return AVERROR_INVALIDDATA;

            }

        }



    if (s->param_presence_flags & PARAM_MATRIX)

        if (get_bits1(VAR_1))

            if ((VAR_4 = read_matrix_params(VAR_0, VAR_2, VAR_1)) < 0)

                return VAR_4;



    if (s->param_presence_flags & PARAM_OUTSHIFT)

        if (get_bits1(VAR_1)) {

            for (VAR_3 = 0; VAR_3 <= s->max_matrix_channel; VAR_3++) {

                s->output_shift[VAR_3] = get_sbits(VAR_1, 4);

                if (s->output_shift[VAR_3] < 0) {

                    avpriv_request_sample(VAR_0->avctx, "Negative output_shift");

                    s->output_shift[VAR_3] = 0;

                }

            }

            if (VAR_2 == VAR_0->max_decoded_substream)

                VAR_0->dsp.mlp_pack_output = VAR_0->dsp.mlp_select_pack_output(s->ch_assign,

                                                                       s->output_shift,

                                                                       s->max_matrix_channel,

                                                                       VAR_0->avctx->sample_fmt == AV_SAMPLE_FMT_S32);

        }



    if (s->param_presence_flags & PARAM_QUANTSTEP)

        if (get_bits1(VAR_1))

            for (VAR_3 = 0; VAR_3 <= s->max_channel; VAR_3++) {

                ChannelParams *cp = &s->channel_params[VAR_3];



                s->quant_step_size[VAR_3] = get_bits(VAR_1, 4);



                cp->sign_huff_offset = calculate_sign_huff(VAR_0, VAR_2, VAR_3);

            }



    for (VAR_3 = s->min_channel; VAR_3 <= s->max_channel; VAR_3++)

        if (get_bits1(VAR_1))

            if ((VAR_4 = read_channel_params(VAR_0, VAR_2, VAR_1, VAR_3)) < 0)

                return VAR_4;



    return 0;

}

static int FUNC_0(MLPDecodeContext *VAR_0, GetBitContext *VAR_1,
unsigned int VAR_2)
{ SubStream *s = &VAR_0->substream[VAR_2]; unsigned int VAR_3; int VAR_4; if (s->param_presence_flags & PARAM_PRESENCE)
if (get_bits1(VAR_1))
s->param_presence_flags = get_bits(VAR_1, 8); if (s->param_presence_flags & PARAM_BLOCKSIZE)
if (get_bits1(VAR_1)) { s->blocksize = get_bits(VAR_1, 9); if (s->blocksize < 8 || s->blocksize > VAR_0->access_unit_size) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Invalid blocksize.\n"); s->blocksize = 0; return AVERROR_INVALIDDATA; } } if (s->param_presence_flags & PARAM_MATRIX)
if (get_bits1(VAR_1))
if ((VAR_4 = read_matrix_params(VAR_0, VAR_2, VAR_1)) < 0)
return VAR_4; if (s->param_presence_flags & PARAM_OUTSHIFT)
if (get_bits1(VAR_1)) { for (VAR_3 = 0; VAR_3 <= s->max_matrix_channel; VAR_3++) { s->output_shift[VAR_3] = get_sbits(VAR_1, 4); if (s->output_shift[VAR_3] < 0) { avpriv_request_sample(VAR_0->avctx, "Negative output_shift"); s->output_shift[VAR_3] = 0; } } if (VAR_2 == VAR_0->max_decoded_substream)
VAR_0->dsp.mlp_pack_output = VAR_0->dsp.mlp_select_pack_output(s->ch_assign,
s->output_shift,
s->max_matrix_channel,
VAR_0->avctx->sample_fmt == AV_SAMPLE_FMT_S32); } if (s->param_presence_flags & PARAM_QUANTSTEP)
if (get_bits1(VAR_1))
for (VAR_3 = 0; VAR_3 <= s->max_channel; VAR_3++) { ChannelParams *cp = &s->channel_params[VAR_3]; s->quant_step_size[VAR_3] = get_bits(VAR_1, 4); cp->sign_huff_offset = calculate_sign_huff(VAR_0, VAR_2, VAR_3); } for (VAR_3 = s->min_channel; VAR_3 <= s->max_channel; VAR_3++) if (get_bits1(VAR_1))
if ((VAR_4 = read_channel_params(VAR_0, VAR_2, VAR_1, VAR_3)) < 0)
return VAR_4; return 0; }