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

                            int trellis_node, int x, int y, int mbs_per_slice,

                            ProresThreadData *td)

{

    ProresContext *ctx = avctx->priv_data;

    int i, q, pq, xp, yp;

    const uint16_t *src;

    int slice_width_factor = av_log2(mbs_per_slice);

    int num_cblocks[MAX_PLANES], pwidth;

    int plane_factor[MAX_PLANES], is_chroma[MAX_PLANES];

    const int min_quant = ctx->profile_info->min_quant;

    const int max_quant = ctx->profile_info->max_quant;

    int error, bits, bits_limit;

    int mbs, prev, cur, new_score;

    int slice_bits[TRELLIS_WIDTH], slice_score[TRELLIS_WIDTH];

    int overquant;

    uint16_t *qmat;

    int linesize[4], line_add;



    if (ctx->pictures_per_frame == 1)

        line_add = 0;

    else

        line_add = ctx->cur_picture_idx ^ !pic->top_field_first;

    mbs = x + mbs_per_slice;



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

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

        plane_factor[i] = slice_width_factor + 2;

        if (is_chroma[i])

            plane_factor[i] += ctx->chroma_factor - 3;

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

            xp             = x << 4;

            yp             = y << 4;

            num_cblocks[i] = 4;

            pwidth         = avctx->width;

        } else {

            xp             = x << 3;

            yp             = y << 4;

            num_cblocks[i] = 2;

            pwidth         = avctx->width >> 1;

        }



        linesize[i] = pic->linesize[i] * ctx->pictures_per_frame;

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

                                line_add * pic->linesize[i]) + xp;



        if (i < 3) {

            get_slice_data(ctx, src, linesize[i], xp, yp,

                           pwidth, avctx->height / ctx->pictures_per_frame,

                           td->blocks[i], td->emu_buf,

                           mbs_per_slice, num_cblocks[i], is_chroma[i]);

        } else {

            get_alpha_data(ctx, src, linesize[i], xp, yp,

                           pwidth, avctx->height / ctx->pictures_per_frame,

                           td->blocks[i], mbs_per_slice, ctx->alpha_bits);

        }

    }



    for (q = min_quant; q < max_quant + 2; q++) {

        td->nodes[trellis_node + q].prev_node = -1;

        td->nodes[trellis_node + q].quant     = q;

    }



    // todo: maybe perform coarser quantising to fit into frame size when needed

    for (q = min_quant; q <= max_quant; q++) {

        bits  = 0;

        error = 0;

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

            bits += estimate_slice_plane(ctx, &error, i,

                                         src, linesize[i],

                                         mbs_per_slice,

                                         num_cblocks[i], plane_factor[i],

                                         ctx->quants[q], td);

        }

        if (ctx->alpha_bits)

            bits += estimate_alpha_plane(ctx, &error, src, linesize[3],

                                         mbs_per_slice, q, td->blocks[3]);

        if (bits > 65000 * 8) {

            error = SCORE_LIMIT;

            break;

        }

        slice_bits[q]  = bits;

        slice_score[q] = error;

    }

    if (slice_bits[max_quant] <= ctx->bits_per_mb * mbs_per_slice) {

        slice_bits[max_quant + 1]  = slice_bits[max_quant];

        slice_score[max_quant + 1] = slice_score[max_quant] + 1;

        overquant = max_quant;

    } else {

        for (q = max_quant + 1; q < 128; q++) {

            bits  = 0;

            error = 0;

            if (q < MAX_STORED_Q) {

                qmat = ctx->quants[q];

            } else {

                qmat = td->custom_q;

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

                    qmat[i] = ctx->quant_mat[i] * q;

            }

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

                bits += estimate_slice_plane(ctx, &error, i,

                                             src, linesize[i],

                                             mbs_per_slice,

                                             num_cblocks[i], plane_factor[i],

                                             qmat, td);

            }

            if (ctx->alpha_bits)

                bits += estimate_alpha_plane(ctx, &error, src, linesize[3],

                                             mbs_per_slice, q, td->blocks[3]);

            if (bits <= ctx->bits_per_mb * mbs_per_slice)

                break;

        }



        slice_bits[max_quant + 1]  = bits;

        slice_score[max_quant + 1] = error;

        overquant = q;

    }

    td->nodes[trellis_node + max_quant + 1].quant = overquant;



    bits_limit = mbs * ctx->bits_per_mb;

    for (pq = min_quant; pq < max_quant + 2; pq++) {

        prev = trellis_node - TRELLIS_WIDTH + pq;



        for (q = min_quant; q < max_quant + 2; q++) {

            cur = trellis_node + q;



            bits  = td->nodes[prev].bits + slice_bits[q];

            error = slice_score[q];

            if (bits > bits_limit)

                error = SCORE_LIMIT;



            if (td->nodes[prev].score < SCORE_LIMIT && error < SCORE_LIMIT)

                new_score = td->nodes[prev].score + error;

            else

                new_score = SCORE_LIMIT;

            if (td->nodes[cur].prev_node == -1 ||

                td->nodes[cur].score >= new_score) {



                td->nodes[cur].bits      = bits;

                td->nodes[cur].score     = new_score;

                td->nodes[cur].prev_node = prev;

            }

        }

    }



    error = td->nodes[trellis_node + min_quant].score;

    pq    = trellis_node + min_quant;

    for (q = min_quant + 1; q < max_quant + 2; q++) {

        if (td->nodes[trellis_node + q].score <= error) {

            error = td->nodes[trellis_node + q].score;

            pq    = trellis_node + q;

        }

    }



    return pq;

}

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

                            int trellis_node, int x, int y, int mbs_per_slice,

                            ProresThreadData *td)

