2 * Copyright (c) 2002 Michael Niedermayer <michaelni@gmx.at>
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms,
33 AVFilterBufferRef *picref =
34 ff_default_get_video_buffer(link, perms, w, h);
38 tmp = picref->data[2];
39 picref->data[2] = picref->data[1];
40 picref->data[1] = tmp;
42 tmp2 = picref->linesize[2];
43 picref->linesize[2] = picref->linesize[1];
44 picref->linesize[1] = tmp2;
49 static void start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref)
51 AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0);
53 outpicref->data[1] = inpicref->data[2];
54 outpicref->data[2] = inpicref->data[1];
56 outpicref->linesize[1] = inpicref->linesize[2];
57 outpicref->linesize[2] = inpicref->linesize[1];
59 ff_start_frame(link->dst->outputs[0], outpicref);
62 static int query_formats(AVFilterContext *ctx)
64 static const enum PixelFormat pix_fmts[] = {
65 PIX_FMT_YUV420P, PIX_FMT_YUVJ420P, PIX_FMT_YUVA420P,
66 PIX_FMT_YUV444P, PIX_FMT_YUVJ444P, PIX_FMT_YUVA444P,
67 PIX_FMT_YUV440P, PIX_FMT_YUVJ440P,
68 PIX_FMT_YUV422P, PIX_FMT_YUVJ422P,
73 ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
77 AVFilter avfilter_vf_swapuv = {
79 .description = NULL_IF_CONFIG_SMALL("Swap U and V components."),
81 .query_formats = query_formats,
83 .inputs = (const AVFilterPad[]) {
85 .type = AVMEDIA_TYPE_VIDEO,
86 .get_video_buffer = get_video_buffer,
87 .start_frame = start_frame, },
90 .outputs = (const AVFilterPad[]) {
92 .type = AVMEDIA_TYPE_VIDEO, },