[FFmpeg-devel] [PATCH] lavfi/swapuv: support all planar yuv pixel formats

Paul B Mahol onemda at gmail.com
Fri Dec 21 22:18:13 CET 2012


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavfilter/vf_swapuv.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_swapuv.c b/libavfilter/vf_swapuv.c
index e7e5e88..efa9fc2 100644
--- a/libavfilter/vf_swapuv.c
+++ b/libavfilter/vf_swapuv.c
@@ -23,6 +23,7 @@
  * swap UV filter
  */
 
+#include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "formats.h"
 #include "internal.h"
@@ -50,16 +51,17 @@ static int filter_frame(AVFilterLink *link, AVFilterBufferRef *inpicref)
 
 static int query_formats(AVFilterContext *ctx)
 {
-    static const enum AVPixelFormat pix_fmts[] = {
-        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVA420P,
-        AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVA444P,
-        AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUVJ440P,
-        AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ422P,
-        AV_PIX_FMT_YUV411P,
-        AV_PIX_FMT_NONE,
-    };
+    AVFilterFormats *formats = NULL;
+    int fmt;
 
-    ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
+    for (fmt = 0; fmt < AV_PIX_FMT_NB; fmt++) {
+        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+        if (!(desc->flags & ~(PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA)) &&
+            desc->nb_components >= 3)
+            ff_add_format(&formats, fmt);
+    }
+
+    ff_set_common_formats(ctx, formats);
     return 0;
 }
 
-- 
1.7.11.4



More information about the ffmpeg-devel mailing list