[FFmpeg-cvslog] lavfi: add negate filter

Stefano Sabatini git at videolan.org
Tue Oct 18 01:57:31 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Sat May 28 22:00:26 2011 +0200| [171868e25a231ff06864e9f37400680148af10b4] | committer: Anton Khirnov

lavfi: add negate filter

This filter is a simple wrapper around the LUT filter.

Signed-off-by: Anton Khirnov <anton at khirnov.net>

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

 doc/filters.texi         |    7 ++++++-
 libavfilter/Makefile     |    1 +
 libavfilter/allfilters.c |    1 +
 libavfilter/avfilter.h   |    2 +-
 libavfilter/vf_lut.c     |   23 +++++++++++++++++++++++
 5 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index f7aacf2..c71fd48 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -813,7 +813,12 @@ format=rgba,lutrgb=a="maxval-minval/2"
 lutyuv=y=gammaval(0.5)
 @end example
 
- at section noformat
+ at section negate
+
+Negate input video.
+
+This filter accepts an integer in input, if non-zero it negates the
+alpha component (if available). The default value in input is 0.
 
 Force libavfilter not to use any of the specified pixel formats for the
 input to the next filter.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 9659fd6..e2285e4 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -36,6 +36,7 @@ OBJS-$(CONFIG_HQDN3D_FILTER)                 += vf_hqdn3d.o
 OBJS-$(CONFIG_LUT_FILTER)                    += vf_lut.o
 OBJS-$(CONFIG_LUTRGB_FILTER)                 += vf_lut.o
 OBJS-$(CONFIG_LUTYUV_FILTER)                 += vf_lut.o
+OBJS-$(CONFIG_NEGATE_FILTER)                 += vf_lut.o
 OBJS-$(CONFIG_NOFORMAT_FILTER)               += vf_format.o
 OBJS-$(CONFIG_NULL_FILTER)                   += vf_null.o
 OBJS-$(CONFIG_OCV_FILTER)                    += vf_libopencv.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 1357322..ba853c7 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -57,6 +57,7 @@ void avfilter_register_all(void)
     REGISTER_FILTER (LUT,         lut,         vf);
     REGISTER_FILTER (LUTRGB,      lutrgb,      vf);
     REGISTER_FILTER (LUTYUV,      lutyuv,      vf);
+    REGISTER_FILTER (NEGATE,      negate,      vf);
     REGISTER_FILTER (NOFORMAT,    noformat,    vf);
     REGISTER_FILTER (NULL,        null,        vf);
     REGISTER_FILTER (OCV,         ocv,         vf);
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index d4c0379..66237c5 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -29,7 +29,7 @@
 #include "libavutil/rational.h"
 
 #define LIBAVFILTER_VERSION_MAJOR  2
-#define LIBAVFILTER_VERSION_MINOR  8
+#define LIBAVFILTER_VERSION_MINOR  9
 #define LIBAVFILTER_VERSION_MICRO  0
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c
index d7fab5e..7f3e913 100644
--- a/libavfilter/vf_lut.c
+++ b/libavfilter/vf_lut.c
@@ -69,6 +69,7 @@ typedef struct {
     int is_rgb, is_yuv;
     int rgba_map[4];
     int step;
+    int negate_alpha; /* only used by negate */
 } LutContext;
 
 #define Y 0
@@ -369,3 +370,25 @@ DEFINE_LUT_FILTER(lutyuv, "Compute and apply a lookup table to the YUV input vid
 #if CONFIG_LUTRGB_FILTER
 DEFINE_LUT_FILTER(lutrgb, "Compute and apply a lookup table to the RGB input video.",     init);
 #endif
+
+#if CONFIG_NEGATE_FILTER
+
+static int negate_init(AVFilterContext *ctx, const char *args, void *opaque)
+{
+    LutContext *lut = ctx->priv;
+    char lut_params[64];
+
+    if (args)
+        sscanf(args, "%d", &lut->negate_alpha);
+
+    av_log(ctx, AV_LOG_DEBUG, "negate_alpha:%d\n", lut->negate_alpha);
+
+    snprintf(lut_params, sizeof(lut_params), "c0=negval:c1=negval:c2=negval:a=%s",
+             lut->negate_alpha ? "negval" : "val");
+
+    return init(ctx, lut_params, opaque);
+}
+
+DEFINE_LUT_FILTER(negate, "Negate input video.", negate_init);
+
+#endif



More information about the ffmpeg-cvslog mailing list