1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

lavfi/swapuv: support all planar yuv pixel formats

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2012-12-22 01:48:17 +00:00
parent b90ab2b993
commit a793a587df

View File

@ -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,
};
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 (is_planar_yuv(desc))
ff_add_format(&formats, fmt);
}
ff_set_common_formats(ctx, formats);
return 0;
}