static inline int decode_ac_coeffs(GetBitContext *gb, int16_t *out,

                                   int blocks_per_slice,

                                   int plane_size_factor,

                                   const uint8_t *scan)

{

    int pos, block_mask, run, level, sign, run_cb_index, lev_cb_index;

    int max_coeffs, bits_left;



    /* set initial prediction values */

    run   = 4;

    level = 2;



    max_coeffs = blocks_per_slice << 6;

    block_mask = blocks_per_slice - 1;



    for (pos = blocks_per_slice - 1; pos < max_coeffs;) {

        run_cb_index = ff_prores_run_to_cb_index[FFMIN(run, 15)];

        lev_cb_index = ff_prores_lev_to_cb_index[FFMIN(level, 9)];



        bits_left = get_bits_left(gb);

        if (bits_left <= 0 || (bits_left <= 8 && !show_bits(gb, bits_left)))

            return 0;



        run = decode_vlc_codeword(gb, ff_prores_ac_codebook[run_cb_index]);

        if (run < 0)

            return AVERROR_INVALIDDATA;



        bits_left = get_bits_left(gb);

        if (bits_left <= 0 || (bits_left <= 8 && !show_bits(gb, bits_left)))

            return AVERROR_INVALIDDATA;



        level = decode_vlc_codeword(gb, ff_prores_ac_codebook[lev_cb_index]) + 1;

        if (level < 0)

            return AVERROR_INVALIDDATA;



        pos += run + 1;

        if (pos >= max_coeffs)

            break;



        sign = get_sbits(gb, 1);

        out[((pos & block_mask) << 6) + scan[pos >> plane_size_factor]] =

            (level ^ sign) - sign;

    }



    return 0;

}

static inline int decode_ac_coeffs(GetBitContext *gb, int16_t *out,

                                   int blocks_per_slice,

                                   int plane_size_factor,

                                   const uint8_t *scan)

{

    int pos, block_mask, run, level, sign, run_cb_index, lev_cb_index;

    int max_coeffs, bits_left;



    

    run   = 4;

    level = 2;



    max_coeffs = blocks_per_slice << 6;

    block_mask = blocks_per_slice - 1;



    for (pos = blocks_per_slice - 1; pos < max_coeffs;) {

        run_cb_index = ff_prores_run_to_cb_index[FFMIN(run, 15)];

        lev_cb_index = ff_prores_lev_to_cb_index[FFMIN(level, 9)];



        bits_left = get_bits_left(gb);

        if (bits_left <= 0 || (bits_left <= 8 && !show_bits(gb, bits_left)))

            return 0;



        run = decode_vlc_codeword(gb, ff_prores_ac_codebook[run_cb_index]);

        if (run < 0)

            return AVERROR_INVALIDDATA;



        bits_left = get_bits_left(gb);

        if (bits_left <= 0 || (bits_left <= 8 && !show_bits(gb, bits_left)))

            return AVERROR_INVALIDDATA;



        level = decode_vlc_codeword(gb, ff_prores_ac_codebook[lev_cb_index]) + 1;

        if (level < 0)

            return AVERROR_INVALIDDATA;



        pos += run + 1;

        if (pos >= max_coeffs)

            break;



        sign = get_sbits(gb, 1);

        out[((pos & block_mask) << 6) + scan[pos >> plane_size_factor]] =

            (level ^ sign) - sign;

    }



    return 0;

}

static inline int FUNC_0(GetBitContext *VAR_0, int16_t *VAR_1,

                                   int VAR_2,

                                   int VAR_3,

                                   const uint8_t *VAR_4)

{

    int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;

    int VAR_12, VAR_13;



    

    VAR_7   = 4;

    VAR_8 = 2;



    VAR_12 = VAR_2 << 6;

    VAR_6 = VAR_2 - 1;



    for (VAR_5 = VAR_2 - 1; VAR_5 < VAR_12;) {

        VAR_10 = ff_prores_run_to_cb_index[FFMIN(VAR_7, 15)];

        VAR_11 = ff_prores_lev_to_cb_index[FFMIN(VAR_8, 9)];



        VAR_13 = get_bits_left(VAR_0);

        if (VAR_13 <= 0 || (VAR_13 <= 8 && !show_bits(VAR_0, VAR_13)))

            return 0;



        VAR_7 = decode_vlc_codeword(VAR_0, ff_prores_ac_codebook[VAR_10]);

        if (VAR_7 < 0)

            return AVERROR_INVALIDDATA;



        VAR_13 = get_bits_left(VAR_0);

        if (VAR_13 <= 0 || (VAR_13 <= 8 && !show_bits(VAR_0, VAR_13)))

            return AVERROR_INVALIDDATA;



        VAR_8 = decode_vlc_codeword(VAR_0, ff_prores_ac_codebook[VAR_11]) + 1;

        if (VAR_8 < 0)

            return AVERROR_INVALIDDATA;



        VAR_5 += VAR_7 + 1;

        if (VAR_5 >= VAR_12)

            break;



        VAR_9 = get_sbits(VAR_0, 1);

        VAR_1[((VAR_5 & VAR_6) << 6) + VAR_4[VAR_5 >> VAR_3]] =

            (VAR_8 ^ VAR_9) - VAR_9;

    }



    return 0;

}

static inline int FUNC_0(GetBitContext *VAR_0, int16_t *VAR_1,
int VAR_2,
int VAR_3,
const uint8_t *VAR_4)
{ int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11; int VAR_12, VAR_13; VAR_7   = 4; VAR_8 = 2; VAR_12 = VAR_2 << 6; VAR_6 = VAR_2 - 1; for (VAR_5 = VAR_2 - 1; VAR_5 < VAR_12;) { VAR_10 = ff_prores_run_to_cb_index[FFMIN(VAR_7, 15)]; VAR_11 = ff_prores_lev_to_cb_index[FFMIN(VAR_8, 9)]; VAR_13 = get_bits_left(VAR_0); if (VAR_13 <= 0 || (VAR_13 <= 8 && !show_bits(VAR_0, VAR_13)))
return 0; VAR_7 = decode_vlc_codeword(VAR_0, ff_prores_ac_codebook[VAR_10]); if (VAR_7 < 0)
return AVERROR_INVALIDDATA; VAR_13 = get_bits_left(VAR_0); if (VAR_13 <= 0 || (VAR_13 <= 8 && !show_bits(VAR_0, VAR_13)))
return AVERROR_INVALIDDATA; VAR_8 = decode_vlc_codeword(VAR_0, ff_prores_ac_codebook[VAR_11]) + 1; if (VAR_8 < 0)
return AVERROR_INVALIDDATA; VAR_5 += VAR_7 + 1; if (VAR_5 >= VAR_12)
break; VAR_9 = get_sbits(VAR_0, 1); VAR_1[((VAR_5 & VAR_6) << 6) + VAR_4[VAR_5 >> VAR_3]] =
(VAR_8 ^ VAR_9) - VAR_9; } return 0; }