static int decode_coeffs(WMAProDecodeCtx *s, int c)

{

    /* Integers 0..15 as single-precision floats.  The table saves a

       costly int to float conversion, and storing the values as

       integers allows fast sign-flipping. */

    static const int fval_tab[16] = {

        0x00000000, 0x3f800000, 0x40000000, 0x40400000,

        0x40800000, 0x40a00000, 0x40c00000, 0x40e00000,

        0x41000000, 0x41100000, 0x41200000, 0x41300000,

        0x41400000, 0x41500000, 0x41600000, 0x41700000,

    };

    int vlctable;

    VLC* vlc;

    WMAProChannelCtx* ci = &s->channel[c];

    int rl_mode = 0;

    int cur_coeff = 0;

    int num_zeros = 0;

    const uint16_t* run;

    const float* level;



    av_dlog(s->avctx, "decode coefficients for channel %i\n", c);



    vlctable = get_bits1(&s->gb);

    vlc = &coef_vlc[vlctable];



    if (vlctable) {

        run = coef1_run;

        level = coef1_level;

    } else {

        run = coef0_run;

        level = coef0_level;

    }



    /** decode vector coefficients (consumes up to 167 bits per iteration for

      4 vector coded large values) */

    while ((s->transmit_num_vec_coeffs || !rl_mode) &&

           (cur_coeff + 3 < ci->num_vec_coeffs)) {

        int vals[4];

        int i;

        unsigned int idx;



        idx = get_vlc2(&s->gb, vec4_vlc.table, VLCBITS, VEC4MAXDEPTH);



        if (idx == HUFF_VEC4_SIZE - 1) {

            for (i = 0; i < 4; i += 2) {

                idx = get_vlc2(&s->gb, vec2_vlc.table, VLCBITS, VEC2MAXDEPTH);

                if (idx == HUFF_VEC2_SIZE - 1) {

                    int v0, v1;

                    v0 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);

                    if (v0 == HUFF_VEC1_SIZE - 1)

                        v0 += ff_wma_get_large_val(&s->gb);

                    v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);

                    if (v1 == HUFF_VEC1_SIZE - 1)

                        v1 += ff_wma_get_large_val(&s->gb);

                    ((float*)vals)[i  ] = v0;

                    ((float*)vals)[i+1] = v1;

                } else {

                    vals[i]   = fval_tab[symbol_to_vec2[idx] >> 4 ];

                    vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF];

                }

            }

        } else {

            vals[0] = fval_tab[ symbol_to_vec4[idx] >> 12      ];

            vals[1] = fval_tab[(symbol_to_vec4[idx] >> 8) & 0xF];

            vals[2] = fval_tab[(symbol_to_vec4[idx] >> 4) & 0xF];

            vals[3] = fval_tab[ symbol_to_vec4[idx]       & 0xF];

        }



        /** decode sign */

        for (i = 0; i < 4; i++) {

            if (vals[i]) {

                int sign = get_bits1(&s->gb) - 1;

                *(uint32_t*)&ci->coeffs[cur_coeff] = vals[i] ^ sign<<31;

                num_zeros = 0;

            } else {

                ci->coeffs[cur_coeff] = 0;

                /** switch to run level mode when subframe_len / 128 zeros

                    were found in a row */

                rl_mode |= (++num_zeros > s->subframe_len >> 8);

            }

            ++cur_coeff;

        }

    }



    /** decode run level coded coefficients */

    if (cur_coeff < s->subframe_len) {

        memset(&ci->coeffs[cur_coeff], 0,

               sizeof(*ci->coeffs) * (s->subframe_len - cur_coeff));

        if (ff_wma_run_level_decode(s->avctx, &s->gb, vlc,

                                    level, run, 1, ci->coeffs,

                                    cur_coeff, s->subframe_len,

                                    s->subframe_len, s->esc_len, 0))

            return AVERROR_INVALIDDATA;

    }



    return 0;

}

static int decode_coeffs(WMAProDecodeCtx *s, int c)

