static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, int point_transform){

    int i, mb_x, mb_y;

    const int nb_components=3;



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

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

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

                s->restart_count = s->restart_interval;



            if(mb_x==0 || mb_y==0 || s->interlaced){

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

                    uint8_t *ptr;

                    int n, h, v, x, y, c, j, linesize;

                    n = s->nb_blocks[i];

                    c = s->comp_index[i];

                    h = s->h_scount[i];

                    v = s->v_scount[i];

                    x = 0;

                    y = 0;

                    linesize= s->linesize[c];



                    for(j=0; j<n; j++) {

                        int pred;



                        ptr = s->picture.data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap

                        if(y==0 && mb_y==0){

                            if(x==0 && mb_x==0){

                                pred= 128 << point_transform;

                            }else{

                                pred= ptr[-1];

                            }

                        }else{

                            if(x==0 && mb_x==0){

                                pred= ptr[-linesize];

                            }else{

                                PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);

                            }

                        }



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

                            ptr += linesize >> 1;

                        *ptr= pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform);



                        if (++x == h) {

                            x = 0;

                            y++;

                        }

                    }

                }

            }else{

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

                    uint8_t *ptr;

                    int n, h, v, x, y, c, j, linesize;

                    n = s->nb_blocks[i];

                    c = s->comp_index[i];

                    h = s->h_scount[i];

                    v = s->v_scount[i];

                    x = 0;

                    y = 0;

                    linesize= s->linesize[c];



                    for(j=0; j<n; j++) {

                        int pred;



                        ptr = s->picture.data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap

                        PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);

                        *ptr= pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform);

                        if (++x == h) {

                            x = 0;

                            y++;

                        }

                    }

                }

            }

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

                align_get_bits(&s->gb);

                skip_bits(&s->gb, 16); /* skip RSTn */

            }

        }

    }

    return 0;

}

static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, int point_transform){

    int i, mb_x, mb_y;

    const int nb_components=3;



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

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

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

                s->restart_count = s->restart_interval;



            if(mb_x==0 || mb_y==0 || s->interlaced){

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

                    uint8_t *ptr;

                    int n, h, v, x, y, c, j, linesize;

                    n = s->nb_blocks[i];

                    c = s->comp_index[i];

                    h = s->h_scount[i];

                    v = s->v_scount[i];

                    x = 0;

                    y = 0;

                    linesize= s->linesize[c];



                    for(j=0; j<n; j++) {

                        int pred;



                        ptr = s->picture.data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); 

                        if(y==0 && mb_y==0){

                            if(x==0 && mb_x==0){

                                pred= 128 << point_transform;

                            }else{

                                pred= ptr[-1];

                            }

                        }else{

                            if(x==0 && mb_x==0){

                                pred= ptr[-linesize];

                            }else{

                                PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);

                            }

                        }



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

                            ptr += linesize >> 1;

                        *ptr= pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform);



                        if (++x == h) {

                            x = 0;

                            y++;

                        }

                    }

                }

            }else{

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

                    uint8_t *ptr;

                    int n, h, v, x, y, c, j, linesize;

                    n = s->nb_blocks[i];

                    c = s->comp_index[i];

                    h = s->h_scount[i];

                    v = s->v_scount[i];

                    x = 0;

                    y = 0;

                    linesize= s->linesize[c];



                    for(j=0; j<n; j++) {

                        int pred;



                        ptr = s->picture.data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); 

                        PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);

                        *ptr= pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform);

                        if (++x == h) {

                            x = 0;

                            y++;

                        }

                    }

                }

            }

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

                align_get_bits(&s->gb);

                skip_bits(&s->gb, 16); 

            }

        }

    }

    return 0;

}

