static int binkb_decode_plane(BinkContext *c, AVFrame *frame, BitstreamContext *bc,

                              int plane_idx, int is_key, int is_chroma)

{

    int blk, ret;

    int i, j, bx, by;

    uint8_t *dst, *ref, *ref_start, *ref_end;

    int v, col[2];

    const uint8_t *scan;

    int xoff, yoff;

    LOCAL_ALIGNED_16(int16_t, block, [64]);

    LOCAL_ALIGNED_16(int32_t, dctblock, [64]);

    int coordmap[64];

    int ybias = is_key ? -15 : 0;

    int qp;



    const int stride = frame->linesize[plane_idx];

    int bw = is_chroma ? (c->avctx->width  + 15) >> 4 : (c->avctx->width  + 7) >> 3;

    int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3;



    binkb_init_bundles(c);

    ref_start = frame->data[plane_idx];

    ref_end   = frame->data[plane_idx] + (bh * frame->linesize[plane_idx] + bw) * 8;



    for (i = 0; i < 64; i++)

        coordmap[i] = (i & 7) + (i >> 3) * stride;



    for (by = 0; by < bh; by++) {

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

            if ((ret = binkb_read_bundle(c, bc, i)) < 0)

                return ret;

        }



        dst  = frame->data[plane_idx]  + 8*by*stride;

        for (bx = 0; bx < bw; bx++, dst += 8) {

            blk = binkb_get_value(c, BINKB_SRC_BLOCK_TYPES);

            switch (blk) {

            case 0:

                break;

            case 1:

                scan = bink_patterns[bitstream_read(bc, 4)];

                i = 0;

                do {

                    int mode = bitstream_read_bit(bc);

                    int run  = bitstream_read(bc, binkb_runbits[i]) + 1;



                    i += run;

                    if (i > 64) {

                        av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");

                        return AVERROR_INVALIDDATA;

                    }

                    if (mode) {

                        v = binkb_get_value(c, BINKB_SRC_COLORS);

                        for (j = 0; j < run; j++)

                            dst[coordmap[*scan++]] = v;

                    } else {

                        for (j = 0; j < run; j++)

                            dst[coordmap[*scan++]] = binkb_get_value(c, BINKB_SRC_COLORS);

                    }

                } while (i < 63);

                if (i == 63)

                    dst[coordmap[*scan++]] = binkb_get_value(c, BINKB_SRC_COLORS);

                break;

            case 2:

                memset(dctblock, 0, sizeof(*dctblock) * 64);

                dctblock[0] = binkb_get_value(c, BINKB_SRC_INTRA_DC);

                qp = binkb_get_value(c, BINKB_SRC_INTRA_Q);

                read_dct_coeffs(bc, dctblock, bink_scan, binkb_intra_quant, qp);

                c->binkdsp.idct_put(dst, stride, dctblock);

                break;

            case 3:

                xoff = binkb_get_value(c, BINKB_SRC_X_OFF);

                yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;

                ref = dst + xoff + yoff * stride;

                if (ref < ref_start || ref + 8*stride > ref_end) {

                    av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");

                } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {

                    c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);

                } else {

                    put_pixels8x8_overlapped(dst, ref, stride);

                }

                c->bdsp.clear_block(block);

                v = binkb_get_value(c, BINKB_SRC_INTER_COEFS);

                read_residue(bc, block, v);

                c->binkdsp.add_pixels8(dst, block, stride);

                break;

            case 4:

                xoff = binkb_get_value(c, BINKB_SRC_X_OFF);

                yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;

                ref = dst + xoff + yoff * stride;

                if (ref < ref_start || ref + 8 * stride > ref_end) {

                    av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");

                } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {

                    c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);

                } else {

                    put_pixels8x8_overlapped(dst, ref, stride);

                }

                memset(dctblock, 0, sizeof(*dctblock) * 64);

                dctblock[0] = binkb_get_value(c, BINKB_SRC_INTER_DC);

                qp = binkb_get_value(c, BINKB_SRC_INTER_Q);

                read_dct_coeffs(bc, dctblock, bink_scan, binkb_inter_quant, qp);

                c->binkdsp.idct_add(dst, stride, dctblock);

                break;

            case 5:

                v = binkb_get_value(c, BINKB_SRC_COLORS);

                c->bdsp.fill_block_tab[1](dst, v, stride, 8);

                break;

            case 6:

                for (i = 0; i < 2; i++)

                    col[i] = binkb_get_value(c, BINKB_SRC_COLORS);

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

                    v = binkb_get_value(c, BINKB_SRC_PATTERN);

                    for (j = 0; j < 8; j++, v >>= 1)

                        dst[i*stride + j] = col[v & 1];

                }

                break;

            case 7:

                xoff = binkb_get_value(c, BINKB_SRC_X_OFF);

                yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;

                ref = dst + xoff + yoff * stride;

                if (ref < ref_start || ref + 8 * stride > ref_end) {

                    av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");

                } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {

                    c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);

                } else {

                    put_pixels8x8_overlapped(dst, ref, stride);

                }

                break;

            case 8:

                for (i = 0; i < 8; i++)

                    memcpy(dst + i*stride, c->bundle[BINKB_SRC_COLORS].cur_ptr + i*8, 8);

                c->bundle[BINKB_SRC_COLORS].cur_ptr += 64;

                break;

            default:

                av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk);

                return AVERROR_INVALIDDATA;

            }

        }

    }

    if (bitstream_tell(bc) & 0x1F) // next plane data starts at 32-bit boundary

        bitstream_skip(bc, 32 - (bitstream_tell(bc) & 0x1F));



    return 0;

}

