static int decode_block_progressive(MJpegDecodeContext *s, int16_t *block,

                                    uint8_t *last_nnz, int ac_index,

                                    uint16_t *quant_matrix,

                                    int ss, int se, int Al, int *EOBRUN)

{

    int code, i, j, level, val, run;



    if (*EOBRUN) {

        (*EOBRUN)--;

        return 0;

    }



    {

        OPEN_READER(re, &s->gb);

        for (i = ss; ; i++) {

            UPDATE_CACHE(re, &s->gb);

            GET_VLC(code, re, &s->gb, s->vlcs[2][ac_index].table, 9, 2);



            run = ((unsigned) code) >> 4;

            code &= 0xF;

            if (code) {

                i += run;

                if (code > MIN_CACHE_BITS - 16)

                    UPDATE_CACHE(re, &s->gb);



                {

                    int cache = GET_CACHE(re, &s->gb);

                    int sign  = (~cache) >> 31;

                    level     = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;

                }



                LAST_SKIP_BITS(re, &s->gb, code);



                if (i >= se) {

                    if (i == se) {

                        j = s->scantable.permutated[se];

                        block[j] = level * (quant_matrix[se] << Al);

                        break;

                    }

                    av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);

                    return AVERROR_INVALIDDATA;

                }

                j = s->scantable.permutated[i];

                block[j] = level * (quant_matrix[i] << Al);

            } else {

                if (run == 0xF) {// ZRL - skip 15 coefficients

                    i += 15;

                    if (i >= se) {

                        av_log(s->avctx, AV_LOG_ERROR, "ZRL overflow: %d\n", i);

                        return AVERROR_INVALIDDATA;

                    }

                } else {

                    val = (1 << run);

                    if (run) {

                        UPDATE_CACHE(re, &s->gb);

                        val += NEG_USR32(GET_CACHE(re, &s->gb), run);

                        LAST_SKIP_BITS(re, &s->gb, run);

                    }

                    *EOBRUN = val - 1;

                    break;

                }

            }

        }

        CLOSE_READER(re, &s->gb);

    }



    if (i > *last_nnz)

        *last_nnz = i;



    return 0;

}

static int decode_block_progressive(MJpegDecodeContext *s, int16_t *block,

                                    uint8_t *last_nnz, int ac_index,

                                    uint16_t *quant_matrix,

                                    int ss, int se, int Al, int *EOBRUN)

{

    int code, i, j, level, val, run;



    if (*EOBRUN) {

        (*EOBRUN)--;

        return 0;

    }



    {

        OPEN_READER(re, &s->gb);

        for (i = ss; ; i++) {

            UPDATE_CACHE(re, &s->gb);

            GET_VLC(code, re, &s->gb, s->vlcs[2][ac_index].table, 9, 2);



            run = ((unsigned) code) >> 4;

            code &= 0xF;

            if (code) {

                i += run;

                if (code > MIN_CACHE_BITS - 16)

                    UPDATE_CACHE(re, &s->gb);



                {

                    int cache = GET_CACHE(re, &s->gb);

                    int sign  = (~cache) >> 31;

                    level     = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;

                }



                LAST_SKIP_BITS(re, &s->gb, code);



                if (i >= se) {

                    if (i == se) {

                        j = s->scantable.permutated[se];

                        block[j] = level * (quant_matrix[se] << Al);

                        break;

                    }

                    av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);

                    return AVERROR_INVALIDDATA;

                }

                j = s->scantable.permutated[i];

                block[j] = level * (quant_matrix[i] << Al);

            } else {

                if (run == 0xF) {

                    i += 15;

                    if (i >= se) {

                        av_log(s->avctx, AV_LOG_ERROR, "ZRL overflow: %d\n", i);

                        return AVERROR_INVALIDDATA;

                    }

                } else {

                    val = (1 << run);

                    if (run) {

                        UPDATE_CACHE(re, &s->gb);

                        val += NEG_USR32(GET_CACHE(re, &s->gb), run);

                        LAST_SKIP_BITS(re, &s->gb, run);

                    }

                    *EOBRUN = val - 1;

                    break;

                }

            }

        }

        CLOSE_READER(re, &s->gb);

    }



    if (i > *last_nnz)

        *last_nnz = i;



    return 0;

}

    int code, i, j, level, val, run;
static int FUNC_0(MJpegDecodeContext *VAR_0, int16_t *VAR_1,

                                    uint8_t *VAR_2, int VAR_3,

                                    uint16_t *VAR_4,

                                    int VAR_5, int VAR_6, int VAR_7, int *VAR_8)

