1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge commit '335c31293baec6e6cf5907bd29840af3de8ff735'

* commit '335c31293baec6e6cf5907bd29840af3de8ff735':
  vf_drawbox: switch to an AVOptions-based system.

Conflicts:
	doc/filters.texi
	libavfilter/vf_drawbox.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-04-10 18:11:15 +02:00
commit 0726d516dc
3 changed files with 22 additions and 29 deletions

View File

@ -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

View File

@ -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")

View File

@ -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,
};