static void set_frame_data(MIContext *mi_ctx, int alpha, AVFrame *avf_out)

{

    int x, y, plane;



    for (plane = 0; plane < mi_ctx->nb_planes; plane++) {

        int width = avf_out->width;

        int height = avf_out->height;

        int chroma = plane == 1 || plane == 2;



        for (y = 0; y < height; y++)

            for (x = 0; x < width; x++) {

                int x_mv, y_mv;

                int weight_sum = 0;

                int i, val = 0;

                Pixel *pixel = &mi_ctx->pixels[x + y * avf_out->width];



                for (i = 0; i < pixel->nb; i++)

                    weight_sum += pixel->weights[i];



                if (!weight_sum || !pixel->nb) {

                    pixel->weights[0] = ALPHA_MAX - alpha;

                    pixel->refs[0] = 1;

                    pixel->mvs[0][0] = 0;

                    pixel->mvs[0][1] = 0;

                    pixel->weights[1] = alpha;

                    pixel->refs[1] = 2;

                    pixel->mvs[1][0] = 0;

                    pixel->mvs[1][1] = 0;

                    pixel->nb = 2;



                    weight_sum = ALPHA_MAX;

                }



                for (i = 0; i < pixel->nb; i++) {

                    Frame *frame = &mi_ctx->frames[pixel->refs[i]];

                    if (chroma) {

                        x_mv = (x >> mi_ctx->chroma_h_shift) + (pixel->mvs[i][0] >> mi_ctx->chroma_h_shift);

                        y_mv = (y >> mi_ctx->chroma_v_shift) + (pixel->mvs[i][1] >> mi_ctx->chroma_v_shift);

                    } else {

                        x_mv = x + pixel->mvs[i][0];

                        y_mv = y + pixel->mvs[i][1];

                    }



                    val += pixel->weights[i] * frame->avf->data[plane][x_mv + y_mv * frame->avf->linesize[plane]];

                }



                val = ROUNDED_DIV(val, weight_sum);



                if (chroma)

                    avf_out->data[plane][(x >> mi_ctx->chroma_h_shift) + (y >> mi_ctx->chroma_v_shift) * avf_out->linesize[plane]] = val;

                else

                    avf_out->data[plane][x + y * avf_out->linesize[plane]] = val;

            }

    }

}

static void set_frame_data(MIContext *mi_ctx, int alpha, AVFrame *avf_out)

{

    int x, y, plane;



    for (plane = 0; plane < mi_ctx->nb_planes; plane++) {

        int width = avf_out->width;

        int height = avf_out->height;

        int chroma = plane == 1 || plane == 2;



        for (y = 0; y < height; y++)

            for (x = 0; x < width; x++) {

                int x_mv, y_mv;

                int weight_sum = 0;

                int i, val = 0;

                Pixel *pixel = &mi_ctx->pixels[x + y * avf_out->width];



                for (i = 0; i < pixel->nb; i++)

                    weight_sum += pixel->weights[i];



                if (!weight_sum || !pixel->nb) {

                    pixel->weights[0] = ALPHA_MAX - alpha;

                    pixel->refs[0] = 1;

                    pixel->mvs[0][0] = 0;

                    pixel->mvs[0][1] = 0;

                    pixel->weights[1] = alpha;

                    pixel->refs[1] = 2;

                    pixel->mvs[1][0] = 0;

                    pixel->mvs[1][1] = 0;

                    pixel->nb = 2;



                    weight_sum = ALPHA_MAX;

                }



                for (i = 0; i < pixel->nb; i++) {

                    Frame *frame = &mi_ctx->frames[pixel->refs[i]];

                    if (chroma) {

                        x_mv = (x >> mi_ctx->chroma_h_shift) + (pixel->mvs[i][0] >> mi_ctx->chroma_h_shift);

                        y_mv = (y >> mi_ctx->chroma_v_shift) + (pixel->mvs[i][1] >> mi_ctx->chroma_v_shift);

                    } else {

                        x_mv = x + pixel->mvs[i][0];

                        y_mv = y + pixel->mvs[i][1];

                    }



                    val += pixel->weights[i] * frame->avf->data[plane][x_mv + y_mv * frame->avf->linesize[plane]];

                }



                val = ROUNDED_DIV(val, weight_sum);



                if (chroma)

                    avf_out->data[plane][(x >> mi_ctx->chroma_h_shift) + (y >> mi_ctx->chroma_v_shift) * avf_out->linesize[plane]] = val;

                else

                    avf_out->data[plane][x + y * avf_out->linesize[plane]] = val;

            }

    }

}

                        x_mv = (x >> mi_ctx->chroma_h_shift) + (pixel->mvs[i][0] >> mi_ctx->chroma_h_shift);                         y_mv = (y >> mi_ctx->chroma_v_shift) + (pixel->mvs[i][1] >> mi_ctx->chroma_v_shift);