{

    





    static const int fval_tab[16] = {

        0x00000000, 0x3f800000, 0x40000000, 0x40400000,

        0x40800000, 0x40a00000, 0x40c00000, 0x40e00000,

        0x41000000, 0x41100000, 0x41200000, 0x41300000,

        0x41400000, 0x41500000, 0x41600000, 0x41700000,

    };

    int vlctable;

    VLC* vlc;

    WMAProChannelCtx* ci = &s->channel[c];

    int rl_mode = 0;

    int cur_coeff = 0;

    int num_zeros = 0;

    const uint16_t* run;

    const float* level;



    av_dlog(s->avctx, "decode coefficients for channel %i\n", c);



    vlctable = get_bits1(&s->gb);

    vlc = &coef_vlc[vlctable];



    if (vlctable) {

        run = coef1_run;

        level = coef1_level;

    } else {

        run = coef0_run;

        level = coef0_level;

    }



    



    while ((s->transmit_num_vec_coeffs || !rl_mode) &&

           (cur_coeff + 3 < ci->num_vec_coeffs)) {

        int vals[4];

        int i;

        unsigned int idx;



        idx = get_vlc2(&s->gb, vec4_vlc.table, VLCBITS, VEC4MAXDEPTH);



        if (idx == HUFF_VEC4_SIZE - 1) {

            for (i = 0; i < 4; i += 2) {

                idx = get_vlc2(&s->gb, vec2_vlc.table, VLCBITS, VEC2MAXDEPTH);

                if (idx == HUFF_VEC2_SIZE - 1) {

                    int v0, v1;

                    v0 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);

                    if (v0 == HUFF_VEC1_SIZE - 1)

                        v0 += ff_wma_get_large_val(&s->gb);

                    v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);

                    if (v1 == HUFF_VEC1_SIZE - 1)

                        v1 += ff_wma_get_large_val(&s->gb);

                    ((float*)vals)[i  ] = v0;

                    ((float*)vals)[i+1] = v1;

                } else {

                    vals[i]   = fval_tab[symbol_to_vec2[idx] >> 4 ];

                    vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF];

                }

            }

        } else {

            vals[0] = fval_tab[ symbol_to_vec4[idx] >> 12      ];

            vals[1] = fval_tab[(symbol_to_vec4[idx] >> 8) & 0xF];

            vals[2] = fval_tab[(symbol_to_vec4[idx] >> 4) & 0xF];

            vals[3] = fval_tab[ symbol_to_vec4[idx]       & 0xF];

        }



        

        for (i = 0; i < 4; i++) {

            if (vals[i]) {

                int sign = get_bits1(&s->gb) - 1;

                *(uint32_t*)&ci->coeffs[cur_coeff] = vals[i] ^ sign<<31;

                num_zeros = 0;

            } else {

                ci->coeffs[cur_coeff] = 0;

                



                rl_mode |= (++num_zeros > s->subframe_len >> 8);

            }

            ++cur_coeff;

        }

    }



    

    if (cur_coeff < s->subframe_len) {

        memset(&ci->coeffs[cur_coeff], 0,

               sizeof(*ci->coeffs) * (s->subframe_len - cur_coeff));

        if (ff_wma_run_level_decode(s->avctx, &s->gb, vlc,

                                    level, run, 1, ci->coeffs,

                                    cur_coeff, s->subframe_len,

                                    s->subframe_len, s->esc_len, 0))

            return AVERROR_INVALIDDATA;

    }



    return 0;

}

static int FUNC_0(WMAProDecodeCtx *VAR_0, int VAR_1)

