static int drawgrid_filter_frame(AVFilterLink *inlink, AVFrame *frame)

{

    DrawBoxContext *drawgrid = inlink->dst->priv;

    int plane, x, y;

    uint8_t *row[4];



    if (drawgrid->have_alpha) {

        for (y = 0; y < frame->height; y++) {

            row[0] = frame->data[0] + y * frame->linesize[0];

            row[3] = frame->data[3] + y * frame->linesize[3];



            for (plane = 1; plane < 3; plane++)

                row[plane] = frame->data[plane] +

                     frame->linesize[plane] * (y >> drawgrid->vsub);



            if (drawgrid->invert_color) {

                for (x = 0; x < frame->width; x++)

                    if (pixel_belongs_to_grid(drawgrid, x, y))

                        row[0][x] = 0xff - row[0][x];

            } else {

                for (x = 0; x < frame->width; x++) {

                    if (pixel_belongs_to_grid(drawgrid, x, y)) {

                        row[0][x                  ] = drawgrid->yuv_color[Y];

                        row[1][x >> drawgrid->hsub] = drawgrid->yuv_color[U];

                        row[2][x >> drawgrid->hsub] = drawgrid->yuv_color[V];

                        row[3][x                  ] = drawgrid->yuv_color[A];

                    }

                }

            }

        }

    } else {

        for (y = 0; y < frame->height; y++) {

            row[0] = frame->data[0] + y * frame->linesize[0];



            for (plane = 1; plane < 3; plane++)

                row[plane] = frame->data[plane] +

                     frame->linesize[plane] * (y >> drawgrid->vsub);



            if (drawgrid->invert_color) {

                for (x = 0; x < frame->width; x++)

                    if (pixel_belongs_to_grid(drawgrid, x, y))

                        row[0][x] = 0xff - row[0][x];

            } else {

                for (x = 0; x < frame->width; x++) {

                    double alpha = (double)drawgrid->yuv_color[A] / 255;



                    if (pixel_belongs_to_grid(drawgrid, x, y)) {

                        row[0][x                  ] = (1 - alpha) * row[0][x                  ] + alpha * drawgrid->yuv_color[Y];

                        row[1][x >> drawgrid->hsub] = (1 - alpha) * row[1][x >> drawgrid->hsub] + alpha * drawgrid->yuv_color[U];

                        row[2][x >> drawgrid->hsub] = (1 - alpha) * row[2][x >> drawgrid->hsub] + alpha * drawgrid->yuv_color[V];

                    }

                }

            }

        }

    }



    return ff_filter_frame(inlink->dst->outputs[0], frame);

}

static int drawgrid_filter_frame(AVFilterLink *inlink, AVFrame *frame)

