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

                              unsigned int substr, unsigned int channel,

                              unsigned int filter)

{

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

    FilterParams *fp = &s->channel_params[channel].filter_params[filter];

    const int max_order = filter ? MAX_IIR_ORDER : MAX_FIR_ORDER;

    const char fchar = filter ? 'I' : 'F';

    int i, order;



    // Filter is 0 for FIR, 1 for IIR.

    av_assert0(filter < 2);



    if (m->filter_changed[channel][filter]++ > 1) {

        av_log(m->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n");

        return AVERROR_INVALIDDATA;

    }



    order = get_bits(gbp, 4);

    if (order > max_order) {

        av_log(m->avctx, AV_LOG_ERROR,

               "%cIR filter order %d is greater than maximum %d.\n",

               fchar, order, max_order);

        return AVERROR_INVALIDDATA;

    }

    fp->order = order;



    if (order > 0) {

        int32_t *fcoeff = s->channel_params[channel].coeff[filter];

        int coeff_bits, coeff_shift;



        fp->shift = get_bits(gbp, 4);



        coeff_bits  = get_bits(gbp, 5);

        coeff_shift = get_bits(gbp, 3);

        if (coeff_bits < 1 || coeff_bits > 16) {

            av_log(m->avctx, AV_LOG_ERROR,

                   "%cIR filter coeff_bits must be between 1 and 16.\n",

                   fchar);

            return AVERROR_INVALIDDATA;

        }

        if (coeff_bits + coeff_shift > 16) {

            av_log(m->avctx, AV_LOG_ERROR,

                   "Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n",

                   fchar);

            return AVERROR_INVALIDDATA;

        }



        for (i = 0; i < order; i++)

            fcoeff[i] = get_sbits(gbp, coeff_bits) * (1 << coeff_shift);



        if (get_bits1(gbp)) {

            int state_bits, state_shift;



            if (filter == FIR) {

                av_log(m->avctx, AV_LOG_ERROR,

                       "FIR filter has state data specified.\n");

                return AVERROR_INVALIDDATA;

            }



            state_bits  = get_bits(gbp, 4);

            state_shift = get_bits(gbp, 4);



            /* TODO: Check validity of state data. */



            for (i = 0; i < order; i++)

                fp->state[i] = state_bits ? get_sbits(gbp, state_bits) << state_shift : 0;

        }

    }



    return 0;

}

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

                              unsigned int substr, unsigned int channel,

                              unsigned int filter)

{

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

    FilterParams *fp = &s->channel_params[channel].filter_params[filter];

    const int max_order = filter ? MAX_IIR_ORDER : MAX_FIR_ORDER;

    const char fchar = filter ? 'I' : 'F';

    int i, order;



    

    av_assert0(filter < 2);



    if (m->filter_changed[channel][filter]++ > 1) {

        av_log(m->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n");

        return AVERROR_INVALIDDATA;

    }



    order = get_bits(gbp, 4);

    if (order > max_order) {

        av_log(m->avctx, AV_LOG_ERROR,

               "%cIR filter order %d is greater than maximum %d.\n",

               fchar, order, max_order);

        return AVERROR_INVALIDDATA;

    }

    fp->order = order;



    if (order > 0) {

        int32_t *fcoeff = s->channel_params[channel].coeff[filter];

        int coeff_bits, coeff_shift;



        fp->shift = get_bits(gbp, 4);



        coeff_bits  = get_bits(gbp, 5);

        coeff_shift = get_bits(gbp, 3);

        if (coeff_bits < 1 || coeff_bits > 16) {

            av_log(m->avctx, AV_LOG_ERROR,

                   "%cIR filter coeff_bits must be between 1 and 16.\n",

                   fchar);

            return AVERROR_INVALIDDATA;

        }

        if (coeff_bits + coeff_shift > 16) {

            av_log(m->avctx, AV_LOG_ERROR,

                   "Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n",

                   fchar);

            return AVERROR_INVALIDDATA;

        }



        for (i = 0; i < order; i++)

            fcoeff[i] = get_sbits(gbp, coeff_bits) * (1 << coeff_shift);



        if (get_bits1(gbp)) {

            int state_bits, state_shift;



            if (filter == FIR) {

                av_log(m->avctx, AV_LOG_ERROR,

                       "FIR filter has state data specified.\n");

                return AVERROR_INVALIDDATA;

            }



            state_bits  = get_bits(gbp, 4);

            state_shift = get_bits(gbp, 4);



            



            for (i = 0; i < order; i++)

                fp->state[i] = state_bits ? get_sbits(gbp, state_bits) << state_shift : 0;

        }

    }



    return 0;

}

                fp->state[i] = state_bits ? get_sbits(gbp, state_bits) << state_shift : 0;
static int FUNC_0(MLPDecodeContext *VAR_0, GetBitContext *VAR_1,

                              unsigned int VAR_2, unsigned int VAR_3,

                              unsigned int VAR_4)

{

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

    FilterParams *fp = &s->channel_params[VAR_3].filter_params[VAR_4];

    const int VAR_5 = VAR_4 ? MAX_IIR_ORDER : MAX_FIR_ORDER;

    const char VAR_6 = VAR_4 ? 'I' : 'F';

    int VAR_7, VAR_8;



    

    av_assert0(VAR_4 < 2);



    if (VAR_0->filter_changed[VAR_3][VAR_4]++ > 1) {

        av_log(VAR_0->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n");

        return AVERROR_INVALIDDATA;

    }



    VAR_8 = get_bits(VAR_1, 4);

    if (VAR_8 > VAR_5) {

        av_log(VAR_0->avctx, AV_LOG_ERROR,

               "%cIR VAR_4 VAR_8 %d is greater than maximum %d.\n",

               VAR_6, VAR_8, VAR_5);

        return AVERROR_INVALIDDATA;

    }

    fp->VAR_8 = VAR_8;



    if (VAR_8 > 0) {

        int32_t *fcoeff = s->channel_params[VAR_3].coeff[VAR_4];

        int VAR_9, VAR_10;



        fp->shift = get_bits(VAR_1, 4);



        VAR_9  = get_bits(VAR_1, 5);

        VAR_10 = get_bits(VAR_1, 3);

        if (VAR_9 < 1 || VAR_9 > 16) {

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "%cIR VAR_4 VAR_9 must be between 1 and 16.\n",

                   VAR_6);

            return AVERROR_INVALIDDATA;

        }

        if (VAR_9 + VAR_10 > 16) {

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "Sum of VAR_9 and VAR_10 for %cIR VAR_4 must be 16 or less.\n",

                   VAR_6);

            return AVERROR_INVALIDDATA;

        }



        for (VAR_7 = 0; VAR_7 < VAR_8; VAR_7++)

            fcoeff[VAR_7] = get_sbits(VAR_1, VAR_9) * (1 << VAR_10);



        if (get_bits1(VAR_1)) {

            int VAR_11, VAR_12;



            if (VAR_4 == FIR) {

                av_log(VAR_0->avctx, AV_LOG_ERROR,

                       "FIR VAR_4 has state data specified.\n");

                return AVERROR_INVALIDDATA;

            }



            VAR_11  = get_bits(VAR_1, 4);

            VAR_12 = get_bits(VAR_1, 4);



            



            for (VAR_7 = 0; VAR_7 < VAR_8; VAR_7++)

                fp->state[VAR_7] = VAR_11 ? get_sbits(VAR_1, VAR_11) << VAR_12 : 0;

        }

    }



    return 0;

}