{

    int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14;



    if (*VAR_8) {

        (*VAR_8)--;

        return 0;

    }



    {

        OPEN_READER(re, &VAR_0->gb);

        for (VAR_10 = VAR_5; ; VAR_10++) {

            UPDATE_CACHE(re, &VAR_0->gb);

            GET_VLC(VAR_9, re, &VAR_0->gb, VAR_0->vlcs[2][VAR_3].table, 9, 2);



            VAR_14 = ((unsigned) VAR_9) >> 4;

            VAR_9 &= 0xF;

            if (VAR_9) {

                VAR_10 += VAR_14;

                if (VAR_9 > MIN_CACHE_BITS - 16)

                    UPDATE_CACHE(re, &VAR_0->gb);



                {

                    int VAR_15 = GET_CACHE(re, &VAR_0->gb);

                    int VAR_16  = (~VAR_15) >> 31;

                    VAR_12     = (NEG_USR32(VAR_16 ^ VAR_15,VAR_9) ^ VAR_16) - VAR_16;

                }



                LAST_SKIP_BITS(re, &VAR_0->gb, VAR_9);



                if (VAR_10 >= VAR_6) {

                    if (VAR_10 == VAR_6) {

                        VAR_11 = VAR_0->scantable.permutated[VAR_6];

                        VAR_1[VAR_11] = VAR_12 * (VAR_4[VAR_6] << VAR_7);

                        break;

                    }

                    av_log(VAR_0->avctx, AV_LOG_ERROR, "error count: %d\n", VAR_10);

                    return AVERROR_INVALIDDATA;

                }

                VAR_11 = VAR_0->scantable.permutated[VAR_10];

                VAR_1[VAR_11] = VAR_12 * (VAR_4[VAR_10] << VAR_7);

            } else {

                if (VAR_14 == 0xF) {

                    VAR_10 += 15;

                    if (VAR_10 >= VAR_6) {

                        av_log(VAR_0->avctx, AV_LOG_ERROR, "ZRL overflow: %d\n", VAR_10);

                        return AVERROR_INVALIDDATA;

                    }

                } else {

                    VAR_13 = (1 << VAR_14);

                    if (VAR_14) {

                        UPDATE_CACHE(re, &VAR_0->gb);

                        VAR_13 += NEG_USR32(GET_CACHE(re, &VAR_0->gb), VAR_14);

                        LAST_SKIP_BITS(re, &VAR_0->gb, VAR_14);

                    }

                    *VAR_8 = VAR_13 - 1;

                    break;

                }

            }

        }

        CLOSE_READER(re, &VAR_0->gb);

    }



    if (VAR_10 > *VAR_2)

        *VAR_2 = VAR_10;



    return 0;

}

static int FUNC_0(MJpegDecodeContext *VAR_0, int16_t *VAR_1,
uint8_t *VAR_2, int VAR_3,
uint16_t *VAR_4,
int VAR_5, int VAR_6, int VAR_7, int *VAR_8)
{ int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14; if (*VAR_8) { (*VAR_8)--; return 0; } { OPEN_READER(re, &VAR_0->gb); for (VAR_10 = VAR_5; ; VAR_10++) { UPDATE_CACHE(re, &VAR_0->gb); GET_VLC(VAR_9, re, &VAR_0->gb, VAR_0->vlcs[2][VAR_3].table, 9, 2); VAR_14 = ((unsigned) VAR_9) >> 4; VAR_9 &= 0xF; if (VAR_9) { VAR_10 += VAR_14; if (VAR_9 > MIN_CACHE_BITS - 16)
UPDATE_CACHE(re, &VAR_0->gb); { int VAR_15 = GET_CACHE(re, &VAR_0->gb); int VAR_16  = (~VAR_15) >> 31; VAR_12     = (NEG_USR32(VAR_16 ^ VAR_15,VAR_9) ^ VAR_16) - VAR_16; } LAST_SKIP_BITS(re, &VAR_0->gb, VAR_9); if (VAR_10 >= VAR_6) { if (VAR_10 == VAR_6) { VAR_11 = VAR_0->scantable.permutated[VAR_6]; VAR_1[VAR_11] = VAR_12 * (VAR_4[VAR_6] << VAR_7); break; } av_log(VAR_0->avctx, AV_LOG_ERROR, "error count: %d\n", VAR_10); return AVERROR_INVALIDDATA; } VAR_11 = VAR_0->scantable.permutated[VAR_10]; VAR_1[VAR_11] = VAR_12 * (VAR_4[VAR_10] << VAR_7); } else { if (VAR_14 == 0xF) { VAR_10 += 15; if (VAR_10 >= VAR_6) { av_log(VAR_0->avctx, AV_LOG_ERROR, "ZRL overflow: %d\n", VAR_10); return AVERROR_INVALIDDATA; } } else { VAR_13 = (1 << VAR_14); if (VAR_14) { UPDATE_CACHE(re, &VAR_0->gb); VAR_13 += NEG_USR32(GET_CACHE(re, &VAR_0->gb), VAR_14); LAST_SKIP_BITS(re, &VAR_0->gb, VAR_14); } *VAR_8 = VAR_13 - 1; break; } } } CLOSE_READER(re, &VAR_0->gb); } if (VAR_10 > *VAR_2)
*VAR_2 = VAR_10; return 0; }