{

    DrawBoxContext *drawgrid = inlink->dst->priv;

    int plane, x, y;

    uint8_t *row[4];



    if (drawgrid->have_alpha) {

        for (y = 0; y < frame->height; y++) {

            row[0] = frame->data[0] + y * frame->linesize[0];

            row[3] = frame->data[3] + y * frame->linesize[3];



            for (plane = 1; plane < 3; plane++)

                row[plane] = frame->data[plane] +

                     frame->linesize[plane] * (y >> drawgrid->vsub);



            if (drawgrid->invert_color) {

                for (x = 0; x < frame->width; x++)

                    if (pixel_belongs_to_grid(drawgrid, x, y))

                        row[0][x] = 0xff - row[0][x];

            } else {

                for (x = 0; x < frame->width; x++) {

                    if (pixel_belongs_to_grid(drawgrid, x, y)) {

                        row[0][x                  ] = drawgrid->yuv_color[Y];

                        row[1][x >> drawgrid->hsub] = drawgrid->yuv_color[U];

                        row[2][x >> drawgrid->hsub] = drawgrid->yuv_color[V];

                        row[3][x                  ] = drawgrid->yuv_color[A];

                    }

                }

            }

        }

    } else {

        for (y = 0; y < frame->height; y++) {

            row[0] = frame->data[0] + y * frame->linesize[0];



            for (plane = 1; plane < 3; plane++)

                row[plane] = frame->data[plane] +

                     frame->linesize[plane] * (y >> drawgrid->vsub);



            if (drawgrid->invert_color) {

                for (x = 0; x < frame->width; x++)

                    if (pixel_belongs_to_grid(drawgrid, x, y))

                        row[0][x] = 0xff - row[0][x];

            } else {

                for (x = 0; x < frame->width; x++) {

                    double alpha = (double)drawgrid->yuv_color[A] / 255;



                    if (pixel_belongs_to_grid(drawgrid, x, y)) {

                        row[0][x                  ] = (1 - alpha) * row[0][x                  ] + alpha * drawgrid->yuv_color[Y];

                        row[1][x >> drawgrid->hsub] = (1 - alpha) * row[1][x >> drawgrid->hsub] + alpha * drawgrid->yuv_color[U];

                        row[2][x >> drawgrid->hsub] = (1 - alpha) * row[2][x >> drawgrid->hsub] + alpha * drawgrid->yuv_color[V];

                    }

                }

            }

        }

    }



    return ff_filter_frame(inlink->dst->outputs[0], frame);

}

    if (drawgrid->have_alpha) {
static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)

{

    DrawBoxContext *drawgrid = VAR_0->dst->priv;

    int VAR_2, VAR_3, VAR_4;

    uint8_t *row[4];



    if (drawgrid->have_alpha) {

        for (VAR_4 = 0; VAR_4 < VAR_1->height; VAR_4++) {

            row[0] = VAR_1->data[0] + VAR_4 * VAR_1->linesize[0];

            row[3] = VAR_1->data[3] + VAR_4 * VAR_1->linesize[3];



            for (VAR_2 = 1; VAR_2 < 3; VAR_2++)

                row[VAR_2] = VAR_1->data[VAR_2] +

                     VAR_1->linesize[VAR_2] * (VAR_4 >> drawgrid->vsub);



            if (drawgrid->invert_color) {

                for (VAR_3 = 0; VAR_3 < VAR_1->width; VAR_3++)

                    if (pixel_belongs_to_grid(drawgrid, VAR_3, VAR_4))

                        row[0][VAR_3] = 0xff - row[0][VAR_3];

            } else {

                for (VAR_3 = 0; VAR_3 < VAR_1->width; VAR_3++) {

                    if (pixel_belongs_to_grid(drawgrid, VAR_3, VAR_4)) {

                        row[0][VAR_3                  ] = drawgrid->yuv_color[Y];

                        row[1][VAR_3 >> drawgrid->hsub] = drawgrid->yuv_color[U];

                        row[2][VAR_3 >> drawgrid->hsub] = drawgrid->yuv_color[V];

                        row[3][VAR_3                  ] = drawgrid->yuv_color[A];

                    }

                }

            }

        }

    } else {

        for (VAR_4 = 0; VAR_4 < VAR_1->height; VAR_4++) {

            row[0] = VAR_1->data[0] + VAR_4 * VAR_1->linesize[0];



            for (VAR_2 = 1; VAR_2 < 3; VAR_2++)

                row[VAR_2] = VAR_1->data[VAR_2] +

                     VAR_1->linesize[VAR_2] * (VAR_4 >> drawgrid->vsub);



            if (drawgrid->invert_color) {

                for (VAR_3 = 0; VAR_3 < VAR_1->width; VAR_3++)

                    if (pixel_belongs_to_grid(drawgrid, VAR_3, VAR_4))

                        row[0][VAR_3] = 0xff - row[0][VAR_3];

            } else {

                for (VAR_3 = 0; VAR_3 < VAR_1->width; VAR_3++) {

                    double alpha = (double)drawgrid->yuv_color[A] / 255;



                    if (pixel_belongs_to_grid(drawgrid, VAR_3, VAR_4)) {

                        row[0][VAR_3                  ] = (1 - alpha) * row[0][VAR_3                  ] + alpha * drawgrid->yuv_color[Y];

                        row[1][VAR_3 >> drawgrid->hsub] = (1 - alpha) * row[1][VAR_3 >> drawgrid->hsub] + alpha * drawgrid->yuv_color[U];

                        row[2][VAR_3 >> drawgrid->hsub] = (1 - alpha) * row[2][VAR_3 >> drawgrid->hsub] + alpha * drawgrid->yuv_color[V];

                    }

                }

            }

        }

    }



    return ff_filter_frame(VAR_0->dst->outputs[0], VAR_1);

}

