diff --git a/doc/filters.texi b/doc/filters.texi index 158b74b3ae038dbfb2669bb72d935e4b7125d6f0..d2a3479ac6074d9b5c1baef3d562759d6191c169 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2612,12 +2612,7 @@ FFmpeg was configured with @code{--enable-opencl}. Default value is 0. Draw a colored box on the input image. -The filter accepts parameters as a list of @var{key}=@var{value} -pairs, separated by ":". If the key of the first options is omitted, -the arguments are interpreted according to the syntax -@option{x}:@option{y}:@option{width}:@option{height}:@option{color}:@option{thickness}. - -A description of the accepted options follows. +This filter accepts the following options: @table @option @item x, y diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 1433422f3d63e02604963b9b563546a84e817d3d..efe378c9896cb55a9f8e475044bc7aaba2e37a7e 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -662,6 +662,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "crop" ) || !strcmp(filter->filter->name, "cropdetect") || !strcmp(filter->filter->name, "delogo" ) || + !strcmp(filter->filter->name, "drawbox" ) || !strcmp(filter->filter->name, "format") || !strcmp(filter->filter->name, "noformat") || !strcmp(filter->filter->name, "resample") diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c index b831182c8b548964356e55ae31fb9241d12af546..c575b2fa56e049d8e9ae92c444c464683de227de 100644 --- a/libavfilter/vf_drawbox.c +++ b/libavfilter/vf_drawbox.c @@ -45,25 +45,6 @@ typedef struct { int vsub, hsub; ///< chroma subsampling } DrawBoxContext; -#define OFFSET(x) offsetof(DrawBoxContext, x) -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM - -static const AVOption drawbox_options[] = { - { "x", "set the box top-left corner x position", OFFSET(x), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGS }, - { "y", "set the box top-left corner y position", OFFSET(y), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGS }, - { "width", "set the box width", OFFSET(w), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS }, - { "w", "set the box width", OFFSET(w), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS }, - { "height", "set the box height", OFFSET(h), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS }, - { "h", "set the box height", OFFSET(h), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS }, - { "color", "set the box edge color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS }, - { "c", "set the box edge color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS }, - { "thickness", "set the box maximum thickness", OFFSET(thickness), AV_OPT_TYPE_INT, {.i64=4}, 0, INT_MAX, FLAGS }, - { "t", "set the box maximum thickness", OFFSET(thickness), AV_OPT_TYPE_INT, {.i64=4}, 0, INT_MAX, FLAGS }, - {NULL}, -}; - -AVFILTER_DEFINE_CLASS(drawbox); - static av_cold int init(AVFilterContext *ctx, const char *args) { DrawBoxContext *drawbox = ctx->priv; @@ -151,6 +132,25 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) return ff_filter_frame(inlink->dst->outputs[0], frame); } +#define OFFSET(x) offsetof(DrawBoxContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption drawbox_options[] = { + { "x", "Horizontal position of the left box edge", OFFSET(x), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS }, + { "y", "Vertical position of the top box edge", OFFSET(y), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS }, + { "width", "Width of the box", OFFSET(w), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, + { "w", "Width of the box", OFFSET(w), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, + { "height", "Height of the box", OFFSET(h), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, + { "h", "Height of the box", OFFSET(h), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, + { "color", "Color of the box", OFFSET(color_str), AV_OPT_TYPE_STRING, { .str = "black" }, CHAR_MIN, CHAR_MAX, .flags = FLAGS }, + { "c", "Color of the box", OFFSET(color_str), AV_OPT_TYPE_STRING, { .str = "black" }, CHAR_MIN, CHAR_MAX, .flags = FLAGS }, + { "thickness", "set the box maximum thickness", OFFSET(thickness), AV_OPT_TYPE_INT, {.i64=4}, 0, INT_MAX, FLAGS }, + { "t", "set the box maximum thickness", OFFSET(thickness), AV_OPT_TYPE_INT, {.i64=4}, 0, INT_MAX, FLAGS }, + { NULL }, +}; + +AVFILTER_DEFINE_CLASS(drawbox); + static const AVFilterPad avfilter_vf_drawbox_inputs[] = { { .name = "default", @@ -171,17 +171,14 @@ static const AVFilterPad avfilter_vf_drawbox_outputs[] = { { NULL } }; -static const char *const shorthand[] = { "x", "y", "w", "h", "color", "thickness", NULL }; - AVFilter avfilter_vf_drawbox = { .name = "drawbox", .description = NULL_IF_CONFIG_SMALL("Draw a colored box on the input video."), .priv_size = sizeof(DrawBoxContext), + .priv_class = &drawbox_class, .init = init, .query_formats = query_formats, .inputs = avfilter_vf_drawbox_inputs, .outputs = avfilter_vf_drawbox_outputs, - .priv_class = &drawbox_class, - .shorthand = shorthand, };