LCOV - code coverage report
Current view: top level - libavfilter - vf_drawbox.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 72 158 45.6 %
Date: 2017-12-16 13:57:32 Functions: 4 6 66.7 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2008 Affine Systems, Inc (Michael Sullivan, Bobby Impollonia)
       3             :  * Copyright (c) 2013 Andrey Utkin <andrey.krieger.utkin gmail com>
       4             :  *
       5             :  * This file is part of FFmpeg.
       6             :  *
       7             :  * FFmpeg is free software; you can redistribute it and/or
       8             :  * modify it under the terms of the GNU Lesser General Public
       9             :  * License as published by the Free Software Foundation; either
      10             :  * version 2.1 of the License, or (at your option) any later version.
      11             :  *
      12             :  * FFmpeg is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :  * Lesser General Public License for more details.
      16             :  *
      17             :  * You should have received a copy of the GNU Lesser General Public
      18             :  * License along with FFmpeg; if not, write to the Free Software
      19             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      20             :  */
      21             : 
      22             : /**
      23             :  * @file
      24             :  * Box and grid drawing filters. Also a nice template for a filter
      25             :  * that needs to write in the input frame.
      26             :  */
      27             : 
      28             : #include "libavutil/colorspace.h"
      29             : #include "libavutil/common.h"
      30             : #include "libavutil/opt.h"
      31             : #include "libavutil/eval.h"
      32             : #include "libavutil/pixdesc.h"
      33             : #include "libavutil/parseutils.h"
      34             : #include "avfilter.h"
      35             : #include "formats.h"
      36             : #include "internal.h"
      37             : #include "video.h"
      38             : 
      39             : static const char *const var_names[] = {
      40             :     "dar",
      41             :     "hsub", "vsub",
      42             :     "in_h", "ih",      ///< height of the input video
      43             :     "in_w", "iw",      ///< width  of the input video
      44             :     "sar",
      45             :     "x",
      46             :     "y",
      47             :     "h",              ///< height of the rendered box
      48             :     "w",              ///< width  of the rendered box
      49             :     "t",
      50             :     "fill",
      51             :     NULL
      52             : };
      53             : 
      54             : enum { Y, U, V, A };
      55             : 
      56             : enum var_name {
      57             :     VAR_DAR,
      58             :     VAR_HSUB, VAR_VSUB,
      59             :     VAR_IN_H, VAR_IH,
      60             :     VAR_IN_W, VAR_IW,
      61             :     VAR_SAR,
      62             :     VAR_X,
      63             :     VAR_Y,
      64             :     VAR_H,
      65             :     VAR_W,
      66             :     VAR_T,
      67             :     VAR_MAX,
      68             :     VARS_NB
      69             : };
      70             : 
      71             : typedef struct DrawBoxContext {
      72             :     const AVClass *class;
      73             :     int x, y, w, h;
      74             :     int thickness;
      75             :     char *color_str;
      76             :     unsigned char yuv_color[4];
      77             :     int invert_color; ///< invert luma color
      78             :     int vsub, hsub;   ///< chroma subsampling
      79             :     char *x_expr, *y_expr; ///< expression for x and y
      80             :     char *w_expr, *h_expr; ///< expression for width and height
      81             :     char *t_expr;          ///< expression for thickness
      82             :     int have_alpha;
      83             :     int replace;
      84             : } DrawBoxContext;
      85             : 
      86             : static const int NUM_EXPR_EVALS = 5;
      87             : 
      88           1 : static av_cold int init(AVFilterContext *ctx)
      89             : {
      90           1 :     DrawBoxContext *s = ctx->priv;
      91             :     uint8_t rgba_color[4];
      92             : 
      93           1 :     if (!strcmp(s->color_str, "invert"))
      94           0 :         s->invert_color = 1;
      95           1 :     else if (av_parse_color(rgba_color, s->color_str, -1, ctx) < 0)
      96           0 :         return AVERROR(EINVAL);
      97             : 
      98           1 :     if (!s->invert_color) {
      99           1 :         s->yuv_color[Y] = RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
     100           1 :         s->yuv_color[U] = RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
     101           1 :         s->yuv_color[V] = RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
     102           1 :         s->yuv_color[A] = rgba_color[3];
     103             :     }
     104             : 
     105           1 :     return 0;
     106             : }
     107             : 
     108           1 : static int query_formats(AVFilterContext *ctx)
     109             : {
     110             :     static const enum AVPixelFormat pix_fmts[] = {
     111             :         AV_PIX_FMT_YUV444P,  AV_PIX_FMT_YUV422P,  AV_PIX_FMT_YUV420P,
     112             :         AV_PIX_FMT_YUV411P,  AV_PIX_FMT_YUV410P,
     113             :         AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P,
     114             :         AV_PIX_FMT_YUV440P,  AV_PIX_FMT_YUVJ440P,
     115             :         AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
     116             :         AV_PIX_FMT_NONE
     117             :     };
     118           1 :     AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
     119           1 :     if (!fmts_list)
     120           0 :         return AVERROR(ENOMEM);
     121           1 :     return ff_set_common_formats(ctx, fmts_list);
     122             : }
     123             : 
     124           1 : static int config_input(AVFilterLink *inlink)
     125             : {
     126           1 :     AVFilterContext *ctx = inlink->dst;
     127           1 :     DrawBoxContext *s = ctx->priv;
     128           1 :     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
     129             :     double var_values[VARS_NB], res;
     130             :     char *expr;
     131             :     int ret;
     132             :     int i;
     133             : 
     134           1 :     s->hsub = desc->log2_chroma_w;
     135           1 :     s->vsub = desc->log2_chroma_h;
     136           1 :     s->have_alpha = desc->flags & AV_PIX_FMT_FLAG_ALPHA;
     137             : 
     138           1 :     var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h;
     139           1 :     var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w;
     140           1 :     var_values[VAR_SAR]  = inlink->sample_aspect_ratio.num ? av_q2d(inlink->sample_aspect_ratio) : 1;
     141           1 :     var_values[VAR_DAR]  = (double)inlink->w / inlink->h * var_values[VAR_SAR];
     142           1 :     var_values[VAR_HSUB] = s->hsub;
     143           1 :     var_values[VAR_VSUB] = s->vsub;
     144           1 :     var_values[VAR_X] = NAN;
     145           1 :     var_values[VAR_Y] = NAN;
     146           1 :     var_values[VAR_H] = NAN;
     147           1 :     var_values[VAR_W] = NAN;
     148           1 :     var_values[VAR_T] = NAN;
     149             : 
     150           7 :     for (i = 0; i <= NUM_EXPR_EVALS; i++) {
     151             :         /* evaluate expressions, fail on last iteration */
     152           6 :         var_values[VAR_MAX] = inlink->w;
     153           6 :         if ((ret = av_expr_parse_and_eval(&res, (expr = s->x_expr),
     154             :                                           var_names, var_values,
     155           0 :                                           NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS)
     156           0 :             goto fail;
     157           6 :         s->x = var_values[VAR_X] = res;
     158             : 
     159           6 :         var_values[VAR_MAX] = inlink->h;
     160           6 :         if ((ret = av_expr_parse_and_eval(&res, (expr = s->y_expr),
     161             :                                           var_names, var_values,
     162           0 :                                           NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS)
     163           0 :             goto fail;
     164           6 :         s->y = var_values[VAR_Y] = res;
     165             : 
     166           6 :         var_values[VAR_MAX] = inlink->w - s->x;
     167           6 :         if ((ret = av_expr_parse_and_eval(&res, (expr = s->w_expr),
     168             :                                           var_names, var_values,
     169           0 :                                           NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS)
     170           0 :             goto fail;
     171           6 :         s->w = var_values[VAR_W] = res;
     172             : 
     173           6 :         var_values[VAR_MAX] = inlink->h - s->y;
     174           6 :         if ((ret = av_expr_parse_and_eval(&res, (expr = s->h_expr),
     175             :                                           var_names, var_values,
     176           0 :                                           NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS)
     177           0 :             goto fail;
     178           6 :         s->h = var_values[VAR_H] = res;
     179             : 
     180           6 :         var_values[VAR_MAX] = INT_MAX;
     181           6 :         if ((ret = av_expr_parse_and_eval(&res, (expr = s->t_expr),
     182             :                                           var_names, var_values,
     183           0 :                                           NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i == NUM_EXPR_EVALS)
     184           0 :             goto fail;
     185           6 :         s->thickness = var_values[VAR_T] = res;
     186             :     }
     187             : 
     188             :     /* if w or h are zero, use the input w/h */
     189           1 :     s->w = (s->w > 0) ? s->w : inlink->w;
     190           1 :     s->h = (s->h > 0) ? s->h : inlink->h;
     191             : 
     192             :     /* sanity check width and height */
     193           1 :     if (s->w <  0 || s->h <  0) {
     194           0 :         av_log(ctx, AV_LOG_ERROR, "Size values less than 0 are not acceptable.\n");
     195           0 :         return AVERROR(EINVAL);
     196             :     }
     197             : 
     198           4 :     av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d w:%d h:%d color:0x%02X%02X%02X%02X\n",
     199             :            s->x, s->y, s->w, s->h,
     200           4 :            s->yuv_color[Y], s->yuv_color[U], s->yuv_color[V], s->yuv_color[A]);
     201             : 
     202           1 :     return 0;
     203             : 
     204           0 : fail:
     205           0 :     av_log(ctx, AV_LOG_ERROR,
     206             :            "Error when evaluating the expression '%s'.\n",
     207             :            expr);
     208           0 :     return ret;
     209             : }
     210             : 
     211          50 : static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     212             : {
     213          50 :     DrawBoxContext *s = inlink->dst->priv;
     214          50 :     int plane, x, y, xb = s->x, yb = s->y;
     215             :     unsigned char *row[4];
     216             : 
     217          50 :     if (s->have_alpha && s->replace) {
     218           0 :         for (y = FFMAX(yb, 0); y < frame->height && y < (yb + s->h); y++) {
     219           0 :             row[0] = frame->data[0] + y * frame->linesize[0];
     220           0 :             row[3] = frame->data[3] + y * frame->linesize[3];
     221             : 
     222           0 :             for (plane = 1; plane < 3; plane++)
     223           0 :                 row[plane] = frame->data[plane] +
     224           0 :                      frame->linesize[plane] * (y >> s->vsub);
     225             : 
     226           0 :             if (s->invert_color) {
     227           0 :                 for (x = FFMAX(xb, 0); x < xb + s->w && x < frame->width; x++)
     228           0 :                     if ((y - yb < s->thickness) || (yb + s->h - 1 - y < s->thickness) ||
     229           0 :                         (x - xb < s->thickness) || (xb + s->w - 1 - x < s->thickness))
     230           0 :                         row[0][x] = 0xff - row[0][x];
     231             :             } else {
     232           0 :                 for (x = FFMAX(xb, 0); x < xb + s->w && x < frame->width; x++) {
     233           0 :                     if ((y - yb < s->thickness) || (yb + s->h - 1 - y < s->thickness) ||
     234           0 :                         (x - xb < s->thickness) || (xb + s->w - 1 - x < s->thickness)) {
     235           0 :                         row[0][x           ] = s->yuv_color[Y];
     236           0 :                         row[1][x >> s->hsub] = s->yuv_color[U];
     237           0 :                         row[2][x >> s->hsub] = s->yuv_color[V];
     238           0 :                         row[3][x           ] = s->yuv_color[A];
     239             :                     }
     240             :                 }
     241             :             }
     242             :         }
     243             :     } else {
     244        3650 :         for (y = FFMAX(yb, 0); y < frame->height && y < (yb + s->h); y++) {
     245        3600 :             row[0] = frame->data[0] + y * frame->linesize[0];
     246             : 
     247       10800 :             for (plane = 1; plane < 3; plane++)
     248       14400 :                 row[plane] = frame->data[plane] +
     249        7200 :                      frame->linesize[plane] * (y >> s->vsub);
     250             : 
     251        3600 :             if (s->invert_color) {
     252           0 :                 for (x = FFMAX(xb, 0); x < xb + s->w && x < frame->width; x++)
     253           0 :                     if ((y - yb < s->thickness) || (yb + s->h - 1 - y < s->thickness) ||
     254           0 :                         (x - xb < s->thickness) || (xb + s->w - 1 - x < s->thickness))
     255           0 :                         row[0][x] = 0xff - row[0][x];
     256             :             } else {
     257      320400 :                 for (x = FFMAX(xb, 0); x < xb + s->w && x < frame->width; x++) {
     258      316800 :                     double alpha = (double)s->yuv_color[A] / 255;
     259             : 
     260      607200 :                     if ((y - yb < s->thickness) || (yb + s->h - 1 - y < s->thickness) ||
     261      570900 :                         (x - xb < s->thickness) || (xb + s->w - 1 - x < s->thickness)) {
     262       46200 :                         row[0][x                 ] = (1 - alpha) * row[0][x                 ] + alpha * s->yuv_color[Y];
     263       46200 :                         row[1][x >> s->hsub] = (1 - alpha) * row[1][x >> s->hsub] + alpha * s->yuv_color[U];
     264       46200 :                         row[2][x >> s->hsub] = (1 - alpha) * row[2][x >> s->hsub] + alpha * s->yuv_color[V];
     265             :                     }
     266             :                 }
     267             :             }
     268             :         }
     269             :     }
     270             : 
     271          50 :     return ff_filter_frame(inlink->dst->outputs[0], frame);
     272             : }
     273             : 
     274             : #define OFFSET(x) offsetof(DrawBoxContext, x)
     275             : #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
     276             : 
     277             : #if CONFIG_DRAWBOX_FILTER
     278             : 
     279             : static const AVOption drawbox_options[] = {
     280             :     { "x",         "set horizontal position of the left box edge", OFFSET(x_expr),    AV_OPT_TYPE_STRING, { .str="0" },       CHAR_MIN, CHAR_MAX, FLAGS },
     281             :     { "y",         "set vertical position of the top box edge",    OFFSET(y_expr),    AV_OPT_TYPE_STRING, { .str="0" },       CHAR_MIN, CHAR_MAX, FLAGS },
     282             :     { "width",     "set width of the box",                         OFFSET(w_expr),    AV_OPT_TYPE_STRING, { .str="0" },       CHAR_MIN, CHAR_MAX, FLAGS },
     283             :     { "w",         "set width of the box",                         OFFSET(w_expr),    AV_OPT_TYPE_STRING, { .str="0" },       CHAR_MIN, CHAR_MAX, FLAGS },
     284             :     { "height",    "set height of the box",                        OFFSET(h_expr),    AV_OPT_TYPE_STRING, { .str="0" },       CHAR_MIN, CHAR_MAX, FLAGS },
     285             :     { "h",         "set height of the box",                        OFFSET(h_expr),    AV_OPT_TYPE_STRING, { .str="0" },       CHAR_MIN, CHAR_MAX, FLAGS },
     286             :     { "color",     "set color of the box",                         OFFSET(color_str), AV_OPT_TYPE_STRING, { .str = "black" }, CHAR_MIN, CHAR_MAX, FLAGS },
     287             :     { "c",         "set color of the box",                         OFFSET(color_str), AV_OPT_TYPE_STRING, { .str = "black" }, CHAR_MIN, CHAR_MAX, FLAGS },
     288             :     { "thickness", "set the box thickness",                        OFFSET(t_expr),    AV_OPT_TYPE_STRING, { .str="3" },       CHAR_MIN, CHAR_MAX, FLAGS },
     289             :     { "t",         "set the box thickness",                        OFFSET(t_expr),    AV_OPT_TYPE_STRING, { .str="3" },       CHAR_MIN, CHAR_MAX, FLAGS },
     290             :     { "replace",   "replace color & alpha",                        OFFSET(replace),   AV_OPT_TYPE_BOOL,   { .i64=0 },         0,        1,        FLAGS },
     291             :     { NULL }
     292             : };
     293             : 
     294             : AVFILTER_DEFINE_CLASS(drawbox);
     295             : 
     296             : static const AVFilterPad drawbox_inputs[] = {
     297             :     {
     298             :         .name           = "default",
     299             :         .type           = AVMEDIA_TYPE_VIDEO,
     300             :         .config_props   = config_input,
     301             :         .filter_frame   = filter_frame,
     302             :         .needs_writable = 1,
     303             :     },
     304             :     { NULL }
     305             : };
     306             : 
     307             : static const AVFilterPad drawbox_outputs[] = {
     308             :     {
     309             :         .name = "default",
     310             :         .type = AVMEDIA_TYPE_VIDEO,
     311             :     },
     312             :     { NULL }
     313             : };
     314             : 
     315             : AVFilter ff_vf_drawbox = {
     316             :     .name          = "drawbox",
     317             :     .description   = NULL_IF_CONFIG_SMALL("Draw a colored box on the input video."),
     318             :     .priv_size     = sizeof(DrawBoxContext),
     319             :     .priv_class    = &drawbox_class,
     320             :     .init          = init,
     321             :     .query_formats = query_formats,
     322             :     .inputs        = drawbox_inputs,
     323             :     .outputs       = drawbox_outputs,
     324             :     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
     325             : };
     326             : #endif /* CONFIG_DRAWBOX_FILTER */
     327             : 
     328             : #if CONFIG_DRAWGRID_FILTER
     329           0 : static av_pure av_always_inline int pixel_belongs_to_grid(DrawBoxContext *drawgrid, int x, int y)
     330             : {
     331             :     // x is horizontal (width) coord,
     332             :     // y is vertical (height) coord
     333             :     int x_modulo;
     334             :     int y_modulo;
     335             : 
     336             :     // Abstract from the offset
     337           0 :     x -= drawgrid->x;
     338           0 :     y -= drawgrid->y;
     339             : 
     340           0 :     x_modulo = x % drawgrid->w;
     341           0 :     y_modulo = y % drawgrid->h;
     342             : 
     343             :     // If x or y got negative, fix values to preserve logics
     344           0 :     if (x_modulo < 0)
     345           0 :         x_modulo += drawgrid->w;
     346           0 :     if (y_modulo < 0)
     347           0 :         y_modulo += drawgrid->h;
     348             : 
     349           0 :     return x_modulo < drawgrid->thickness  // Belongs to vertical line
     350           0 :         || y_modulo < drawgrid->thickness;  // Belongs to horizontal line
     351             : }
     352             : 
     353           0 : static int drawgrid_filter_frame(AVFilterLink *inlink, AVFrame *frame)
     354             : {
     355           0 :     DrawBoxContext *drawgrid = inlink->dst->priv;
     356             :     int plane, x, y;
     357             :     uint8_t *row[4];
     358             : 
     359           0 :     if (drawgrid->have_alpha && drawgrid->replace) {
     360           0 :         for (y = 0; y < frame->height; y++) {
     361           0 :             row[0] = frame->data[0] + y * frame->linesize[0];
     362           0 :             row[3] = frame->data[3] + y * frame->linesize[3];
     363             : 
     364           0 :             for (plane = 1; plane < 3; plane++)
     365           0 :                 row[plane] = frame->data[plane] +
     366           0 :                      frame->linesize[plane] * (y >> drawgrid->vsub);
     367             : 
     368           0 :             if (drawgrid->invert_color) {
     369           0 :                 for (x = 0; x < frame->width; x++)
     370           0 :                     if (pixel_belongs_to_grid(drawgrid, x, y))
     371           0 :                         row[0][x] = 0xff - row[0][x];
     372             :             } else {
     373           0 :                 for (x = 0; x < frame->width; x++) {
     374           0 :                     if (pixel_belongs_to_grid(drawgrid, x, y)) {
     375           0 :                         row[0][x                  ] = drawgrid->yuv_color[Y];
     376           0 :                         row[1][x >> drawgrid->hsub] = drawgrid->yuv_color[U];
     377           0 :                         row[2][x >> drawgrid->hsub] = drawgrid->yuv_color[V];
     378           0 :                         row[3][x                  ] = drawgrid->yuv_color[A];
     379             :                     }
     380             :                 }
     381             :             }
     382             :         }
     383             :     } else {
     384           0 :         for (y = 0; y < frame->height; y++) {
     385           0 :             row[0] = frame->data[0] + y * frame->linesize[0];
     386             : 
     387           0 :             for (plane = 1; plane < 3; plane++)
     388           0 :                 row[plane] = frame->data[plane] +
     389           0 :                      frame->linesize[plane] * (y >> drawgrid->vsub);
     390             : 
     391           0 :             if (drawgrid->invert_color) {
     392           0 :                 for (x = 0; x < frame->width; x++)
     393           0 :                     if (pixel_belongs_to_grid(drawgrid, x, y))
     394           0 :                         row[0][x] = 0xff - row[0][x];
     395             :             } else {
     396           0 :                 for (x = 0; x < frame->width; x++) {
     397           0 :                     double alpha = (double)drawgrid->yuv_color[A] / 255;
     398             : 
     399           0 :                     if (pixel_belongs_to_grid(drawgrid, x, y)) {
     400           0 :                         row[0][x                  ] = (1 - alpha) * row[0][x                  ] + alpha * drawgrid->yuv_color[Y];
     401           0 :                         row[1][x >> drawgrid->hsub] = (1 - alpha) * row[1][x >> drawgrid->hsub] + alpha * drawgrid->yuv_color[U];
     402           0 :                         row[2][x >> drawgrid->hsub] = (1 - alpha) * row[2][x >> drawgrid->hsub] + alpha * drawgrid->yuv_color[V];
     403             :                     }
     404             :                 }
     405             :             }
     406             :         }
     407             :     }
     408             : 
     409           0 :     return ff_filter_frame(inlink->dst->outputs[0], frame);
     410             : }
     411             : 
     412             : static const AVOption drawgrid_options[] = {
     413             :     { "x",         "set horizontal offset",   OFFSET(x_expr),    AV_OPT_TYPE_STRING, { .str="0" },       CHAR_MIN, CHAR_MAX, FLAGS },
     414             :     { "y",         "set vertical offset",     OFFSET(y_expr),    AV_OPT_TYPE_STRING, { .str="0" },       CHAR_MIN, CHAR_MAX, FLAGS },
     415             :     { "width",     "set width of grid cell",  OFFSET(w_expr),    AV_OPT_TYPE_STRING, { .str="0" },       CHAR_MIN, CHAR_MAX, FLAGS },
     416             :     { "w",         "set width of grid cell",  OFFSET(w_expr),    AV_OPT_TYPE_STRING, { .str="0" },       CHAR_MIN, CHAR_MAX, FLAGS },
     417             :     { "height",    "set height of grid cell", OFFSET(h_expr),    AV_OPT_TYPE_STRING, { .str="0" },       CHAR_MIN, CHAR_MAX, FLAGS },
     418             :     { "h",         "set height of grid cell", OFFSET(h_expr),    AV_OPT_TYPE_STRING, { .str="0" },       CHAR_MIN, CHAR_MAX, FLAGS },
     419             :     { "color",     "set color of the grid",   OFFSET(color_str), AV_OPT_TYPE_STRING, { .str = "black" }, CHAR_MIN, CHAR_MAX, FLAGS },
     420             :     { "c",         "set color of the grid",   OFFSET(color_str), AV_OPT_TYPE_STRING, { .str = "black" }, CHAR_MIN, CHAR_MAX, FLAGS },
     421             :     { "thickness", "set grid line thickness", OFFSET(t_expr),    AV_OPT_TYPE_STRING, {.str="1"},         CHAR_MIN, CHAR_MAX, FLAGS },
     422             :     { "t",         "set grid line thickness", OFFSET(t_expr),    AV_OPT_TYPE_STRING, {.str="1"},         CHAR_MIN, CHAR_MAX, FLAGS },
     423             :     { "replace",   "replace color & alpha",   OFFSET(replace),   AV_OPT_TYPE_BOOL,   { .i64=0 },         0,        1,        FLAGS },
     424             :     { NULL }
     425             : };
     426             : 
     427             : AVFILTER_DEFINE_CLASS(drawgrid);
     428             : 
     429             : static const AVFilterPad drawgrid_inputs[] = {
     430             :     {
     431             :         .name           = "default",
     432             :         .type           = AVMEDIA_TYPE_VIDEO,
     433             :         .config_props   = config_input,
     434             :         .filter_frame   = drawgrid_filter_frame,
     435             :         .needs_writable = 1,
     436             :     },
     437             :     { NULL }
     438             : };
     439             : 
     440             : static const AVFilterPad drawgrid_outputs[] = {
     441             :     {
     442             :         .name = "default",
     443             :         .type = AVMEDIA_TYPE_VIDEO,
     444             :     },
     445             :     { NULL }
     446             : };
     447             : 
     448             : AVFilter ff_vf_drawgrid = {
     449             :     .name          = "drawgrid",
     450             :     .description   = NULL_IF_CONFIG_SMALL("Draw a colored grid on the input video."),
     451             :     .priv_size     = sizeof(DrawBoxContext),
     452             :     .priv_class    = &drawgrid_class,
     453             :     .init          = init,
     454             :     .query_formats = query_formats,
     455             :     .inputs        = drawgrid_inputs,
     456             :     .outputs       = drawgrid_outputs,
     457             :     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
     458             : };
     459             : 
     460             : #endif  /* CONFIG_DRAWGRID_FILTER */

Generated by: LCOV version 1.13