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