Also generalize it, making it accept ints rather than pixel formats. Allow factorization.
Unified · Split
| @@ -27,7 +27,7 @@ · 26 unmodified lines | ||
| 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 @@ · 21 unmodified lines | ||
| 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) · 45 unmodified lines | ||
| 73 | 74 | return ret; |
| 74 | 75 | } |
| 75 | 76 | |
| 77 | +int ff_fmt_is_in(int fmt, const int *fmts) | |
| 78 | +{ | |
| 79 | + const int *p; | |
| 80 | + | |
| 81 | + for (p = fmts; *p != -1; p++) { | |
| 82 | + if (fmt == *p) | |
| 83 | + return 1; | |
| 84 | + } | |
| 85 | + return 0; | |
| 86 | +} | |
| 87 | + | |
| 76 | 88 | #define MAKE_FORMAT_LIST() \ |
| 77 | 89 | AVFilterFormats *formats; \ |
| 78 | 90 | int count = 0; \ |
| @@ -58,4 +58,7 @@ int ff_avfilter_graph_config_formats(AVFilterGraph *graphctx, AVClass *log_ctx); · 57 unmodified lines | ||
| 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 @@ · 27 unmodified lines | ||
| 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) · 131 unmodified lines | ||
| 165 | 166 | return 0; |
| 166 | 167 | } |
| 167 | 168 | |
| 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 | 169 | /** |
| 179 | 170 | * Clip value val in the minval - maxval range. |
| 180 | 171 | */ |
| @@ -245,8 +236,8 @@ static int config_props(AVFilterLink *inlink) · 64 unmodified lines | ||
| 245 | 236 | } |
| 246 | 237 | |
| 247 | 238 | 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; | |
| 239 | + if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1; | |
| 240 | + else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1; | |
| 250 | 241 | |
| 251 | 242 | if (lut->is_rgb) { |
| 252 | 243 | switch (inlink->format) { |