Signed-off-by: Paul B Mahol <onemda@gmail.com>
Paul B Mahol authored on 2013/05/26 18:22:02... | ... |
@@ -1925,6 +1925,13 @@ luminance value greater than the minimum allowed value. |
1925 | 1925 |
The parameters describing the bounding box are printed on the filter |
1926 | 1926 |
log. |
1927 | 1927 |
|
1928 |
+The filter accepts the following option: |
|
1929 |
+ |
|
1930 |
+@table @option |
|
1931 |
+@item min_val |
|
1932 |
+Set the minimal luminance value. Default is @code{16}. |
|
1933 |
+@end table |
|
1934 |
+ |
|
1928 | 1935 |
@section blackdetect |
1929 | 1936 |
|
1930 | 1937 |
Detect video intervals that are (almost) completely black. Can be |
... | ... |
@@ -31,7 +31,7 @@ |
31 | 31 |
|
32 | 32 |
#define LIBAVFILTER_VERSION_MAJOR 3 |
33 | 33 |
#define LIBAVFILTER_VERSION_MINOR 70 |
34 |
-#define LIBAVFILTER_VERSION_MICRO 100 |
|
34 |
+#define LIBAVFILTER_VERSION_MICRO 101 |
|
35 | 35 |
|
36 | 36 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
37 | 37 |
LIBAVFILTER_VERSION_MINOR, \ |
... | ... |
@@ -23,6 +23,7 @@ |
23 | 23 |
* bounding box detection filter |
24 | 24 |
*/ |
25 | 25 |
|
26 |
+#include "libavutil/opt.h" |
|
26 | 27 |
#include "libavutil/pixdesc.h" |
27 | 28 |
#include "libavutil/timestamp.h" |
28 | 29 |
#include "avfilter.h" |
... | ... |
@@ -30,9 +31,20 @@ |
30 | 30 |
#include "internal.h" |
31 | 31 |
|
32 | 32 |
typedef struct { |
33 |
- int unused; |
|
33 |
+ const AVClass *class; |
|
34 |
+ int min_val; |
|
34 | 35 |
} BBoxContext; |
35 | 36 |
|
37 |
+#define OFFSET(x) offsetof(BBoxContext, x) |
|
38 |
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM |
|
39 |
+ |
|
40 |
+static const AVOption bbox_options[] = { |
|
41 |
+ { "min_val", "set minimum luminance value for bounding box", OFFSET(min_val), AV_OPT_TYPE_INT, { .i64 = 16 }, 0, 254, FLAGS }, |
|
42 |
+ { NULL } |
|
43 |
+}; |
|
44 |
+ |
|
45 |
+AVFILTER_DEFINE_CLASS(bbox); |
|
46 |
+ |
|
36 | 47 |
static int query_formats(AVFilterContext *ctx) |
37 | 48 |
{ |
38 | 49 |
static const enum AVPixelFormat pix_fmts[] = { |
... | ... |
@@ -58,7 +70,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) |
58 | 58 |
has_bbox = |
59 | 59 |
ff_calculate_bounding_box(&box, |
60 | 60 |
frame->data[0], frame->linesize[0], |
61 |
- inlink->w, inlink->h, 16); |
|
61 |
+ inlink->w, inlink->h, bbox->min_val); |
|
62 | 62 |
w = box.x2 - box.x1 + 1; |
63 | 63 |
h = box.y2 - box.y1 + 1; |
64 | 64 |
|
... | ... |
@@ -100,6 +112,7 @@ AVFilter avfilter_vf_bbox = { |
100 | 100 |
.name = "bbox", |
101 | 101 |
.description = NULL_IF_CONFIG_SMALL("Compute bounding box for each frame."), |
102 | 102 |
.priv_size = sizeof(BBoxContext), |
103 |
+ .priv_class = &bbox_class, |
|
103 | 104 |
.query_formats = query_formats, |
104 | 105 |
.inputs = bbox_inputs, |
105 | 106 |
.outputs = bbox_outputs, |