static int decode(MimicContext *ctx, int quality, int num_coeffs,

                  int is_iframe)

{

    int y, x, plane, cur_row = 0;



    for(plane = 0; plane < 3; plane++) {

        const int is_chroma = !!plane;

        const int qscale = av_clip(10000-quality,is_chroma?1000:2000,10000)<<2;

        const int stride = ctx->flipped_ptrs[ctx->cur_index].linesize[plane];

        const uint8_t *src = ctx->flipped_ptrs[ctx->prev_index].data[plane];

        uint8_t       *dst = ctx->flipped_ptrs[ctx->cur_index ].data[plane];



        for(y = 0; y < ctx->num_vblocks[plane]; y++) {

            for(x = 0; x < ctx->num_hblocks[plane]; x++) {



                /* Check for a change condition in the current block.

                 * - iframes always change.

                 * - Luma plane changes on get_bits1 == 0

                 * - Chroma planes change on get_bits1 == 1 */

                if(is_iframe || get_bits1(&ctx->gb) == is_chroma) {



                    /* Luma planes may use a backreference from the 15 last

                     * frames preceding the previous. (get_bits1 == 1)

                     * Chroma planes don't use backreferences. */

                    if(is_chroma || is_iframe || !get_bits1(&ctx->gb)) {



                        if(!vlc_decode_block(ctx, num_coeffs, qscale))

                            return 0;

                        ctx->dsp.idct_put(dst, stride, ctx->dct_block);

                    } else {

                        unsigned int backref = get_bits(&ctx->gb, 4);

                        int index = (ctx->cur_index+backref)&15;

                        uint8_t *p = ctx->flipped_ptrs[index].data[0];



                        ff_thread_await_progress(&ctx->buf_ptrs[index], cur_row, 0);

                        if(p) {

                            p += src -

                                ctx->flipped_ptrs[ctx->prev_index].data[plane];

                            ctx->dsp.put_pixels_tab[1][0](dst, p, stride, 8);

                        } else {

                            av_log(ctx->avctx, AV_LOG_ERROR,

                                     "No such backreference! Buggy sample.\n");

                        }

                    }

                } else {

                    ff_thread_await_progress(&ctx->buf_ptrs[ctx->prev_index], cur_row, 0);

                    ctx->dsp.put_pixels_tab[1][0](dst, src, stride, 8);

                }

                src += 8;

                dst += 8;

            }

            src += (stride - ctx->num_hblocks[plane])<<3;

            dst += (stride - ctx->num_hblocks[plane])<<3;



            ff_thread_report_progress(&ctx->buf_ptrs[ctx->cur_index], cur_row++, 0);

        }

    }



    return 1;

}

static int decode(MimicContext *ctx, int quality, int num_coeffs,

                  int is_iframe)

