summaryrefslogtreecommitdiff
path: root/libavfilter/vf_bbox.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2013-05-26 09:22:02 +0000
committerPaul B Mahol <onemda@gmail.com>2013-05-26 14:00:09 +0000
commit7aa99a69c7a41b3d1a01ea3548ce78dcab211870 (patch)
tree344764aca4ec2dc044a537ba2175840d24680f94 /libavfilter/vf_bbox.c
parente9c3851d6006f5548d2bb6bfa5711195339f32df (diff)
downloadffmpeg-7aa99a69c7a41b3d1a01ea3548ce78dcab211870.tar.gz
lavfi/bbox: make min_val user configurable
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/vf_bbox.c')
-rw-r--r--libavfilter/vf_bbox.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/libavfilter/vf_bbox.c b/libavfilter/vf_bbox.c
index db73f018bf..1c28f8c13e 100644
--- a/libavfilter/vf_bbox.c
+++ b/libavfilter/vf_bbox.c
@@ -23,6 +23,7 @@
* bounding box detection filter
*/
+#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/timestamp.h"
#include "avfilter.h"
@@ -30,9 +31,20 @@
#include "internal.h"
typedef struct {
- int unused;
+ const AVClass *class;
+ int min_val;
} BBoxContext;
+#define OFFSET(x) offsetof(BBoxContext, x)
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption bbox_options[] = {
+ { "min_val", "set minimum luminance value for bounding box", OFFSET(min_val), AV_OPT_TYPE_INT, { .i64 = 16 }, 0, 254, FLAGS },
+ { NULL }
+};
+
+AVFILTER_DEFINE_CLASS(bbox);
+
static int query_formats(AVFilterContext *ctx)
{
static const enum AVPixelFormat pix_fmts[] = {
@@ -58,7 +70,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
has_bbox =
ff_calculate_bounding_box(&box,
frame->data[0], frame->linesize[0],
- inlink->w, inlink->h, 16);
+ inlink->w, inlink->h, bbox->min_val);
w = box.x2 - box.x1 + 1;
h = box.y2 - box.y1 + 1;
@@ -100,6 +112,7 @@ AVFilter avfilter_vf_bbox = {
.name = "bbox",
.description = NULL_IF_CONFIG_SMALL("Compute bounding box for each frame."),
.priv_size = sizeof(BBoxContext),
+ .priv_class = &bbox_class,
.query_formats = query_formats,
.inputs = bbox_inputs,
.outputs = bbox_outputs,