{

    





    static const int VAR_2[16] = {

        0x00000000, 0x3f800000, 0x40000000, 0x40400000,

        0x40800000, 0x40a00000, 0x40c00000, 0x40e00000,

        0x41000000, 0x41100000, 0x41200000, 0x41300000,

        0x41400000, 0x41500000, 0x41600000, 0x41700000,

    };

    int VAR_3;

    VLC* vlc;

    WMAProChannelCtx* ci = &VAR_0->channel[VAR_1];

    int VAR_4 = 0;

    int VAR_5 = 0;

    int VAR_6 = 0;

    const uint16_t* VAR_7;

    const float* VAR_8;



    av_dlog(VAR_0->avctx, "decode coefficients for channel %VAR_10\n", VAR_1);



    VAR_3 = get_bits1(&VAR_0->gb);

    vlc = &coef_vlc[VAR_3];



    if (VAR_3) {

        VAR_7 = coef1_run;

        VAR_8 = coef1_level;

    } else {

        VAR_7 = coef0_run;

        VAR_8 = coef0_level;

    }



    



    while ((VAR_0->transmit_num_vec_coeffs || !VAR_4) &&

           (VAR_5 + 3 < ci->num_vec_coeffs)) {

        int VAR_9[4];

        int VAR_10;

        unsigned int VAR_11;



        VAR_11 = get_vlc2(&VAR_0->gb, vec4_vlc.table, VLCBITS, VEC4MAXDEPTH);



        if (VAR_11 == HUFF_VEC4_SIZE - 1) {

            for (VAR_10 = 0; VAR_10 < 4; VAR_10 += 2) {

                VAR_11 = get_vlc2(&VAR_0->gb, vec2_vlc.table, VLCBITS, VEC2MAXDEPTH);

                if (VAR_11 == HUFF_VEC2_SIZE - 1) {

                    int VAR_12, VAR_13;

                    VAR_12 = get_vlc2(&VAR_0->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);

                    if (VAR_12 == HUFF_VEC1_SIZE - 1)

                        VAR_12 += ff_wma_get_large_val(&VAR_0->gb);

                    VAR_13 = get_vlc2(&VAR_0->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);

                    if (VAR_13 == HUFF_VEC1_SIZE - 1)

                        VAR_13 += ff_wma_get_large_val(&VAR_0->gb);

                    ((float*)VAR_9)[VAR_10  ] = VAR_12;

                    ((float*)VAR_9)[VAR_10+1] = VAR_13;

                } else {

                    VAR_9[VAR_10]   = VAR_2[symbol_to_vec2[VAR_11] >> 4 ];

                    VAR_9[VAR_10+1] = VAR_2[symbol_to_vec2[VAR_11] & 0xF];

                }

            }

        } else {

            VAR_9[0] = VAR_2[ symbol_to_vec4[VAR_11] >> 12      ];

            VAR_9[1] = VAR_2[(symbol_to_vec4[VAR_11] >> 8) & 0xF];

            VAR_9[2] = VAR_2[(symbol_to_vec4[VAR_11] >> 4) & 0xF];

            VAR_9[3] = VAR_2[ symbol_to_vec4[VAR_11]       & 0xF];

        }



        

        for (VAR_10 = 0; VAR_10 < 4; VAR_10++) {

            if (VAR_9[VAR_10]) {

                int VAR_14 = get_bits1(&VAR_0->gb) - 1;

                *(uint32_t*)&ci->coeffs[VAR_5] = VAR_9[VAR_10] ^ VAR_14<<31;

                VAR_6 = 0;

            } else {

                ci->coeffs[VAR_5] = 0;

                



                VAR_4 |= (++VAR_6 > VAR_0->subframe_len >> 8);

            }

            ++VAR_5;

        }

    }



    

    if (VAR_5 < VAR_0->subframe_len) {

        memset(&ci->coeffs[VAR_5], 0,

               sizeof(*ci->coeffs) * (VAR_0->subframe_len - VAR_5));

        if (ff_wma_run_level_decode(VAR_0->avctx, &VAR_0->gb, vlc,

                                    VAR_8, VAR_7, 1, ci->coeffs,

                                    VAR_5, VAR_0->subframe_len,

                                    VAR_0->subframe_len, VAR_0->esc_len, 0))

            return AVERROR_INVALIDDATA;

    }



    return 0;

}