{

    ProresContext *ctx = avctx->priv_data;

    int i, q, pq, xp, yp;

    const uint16_t *src;

    int slice_width_factor = av_log2(mbs_per_slice);

    int num_cblocks[MAX_PLANES], pwidth;

    int plane_factor[MAX_PLANES], is_chroma[MAX_PLANES];

    const int min_quant = ctx->profile_info->min_quant;

    const int max_quant = ctx->profile_info->max_quant;

    int error, bits, bits_limit;

    int mbs, prev, cur, new_score;

    int slice_bits[TRELLIS_WIDTH], slice_score[TRELLIS_WIDTH];

    int overquant;

    uint16_t *qmat;

    int linesize[4], line_add;



    if (ctx->pictures_per_frame == 1)

        line_add = 0;

    else

        line_add = ctx->cur_picture_idx ^ !pic->top_field_first;

    mbs = x + mbs_per_slice;



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

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

        plane_factor[i] = slice_width_factor + 2;

        if (is_chroma[i])

            plane_factor[i] += ctx->chroma_factor - 3;

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

            xp             = x << 4;

            yp             = y << 4;

            num_cblocks[i] = 4;

            pwidth         = avctx->width;

        } else {

            xp             = x << 3;

            yp             = y << 4;

            num_cblocks[i] = 2;

            pwidth         = avctx->width >> 1;

        }



        linesize[i] = pic->linesize[i] * ctx->pictures_per_frame;

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

                                line_add * pic->linesize[i]) + xp;



        if (i < 3) {

            get_slice_data(ctx, src, linesize[i], xp, yp,

                           pwidth, avctx->height / ctx->pictures_per_frame,

                           td->blocks[i], td->emu_buf,

                           mbs_per_slice, num_cblocks[i], is_chroma[i]);

        } else {

            get_alpha_data(ctx, src, linesize[i], xp, yp,

                           pwidth, avctx->height / ctx->pictures_per_frame,

                           td->blocks[i], mbs_per_slice, ctx->alpha_bits);

        }

    }



    for (q = min_quant; q < max_quant + 2; q++) {

        td->nodes[trellis_node + q].prev_node = -1;

        td->nodes[trellis_node + q].quant     = q;

    }



    

    for (q = min_quant; q <= max_quant; q++) {

        bits  = 0;

        error = 0;

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

            bits += estimate_slice_plane(ctx, &error, i,

                                         src, linesize[i],

                                         mbs_per_slice,

                                         num_cblocks[i], plane_factor[i],

                                         ctx->quants[q], td);

        }

        if (ctx->alpha_bits)

            bits += estimate_alpha_plane(ctx, &error, src, linesize[3],

                                         mbs_per_slice, q, td->blocks[3]);

        if (bits > 65000 * 8) {

            error = SCORE_LIMIT;

            break;

        }

        slice_bits[q]  = bits;

        slice_score[q] = error;

    }

    if (slice_bits[max_quant] <= ctx->bits_per_mb * mbs_per_slice) {

        slice_bits[max_quant + 1]  = slice_bits[max_quant];

        slice_score[max_quant + 1] = slice_score[max_quant] + 1;

        overquant = max_quant;

    } else {

        for (q = max_quant + 1; q < 128; q++) {

            bits  = 0;

            error = 0;

            if (q < MAX_STORED_Q) {

                qmat = ctx->quants[q];

            } else {

                qmat = td->custom_q;

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

                    qmat[i] = ctx->quant_mat[i] * q;

            }

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

                bits += estimate_slice_plane(ctx, &error, i,

                                             src, linesize[i],

                                             mbs_per_slice,

                                             num_cblocks[i], plane_factor[i],

                                             qmat, td);

            }

            if (ctx->alpha_bits)

                bits += estimate_alpha_plane(ctx, &error, src, linesize[3],

                                             mbs_per_slice, q, td->blocks[3]);

            if (bits <= ctx->bits_per_mb * mbs_per_slice)

                break;

        }



        slice_bits[max_quant + 1]  = bits;

        slice_score[max_quant + 1] = error;

        overquant = q;

    }

    td->nodes[trellis_node + max_quant + 1].quant = overquant;



    bits_limit = mbs * ctx->bits_per_mb;

    for (pq = min_quant; pq < max_quant + 2; pq++) {

        prev = trellis_node - TRELLIS_WIDTH + pq;



        for (q = min_quant; q < max_quant + 2; q++) {

            cur = trellis_node + q;



            bits  = td->nodes[prev].bits + slice_bits[q];

            error = slice_score[q];

            if (bits > bits_limit)

                error = SCORE_LIMIT;



            if (td->nodes[prev].score < SCORE_LIMIT && error < SCORE_LIMIT)

                new_score = td->nodes[prev].score + error;

            else

                new_score = SCORE_LIMIT;

            if (td->nodes[cur].prev_node == -1 ||

                td->nodes[cur].score >= new_score) {



                td->nodes[cur].bits      = bits;

                td->nodes[cur].score     = new_score;

                td->nodes[cur].prev_node = prev;

            }

        }

    }



    error = td->nodes[trellis_node + min_quant].score;

    pq    = trellis_node + min_quant;

    for (q = min_quant + 1; q < max_quant + 2; q++) {

        if (td->nodes[trellis_node + q].score <= error) {

            error = td->nodes[trellis_node + q].score;

            pq    = trellis_node + q;

        }

    }



    return pq;

}

        if (bits > 65000 * 8) {             break;
static int FUNC_0(AVCodecContext *VAR_0, const AVFrame *VAR_1,

                            int VAR_2, int VAR_3, int VAR_4, int VAR_5,

                            ProresThreadData *VAR_6)

{

    ProresContext *ctx = VAR_0->priv_data;

    int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;

    const uint16_t *VAR_12;

    int VAR_13 = av_log2(VAR_5);

    int VAR_14[MAX_PLANES], pwidth;

    int VAR_15[MAX_PLANES], is_chroma[MAX_PLANES];

    const int VAR_16 = ctx->profile_info->VAR_16;

    const int VAR_17 = ctx->profile_info->VAR_17;

    int VAR_18, VAR_19, VAR_20;

    int VAR_21, VAR_22, VAR_23, VAR_24;

    int VAR_25[TRELLIS_WIDTH], slice_score[TRELLIS_WIDTH];

    int VAR_26;

    uint16_t *qmat;

    int VAR_27[4], VAR_28;



    if (ctx->pictures_per_frame == 1)

        VAR_28 = 0;

    else

        VAR_28 = ctx->cur_picture_idx ^ !VAR_1->top_field_first;

    VAR_21 = VAR_3 + VAR_5;



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

        is_chroma[VAR_7]    = (VAR_7 == 1 || VAR_7 == 2);

        VAR_15[VAR_7] = VAR_13 + 2;

        if (is_chroma[VAR_7])

            VAR_15[VAR_7] += ctx->chroma_factor - 3;

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

            VAR_10             = VAR_3 << 4;

            VAR_11             = VAR_4 << 4;

            VAR_14[VAR_7] = 4;

            pwidth         = VAR_0->width;

        } else {

            VAR_10             = VAR_3 << 3;

            VAR_11             = VAR_4 << 4;

            VAR_14[VAR_7] = 2;

            pwidth         = VAR_0->width >> 1;

        }



        VAR_27[VAR_7] = VAR_1->VAR_27[VAR_7] * ctx->pictures_per_frame;

        VAR_12 = (const uint16_t*)(VAR_1->data[VAR_7] + VAR_11 * VAR_27[VAR_7] +

                                VAR_28 * VAR_1->VAR_27[VAR_7]) + VAR_10;



        if (VAR_7 < 3) {

            get_slice_data(ctx, VAR_12, VAR_27[VAR_7], VAR_10, VAR_11,

                           pwidth, VAR_0->height / ctx->pictures_per_frame,

                           VAR_6->blocks[VAR_7], VAR_6->emu_buf,

                           VAR_5, VAR_14[VAR_7], is_chroma[VAR_7]);

        } else {

            get_alpha_data(ctx, VAR_12, VAR_27[VAR_7], VAR_10, VAR_11,

                           pwidth, VAR_0->height / ctx->pictures_per_frame,

                           VAR_6->blocks[VAR_7], VAR_5, ctx->alpha_bits);

        }

    }



    for (VAR_8 = VAR_16; VAR_8 < VAR_17 + 2; VAR_8++) {

        VAR_6->nodes[VAR_2 + VAR_8].prev_node = -1;

        VAR_6->nodes[VAR_2 + VAR_8].quant     = VAR_8;

    }



    

    for (VAR_8 = VAR_16; VAR_8 <= VAR_17; VAR_8++) {

        VAR_19  = 0;

        VAR_18 = 0;

        for (VAR_7 = 0; VAR_7 < ctx->num_planes - !!ctx->alpha_bits; VAR_7++) {

            VAR_19 += estimate_slice_plane(ctx, &VAR_18, VAR_7,

                                         VAR_12, VAR_27[VAR_7],

                                         VAR_5,

                                         VAR_14[VAR_7], VAR_15[VAR_7],

                                         ctx->quants[VAR_8], VAR_6);

        }

        if (ctx->alpha_bits)

            VAR_19 += estimate_alpha_plane(ctx, &VAR_18, VAR_12, VAR_27[3],

                                         VAR_5, VAR_8, VAR_6->blocks[3]);

        if (VAR_19 > 65000 * 8) {

            VAR_18 = SCORE_LIMIT;

            break;

        }

        VAR_25[VAR_8]  = VAR_19;

        slice_score[VAR_8] = VAR_18;

    }

    if (VAR_25[VAR_17] <= ctx->bits_per_mb * VAR_5) {

        VAR_25[VAR_17 + 1]  = VAR_25[VAR_17];

        slice_score[VAR_17 + 1] = slice_score[VAR_17] + 1;

        VAR_26 = VAR_17;

    } else {

        for (VAR_8 = VAR_17 + 1; VAR_8 < 128; VAR_8++) {

            VAR_19  = 0;

            VAR_18 = 0;

            if (VAR_8 < MAX_STORED_Q) {

                qmat = ctx->quants[VAR_8];

            } else {

                qmat = VAR_6->custom_q;

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

                    qmat[VAR_7] = ctx->quant_mat[VAR_7] * VAR_8;

            }

            for (VAR_7 = 0; VAR_7 < ctx->num_planes - !!ctx->alpha_bits; VAR_7++) {

                VAR_19 += estimate_slice_plane(ctx, &VAR_18, VAR_7,

                                             VAR_12, VAR_27[VAR_7],

                                             VAR_5,

                                             VAR_14[VAR_7], VAR_15[VAR_7],

                                             qmat, VAR_6);

            }

            if (ctx->alpha_bits)

                VAR_19 += estimate_alpha_plane(ctx, &VAR_18, VAR_12, VAR_27[3],

                                             VAR_5, VAR_8, VAR_6->blocks[3]);

            if (VAR_19 <= ctx->bits_per_mb * VAR_5)

                break;

        }



        VAR_25[VAR_17 + 1]  = VAR_19;

        slice_score[VAR_17 + 1] = VAR_18;

        VAR_26 = VAR_8;

    }

    VAR_6->nodes[VAR_2 + VAR_17 + 1].quant = VAR_26;



    VAR_20 = VAR_21 * ctx->bits_per_mb;

    for (VAR_9 = VAR_16; VAR_9 < VAR_17 + 2; VAR_9++) {

        VAR_22 = VAR_2 - TRELLIS_WIDTH + VAR_9;



        for (VAR_8 = VAR_16; VAR_8 < VAR_17 + 2; VAR_8++) {

            VAR_23 = VAR_2 + VAR_8;



            VAR_19  = VAR_6->nodes[VAR_22].VAR_19 + VAR_25[VAR_8];

            VAR_18 = slice_score[VAR_8];

            if (VAR_19 > VAR_20)

                VAR_18 = SCORE_LIMIT;



            if (VAR_6->nodes[VAR_22].score < SCORE_LIMIT && VAR_18 < SCORE_LIMIT)

                VAR_24 = VAR_6->nodes[VAR_22].score + VAR_18;

            else

                VAR_24 = SCORE_LIMIT;

            if (VAR_6->nodes[VAR_23].prev_node == -1 ||

                VAR_6->nodes[VAR_23].score >= VAR_24) {



                VAR_6->nodes[VAR_23].VAR_19      = VAR_19;

                VAR_6->nodes[VAR_23].score     = VAR_24;

                VAR_6->nodes[VAR_23].prev_node = VAR_22;

            }

        }

    }



    VAR_18 = VAR_6->nodes[VAR_2 + VAR_16].score;

    VAR_9    = VAR_2 + VAR_16;

    for (VAR_8 = VAR_16 + 1; VAR_8 < VAR_17 + 2; VAR_8++) {

        if (VAR_6->nodes[VAR_2 + VAR_8].score <= VAR_18) {

            VAR_18 = VAR_6->nodes[VAR_2 + VAR_8].score;

            VAR_9    = VAR_2 + VAR_8;

        }

    }



    return VAR_9;

}

