FFmpeg  4.3
vf_swapuv.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002 Michael Niedermayer <michaelni@gmx.at>
3  *
4  * This file is part of FFmpeg.
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 /**
22  * @file
23  * swap UV filter
24  */
25 
26 #include "libavutil/opt.h"
27 #include "libavutil/pixdesc.h"
28 #include "libavutil/version.h"
29 #include "avfilter.h"
30 #include "formats.h"
31 #include "internal.h"
32 #include "video.h"
33 
34 typedef struct SwapUVContext {
35  const AVClass *class;
37 
38 static const AVOption swapuv_options[] = {
39  { NULL }
40 };
41 
42 AVFILTER_DEFINE_CLASS(swapuv);
43 
44 static void do_swap(AVFrame *frame)
45 {
46  FFSWAP(uint8_t*, frame->data[1], frame->data[2]);
47  FFSWAP(int, frame->linesize[1], frame->linesize[2]);
48  FFSWAP(AVBufferRef*, frame->buf[1], frame->buf[2]);
49 
50 #if FF_API_ERROR_FRAME
52  FFSWAP(uint64_t, frame->error[1], frame->error[2]);
54 #endif
55 }
56 
58 {
60  do_swap(picref);
61  return picref;
62 }
63 
64 static int filter_frame(AVFilterLink *link, AVFrame *inpicref)
65 {
66  do_swap(inpicref);
67  return ff_filter_frame(link->dst->outputs[0], inpicref);
68 }
69 
71 {
72  int i;
73 
75  desc->nb_components < 3 ||
76  (desc->comp[1].depth != desc->comp[2].depth))
77  return 0;
78  for (i = 0; i < desc->nb_components; i++) {
79  if (desc->comp[i].offset != 0 ||
80  desc->comp[i].shift != 0 ||
81  desc->comp[i].plane != i)
82  return 0;
83  }
84 
85  return 1;
86 }
87 
89 {
91  int fmt, ret;
92 
93  for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
95  if (is_planar_yuv(desc) && (ret = ff_add_format(&formats, fmt)) < 0)
96  return ret;
97  }
98 
100 }
101 
102 static const AVFilterPad swapuv_inputs[] = {
103  {
104  .name = "default",
105  .type = AVMEDIA_TYPE_VIDEO,
106  .get_video_buffer = get_video_buffer,
107  .filter_frame = filter_frame,
108  },
109  { NULL }
110 };
111 
112 static const AVFilterPad swapuv_outputs[] = {
113  {
114  .name = "default",
115  .type = AVMEDIA_TYPE_VIDEO,
116  },
117  { NULL }
118 };
119 
121  .name = "swapuv",
122  .description = NULL_IF_CONFIG_SMALL("Swap U and V components."),
123  .query_formats = query_formats,
124  .priv_size = sizeof(SwapUVContext),
125  .priv_class = &swapuv_class,
129 };
formats
formats
Definition: signature.h:48
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:85
opt.h
FFSWAP
#define FFSWAP(type, a, b)
Definition: common.h:99
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1075
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2549
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:300
pixdesc.h
AVOption
AVOption.
Definition: opt.h:246
get_video_buffer
static AVFrame * get_video_buffer(AVFilterLink *link, int w, int h)
Definition: vf_swapuv.c:57
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:148
video.h
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(swapuv)
ff_default_get_video_buffer
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:44
swapuv_outputs
static const AVFilterPad swapuv_outputs[]
Definition: vf_swapuv.c:112
swapuv_inputs
static const AVFilterPad swapuv_inputs[]
Definition: vf_swapuv.c:102
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
ff_set_common_formats
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:600
do_swap
static void do_swap(AVFrame *frame)
Definition: vf_swapuv.c:44
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
AV_PIX_FMT_FLAG_ALPHA
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:177
ctx
AVFormatContext * ctx
Definition: movenc.c:48
link
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
Definition: filter_design.txt:23
ff_vf_swapuv
AVFilter ff_vf_swapuv
Definition: vf_swapuv.c:120
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
NULL
#define NULL
Definition: coverity.c:32
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_swapuv.c:88
ff_add_format
int ff_add_format(AVFilterFormats **avff, int64_t fmt)
Add fmt to the list of media formats contained in *avff.
Definition: formats.c:336
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
desc
const char * desc
Definition: nvenc.c:79
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:186
is_planar_yuv
static int is_planar_yuv(const AVPixFmtDescriptor *desc)
Definition: vf_swapuv.c:70
internal.h
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:125
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AV_PIX_FMT_FLAG_BE
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
Definition: pixdesc.h:128
uint8_t
uint8_t
Definition: audio_convert.c:194
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
AVFilter
Filter definition.
Definition: avfilter.h:144
version.h
ret
ret
Definition: filter_design.txt:187
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
w
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo ug o o w
Definition: fate.txt:150
SwapUVContext
Definition: vf_swapuv.c:34
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *inpicref)
Definition: vf_swapuv.c:64
avfilter.h
AV_PIX_FMT_FLAG_PLANAR
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition: pixdesc.h:144
AVFilterContext
An instance of a filter.
Definition: avfilter.h:338
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:84
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:81
swapuv_options
static const AVOption swapuv_options[]
Definition: vf_swapuv.c:38
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:564
h
h
Definition: vp9dsp_template.c:2038