static int FUNC_0(WMAProDecodeCtx *VAR_0, int VAR_1)
{ static const int VAR_2[16] = { 0x00000000, 0x3f800000, 0x40000000, 0x40400000,
0x40800000, 0x40a00000, 0x40c00000, 0x40e00000,
0x41000000, 0x41100000, 0x41200000, 0x41300000,
0x41400000, 0x41500000, 0x41600000, 0x41700000,
}; int VAR_3; VLC* vlc; WMAProChannelCtx* ci = &VAR_0->channel[VAR_1]; int VAR_4 = 0; int VAR_5 = 0; int VAR_6 = 0; const uint16_t* VAR_7; const float* VAR_8; av_dlog(VAR_0->avctx, "decode coefficients for channel %VAR_10\n", VAR_1); VAR_3 = get_bits1(&VAR_0->gb); vlc = &coef_vlc[VAR_3]; if (VAR_3) { VAR_7 = coef1_run; VAR_8 = coef1_level; } else { VAR_7 = coef0_run; VAR_8 = coef0_level; } while ((VAR_0->transmit_num_vec_coeffs || !VAR_4) &&
(VAR_5 + 3 < ci->num_vec_coeffs)) { int VAR_9[4]; int VAR_10; unsigned int VAR_11; VAR_11 = get_vlc2(&VAR_0->gb, vec4_vlc.table, VLCBITS, VEC4MAXDEPTH); if (VAR_11 == HUFF_VEC4_SIZE - 1) { for (VAR_10 = 0; VAR_10 < 4; VAR_10 += 2) { VAR_11 = get_vlc2(&VAR_0->gb, vec2_vlc.table, VLCBITS, VEC2MAXDEPTH); if (VAR_11 == HUFF_VEC2_SIZE - 1) { int VAR_12, VAR_13; VAR_12 = get_vlc2(&VAR_0->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); if (VAR_12 == HUFF_VEC1_SIZE - 1)
VAR_12 += ff_wma_get_large_val(&VAR_0->gb); VAR_13 = get_vlc2(&VAR_0->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); if (VAR_13 == HUFF_VEC1_SIZE - 1)
VAR_13 += ff_wma_get_large_val(&VAR_0->gb); ((float*)VAR_9)[VAR_10  ] = VAR_12; ((float*)VAR_9)[VAR_10+1] = VAR_13; } else { VAR_9[VAR_10]   = VAR_2[symbol_to_vec2[VAR_11] >> 4 ]; VAR_9[VAR_10+1] = VAR_2[symbol_to_vec2[VAR_11] & 0xF]; } } } else { VAR_9[0] = VAR_2[ symbol_to_vec4[VAR_11] >> 12      ]; VAR_9[1] = VAR_2[(symbol_to_vec4[VAR_11] >> 8) & 0xF]; VAR_9[2] = VAR_2[(symbol_to_vec4[VAR_11] >> 4) & 0xF]; VAR_9[3] = VAR_2[ symbol_to_vec4[VAR_11]       & 0xF]; } for (VAR_10 = 0; VAR_10 < 4; VAR_10++) { if (VAR_9[VAR_10]) { int VAR_14 = get_bits1(&VAR_0->gb) - 1; *(uint32_t*)&ci->coeffs[VAR_5] = VAR_9[VAR_10] ^ VAR_14<<31; VAR_6 = 0; } else { ci->coeffs[VAR_5] = 0; VAR_4 |= (++VAR_6 > VAR_0->subframe_len >> 8); } ++VAR_5; } } if (VAR_5 < VAR_0->subframe_len) { memset(&ci->coeffs[VAR_5], 0,
sizeof(*ci->coeffs) * (VAR_0->subframe_len - VAR_5)); if (ff_wma_run_level_decode(VAR_0->avctx, &VAR_0->gb, vlc,
VAR_8, VAR_7, 1, ci->coeffs,
VAR_5, VAR_0->subframe_len,
VAR_0->subframe_len, VAR_0->esc_len, 0))
return AVERROR_INVALIDDATA; } return 0; }