static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,

                                            int se, int Ah, int Al)

{

    int mb_x, mb_y;

    int EOBRUN = 0;

    int c = s->comp_index[0];

    uint8_t *data = s->picture_ptr->data[c];

    int linesize  = s->linesize[c];

    int last_scan = 0;

    int16_t *quant_matrix = s->quant_matrixes[s->quant_sindex[0]];

    int bytes_per_pixel = 1 + (s->bits > 8);



    av_assert0(ss>=0 && Ah>=0 && Al>=0);

    if (se < ss || se > 63) {

        av_log(s->avctx, AV_LOG_ERROR, "SS/SE %d/%d is invalid\n", ss, se);

        return AVERROR_INVALIDDATA;

    }



    if (!Al) {

        s->coefs_finished[c] |= (2LL << se) - (1LL << ss);

        last_scan = !~s->coefs_finished[c];

    }



    if (s->interlaced && s->bottom_field)

        data += linesize >> 1;



    s->restart_count = 0;



    for (mb_y = 0; mb_y < s->mb_height; mb_y++) {

        uint8_t *ptr     = data + (mb_y * linesize * 8 >> s->avctx->lowres);

        int block_idx    = mb_y * s->block_stride[c];

        int16_t (*block)[64] = &s->blocks[c][block_idx];

        uint8_t *last_nnz    = &s->last_nnz[c][block_idx];

        for (mb_x = 0; mb_x < s->mb_width; mb_x++, block++, last_nnz++) {

                int ret;

                if (s->restart_interval && !s->restart_count)

                    s->restart_count = s->restart_interval;



                if (Ah)

                    ret = decode_block_refinement(s, *block, last_nnz, s->ac_index[0],

                                                  quant_matrix, ss, se, Al, &EOBRUN);

                else

                    ret = decode_block_progressive(s, *block, last_nnz, s->ac_index[0],

                                                   quant_matrix, ss, se, Al, &EOBRUN);

                if (ret < 0) {

                    av_log(s->avctx, AV_LOG_ERROR,

                           "error y=%d x=%d\n", mb_y, mb_x);

                    return AVERROR_INVALIDDATA;

                }



            if (last_scan) {

                    s->dsp.idct_put(ptr, linesize, *block);

                    if (s->bits & 7)

                        shift_output(s, ptr, linesize);

                    ptr += bytes_per_pixel*8 >> s->avctx->lowres;

            }

            if (handle_rstn(s, 0))

                EOBRUN = 0;

        }

    }

    return 0;

}

static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,

                                            int se, int Ah, int Al)

{

    int mb_x, mb_y;

    int EOBRUN = 0;

    int c = s->comp_index[0];

    uint8_t *data = s->picture_ptr->data[c];

    int linesize  = s->linesize[c];

    int last_scan = 0;

    int16_t *quant_matrix = s->quant_matrixes[s->quant_sindex[0]];

    int bytes_per_pixel = 1 + (s->bits > 8);



    av_assert0(ss>=0 && Ah>=0 && Al>=0);

    if (se < ss || se > 63) {

        av_log(s->avctx, AV_LOG_ERROR, "SS/SE %d/%d is invalid\n", ss, se);

        return AVERROR_INVALIDDATA;

    }



    if (!Al) {

        s->coefs_finished[c] |= (2LL << se) - (1LL << ss);

        last_scan = !~s->coefs_finished[c];

    }



    if (s->interlaced && s->bottom_field)

        data += linesize >> 1;



    s->restart_count = 0;



    for (mb_y = 0; mb_y < s->mb_height; mb_y++) {

        uint8_t *ptr     = data + (mb_y * linesize * 8 >> s->avctx->lowres);

        int block_idx    = mb_y * s->block_stride[c];

        int16_t (*block)[64] = &s->blocks[c][block_idx];

        uint8_t *last_nnz    = &s->last_nnz[c][block_idx];

        for (mb_x = 0; mb_x < s->mb_width; mb_x++, block++, last_nnz++) {

                int ret;

                if (s->restart_interval && !s->restart_count)

                    s->restart_count = s->restart_interval;



                if (Ah)

                    ret = decode_block_refinement(s, *block, last_nnz, s->ac_index[0],

                                                  quant_matrix, ss, se, Al, &EOBRUN);

                else

                    ret = decode_block_progressive(s, *block, last_nnz, s->ac_index[0],

                                                   quant_matrix, ss, se, Al, &EOBRUN);

                if (ret < 0) {

                    av_log(s->avctx, AV_LOG_ERROR,

                           "error y=%d x=%d\n", mb_y, mb_x);

                    return AVERROR_INVALIDDATA;

                }



            if (last_scan) {

                    s->dsp.idct_put(ptr, linesize, *block);

                    if (s->bits & 7)

                        shift_output(s, ptr, linesize);

                    ptr += bytes_per_pixel*8 >> s->avctx->lowres;

            }

            if (handle_rstn(s, 0))

                EOBRUN = 0;

        }

    }

    return 0;

}

        s->coefs_finished[c] |= (2LL << se) - (1LL << ss);
static int FUNC_0(MJpegDecodeContext *VAR_0, int VAR_1,

                                            int VAR_2, int VAR_3, int VAR_4)

