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

                              unsigned int channel, unsigned int filter)

{

    FilterParams *fp = &m->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.

    assert(filter < 2);



    m->filter_changed[channel][filter]++;



    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 -1;

    }

    fp->order = order;



    if (order > 0) {

        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 -1;

        }

        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 -1;

        }



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

            fp->coeff[i] = get_sbits(gbp, coeff_bits) << 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 -1;

            }



            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] = get_sbits(gbp, state_bits) << state_shift;

        }

    }



    return 0;

}

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

                              unsigned int channel, unsigned int filter)

{

    FilterParams *fp = &m->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;



    

    assert(filter < 2);



    m->filter_changed[channel][filter]++;



    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 -1;

    }

    fp->order = order;



    if (order > 0) {

        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 -1;

        }

        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 -1;

        }



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

            fp->coeff[i] = get_sbits(gbp, coeff_bits) << 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 -1;

            }



            state_bits  = get_bits(gbp, 4);

            state_shift = get_bits(gbp, 4);



            



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

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

        }

    }



    return 0;

}

static int FUNC_0(MLPDecodeContext *VAR_0, GetBitContext *VAR_1,

                              unsigned int VAR_2, unsigned int VAR_3)

{

    FilterParams *fp = &VAR_0->channel_params[VAR_2].filter_params[VAR_3];

    const int VAR_4 = VAR_3 ? MAX_IIR_ORDER : MAX_FIR_ORDER;

    const char VAR_5 = VAR_3 ? 'I' : 'F';

    int VAR_6, VAR_7;



    

    assert(VAR_3 < 2);



    VAR_0->filter_changed[VAR_2][VAR_3]++;



    VAR_7 = get_bits(VAR_1, 4);

    if (VAR_7 > VAR_4) {

        av_log(VAR_0->avctx, AV_LOG_ERROR,

               "%cIR VAR_3 VAR_7 %d is greater than maximum %d.\n",

               VAR_5, VAR_7, VAR_4);

        return -1;

    }

    fp->VAR_7 = VAR_7;



    if (VAR_7 > 0) {

        int VAR_8, VAR_9;



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



        VAR_8  = get_bits(VAR_1, 5);

        VAR_9 = get_bits(VAR_1, 3);

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

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "%cIR VAR_3 VAR_8 must be between 1 and 16.\n",

                   VAR_5);

            return -1;

        }

        if (VAR_8 + VAR_9 > 16) {

            av_log(VAR_0->avctx, AV_LOG_ERROR,

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

                   VAR_5);

            return -1;

        }



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

            fp->coeff[VAR_6] = get_sbits(VAR_1, VAR_8) << VAR_9;



        if (get_bits1(VAR_1)) {

            int VAR_10, VAR_11;



            if (VAR_3 == FIR) {

                av_log(VAR_0->avctx, AV_LOG_ERROR,

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

                return -1;

            }



            VAR_10  = get_bits(VAR_1, 4);

            VAR_11 = get_bits(VAR_1, 4);



            



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

                fp->state[VAR_6] = get_sbits(VAR_1, VAR_10) << VAR_11;

        }

    }



    return 0;

}

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