static void FUNC_0(MIContext *VAR_0, int VAR_1, AVFrame *VAR_2)

{

    int VAR_3, VAR_4, VAR_5;



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

        int width = VAR_2->width;

        int height = VAR_2->height;

        int chroma = VAR_5 == 1 || VAR_5 == 2;



        for (VAR_4 = 0; VAR_4 < height; VAR_4++)

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

                int x_mv, y_mv;

                int weight_sum = 0;

                int i, val = 0;

                Pixel *pixel = &VAR_0->pixels[VAR_3 + VAR_4 * VAR_2->width];



                for (i = 0; i < pixel->nb; i++)

                    weight_sum += pixel->weights[i];



                if (!weight_sum || !pixel->nb) {

                    pixel->weights[0] = ALPHA_MAX - VAR_1;

                    pixel->refs[0] = 1;

                    pixel->mvs[0][0] = 0;

                    pixel->mvs[0][1] = 0;

                    pixel->weights[1] = VAR_1;

                    pixel->refs[1] = 2;

                    pixel->mvs[1][0] = 0;

                    pixel->mvs[1][1] = 0;

                    pixel->nb = 2;



                    weight_sum = ALPHA_MAX;

                }



                for (i = 0; i < pixel->nb; i++) {

                    Frame *frame = &VAR_0->frames[pixel->refs[i]];

                    if (chroma) {

                        x_mv = (VAR_3 >> VAR_0->chroma_h_shift) + (pixel->mvs[i][0] >> VAR_0->chroma_h_shift);

                        y_mv = (VAR_4 >> VAR_0->chroma_v_shift) + (pixel->mvs[i][1] >> VAR_0->chroma_v_shift);

                    } else {

                        x_mv = VAR_3 + pixel->mvs[i][0];

                        y_mv = VAR_4 + pixel->mvs[i][1];

                    }



                    val += pixel->weights[i] * frame->avf->data[VAR_5][x_mv + y_mv * frame->avf->linesize[VAR_5]];

                }



                val = ROUNDED_DIV(val, weight_sum);



                if (chroma)

                    VAR_2->data[VAR_5][(VAR_3 >> VAR_0->chroma_h_shift) + (VAR_4 >> VAR_0->chroma_v_shift) * VAR_2->linesize[VAR_5]] = val;

                else

                    VAR_2->data[VAR_5][VAR_3 + VAR_4 * VAR_2->linesize[VAR_5]] = val;

            }

    }

}

static void FUNC_0(MIContext *VAR_0, int VAR_1, AVFrame *VAR_2)
{ int VAR_3, VAR_4, VAR_5; for (VAR_5 = 0; VAR_5 < VAR_0->nb_planes; VAR_5++) { int width = VAR_2->width; int height = VAR_2->height; int chroma = VAR_5 == 1 || VAR_5 == 2; for (VAR_4 = 0; VAR_4 < height; VAR_4++) for (VAR_3 = 0; VAR_3 < width; VAR_3++) { int x_mv, y_mv; int weight_sum = 0; int i, val = 0; Pixel *pixel = &VAR_0->pixels[VAR_3 + VAR_4 * VAR_2->width]; for (i = 0; i < pixel->nb; i++) weight_sum += pixel->weights[i]; if (!weight_sum || !pixel->nb) { pixel->weights[0] = ALPHA_MAX - VAR_1; pixel->refs[0] = 1; pixel->mvs[0][0] = 0; pixel->mvs[0][1] = 0; pixel->weights[1] = VAR_1; pixel->refs[1] = 2; pixel->mvs[1][0] = 0; pixel->mvs[1][1] = 0; pixel->nb = 2; weight_sum = ALPHA_MAX; } for (i = 0; i < pixel->nb; i++) { Frame *frame = &VAR_0->frames[pixel->refs[i]]; if (chroma) { x_mv = (VAR_3 >> VAR_0->chroma_h_shift) + (pixel->mvs[i][0] >> VAR_0->chroma_h_shift); y_mv = (VAR_4 >> VAR_0->chroma_v_shift) + (pixel->mvs[i][1] >> VAR_0->chroma_v_shift); } else { x_mv = VAR_3 + pixel->mvs[i][0]; y_mv = VAR_4 + pixel->mvs[i][1]; } val += pixel->weights[i] * frame->avf->data[VAR_5][x_mv + y_mv * frame->avf->linesize[VAR_5]]; } val = ROUNDED_DIV(val, weight_sum); if (chroma)
VAR_2->data[VAR_5][(VAR_3 >> VAR_0->chroma_h_shift) + (VAR_4 >> VAR_0->chroma_v_shift) * VAR_2->linesize[VAR_5]] = val; else
VAR_2->data[VAR_5][VAR_3 + VAR_4 * VAR_2->linesize[VAR_5]] = val; } } }