{

    int VAR_5, VAR_6;

    int VAR_7 = 0;

    int VAR_8 = VAR_0->comp_index[0];

    uint8_t *data = VAR_0->picture_ptr->data[VAR_8];

    int VAR_9  = VAR_0->VAR_9[VAR_8];

    int VAR_10 = 0;

    int16_t *quant_matrix = VAR_0->quant_matrixes[VAR_0->quant_sindex[0]];

    int VAR_11 = 1 + (VAR_0->bits > 8);



    av_assert0(VAR_1>=0 && VAR_3>=0 && VAR_4>=0);

    if (VAR_2 < VAR_1 || VAR_2 > 63) {

        av_log(VAR_0->avctx, AV_LOG_ERROR, "SS/SE %d/%d is invalid\n", VAR_1, VAR_2);

        return AVERROR_INVALIDDATA;

    }



    if (!VAR_4) {

        VAR_0->coefs_finished[VAR_8] |= (2LL << VAR_2) - (1LL << VAR_1);

        VAR_10 = !~VAR_0->coefs_finished[VAR_8];

    }



    if (VAR_0->interlaced && VAR_0->bottom_field)

        data += VAR_9 >> 1;



    VAR_0->restart_count = 0;



    for (VAR_6 = 0; VAR_6 < VAR_0->mb_height; VAR_6++) {

        uint8_t *ptr     = data + (VAR_6 * VAR_9 * 8 >> VAR_0->avctx->lowres);

        int block_idx    = VAR_6 * VAR_0->block_stride[VAR_8];

        int16_t (*block)[64] = &VAR_0->blocks[VAR_8][block_idx];

        uint8_t *last_nnz    = &VAR_0->last_nnz[VAR_8][block_idx];

        for (VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++, block++, last_nnz++) {

                int ret;

                if (VAR_0->restart_interval && !VAR_0->restart_count)

                    VAR_0->restart_count = VAR_0->restart_interval;



                if (VAR_3)

                    ret = decode_block_refinement(VAR_0, *block, last_nnz, VAR_0->ac_index[0],

                                                  quant_matrix, VAR_1, VAR_2, VAR_4, &VAR_7);

                else

                    ret = decode_block_progressive(VAR_0, *block, last_nnz, VAR_0->ac_index[0],

                                                   quant_matrix, VAR_1, VAR_2, VAR_4, &VAR_7);

                if (ret < 0) {

                    av_log(VAR_0->avctx, AV_LOG_ERROR,

                           "error y=%d x=%d\n", VAR_6, VAR_5);

                    return AVERROR_INVALIDDATA;

                }



            if (VAR_10) {

                    VAR_0->dsp.idct_put(ptr, VAR_9, *block);

                    if (VAR_0->bits & 7)

                        shift_output(VAR_0, ptr, VAR_9);

                    ptr += VAR_11*8 >> VAR_0->avctx->lowres;

            }

            if (handle_rstn(VAR_0, 0))

                VAR_7 = 0;

        }

    }

    return 0;

}

static int FUNC_0(MJpegDecodeContext *VAR_0, int VAR_1,
int VAR_2, int VAR_3, int VAR_4)
{ int VAR_5, VAR_6; int VAR_7 = 0; int VAR_8 = VAR_0->comp_index[0]; uint8_t *data = VAR_0->picture_ptr->data[VAR_8]; int VAR_9  = VAR_0->VAR_9[VAR_8]; int VAR_10 = 0; int16_t *quant_matrix = VAR_0->quant_matrixes[VAR_0->quant_sindex[0]]; int VAR_11 = 1 + (VAR_0->bits > 8); av_assert0(VAR_1>=0 && VAR_3>=0 && VAR_4>=0); if (VAR_2 < VAR_1 || VAR_2 > 63) { av_log(VAR_0->avctx, AV_LOG_ERROR, "SS/SE %d/%d is invalid\n", VAR_1, VAR_2); return AVERROR_INVALIDDATA; } if (!VAR_4) { VAR_0->coefs_finished[VAR_8] |= (2LL << VAR_2) - (1LL << VAR_1); VAR_10 = !~VAR_0->coefs_finished[VAR_8]; } if (VAR_0->interlaced && VAR_0->bottom_field)
data += VAR_9 >> 1; VAR_0->restart_count = 0; for (VAR_6 = 0; VAR_6 < VAR_0->mb_height; VAR_6++) { uint8_t *ptr     = data + (VAR_6 * VAR_9 * 8 >> VAR_0->avctx->lowres); int block_idx    = VAR_6 * VAR_0->block_stride[VAR_8]; int16_t (*block)[64] = &VAR_0->blocks[VAR_8][block_idx]; uint8_t *last_nnz    = &VAR_0->last_nnz[VAR_8][block_idx]; for (VAR_5 = 0; VAR_5 < VAR_0->mb_width; VAR_5++, block++, last_nnz++) { int ret; if (VAR_0->restart_interval && !VAR_0->restart_count)
VAR_0->restart_count = VAR_0->restart_interval; if (VAR_3)
ret = decode_block_refinement(VAR_0, *block, last_nnz, VAR_0->ac_index[0],
quant_matrix, VAR_1, VAR_2, VAR_4, &VAR_7); else
ret = decode_block_progressive(VAR_0, *block, last_nnz, VAR_0->ac_index[0],
quant_matrix, VAR_1, VAR_2, VAR_4, &VAR_7); if (ret < 0) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"error y=%d x=%d\n", VAR_6, VAR_5); return AVERROR_INVALIDDATA; } if (VAR_10) { VAR_0->dsp.idct_put(ptr, VAR_9, *block); if (VAR_0->bits & 7)
shift_output(VAR_0, ptr, VAR_9); ptr += VAR_11*8 >> VAR_0->avctx->lowres; } if (handle_rstn(VAR_0, 0))
VAR_7 = 0; } } return 0; }