[FFmpeg-cvslog] lavfi: make pix_fmt_is_in() in vf_lut.c an internal function

Stefano Sabatini git at videolan.org
Fri Jul 1 12:19:55 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Thu Jun 30 09:51:17 2011 +0200| [7464a53aaa5a241858ffbcb0194d3fc44a7aa441] | committer: Stefano Sabatini

lavfi: make pix_fmt_is_in() in vf_lut.c an internal function

Also generalize it, making it accept ints rather than pixel formats.
Allow factorization.

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

 libavfilter/avfilter.h |    2 +-
 libavfilter/formats.c  |   12 ++++++++++++
 libavfilter/internal.h |    3 +++
 libavfilter/vf_lut.c   |   15 +++------------
 4 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 5d25c72..0b8f2d4 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -27,7 +27,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR  2
 #define LIBAVFILTER_VERSION_MINOR 24
-#define LIBAVFILTER_VERSION_MICRO  0
+#define LIBAVFILTER_VERSION_MICRO  1
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index eccb523..b6e30e7 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -22,6 +22,7 @@
 #include "libavutil/pixdesc.h"
 #include "libavutil/audioconvert.h"
 #include "avfilter.h"
+#include "internal.h"
 
 /**
  * Add all refs from a to ret and destroy a.
@@ -73,6 +74,17 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
     return ret;
 }
 
+int ff_fmt_is_in(int fmt, const int *fmts)
+{
+    const int *p;
+
+    for (p = fmts; *p != -1; p++) {
+        if (fmt == *p)
+            return 1;
+    }
+    return 0;
+}
+
 #define MAKE_FORMAT_LIST()                                              \
     AVFilterFormats *formats;                                           \
     int count = 0;                                                      \
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index be1e9b0..7537565 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -58,4 +58,7 @@ int ff_avfilter_graph_config_formats(AVFilterGraph *graphctx, AVClass *log_ctx);
 /** default handler for freeing audio/video buffer when there are no references left */
 void ff_avfilter_default_free_buffer(AVFilterBuffer *buf);
 
+/** Tell is a format is contained in the provided list terminated by -1. */
+int ff_fmt_is_in(int fmt, const int *fmts);
+
 #endif /* AVFILTER_INTERNAL_H */
diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c
index fdab694..8607ee9 100644
--- a/libavfilter/vf_lut.c
+++ b/libavfilter/vf_lut.c
@@ -28,6 +28,7 @@
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
+#include "internal.h"
 
 static const char *var_names[] = {
     "E",
@@ -165,16 +166,6 @@ static int query_formats(AVFilterContext *ctx)
     return 0;
 }
 
-static int pix_fmt_is_in(enum PixelFormat pix_fmt, enum PixelFormat *pix_fmts)
-{
-    enum PixelFormat *p;
-    for (p = pix_fmts; *p != PIX_FMT_NONE; p++) {
-        if (pix_fmt == *p)
-            return 1;
-    }
-    return 0;
-}
-
 /**
  * Clip value val in the minval - maxval range.
  */
@@ -245,8 +236,8 @@ static int config_props(AVFilterLink *inlink)
     }
 
     lut->is_yuv = lut->is_rgb = 0;
-    if      (pix_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1;
-    else if (pix_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1;
+    if      (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1;
+    else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1;
 
     if (lut->is_rgb) {
         switch (inlink->format) {



More information about the ffmpeg-cvslog mailing list