Browse code

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>

Michael Niedermayer authored on 2013/04/11 01:11:15
Showing 3 changed files
... ...
@@ -2612,12 +2612,7 @@ FFmpeg was configured with @code{--enable-opencl}. Default value is 0.
2612 2612
 
2613 2613
 Draw a colored box on the input image.
2614 2614
 
2615
-The filter accepts parameters as a list of @var{key}=@var{value}
2616
-pairs, separated by ":". If the key of the first options is omitted,
2617
-the arguments are interpreted according to the syntax
2618
-@option{x}:@option{y}:@option{width}:@option{height}:@option{color}:@option{thickness}.
2619
-
2620
-A description of the accepted options follows.
2615
+This filter accepts the following options:
2621 2616
 
2622 2617
 @table @option
2623 2618
 @item x, y
... ...
@@ -662,6 +662,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
662 662
         !strcmp(filter->filter->name,  "crop"      ) ||
663 663
         !strcmp(filter->filter->name,  "cropdetect") ||
664 664
         !strcmp(filter->filter->name,  "delogo"    ) ||
665
+        !strcmp(filter->filter->name,  "drawbox"   ) ||
665 666
         !strcmp(filter->filter->name,   "format") ||
666 667
         !strcmp(filter->filter->name, "noformat") ||
667 668
         !strcmp(filter->filter->name, "resample")
... ...
@@ -45,25 +45,6 @@ typedef struct {
45 45
     int vsub, hsub;   ///< chroma subsampling
46 46
 } DrawBoxContext;
47 47
 
48
-#define OFFSET(x) offsetof(DrawBoxContext, x)
49
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
50
-
51
-static const AVOption drawbox_options[] = {
52
-    { "x",           "set the box top-left corner x position", OFFSET(x), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGS },
53
-    { "y",           "set the box top-left corner y position", OFFSET(y), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX, FLAGS },
54
-    { "width",       "set the box width",  OFFSET(w), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
55
-    { "w",           "set the box width",  OFFSET(w), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
56
-    { "height",      "set the box height", OFFSET(h), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
57
-    { "h",           "set the box height", OFFSET(h), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
58
-    { "color",       "set the box edge color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS },
59
-    { "c",           "set the box edge color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS },
60
-    { "thickness",   "set the box maximum thickness", OFFSET(thickness), AV_OPT_TYPE_INT, {.i64=4}, 0, INT_MAX, FLAGS },
61
-    { "t",           "set the box maximum thickness", OFFSET(thickness), AV_OPT_TYPE_INT, {.i64=4}, 0, INT_MAX, FLAGS },
62
-    {NULL},
63
-};
64
-
65
-AVFILTER_DEFINE_CLASS(drawbox);
66
-
67 48
 static av_cold int init(AVFilterContext *ctx, const char *args)
68 49
 {
69 50
     DrawBoxContext *drawbox = ctx->priv;
... ...
@@ -151,6 +132,25 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
151 151
     return ff_filter_frame(inlink->dst->outputs[0], frame);
152 152
 }
153 153
 
154
+#define OFFSET(x) offsetof(DrawBoxContext, x)
155
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
156
+
157
+static const AVOption drawbox_options[] = {
158
+    { "x",      "Horizontal position of the left box edge", OFFSET(x),         AV_OPT_TYPE_INT,    { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS },
159
+    { "y",      "Vertical position of the top box edge",    OFFSET(y),         AV_OPT_TYPE_INT,    { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS },
160
+    { "width",  "Width of the box",                         OFFSET(w),         AV_OPT_TYPE_INT,    { .i64 = 0 }, 0,       INT_MAX, FLAGS },
161
+    { "w",      "Width of the box",                         OFFSET(w),         AV_OPT_TYPE_INT,    { .i64 = 0 }, 0,       INT_MAX, FLAGS },
162
+    { "height", "Height of the box",                        OFFSET(h),         AV_OPT_TYPE_INT,    { .i64 = 0 }, 0,       INT_MAX, FLAGS },
163
+    { "h",      "Height of the box",                        OFFSET(h),         AV_OPT_TYPE_INT,    { .i64 = 0 }, 0,       INT_MAX, FLAGS },
164
+    { "color",  "Color of the box",                         OFFSET(color_str), AV_OPT_TYPE_STRING, { .str = "black" }, CHAR_MIN, CHAR_MAX, .flags = FLAGS },
165
+    { "c",      "Color of the box",                         OFFSET(color_str), AV_OPT_TYPE_STRING, { .str = "black" }, CHAR_MIN, CHAR_MAX, .flags = FLAGS },
166
+    { "thickness",   "set the box maximum thickness",       OFFSET(thickness), AV_OPT_TYPE_INT, {.i64=4}, 0, INT_MAX, FLAGS },
167
+    { "t",           "set the box maximum thickness",       OFFSET(thickness), AV_OPT_TYPE_INT, {.i64=4}, 0, INT_MAX, FLAGS },
168
+    { NULL },
169
+};
170
+
171
+AVFILTER_DEFINE_CLASS(drawbox);
172
+
154 173
 static const AVFilterPad avfilter_vf_drawbox_inputs[] = {
155 174
     {
156 175
         .name             = "default",
... ...
@@ -171,17 +171,14 @@ static const AVFilterPad avfilter_vf_drawbox_outputs[] = {
171 171
     { NULL }
172 172
 };
173 173
 
174
-static const char *const shorthand[] = { "x", "y", "w", "h", "color", "thickness", NULL };
175
-
176 174
 AVFilter avfilter_vf_drawbox = {
177 175
     .name      = "drawbox",
178 176
     .description = NULL_IF_CONFIG_SMALL("Draw a colored box on the input video."),
179 177
     .priv_size = sizeof(DrawBoxContext),
178
+    .priv_class = &drawbox_class,
180 179
     .init      = init,
181 180
 
182 181
     .query_formats   = query_formats,
183 182
     .inputs    = avfilter_vf_drawbox_inputs,
184 183
     .outputs   = avfilter_vf_drawbox_outputs,
185
-    .priv_class = &drawbox_class,
186
-    .shorthand = shorthand,
187 184
 };