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
00028 static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms,
00029 int w, int h)
00030 {
00031 AVFilterBufferRef *picref =
00032 avfilter_default_get_video_buffer(link, perms, w, h);
00033 uint8_t *tmp;
00034 int tmp2;
00035
00036 tmp = picref->data[2];
00037 picref->data[2] = picref->data[1];
00038 picref->data[1] = tmp;
00039
00040 tmp2 = picref->linesize[2];
00041 picref->linesize[2] = picref->linesize[1];
00042 picref->linesize[1] = tmp2;
00043
00044 return picref;
00045 }
00046
00047 static void start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref)
00048 {
00049 AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0);
00050
00051 outpicref->data[1] = inpicref->data[2];
00052 outpicref->data[2] = inpicref->data[1];
00053
00054 outpicref->linesize[1] = inpicref->linesize[2];
00055 outpicref->linesize[2] = inpicref->linesize[1];
00056
00057 avfilter_start_frame(link->dst->outputs[0], outpicref);
00058 }
00059
00060 static int query_formats(AVFilterContext *ctx)
00061 {
00062 static const enum PixelFormat pix_fmts[] = {
00063 PIX_FMT_YUV420P, PIX_FMT_YUVJ420P, PIX_FMT_YUVA420P,
00064 PIX_FMT_YUV444P, PIX_FMT_YUVJ444P, PIX_FMT_YUVA444P,
00065 PIX_FMT_YUV440P, PIX_FMT_YUVJ440P,
00066 PIX_FMT_YUV422P, PIX_FMT_YUVJ422P,
00067 PIX_FMT_YUV411P,
00068 PIX_FMT_NONE,
00069 };
00070
00071 avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts));
00072 return 0;
00073 }
00074
00075 AVFilter avfilter_vf_swapuv = {
00076 .name = "swapuv",
00077 .description = NULL_IF_CONFIG_SMALL("Swap U and V components."),
00078 .priv_size = 0,
00079 .query_formats = query_formats,
00080
00081 .inputs = (const AVFilterPad[]) {
00082 { .name = "default",
00083 .type = AVMEDIA_TYPE_VIDEO,
00084 .get_video_buffer = get_video_buffer,
00085 .start_frame = start_frame, },
00086 { .name = NULL }
00087 },
00088 .outputs = (const AVFilterPad[]) {
00089 { .name = "default",
00090 .type = AVMEDIA_TYPE_VIDEO, },
00091 { .name = NULL }
00092 },
00093 };