static int binkb_decode_plane(BinkContext *c, AVFrame *frame, BitstreamContext *bc,

                              int plane_idx, int is_key, int is_chroma)

{

    int blk, ret;

    int i, j, bx, by;

    uint8_t *dst, *ref, *ref_start, *ref_end;

    int v, col[2];

    const uint8_t *scan;

    int xoff, yoff;

    LOCAL_ALIGNED_16(int16_t, block, [64]);

    LOCAL_ALIGNED_16(int32_t, dctblock, [64]);

    int coordmap[64];

    int ybias = is_key ? -15 : 0;

    int qp;



    const int stride = frame->linesize[plane_idx];

    int bw = is_chroma ? (c->avctx->width  + 15) >> 4 : (c->avctx->width  + 7) >> 3;

    int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3;



    binkb_init_bundles(c);

    ref_start = frame->data[plane_idx];

    ref_end   = frame->data[plane_idx] + (bh * frame->linesize[plane_idx] + bw) * 8;



    for (i = 0; i < 64; i++)

        coordmap[i] = (i & 7) + (i >> 3) * stride;



    for (by = 0; by < bh; by++) {

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

            if ((ret = binkb_read_bundle(c, bc, i)) < 0)

                return ret;

        }



        dst  = frame->data[plane_idx]  + 8*by*stride;

        for (bx = 0; bx < bw; bx++, dst += 8) {

            blk = binkb_get_value(c, BINKB_SRC_BLOCK_TYPES);

            switch (blk) {

            case 0:

                break;

            case 1:

                scan = bink_patterns[bitstream_read(bc, 4)];

                i = 0;

                do {

                    int mode = bitstream_read_bit(bc);

                    int run  = bitstream_read(bc, binkb_runbits[i]) + 1;



                    i += run;

                    if (i > 64) {

                        av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");

                        return AVERROR_INVALIDDATA;

                    }

                    if (mode) {

                        v = binkb_get_value(c, BINKB_SRC_COLORS);

                        for (j = 0; j < run; j++)

                            dst[coordmap[*scan++]] = v;

                    } else {

                        for (j = 0; j < run; j++)

                            dst[coordmap[*scan++]] = binkb_get_value(c, BINKB_SRC_COLORS);

                    }

                } while (i < 63);

                if (i == 63)

                    dst[coordmap[*scan++]] = binkb_get_value(c, BINKB_SRC_COLORS);

                break;

            case 2:

                memset(dctblock, 0, sizeof(*dctblock) * 64);

                dctblock[0] = binkb_get_value(c, BINKB_SRC_INTRA_DC);

                qp = binkb_get_value(c, BINKB_SRC_INTRA_Q);

                read_dct_coeffs(bc, dctblock, bink_scan, binkb_intra_quant, qp);

                c->binkdsp.idct_put(dst, stride, dctblock);

                break;

            case 3:

                xoff = binkb_get_value(c, BINKB_SRC_X_OFF);

                yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;

                ref = dst + xoff + yoff * stride;

                if (ref < ref_start || ref + 8*stride > ref_end) {

                    av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");

                } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {

                    c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);

                } else {

                    put_pixels8x8_overlapped(dst, ref, stride);

                }

                c->bdsp.clear_block(block);

                v = binkb_get_value(c, BINKB_SRC_INTER_COEFS);

                read_residue(bc, block, v);

                c->binkdsp.add_pixels8(dst, block, stride);

                break;

            case 4:

                xoff = binkb_get_value(c, BINKB_SRC_X_OFF);

                yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;

                ref = dst + xoff + yoff * stride;

                if (ref < ref_start || ref + 8 * stride > ref_end) {

                    av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");

                } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {

                    c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);

                } else {

                    put_pixels8x8_overlapped(dst, ref, stride);

                }

                memset(dctblock, 0, sizeof(*dctblock) * 64);

                dctblock[0] = binkb_get_value(c, BINKB_SRC_INTER_DC);

                qp = binkb_get_value(c, BINKB_SRC_INTER_Q);

                read_dct_coeffs(bc, dctblock, bink_scan, binkb_inter_quant, qp);

                c->binkdsp.idct_add(dst, stride, dctblock);

                break;

            case 5:

                v = binkb_get_value(c, BINKB_SRC_COLORS);

                c->bdsp.fill_block_tab[1](dst, v, stride, 8);

                break;

            case 6:

                for (i = 0; i < 2; i++)

                    col[i] = binkb_get_value(c, BINKB_SRC_COLORS);

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

                    v = binkb_get_value(c, BINKB_SRC_PATTERN);

                    for (j = 0; j < 8; j++, v >>= 1)

                        dst[i*stride + j] = col[v & 1];

                }

                break;

            case 7:

                xoff = binkb_get_value(c, BINKB_SRC_X_OFF);

                yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;

                ref = dst + xoff + yoff * stride;

                if (ref < ref_start || ref + 8 * stride > ref_end) {

                    av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");

                } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {

                    c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);

                } else {

                    put_pixels8x8_overlapped(dst, ref, stride);

                }

                break;

            case 8:

                for (i = 0; i < 8; i++)

                    memcpy(dst + i*stride, c->bundle[BINKB_SRC_COLORS].cur_ptr + i*8, 8);

                c->bundle[BINKB_SRC_COLORS].cur_ptr += 64;

                break;

            default:

                av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk);

                return AVERROR_INVALIDDATA;

            }

        }

    }

    if (bitstream_tell(bc) & 0x1F) 

        bitstream_skip(bc, 32 - (bitstream_tell(bc) & 0x1F));



    return 0;

}

