[FFmpeg-devel] [PATCH] lavfi: make pix_fmt_is_in() in vf_lut.c an internal function
Stefano Sabatini
stefano.sabatini-lala at poste.it
Thu Jun 30 10:09:49 CEST 2011
Also generalize it, making it accepts ints rather than pixel formats.
Allow factorization.
---
libavfilter/formats.c | 11 +++++++++++
libavfilter/internal.h | 3 +++
libavfilter/vf_lut.c | 15 +++------------
3 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index eccb523..0d70765 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,16 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
return ret;
}
+int ff_fmt_is_in(int fmt, int *fmts)
+{
+ 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..e5d2b93 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, 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) {
--
1.7.2.5
More information about the ffmpeg-devel
mailing list