static int FUNC_0(AVFilterLink *VAR_0, AVFrame *VAR_1)
{ DrawBoxContext *drawgrid = VAR_0->dst->priv; int VAR_2, VAR_3, VAR_4; uint8_t *row[4]; if (drawgrid->have_alpha) { for (VAR_4 = 0; VAR_4 < VAR_1->height; VAR_4++) { row[0] = VAR_1->data[0] + VAR_4 * VAR_1->linesize[0]; row[3] = VAR_1->data[3] + VAR_4 * VAR_1->linesize[3]; for (VAR_2 = 1; VAR_2 < 3; VAR_2++) row[VAR_2] = VAR_1->data[VAR_2] +
VAR_1->linesize[VAR_2] * (VAR_4 >> drawgrid->vsub); if (drawgrid->invert_color) { for (VAR_3 = 0; VAR_3 < VAR_1->width; VAR_3++) if (pixel_belongs_to_grid(drawgrid, VAR_3, VAR_4))
row[0][VAR_3] = 0xff - row[0][VAR_3]; } else { for (VAR_3 = 0; VAR_3 < VAR_1->width; VAR_3++) { if (pixel_belongs_to_grid(drawgrid, VAR_3, VAR_4)) { row[0][VAR_3                  ] = drawgrid->yuv_color[Y]; row[1][VAR_3 >> drawgrid->hsub] = drawgrid->yuv_color[U]; row[2][VAR_3 >> drawgrid->hsub] = drawgrid->yuv_color[V]; row[3][VAR_3                  ] = drawgrid->yuv_color[A]; } } } } } else { for (VAR_4 = 0; VAR_4 < VAR_1->height; VAR_4++) { row[0] = VAR_1->data[0] + VAR_4 * VAR_1->linesize[0]; for (VAR_2 = 1; VAR_2 < 3; VAR_2++) row[VAR_2] = VAR_1->data[VAR_2] +
VAR_1->linesize[VAR_2] * (VAR_4 >> drawgrid->vsub); if (drawgrid->invert_color) { for (VAR_3 = 0; VAR_3 < VAR_1->width; VAR_3++) if (pixel_belongs_to_grid(drawgrid, VAR_3, VAR_4))
row[0][VAR_3] = 0xff - row[0][VAR_3]; } else { for (VAR_3 = 0; VAR_3 < VAR_1->width; VAR_3++) { double alpha = (double)drawgrid->yuv_color[A] / 255; if (pixel_belongs_to_grid(drawgrid, VAR_3, VAR_4)) { row[0][VAR_3                  ] = (1 - alpha) * row[0][VAR_3                  ] + alpha * drawgrid->yuv_color[Y]; row[1][VAR_3 >> drawgrid->hsub] = (1 - alpha) * row[1][VAR_3 >> drawgrid->hsub] + alpha * drawgrid->yuv_color[U]; row[2][VAR_3 >> drawgrid->hsub] = (1 - alpha) * row[2][VAR_3 >> drawgrid->hsub] + alpha * drawgrid->yuv_color[V]; } } } } } return ff_filter_frame(VAR_0->dst->outputs[0], VAR_1); }