static int FUNC_0(BinkContext *VAR_0, AVFrame *VAR_1, BitstreamContext *VAR_2,

                              int VAR_3, int VAR_4, int VAR_5)

{

    int VAR_6, VAR_7;

    int VAR_8, VAR_9, VAR_10, VAR_11;

    uint8_t *dst, *ref, *ref_start, *ref_end;

    int VAR_12, VAR_13[2];

    const uint8_t *VAR_14;

    int VAR_15, VAR_16;

    LOCAL_ALIGNED_16(int16_t, block, [64]);

    LOCAL_ALIGNED_16(int32_t, dctblock, [64]);

    int VAR_17[64];

    int VAR_18 = VAR_4 ? -15 : 0;

    int VAR_19;



    const int VAR_20 = VAR_1->linesize[VAR_3];

    int VAR_21 = VAR_5 ? (VAR_0->avctx->width  + 15) >> 4 : (VAR_0->avctx->width  + 7) >> 3;

    int VAR_22 = VAR_5 ? (VAR_0->avctx->height + 15) >> 4 : (VAR_0->avctx->height + 7) >> 3;



    binkb_init_bundles(VAR_0);

    ref_start = VAR_1->data[VAR_3];

    ref_end   = VAR_1->data[VAR_3] + (VAR_22 * VAR_1->linesize[VAR_3] + VAR_21) * 8;



    for (VAR_8 = 0; VAR_8 < 64; VAR_8++)

        VAR_17[VAR_8] = (VAR_8 & 7) + (VAR_8 >> 3) * VAR_20;



    for (VAR_11 = 0; VAR_11 < VAR_22; VAR_11++) {

        for (VAR_8 = 0; VAR_8 < BINKB_NB_SRC; VAR_8++) {

            if ((VAR_7 = binkb_read_bundle(VAR_0, VAR_2, VAR_8)) < 0)

                return VAR_7;

        }



        dst  = VAR_1->data[VAR_3]  + 8*VAR_11*VAR_20;

        for (VAR_10 = 0; VAR_10 < VAR_21; VAR_10++, dst += 8) {

            VAR_6 = binkb_get_value(VAR_0, BINKB_SRC_BLOCK_TYPES);

            switch (VAR_6) {

            case 0:

                break;

            case 1:

                VAR_14 = bink_patterns[bitstream_read(VAR_2, 4)];

                VAR_8 = 0;

                do {

                    int VAR_23 = bitstream_read_bit(VAR_2);

                    int VAR_24  = bitstream_read(VAR_2, binkb_runbits[VAR_8]) + 1;



                    VAR_8 += VAR_24;

                    if (VAR_8 > 64) {

                        av_log(VAR_0->avctx, AV_LOG_ERROR, "Run went out of bounds\n");

                        return AVERROR_INVALIDDATA;

                    }

                    if (VAR_23) {

                        VAR_12 = binkb_get_value(VAR_0, BINKB_SRC_COLORS);

                        for (VAR_9 = 0; VAR_9 < VAR_24; VAR_9++)

                            dst[VAR_17[*VAR_14++]] = VAR_12;

                    } else {

                        for (VAR_9 = 0; VAR_9 < VAR_24; VAR_9++)

                            dst[VAR_17[*VAR_14++]] = binkb_get_value(VAR_0, BINKB_SRC_COLORS);

                    }

                } while (VAR_8 < 63);

                if (VAR_8 == 63)

                    dst[VAR_17[*VAR_14++]] = binkb_get_value(VAR_0, BINKB_SRC_COLORS);

                break;

            case 2:

                memset(dctblock, 0, sizeof(*dctblock) * 64);

                dctblock[0] = binkb_get_value(VAR_0, BINKB_SRC_INTRA_DC);

                VAR_19 = binkb_get_value(VAR_0, BINKB_SRC_INTRA_Q);

                read_dct_coeffs(VAR_2, dctblock, bink_scan, binkb_intra_quant, VAR_19);

                VAR_0->binkdsp.idct_put(dst, VAR_20, dctblock);

                break;

            case 3:

                VAR_15 = binkb_get_value(VAR_0, BINKB_SRC_X_OFF);

                VAR_16 = binkb_get_value(VAR_0, BINKB_SRC_Y_OFF) + VAR_18;

                ref = dst + VAR_15 + VAR_16 * VAR_20;

                if (ref < ref_start || ref + 8*VAR_20 > ref_end) {

                    av_log(VAR_0->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");

                } else if (ref + 8*VAR_20 < dst || ref >= dst + 8*VAR_20) {

                    VAR_0->hdsp.put_pixels_tab[1][0](dst, ref, VAR_20, 8);

                } else {

                    put_pixels8x8_overlapped(dst, ref, VAR_20);

                }

                VAR_0->bdsp.clear_block(block);

                VAR_12 = binkb_get_value(VAR_0, BINKB_SRC_INTER_COEFS);

                read_residue(VAR_2, block, VAR_12);

                VAR_0->binkdsp.add_pixels8(dst, block, VAR_20);

                break;

            case 4:

                VAR_15 = binkb_get_value(VAR_0, BINKB_SRC_X_OFF);

                VAR_16 = binkb_get_value(VAR_0, BINKB_SRC_Y_OFF) + VAR_18;

                ref = dst + VAR_15 + VAR_16 * VAR_20;

                if (ref < ref_start || ref + 8 * VAR_20 > ref_end) {

                    av_log(VAR_0->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");

                } else if (ref + 8*VAR_20 < dst || ref >= dst + 8*VAR_20) {

                    VAR_0->hdsp.put_pixels_tab[1][0](dst, ref, VAR_20, 8);

                } else {

                    put_pixels8x8_overlapped(dst, ref, VAR_20);

                }

                memset(dctblock, 0, sizeof(*dctblock) * 64);

                dctblock[0] = binkb_get_value(VAR_0, BINKB_SRC_INTER_DC);

                VAR_19 = binkb_get_value(VAR_0, BINKB_SRC_INTER_Q);

                read_dct_coeffs(VAR_2, dctblock, bink_scan, binkb_inter_quant, VAR_19);

                VAR_0->binkdsp.idct_add(dst, VAR_20, dctblock);

                break;

            case 5:

                VAR_12 = binkb_get_value(VAR_0, BINKB_SRC_COLORS);

                VAR_0->bdsp.fill_block_tab[1](dst, VAR_12, VAR_20, 8);

                break;

            case 6:

                for (VAR_8 = 0; VAR_8 < 2; VAR_8++)

                    VAR_13[VAR_8] = binkb_get_value(VAR_0, BINKB_SRC_COLORS);

                for (VAR_8 = 0; VAR_8 < 8; VAR_8++) {

                    VAR_12 = binkb_get_value(VAR_0, BINKB_SRC_PATTERN);

                    for (VAR_9 = 0; VAR_9 < 8; VAR_9++, VAR_12 >>= 1)

                        dst[VAR_8*VAR_20 + VAR_9] = VAR_13[VAR_12 & 1];

                }

                break;

            case 7:

                VAR_15 = binkb_get_value(VAR_0, BINKB_SRC_X_OFF);

                VAR_16 = binkb_get_value(VAR_0, BINKB_SRC_Y_OFF) + VAR_18;

                ref = dst + VAR_15 + VAR_16 * VAR_20;

                if (ref < ref_start || ref + 8 * VAR_20 > ref_end) {

                    av_log(VAR_0->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");

                } else if (ref + 8*VAR_20 < dst || ref >= dst + 8*VAR_20) {

                    VAR_0->hdsp.put_pixels_tab[1][0](dst, ref, VAR_20, 8);

                } else {

                    put_pixels8x8_overlapped(dst, ref, VAR_20);

                }

                break;

            case 8:

                for (VAR_8 = 0; VAR_8 < 8; VAR_8++)

                    memcpy(dst + VAR_8*VAR_20, VAR_0->bundle[BINKB_SRC_COLORS].cur_ptr + VAR_8*8, 8);

                VAR_0->bundle[BINKB_SRC_COLORS].cur_ptr += 64;

                break;

            default:

                av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown block type %d\n", VAR_6);

                return AVERROR_INVALIDDATA;

            }

        }

    }

    if (bitstream_tell(VAR_2) & 0x1F) 

        bitstream_skip(VAR_2, 32 - (bitstream_tell(VAR_2) & 0x1F));



    return 0;

}

static int FUNC_0(BinkContext *VAR_0, AVFrame *VAR_1, BitstreamContext *VAR_2,
int VAR_3, int VAR_4, int VAR_5)
{ int VAR_6, VAR_7; int VAR_8, VAR_9, VAR_10, VAR_11; uint8_t *dst, *ref, *ref_start, *ref_end; int VAR_12, VAR_13[2]; const uint8_t *VAR_14; int VAR_15, VAR_16; LOCAL_ALIGNED_16(int16_t, block, [64]); LOCAL_ALIGNED_16(int32_t, dctblock, [64]); int VAR_17[64]; int VAR_18 = VAR_4 ? -15 : 0; int VAR_19; const int VAR_20 = VAR_1->linesize[VAR_3]; int VAR_21 = VAR_5 ? (VAR_0->avctx->width  + 15) >> 4 : (VAR_0->avctx->width  + 7) >> 3; int VAR_22 = VAR_5 ? (VAR_0->avctx->height + 15) >> 4 : (VAR_0->avctx->height + 7) >> 3; binkb_init_bundles(VAR_0); ref_start = VAR_1->data[VAR_3]; ref_end   = VAR_1->data[VAR_3] + (VAR_22 * VAR_1->linesize[VAR_3] + VAR_21) * 8; for (VAR_8 = 0; VAR_8 < 64; VAR_8++) VAR_17[VAR_8] = (VAR_8 & 7) + (VAR_8 >> 3) * VAR_20; for (VAR_11 = 0; VAR_11 < VAR_22; VAR_11++) { for (VAR_8 = 0; VAR_8 < BINKB_NB_SRC; VAR_8++) { if ((VAR_7 = binkb_read_bundle(VAR_0, VAR_2, VAR_8)) < 0)
return VAR_7; } dst  = VAR_1->data[VAR_3]  + 8*VAR_11*VAR_20; for (VAR_10 = 0; VAR_10 < VAR_21; VAR_10++, dst += 8) { VAR_6 = binkb_get_value(VAR_0, BINKB_SRC_BLOCK_TYPES); switch (VAR_6) { case 0:
break; case 1:
VAR_14 = bink_patterns[bitstream_read(VAR_2, 4)]; VAR_8 = 0; do { int VAR_23 = bitstream_read_bit(VAR_2); int VAR_24  = bitstream_read(VAR_2, binkb_runbits[VAR_8]) + 1; VAR_8 += VAR_24; if (VAR_8 > 64) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return AVERROR_INVALIDDATA; } if (VAR_23) { VAR_12 = binkb_get_value(VAR_0, BINKB_SRC_COLORS); for (VAR_9 = 0; VAR_9 < VAR_24; VAR_9++) dst[VAR_17[*VAR_14++]] = VAR_12; } else { for (VAR_9 = 0; VAR_9 < VAR_24; VAR_9++) dst[VAR_17[*VAR_14++]] = binkb_get_value(VAR_0, BINKB_SRC_COLORS); } } while (VAR_8 < 63); if (VAR_8 == 63)
dst[VAR_17[*VAR_14++]] = binkb_get_value(VAR_0, BINKB_SRC_COLORS); break; case 2:
memset(dctblock, 0, sizeof(*dctblock) * 64); dctblock[0] = binkb_get_value(VAR_0, BINKB_SRC_INTRA_DC); VAR_19 = binkb_get_value(VAR_0, BINKB_SRC_INTRA_Q); read_dct_coeffs(VAR_2, dctblock, bink_scan, binkb_intra_quant, VAR_19); VAR_0->binkdsp.idct_put(dst, VAR_20, dctblock); break; case 3:
VAR_15 = binkb_get_value(VAR_0, BINKB_SRC_X_OFF); VAR_16 = binkb_get_value(VAR_0, BINKB_SRC_Y_OFF) + VAR_18; ref = dst + VAR_15 + VAR_16 * VAR_20; if (ref < ref_start || ref + 8*VAR_20 > ref_end) { av_log(VAR_0->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n"); } else if (ref + 8*VAR_20 < dst || ref >= dst + 8*VAR_20) { VAR_0->hdsp.put_pixels_tab[1][0](dst, ref, VAR_20, 8); } else { put_pixels8x8_overlapped(dst, ref, VAR_20); } VAR_0->bdsp.clear_block(block); VAR_12 = binkb_get_value(VAR_0, BINKB_SRC_INTER_COEFS); read_residue(VAR_2, block, VAR_12); VAR_0->binkdsp.add_pixels8(dst, block, VAR_20); break; case 4:
VAR_15 = binkb_get_value(VAR_0, BINKB_SRC_X_OFF); VAR_16 = binkb_get_value(VAR_0, BINKB_SRC_Y_OFF) + VAR_18; ref = dst + VAR_15 + VAR_16 * VAR_20; if (ref < ref_start || ref + 8 * VAR_20 > ref_end) { av_log(VAR_0->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n"); } else if (ref + 8*VAR_20 < dst || ref >= dst + 8*VAR_20) { VAR_0->hdsp.put_pixels_tab[1][0](dst, ref, VAR_20, 8); } else { put_pixels8x8_overlapped(dst, ref, VAR_20); } memset(dctblock, 0, sizeof(*dctblock) * 64); dctblock[0] = binkb_get_value(VAR_0, BINKB_SRC_INTER_DC); VAR_19 = binkb_get_value(VAR_0, BINKB_SRC_INTER_Q); read_dct_coeffs(VAR_2, dctblock, bink_scan, binkb_inter_quant, VAR_19); VAR_0->binkdsp.idct_add(dst, VAR_20, dctblock); break; case 5:
VAR_12 = binkb_get_value(VAR_0, BINKB_SRC_COLORS); VAR_0->bdsp.fill_block_tab[1](dst, VAR_12, VAR_20, 8); break; case 6:
for (VAR_8 = 0; VAR_8 < 2; VAR_8++) VAR_13[VAR_8] = binkb_get_value(VAR_0, BINKB_SRC_COLORS); for (VAR_8 = 0; VAR_8 < 8; VAR_8++) { VAR_12 = binkb_get_value(VAR_0, BINKB_SRC_PATTERN); for (VAR_9 = 0; VAR_9 < 8; VAR_9++, VAR_12 >>= 1) dst[VAR_8*VAR_20 + VAR_9] = VAR_13[VAR_12 & 1]; } break; case 7:
VAR_15 = binkb_get_value(VAR_0, BINKB_SRC_X_OFF); VAR_16 = binkb_get_value(VAR_0, BINKB_SRC_Y_OFF) + VAR_18; ref = dst + VAR_15 + VAR_16 * VAR_20; if (ref < ref_start || ref + 8 * VAR_20 > ref_end) { av_log(VAR_0->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n"); } else if (ref + 8*VAR_20 < dst || ref >= dst + 8*VAR_20) { VAR_0->hdsp.put_pixels_tab[1][0](dst, ref, VAR_20, 8); } else { put_pixels8x8_overlapped(dst, ref, VAR_20); } break; case 8:
for (VAR_8 = 0; VAR_8 < 8; VAR_8++) memcpy(dst + VAR_8*VAR_20, VAR_0->bundle[BINKB_SRC_COLORS].cur_ptr + VAR_8*8, 8); VAR_0->bundle[BINKB_SRC_COLORS].cur_ptr += 64; break; default:
av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown block type %d\n", VAR_6); return AVERROR_INVALIDDATA; } } } if (bitstream_tell(VAR_2) & 0x1F)
bitstream_skip(VAR_2, 32 - (bitstream_tell(VAR_2) & 0x1F)); return 0; }