static int FUNC_0(MJpegDecodeContext *VAR_0, int VAR_1, int VAR_2){

    int VAR_3, VAR_4, VAR_5;

    const int VAR_6=3;



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

        for(VAR_4 = 0; VAR_4 < VAR_0->mb_width; VAR_4++) {

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

                VAR_0->restart_count = VAR_0->restart_interval;



            if(VAR_4==0 || VAR_5==0 || VAR_0->interlaced){

                for(VAR_3=0;VAR_3<VAR_6;VAR_3++) {

                    uint8_t *ptr;

                    int n, h, v, x, y, c, j, linesize;

                    n = VAR_0->nb_blocks[VAR_3];

                    c = VAR_0->comp_index[VAR_3];

                    h = VAR_0->h_scount[VAR_3];

                    v = VAR_0->v_scount[VAR_3];

                    x = 0;

                    y = 0;

                    linesize= VAR_0->linesize[c];



                    for(j=0; j<n; j++) {

                        int pred;



                        ptr = VAR_0->picture.data[c] + (linesize * (v * VAR_5 + y)) + (h * VAR_4 + x); 

                        if(y==0 && VAR_5==0){

                            if(x==0 && VAR_4==0){

                                pred= 128 << VAR_2;

                            }else{

                                pred= ptr[-1];

                            }

                        }else{

                            if(x==0 && VAR_4==0){

                                pred= ptr[-linesize];

                            }else{

                                PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], VAR_1);

                            }

                        }



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

                            ptr += linesize >> 1;

                        *ptr= pred + (mjpeg_decode_dc(VAR_0, VAR_0->dc_index[VAR_3]) << VAR_2);



                        if (++x == h) {

                            x = 0;

                            y++;

                        }

                    }

                }

            }else{

                for(VAR_3=0;VAR_3<VAR_6;VAR_3++) {

                    uint8_t *ptr;

                    int n, h, v, x, y, c, j, linesize;

                    n = VAR_0->nb_blocks[VAR_3];

                    c = VAR_0->comp_index[VAR_3];

                    h = VAR_0->h_scount[VAR_3];

                    v = VAR_0->v_scount[VAR_3];

                    x = 0;

                    y = 0;

                    linesize= VAR_0->linesize[c];



                    for(j=0; j<n; j++) {

                        int pred;



                        ptr = VAR_0->picture.data[c] + (linesize * (v * VAR_5 + y)) + (h * VAR_4 + x); 

                        PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], VAR_1);

                        *ptr= pred + (mjpeg_decode_dc(VAR_0, VAR_0->dc_index[VAR_3]) << VAR_2);

                        if (++x == h) {

                            x = 0;

                            y++;

                        }

                    }

                }

            }

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

                align_get_bits(&VAR_0->gb);

                skip_bits(&VAR_0->gb, 16); 

            }

        }

    }

    return 0;

}

static int FUNC_0(MJpegDecodeContext *VAR_0, int VAR_1, int VAR_2){ int VAR_3, VAR_4, VAR_5; const int VAR_6=3; for(VAR_5 = 0; VAR_5 < VAR_0->mb_height; VAR_5++) { for(VAR_4 = 0; VAR_4 < VAR_0->mb_width; VAR_4++) { if (VAR_0->restart_interval && !VAR_0->restart_count)
VAR_0->restart_count = VAR_0->restart_interval; if(VAR_4==0 || VAR_5==0 || VAR_0->interlaced){ for(VAR_3=0;VAR_3<VAR_6;VAR_3++) { uint8_t *ptr; int n, h, v, x, y, c, j, linesize; n = VAR_0->nb_blocks[VAR_3]; c = VAR_0->comp_index[VAR_3]; h = VAR_0->h_scount[VAR_3]; v = VAR_0->v_scount[VAR_3]; x = 0; y = 0; linesize= VAR_0->linesize[c]; for(j=0; j<n; j++) { int pred; ptr = VAR_0->picture.data[c] + (linesize * (v * VAR_5 + y)) + (h * VAR_4 + x); if(y==0 && VAR_5==0){ if(x==0 && VAR_4==0){ pred= 128 << VAR_2; }else{ pred= ptr[-1]; } }else{ if(x==0 && VAR_4==0){ pred= ptr[-linesize]; }else{ PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], VAR_1); } } if (VAR_0->interlaced && VAR_0->bottom_field)
ptr += linesize >> 1; *ptr= pred + (mjpeg_decode_dc(VAR_0, VAR_0->dc_index[VAR_3]) << VAR_2); if (++x == h) { x = 0; y++; } } } }else{ for(VAR_3=0;VAR_3<VAR_6;VAR_3++) { uint8_t *ptr; int n, h, v, x, y, c, j, linesize; n = VAR_0->nb_blocks[VAR_3]; c = VAR_0->comp_index[VAR_3]; h = VAR_0->h_scount[VAR_3]; v = VAR_0->v_scount[VAR_3]; x = 0; y = 0; linesize= VAR_0->linesize[c]; for(j=0; j<n; j++) { int pred; ptr = VAR_0->picture.data[c] + (linesize * (v * VAR_5 + y)) + (h * VAR_4 + x); PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], VAR_1); *ptr= pred + (mjpeg_decode_dc(VAR_0, VAR_0->dc_index[VAR_3]) << VAR_2); if (++x == h) { x = 0; y++; } } } } if (VAR_0->restart_interval && !--VAR_0->restart_count) { align_get_bits(&VAR_0->gb); skip_bits(&VAR_0->gb, 16); } } } return 0; }