diff options
author | Paul B Mahol <onemda@gmail.com> | 2012-12-22 01:48:17 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2013-01-23 16:13:23 +0000 |
commit | a793a587df05bfc789e040c13329825cf9a261a3 (patch) | |
tree | 0fb9e3a155333a3c1fd8ff80a114ecc0a9a75bc0 | |
parent | b90ab2b99365a6c7f997abdb8ebfb0711c981249 (diff) | |
download | ffmpeg-a793a587df05bfc789e040c13329825cf9a261a3.tar.gz |
lavfi/swapuv: support all planar yuv pixel formats
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r-- | libavfilter/vf_swapuv.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/libavfilter/vf_swapuv.c b/libavfilter/vf_swapuv.c index e7e5e88abd..82cc07c8dc 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; } |