static int FUNC_0(MLPDecodeContext *VAR_0, GetBitContext *VAR_1,
unsigned int VAR_2, unsigned int VAR_3,
unsigned int VAR_4)
{ SubStream *s = &VAR_0->substream[VAR_2]; FilterParams *fp = &s->channel_params[VAR_3].filter_params[VAR_4]; const int VAR_5 = VAR_4 ? MAX_IIR_ORDER : MAX_FIR_ORDER; const char VAR_6 = VAR_4 ? 'I' : 'F'; int VAR_7, VAR_8; av_assert0(VAR_4 < 2); if (VAR_0->filter_changed[VAR_3][VAR_4]++ > 1) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n"); return AVERROR_INVALIDDATA; } VAR_8 = get_bits(VAR_1, 4); if (VAR_8 > VAR_5) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"%cIR VAR_4 VAR_8 %d is greater than maximum %d.\n",
VAR_6, VAR_8, VAR_5); return AVERROR_INVALIDDATA; } fp->VAR_8 = VAR_8; if (VAR_8 > 0) { int32_t *fcoeff = s->channel_params[VAR_3].coeff[VAR_4]; int VAR_9, VAR_10; fp->shift = get_bits(VAR_1, 4); VAR_9  = get_bits(VAR_1, 5); VAR_10 = get_bits(VAR_1, 3); if (VAR_9 < 1 || VAR_9 > 16) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"%cIR VAR_4 VAR_9 must be between 1 and 16.\n",
VAR_6); return AVERROR_INVALIDDATA; } if (VAR_9 + VAR_10 > 16) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"Sum of VAR_9 and VAR_10 for %cIR VAR_4 must be 16 or less.\n",
VAR_6); return AVERROR_INVALIDDATA; } for (VAR_7 = 0; VAR_7 < VAR_8; VAR_7++) fcoeff[VAR_7] = get_sbits(VAR_1, VAR_9) * (1 << VAR_10); if (get_bits1(VAR_1)) { int VAR_11, VAR_12; if (VAR_4 == FIR) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"FIR VAR_4 has state data specified.\n"); return AVERROR_INVALIDDATA; } VAR_11  = get_bits(VAR_1, 4); VAR_12 = get_bits(VAR_1, 4); for (VAR_7 = 0; VAR_7 < VAR_8; VAR_7++) fp->state[VAR_7] = VAR_11 ? get_sbits(VAR_1, VAR_11) << VAR_12 : 0; } } return 0; }