static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,

                        PutBitContext *pb,

                        int sizes[4], int x, int y, int quant,

                        int mbs_per_slice)

{

    ProresContext *ctx = avctx->priv_data;

    int i, xp, yp;

    int total_size = 0;

    const uint16_t *src;

    int slice_width_factor = av_log2(mbs_per_slice);

    int num_cblocks, pwidth;

    int plane_factor, is_chroma;



    for (i = 0; i < ctx->num_planes; i++) {

        is_chroma    = (i == 1 || i == 2);

        plane_factor = slice_width_factor + 2;

        if (is_chroma)

            plane_factor += ctx->chroma_factor - 3;

        if (!is_chroma || ctx->chroma_factor == CFACTOR_Y444) {

            xp          = x << 4;

            yp          = y << 4;

            num_cblocks = 4;

            pwidth      = avctx->width;

        } else {

            xp          = x << 3;

            yp          = y << 4;

            num_cblocks = 2;

            pwidth      = avctx->width >> 1;

        }

        src = (const uint16_t*)(pic->data[i] + yp * pic->linesize[i]) + xp;



        get_slice_data(ctx, src, pic->linesize[i], xp, yp,

                       pwidth, avctx->height, ctx->blocks[0],

                       mbs_per_slice, num_cblocks);

        sizes[i] = encode_slice_plane(ctx, pb, src, pic->linesize[i],

                                      mbs_per_slice, ctx->blocks[0],

                                      num_cblocks, plane_factor,

                                      ctx->quants[quant]);

        total_size += sizes[i];

    }

    return total_size;

}

static int encode_slice(AVCodecContext *avctx, const AVFrame *pic,

                        PutBitContext *pb,

                        int sizes[4], int x, int y, int quant,

                        int mbs_per_slice)

{

    ProresContext *ctx = avctx->priv_data;

    int i, xp, yp;

    int total_size = 0;

    const uint16_t *src;

    int slice_width_factor = av_log2(mbs_per_slice);

    int num_cblocks, pwidth;

    int plane_factor, is_chroma;



    for (i = 0; i < ctx->num_planes; i++) {

        is_chroma    = (i == 1 || i == 2);

        plane_factor = slice_width_factor + 2;

        if (is_chroma)

            plane_factor += ctx->chroma_factor - 3;

        if (!is_chroma || ctx->chroma_factor == CFACTOR_Y444) {

            xp          = x << 4;

            yp          = y << 4;

            num_cblocks = 4;

            pwidth      = avctx->width;

        } else {

            xp          = x << 3;

            yp          = y << 4;

            num_cblocks = 2;

            pwidth      = avctx->width >> 1;

        }

        src = (const uint16_t*)(pic->data[i] + yp * pic->linesize[i]) + xp;



        get_slice_data(ctx, src, pic->linesize[i], xp, yp,

                       pwidth, avctx->height, ctx->blocks[0],

                       mbs_per_slice, num_cblocks);

        sizes[i] = encode_slice_plane(ctx, pb, src, pic->linesize[i],

                                      mbs_per_slice, ctx->blocks[0],

                                      num_cblocks, plane_factor,

                                      ctx->quants[quant]);

        total_size += sizes[i];

    }

    return total_size;

}

static int FUNC_0(AVCodecContext *VAR_0, const AVFrame *VAR_1,

                        PutBitContext *VAR_2,

                        int VAR_3[4], int VAR_4, int VAR_5, int VAR_6,

                        int VAR_7)

{

    ProresContext *ctx = VAR_0->priv_data;

    int VAR_8, VAR_9, VAR_10;

    int VAR_11 = 0;

    const uint16_t *VAR_12;

    int VAR_13 = av_log2(VAR_7);

    int VAR_14, VAR_15;

    int VAR_16, VAR_17;



    for (VAR_8 = 0; VAR_8 < ctx->num_planes; VAR_8++) {

        VAR_17    = (VAR_8 == 1 || VAR_8 == 2);

        VAR_16 = VAR_13 + 2;

        if (VAR_17)

            VAR_16 += ctx->chroma_factor - 3;

        if (!VAR_17 || ctx->chroma_factor == CFACTOR_Y444) {

            VAR_9          = VAR_4 << 4;

            VAR_10          = VAR_5 << 4;

            VAR_14 = 4;

            VAR_15      = VAR_0->width;

        } else {

            VAR_9          = VAR_4 << 3;

            VAR_10          = VAR_5 << 4;

            VAR_14 = 2;

            VAR_15      = VAR_0->width >> 1;

        }

        VAR_12 = (const uint16_t*)(VAR_1->data[VAR_8] + VAR_10 * VAR_1->linesize[VAR_8]) + VAR_9;



        get_slice_data(ctx, VAR_12, VAR_1->linesize[VAR_8], VAR_9, VAR_10,

                       VAR_15, VAR_0->height, ctx->blocks[0],

                       VAR_7, VAR_14);

        VAR_3[VAR_8] = encode_slice_plane(ctx, VAR_2, VAR_12, VAR_1->linesize[VAR_8],

                                      VAR_7, ctx->blocks[0],

                                      VAR_14, VAR_16,

                                      ctx->quants[VAR_6]);

        VAR_11 += VAR_3[VAR_8];

    }

    return VAR_11;

}

static int FUNC_0(AVCodecContext *VAR_0, const AVFrame *VAR_1,
PutBitContext *VAR_2,
int VAR_3[4], int VAR_4, int VAR_5, int VAR_6,
int VAR_7)
{ ProresContext *ctx = VAR_0->priv_data; int VAR_8, VAR_9, VAR_10; int VAR_11 = 0; const uint16_t *VAR_12; int VAR_13 = av_log2(VAR_7); int VAR_14, VAR_15; int VAR_16, VAR_17; for (VAR_8 = 0; VAR_8 < ctx->num_planes; VAR_8++) { VAR_17    = (VAR_8 == 1 || VAR_8 == 2); VAR_16 = VAR_13 + 2; if (VAR_17)
VAR_16 += ctx->chroma_factor - 3; if (!VAR_17 || ctx->chroma_factor == CFACTOR_Y444) { VAR_9          = VAR_4 << 4; VAR_10          = VAR_5 << 4; VAR_14 = 4; VAR_15      = VAR_0->width; } else { VAR_9          = VAR_4 << 3; VAR_10          = VAR_5 << 4; VAR_14 = 2; VAR_15      = VAR_0->width >> 1; } VAR_12 = (const uint16_t*)(VAR_1->data[VAR_8] + VAR_10 * VAR_1->linesize[VAR_8]) + VAR_9; get_slice_data(ctx, VAR_12, VAR_1->linesize[VAR_8], VAR_9, VAR_10,
VAR_15, VAR_0->height, ctx->blocks[0],
VAR_7, VAR_14); VAR_3[VAR_8] = encode_slice_plane(ctx, VAR_2, VAR_12, VAR_1->linesize[VAR_8],
VAR_7, ctx->blocks[0],
VAR_14, VAR_16,
ctx->quants[VAR_6]); VAR_11 += VAR_3[VAR_8]; } return VAR_11; }