[FFmpeg-cvslog] lavfi/bbox: make min_val user configurable

Paul B Mahol git at videolan.org
Sun May 26 16:01:13 CEST 2013


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun May 26 09:22:02 2013 +0000| [7aa99a69c7a41b3d1a01ea3548ce78dcab211870] | committer: Paul B Mahol

lavfi/bbox: make min_val user configurable

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7aa99a69c7a41b3d1a01ea3548ce78dcab211870
---

 doc/filters.texi      |    7 +++++++
 libavfilter/version.h |    2 +-
 libavfilter/vf_bbox.c |   17 +++++++++++++++--
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 8bb132e..04c97f4 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1925,6 +1925,13 @@ luminance value greater than the minimum allowed value.
 The parameters describing the bounding box are printed on the filter
 log.
 
+The filter accepts the following option:
+
+ at table @option
+ at item min_val
+Set the minimal luminance value. Default is @code{16}.
+ at end table
+
 @section blackdetect
 
 Detect video intervals that are (almost) completely black. Can be
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 9b1c881..acb53a5 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR  3
 #define LIBAVFILTER_VERSION_MINOR  70
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \
diff --git a/libavfilter/vf_bbox.c b/libavfilter/vf_bbox.c
index db73f01..1c28f8c 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,



More information about the ffmpeg-cvslog mailing list