Browse code

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.

Stefano Sabatini authored on 2011/06/30 16:51:17
Showing 4 changed files
... ...
@@ -27,7 +27,7 @@
27 27
 
28 28
 #define LIBAVFILTER_VERSION_MAJOR  2
29 29
 #define LIBAVFILTER_VERSION_MINOR 24
30
-#define LIBAVFILTER_VERSION_MICRO  0
30
+#define LIBAVFILTER_VERSION_MICRO  1
31 31
 
32 32
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
33 33
                                                LIBAVFILTER_VERSION_MINOR, \
... ...
@@ -22,6 +22,7 @@
22 22
 #include "libavutil/pixdesc.h"
23 23
 #include "libavutil/audioconvert.h"
24 24
 #include "avfilter.h"
25
+#include "internal.h"
25 26
 
26 27
 /**
27 28
  * Add all refs from a to ret and destroy a.
... ...
@@ -73,6 +74,17 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
73 73
     return ret;
74 74
 }
75 75
 
76
+int ff_fmt_is_in(int fmt, const int *fmts)
77
+{
78
+    const int *p;
79
+
80
+    for (p = fmts; *p != -1; p++) {
81
+        if (fmt == *p)
82
+            return 1;
83
+    }
84
+    return 0;
85
+}
86
+
76 87
 #define MAKE_FORMAT_LIST()                                              \
77 88
     AVFilterFormats *formats;                                           \
78 89
     int count = 0;                                                      \
... ...
@@ -58,4 +58,7 @@ int ff_avfilter_graph_config_formats(AVFilterGraph *graphctx, AVClass *log_ctx);
58 58
 /** default handler for freeing audio/video buffer when there are no references left */
59 59
 void ff_avfilter_default_free_buffer(AVFilterBuffer *buf);
60 60
 
61
+/** Tell is a format is contained in the provided list terminated by -1. */
62
+int ff_fmt_is_in(int fmt, const int *fmts);
63
+
61 64
 #endif /* AVFILTER_INTERNAL_H */
... ...
@@ -28,6 +28,7 @@
28 28
 #include "libavutil/opt.h"
29 29
 #include "libavutil/pixdesc.h"
30 30
 #include "avfilter.h"
31
+#include "internal.h"
31 32
 
32 33
 static const char *var_names[] = {
33 34
     "E",
... ...
@@ -165,16 +166,6 @@ static int query_formats(AVFilterContext *ctx)
165 165
     return 0;
166 166
 }
167 167
 
168
-static int pix_fmt_is_in(enum PixelFormat pix_fmt, enum PixelFormat *pix_fmts)
169
-{
170
-    enum PixelFormat *p;
171
-    for (p = pix_fmts; *p != PIX_FMT_NONE; p++) {
172
-        if (pix_fmt == *p)
173
-            return 1;
174
-    }
175
-    return 0;
176
-}
177
-
178 168
 /**
179 169
  * Clip value val in the minval - maxval range.
180 170
  */
... ...
@@ -245,8 +236,8 @@ static int config_props(AVFilterLink *inlink)
245 245
     }
246 246
 
247 247
     lut->is_yuv = lut->is_rgb = 0;
248
-    if      (pix_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1;
249
-    else if (pix_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1;
248
+    if      (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1;
249
+    else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1;
250 250
 
251 251
     if (lut->is_rgb) {
252 252
         switch (inlink->format) {