{

    int y, x, plane, cur_row = 0;



    for(plane = 0; plane < 3; plane++) {

        const int is_chroma = !!plane;

        const int qscale = av_clip(10000-quality,is_chroma?1000:2000,10000)<<2;

        const int stride = ctx->flipped_ptrs[ctx->cur_index].linesize[plane];

        const uint8_t *src = ctx->flipped_ptrs[ctx->prev_index].data[plane];

        uint8_t       *dst = ctx->flipped_ptrs[ctx->cur_index ].data[plane];



        for(y = 0; y < ctx->num_vblocks[plane]; y++) {

            for(x = 0; x < ctx->num_hblocks[plane]; x++) {



                







                if(is_iframe || get_bits1(&ctx->gb) == is_chroma) {



                    





                    if(is_chroma || is_iframe || !get_bits1(&ctx->gb)) {



                        if(!vlc_decode_block(ctx, num_coeffs, qscale))

                            return 0;

                        ctx->dsp.idct_put(dst, stride, ctx->dct_block);

                    } else {

                        unsigned int backref = get_bits(&ctx->gb, 4);

                        int index = (ctx->cur_index+backref)&15;

                        uint8_t *p = ctx->flipped_ptrs[index].data[0];



                        ff_thread_await_progress(&ctx->buf_ptrs[index], cur_row, 0);

                        if(p) {

                            p += src -

                                ctx->flipped_ptrs[ctx->prev_index].data[plane];

                            ctx->dsp.put_pixels_tab[1][0](dst, p, stride, 8);

                        } else {

                            av_log(ctx->avctx, AV_LOG_ERROR,

                                     "No such backreference! Buggy sample.\n");

                        }

                    }

                } else {

                    ff_thread_await_progress(&ctx->buf_ptrs[ctx->prev_index], cur_row, 0);

                    ctx->dsp.put_pixels_tab[1][0](dst, src, stride, 8);

                }

                src += 8;

                dst += 8;

            }

            src += (stride - ctx->num_hblocks[plane])<<3;

            dst += (stride - ctx->num_hblocks[plane])<<3;



            ff_thread_report_progress(&ctx->buf_ptrs[ctx->cur_index], cur_row++, 0);

        }

    }



    return 1;

}

                        ff_thread_await_progress(&ctx->buf_ptrs[index], cur_row, 0);                         if(p) {
static int FUNC_0(MimicContext *VAR_0, int VAR_1, int VAR_2,

                  int VAR_3)

{

    int VAR_4, VAR_5, VAR_6, VAR_7 = 0;



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

        const int VAR_8 = !!VAR_6;

        const int VAR_9 = av_clip(10000-VAR_1,VAR_8?1000:2000,10000)<<2;

        const int VAR_10 = VAR_0->flipped_ptrs[VAR_0->cur_index].linesize[VAR_6];

        const uint8_t *VAR_11 = VAR_0->flipped_ptrs[VAR_0->prev_index].data[VAR_6];

        uint8_t       *dst = VAR_0->flipped_ptrs[VAR_0->cur_index ].data[VAR_6];



        for(VAR_4 = 0; VAR_4 < VAR_0->num_vblocks[VAR_6]; VAR_4++) {

            for(VAR_5 = 0; VAR_5 < VAR_0->num_hblocks[VAR_6]; VAR_5++) {



                







                if(VAR_3 || get_bits1(&VAR_0->gb) == VAR_8) {



                    





                    if(VAR_8 || VAR_3 || !get_bits1(&VAR_0->gb)) {



                        if(!vlc_decode_block(VAR_0, VAR_2, VAR_9))

                            return 0;

                        VAR_0->dsp.idct_put(dst, VAR_10, VAR_0->dct_block);

                    } else {

                        unsigned int backref = get_bits(&VAR_0->gb, 4);

                        int index = (VAR_0->cur_index+backref)&15;

                        uint8_t *p = VAR_0->flipped_ptrs[index].data[0];



                        ff_thread_await_progress(&VAR_0->buf_ptrs[index], VAR_7, 0);

                        if(p) {

                            p += VAR_11 -

                                VAR_0->flipped_ptrs[VAR_0->prev_index].data[VAR_6];

                            VAR_0->dsp.put_pixels_tab[1][0](dst, p, VAR_10, 8);

                        } else {

                            av_log(VAR_0->avctx, AV_LOG_ERROR,

                                     "No such backreference! Buggy sample.\n");

                        }

                    }

                } else {

                    ff_thread_await_progress(&VAR_0->buf_ptrs[VAR_0->prev_index], VAR_7, 0);

                    VAR_0->dsp.put_pixels_tab[1][0](dst, VAR_11, VAR_10, 8);

                }

                VAR_11 += 8;

                dst += 8;

            }

            VAR_11 += (VAR_10 - VAR_0->num_hblocks[VAR_6])<<3;

            dst += (VAR_10 - VAR_0->num_hblocks[VAR_6])<<3;



            ff_thread_report_progress(&VAR_0->buf_ptrs[VAR_0->cur_index], VAR_7++, 0);

        }

    }



    return 1;

}

static int FUNC_0(MimicContext *VAR_0, int VAR_1, int VAR_2,
int VAR_3)
{ int VAR_4, VAR_5, VAR_6, VAR_7 = 0; for(VAR_6 = 0; VAR_6 < 3; VAR_6++) { const int VAR_8 = !!VAR_6; const int VAR_9 = av_clip(10000-VAR_1,VAR_8?1000:2000,10000)<<2; const int VAR_10 = VAR_0->flipped_ptrs[VAR_0->cur_index].linesize[VAR_6]; const uint8_t *VAR_11 = VAR_0->flipped_ptrs[VAR_0->prev_index].data[VAR_6]; uint8_t       *dst = VAR_0->flipped_ptrs[VAR_0->cur_index ].data[VAR_6]; for(VAR_4 = 0; VAR_4 < VAR_0->num_vblocks[VAR_6]; VAR_4++) { for(VAR_5 = 0; VAR_5 < VAR_0->num_hblocks[VAR_6]; VAR_5++) { if(VAR_3 || get_bits1(&VAR_0->gb) == VAR_8) { if(VAR_8 || VAR_3 || !get_bits1(&VAR_0->gb)) { if(!vlc_decode_block(VAR_0, VAR_2, VAR_9))
return 0; VAR_0->dsp.idct_put(dst, VAR_10, VAR_0->dct_block); } else { unsigned int backref = get_bits(&VAR_0->gb, 4); int index = (VAR_0->cur_index+backref)&15; uint8_t *p = VAR_0->flipped_ptrs[index].data[0]; ff_thread_await_progress(&VAR_0->buf_ptrs[index], VAR_7, 0); if(p) { p += VAR_11 -
VAR_0->flipped_ptrs[VAR_0->prev_index].data[VAR_6]; VAR_0->dsp.put_pixels_tab[1][0](dst, p, VAR_10, 8); } else { av_log(VAR_0->avctx, AV_LOG_ERROR,
"No such backreference! Buggy sample.\n"); } } } else { ff_thread_await_progress(&VAR_0->buf_ptrs[VAR_0->prev_index], VAR_7, 0); VAR_0->dsp.put_pixels_tab[1][0](dst, VAR_11, VAR_10, 8); } VAR_11 += 8; dst += 8; } VAR_11 += (VAR_10 - VAR_0->num_hblocks[VAR_6])<<3; dst += (VAR_10 - VAR_0->num_hblocks[VAR_6])<<3; ff_thread_report_progress(&VAR_0->buf_ptrs[VAR_0->cur_index], VAR_7++, 0); } } return 1; }