[FFmpeg-cvslog] lavfi/swapuv: support all planar yuv pixel formats
Paul B Mahol
git at videolan.org
Wed Jan 23 17:15:42 CET 2013
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Dec 22 01:48:17 2012 +0000| [a793a587df05bfc789e040c13329825cf9a261a3] | committer: Paul B Mahol
lavfi/swapuv: support all planar yuv pixel formats
Signed-off-by: Paul B Mahol <onemda at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a793a587df05bfc789e040c13329825cf9a261a3
---
libavfilter/vf_swapuv.c | 39 +++++++++++++++++++++++++++++----------
1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/libavfilter/vf_swapuv.c b/libavfilter/vf_swapuv.c
index e7e5e88..82cc07c 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"
@@ -48,18 +49,36 @@ static int filter_frame(AVFilterLink *link, AVFilterBufferRef *inpicref)
return ff_filter_frame(link->dst->outputs[0], inpicref);
}
+static int is_planar_yuv(const AVPixFmtDescriptor *desc)
+{
+ int i;
+
+ if (desc->flags & ~(PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA) ||
+ desc->nb_components < 3 ||
+ (desc->comp[1].depth_minus1 != desc->comp[2].depth_minus1))
+ return 0;
+ for (i = 0; i < desc->nb_components; i++) {
+ if (desc->comp[i].offset_plus1 != 1 ||
+ desc->comp[i].shift != 0 ||
+ desc->comp[i].plane != i)
+ return 0;
+ }
+
+ return 1;
+}
+
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,
- };
-
- ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
+ AVFilterFormats *formats = NULL;
+ int fmt;
+
+ for (fmt = 0; fmt < AV_PIX_FMT_NB; fmt++) {
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
+ if (is_planar_yuv(desc))
+ ff_add_format(&formats, fmt);
+ }
+
+ ff_set_common_formats(ctx, formats);
return 0;
}
More information about the ffmpeg-cvslog
mailing list