static int decode_block_progressive(MJpegDecodeContext *s, DCTELEM *block, uint8_t *last_nnz,

                                    int ac_index, int16_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[1][ac_index].table, 9, 2)

        /* Progressive JPEG use AC coeffs from zero and this decoder sets offset 16 by default */

        code -= 16;

        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[j] << Al;

                    break;

                }

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

                return -1;

            }

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

            block[j] = level * quant_matrix[j] << Al;

        }else{

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

                i += 15;

            }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, DCTELEM *block, uint8_t *last_nnz,

                                    int ac_index, int16_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[1][ac_index].table, 9, 2)

        

        code -= 16;

        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[j] << Al;

                    break;

                }

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

                return -1;

            }

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

            block[j] = level * quant_matrix[j] << Al;

        }else{

            if(run == 0xF){

                i += 15;

            }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 FUNC_0(MJpegDecodeContext *VAR_0, DCTELEM *VAR_1, uint8_t *VAR_2,

                                    int VAR_3, int16_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[1][VAR_3].table, 9, 2)

        

        VAR_9 -= 16;

        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 cache=GET_CACHE(re,&VAR_0->gb);

                int sign=(~cache)>>31;

                VAR_12 = (NEG_USR32(sign ^ cache,VAR_9) ^ sign) - sign;

            }



            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_11] << VAR_7;

                    break;

                }

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

                return -1;

            }

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

            VAR_1[VAR_11] = VAR_12 * VAR_4[VAR_11] << VAR_7;

        }else{

            if(VAR_14 == 0xF){

                VAR_10 += 15;

            }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, DCTELEM *VAR_1, uint8_t *VAR_2,
int VAR_3, int16_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[1][VAR_3].table, 9, 2)
VAR_9 -= 16; 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 cache=GET_CACHE(re,&VAR_0->gb); int sign=(~cache)>>31; VAR_12 = (NEG_USR32(sign ^ cache,VAR_9) ^ sign) - sign; } 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_11] << VAR_7; break; } av_log(VAR_0->avctx, AV_LOG_ERROR, "error count: %d\n", VAR_10); return -1; } VAR_11 = VAR_0->scantable.permutated[VAR_10]; VAR_1[VAR_11] = VAR_12 * VAR_4[VAR_11] << VAR_7; }else{ if(VAR_14 == 0xF){ VAR_10 += 15; }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; }