static int FUNC_0(AVCodecContext *VAR_0, const AVFrame *VAR_1,
int VAR_2, int VAR_3, int VAR_4, int VAR_5,
ProresThreadData *VAR_6)
{ ProresContext *ctx = VAR_0->priv_data; int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11; const uint16_t *VAR_12; int VAR_13 = av_log2(VAR_5); int VAR_14[MAX_PLANES], pwidth; int VAR_15[MAX_PLANES], is_chroma[MAX_PLANES]; const int VAR_16 = ctx->profile_info->VAR_16; const int VAR_17 = ctx->profile_info->VAR_17; int VAR_18, VAR_19, VAR_20; int VAR_21, VAR_22, VAR_23, VAR_24; int VAR_25[TRELLIS_WIDTH], slice_score[TRELLIS_WIDTH]; int VAR_26; uint16_t *qmat; int VAR_27[4], VAR_28; if (ctx->pictures_per_frame == 1)
VAR_28 = 0; else
VAR_28 = ctx->cur_picture_idx ^ !VAR_1->top_field_first; VAR_21 = VAR_3 + VAR_5; for (VAR_7 = 0; VAR_7 < ctx->num_planes; VAR_7++) { is_chroma[VAR_7]    = (VAR_7 == 1 || VAR_7 == 2); VAR_15[VAR_7] = VAR_13 + 2; if (is_chroma[VAR_7])
VAR_15[VAR_7] += ctx->chroma_factor - 3; if (!is_chroma[VAR_7] || ctx->chroma_factor == CFACTOR_Y444) { VAR_10             = VAR_3 << 4; VAR_11             = VAR_4 << 4; VAR_14[VAR_7] = 4; pwidth         = VAR_0->width; } else { VAR_10             = VAR_3 << 3; VAR_11             = VAR_4 << 4; VAR_14[VAR_7] = 2; pwidth         = VAR_0->width >> 1; } VAR_27[VAR_7] = VAR_1->VAR_27[VAR_7] * ctx->pictures_per_frame; VAR_12 = (const uint16_t*)(VAR_1->data[VAR_7] + VAR_11 * VAR_27[VAR_7] +
VAR_28 * VAR_1->VAR_27[VAR_7]) + VAR_10; if (VAR_7 < 3) { get_slice_data(ctx, VAR_12, VAR_27[VAR_7], VAR_10, VAR_11,
pwidth, VAR_0->height / ctx->pictures_per_frame,
VAR_6->blocks[VAR_7], VAR_6->emu_buf,
VAR_5, VAR_14[VAR_7], is_chroma[VAR_7]); } else { get_alpha_data(ctx, VAR_12, VAR_27[VAR_7], VAR_10, VAR_11,
pwidth, VAR_0->height / ctx->pictures_per_frame,
VAR_6->blocks[VAR_7], VAR_5, ctx->alpha_bits); } } for (VAR_8 = VAR_16; VAR_8 < VAR_17 + 2; VAR_8++) { VAR_6->nodes[VAR_2 + VAR_8].prev_node = -1; VAR_6->nodes[VAR_2 + VAR_8].quant     = VAR_8; } for (VAR_8 = VAR_16; VAR_8 <= VAR_17; VAR_8++) { VAR_19  = 0; VAR_18 = 0; for (VAR_7 = 0; VAR_7 < ctx->num_planes - !!ctx->alpha_bits; VAR_7++) { VAR_19 += estimate_slice_plane(ctx, &VAR_18, VAR_7,
VAR_12, VAR_27[VAR_7],
VAR_5,
VAR_14[VAR_7], VAR_15[VAR_7],
ctx->quants[VAR_8], VAR_6); } if (ctx->alpha_bits)
VAR_19 += estimate_alpha_plane(ctx, &VAR_18, VAR_12, VAR_27[3],
VAR_5, VAR_8, VAR_6->blocks[3]); if (VAR_19 > 65000 * 8) { VAR_18 = SCORE_LIMIT; break; } VAR_25[VAR_8]  = VAR_19; slice_score[VAR_8] = VAR_18; } if (VAR_25[VAR_17] <= ctx->bits_per_mb * VAR_5) { VAR_25[VAR_17 + 1]  = VAR_25[VAR_17]; slice_score[VAR_17 + 1] = slice_score[VAR_17] + 1; VAR_26 = VAR_17; } else { for (VAR_8 = VAR_17 + 1; VAR_8 < 128; VAR_8++) { VAR_19  = 0; VAR_18 = 0; if (VAR_8 < MAX_STORED_Q) { qmat = ctx->quants[VAR_8]; } else { qmat = VAR_6->custom_q; for (VAR_7 = 0; VAR_7 < 64; VAR_7++) qmat[VAR_7] = ctx->quant_mat[VAR_7] * VAR_8; } for (VAR_7 = 0; VAR_7 < ctx->num_planes - !!ctx->alpha_bits; VAR_7++) { VAR_19 += estimate_slice_plane(ctx, &VAR_18, VAR_7,
VAR_12, VAR_27[VAR_7],
VAR_5,
VAR_14[VAR_7], VAR_15[VAR_7],
qmat, VAR_6); } if (ctx->alpha_bits)
VAR_19 += estimate_alpha_plane(ctx, &VAR_18, VAR_12, VAR_27[3],
VAR_5, VAR_8, VAR_6->blocks[3]); if (VAR_19 <= ctx->bits_per_mb * VAR_5)
break; } VAR_25[VAR_17 + 1]  = VAR_19; slice_score[VAR_17 + 1] = VAR_18; VAR_26 = VAR_8; } VAR_6->nodes[VAR_2 + VAR_17 + 1].quant = VAR_26; VAR_20 = VAR_21 * ctx->bits_per_mb; for (VAR_9 = VAR_16; VAR_9 < VAR_17 + 2; VAR_9++) { VAR_22 = VAR_2 - TRELLIS_WIDTH + VAR_9; for (VAR_8 = VAR_16; VAR_8 < VAR_17 + 2; VAR_8++) { VAR_23 = VAR_2 + VAR_8; VAR_19  = VAR_6->nodes[VAR_22].VAR_19 + VAR_25[VAR_8]; VAR_18 = slice_score[VAR_8]; if (VAR_19 > VAR_20)
VAR_18 = SCORE_LIMIT; if (VAR_6->nodes[VAR_22].score < SCORE_LIMIT && VAR_18 < SCORE_LIMIT)
VAR_24 = VAR_6->nodes[VAR_22].score + VAR_18; else
VAR_24 = SCORE_LIMIT; if (VAR_6->nodes[VAR_23].prev_node == -1 ||
VAR_6->nodes[VAR_23].score >= VAR_24) { VAR_6->nodes[VAR_23].VAR_19      = VAR_19; VAR_6->nodes[VAR_23].score     = VAR_24; VAR_6->nodes[VAR_23].prev_node = VAR_22; } } } VAR_18 = VAR_6->nodes[VAR_2 + VAR_16].score; VAR_9    = VAR_2 + VAR_16; for (VAR_8 = VAR_16 + 1; VAR_8 < VAR_17 + 2; VAR_8++) { if (VAR_6->nodes[VAR_2 + VAR_8].score <= VAR_18) { VAR_18 = VAR_6->nodes[VAR_2 + VAR_8].score; VAR_9    = VAR_2 + VAR_8; } } return VAR_9; }