00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00026 #include "avfilter.h"
00027 #include "formats.h"
00028 #include "video.h"
00029
00030 static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms,
00031 int w, int h)
00032 {
00033 AVFilterBufferRef *picref =
00034 ff_default_get_video_buffer(link, perms, w, h);
00035 uint8_t *tmp;
00036 int tmp2;
00037
00038 tmp = picref->data[2];
00039 picref->data[2] = picref->data[1];
00040 picref->data[1] = tmp;
00041
00042 tmp2 = picref->linesize[2];
00043 picref->linesize[2] = picref->linesize[1];
00044 picref->linesize[1] = tmp2;
00045
00046 return picref;
00047 }
00048
00049 static int start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref)
00050 {
00051 AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0);
00052
00053 outpicref->data[1] = inpicref->data[2];
00054 outpicref->data[2] = inpicref->data[1];
00055
00056 outpicref->linesize[1] = inpicref->linesize[2];
00057 outpicref->linesize[2] = inpicref->linesize[1];
00058
00059 return ff_start_frame(link->dst->outputs[0], outpicref);
00060 }
00061
00062 static int query_formats(AVFilterContext *ctx)
00063 {
00064 static const enum PixelFormat pix_fmts[] = {
00065 PIX_FMT_YUV420P, PIX_FMT_YUVJ420P, PIX_FMT_YUVA420P,
00066 PIX_FMT_YUV444P, PIX_FMT_YUVJ444P, PIX_FMT_YUVA444P,
00067 PIX_FMT_YUV440P, PIX_FMT_YUVJ440P,
00068 PIX_FMT_YUV422P, PIX_FMT_YUVJ422P,
00069 PIX_FMT_YUV411P,
00070 PIX_FMT_NONE,
00071 };
00072
00073 ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
00074 return 0;
00075 }
00076
00077 AVFilter avfilter_vf_swapuv = {
00078 .name = "swapuv",
00079 .description = NULL_IF_CONFIG_SMALL("Swap U and V components."),
00080 .priv_size = 0,
00081 .query_formats = query_formats,
00082
00083 .inputs = (const AVFilterPad[]) {
00084 { .name = "default",
00085 .type = AVMEDIA_TYPE_VIDEO,
00086 .get_video_buffer = get_video_buffer,
00087 .start_frame = start_frame, },
00088 { .name = NULL }
00089 },
00090 .outputs = (const AVFilterPad[]) {
00091 { .name = "default",
00092 .type = AVMEDIA_TYPE_VIDEO, },
00093 { .name = NULL }
00094 },
00095 };