FFmpeg  4.3
vf_vflip.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 Bobby Bingham
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  * video vertical flip filter
24  */
25 
26 #include "libavutil/internal.h"
27 #include "libavutil/opt.h"
28 #include "libavutil/pixdesc.h"
29 #include "avfilter.h"
30 #include "internal.h"
31 #include "video.h"
32 
33 typedef struct FlipContext {
34  const AVClass *class;
35  int vsub; ///< vertical chroma subsampling
36 } FlipContext;
37 
38 static const AVOption vflip_options[] = {
39  { NULL }
40 };
41 
43 
45 {
46  FlipContext *flip = link->dst->priv;
48 
49  flip->vsub = desc->log2_chroma_h;
50 
51  return 0;
52 }
53 
55 {
56  FlipContext *flip = link->dst->priv;
57  AVFrame *frame;
58  int i;
59 
60  frame = ff_get_video_buffer(link->dst->outputs[0], w, h);
61  if (!frame)
62  return NULL;
63 
64  for (i = 0; i < 4; i ++) {
65  int vsub = i == 1 || i == 2 ? flip->vsub : 0;
66  int height = AV_CEIL_RSHIFT(h, vsub);
67 
68  if (frame->data[i]) {
69  frame->data[i] += (height - 1) * frame->linesize[i];
70  frame->linesize[i] = -frame->linesize[i];
71  }
72  }
73 
74  return frame;
75 }
76 
78 {
79  FlipContext *flip = link->dst->priv;
80  int i;
81 
82  for (i = 0; i < 4; i ++) {
83  int vsub = i == 1 || i == 2 ? flip->vsub : 0;
84  int height = AV_CEIL_RSHIFT(link->h, vsub);
85 
86  if (frame->data[i]) {
87  frame->data[i] += (height - 1) * frame->linesize[i];
88  frame->linesize[i] = -frame->linesize[i];
89  }
90  }
91 
92  return ff_filter_frame(link->dst->outputs[0], frame);
93 }
95  {
96  .name = "default",
97  .type = AVMEDIA_TYPE_VIDEO,
98  .get_video_buffer = get_video_buffer,
99  .filter_frame = filter_frame,
100  .config_props = config_input,
101  },
102  { NULL }
103 };
104 
106  {
107  .name = "default",
108  .type = AVMEDIA_TYPE_VIDEO,
109  },
110  { NULL }
111 };
112 
114  .name = "vflip",
115  .description = NULL_IF_CONFIG_SMALL("Flip the input video vertically."),
116  .priv_size = sizeof(FlipContext),
117  .priv_class = &vflip_class,
121 };
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:99
avfilter_vf_vflip_inputs
static const AVFilterPad avfilter_vf_vflip_inputs[]
Definition: vf_vflip.c:94
opt.h
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
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:148
video.h
config_input
static int config_input(AVFilterLink *link)
Definition: vf_vflip.c:44
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: vf_vflip.c:77
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
FlipContext::vsub
int vsub
vertical chroma subsampling
Definition: vf_vflip.c:35
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(vflip)
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
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
NULL
#define NULL
Definition: coverity.c:32
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
get_video_buffer
static AVFrame * get_video_buffer(AVFilterLink *link, int w, int h)
Definition: vf_vflip.c:54
desc
const char * desc
Definition: nvenc.c:79
vflip_options
static const AVOption vflip_options[]
Definition: vf_vflip.c:38
flip
static void flip(AVCodecContext *avctx, AVFrame *frame)
Definition: rawdec.c:136
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
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:373
height
#define height
avfilter_vf_vflip_outputs
static const AVFilterPad avfilter_vf_vflip_outputs[]
Definition: vf_vflip.c:105
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
ff_vf_vflip
AVFilter ff_vf_vflip
Definition: vf_vflip.c:113
internal.h
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
AVFilter
Filter definition.
Definition: avfilter.h:144
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
FlipContext
Definition: hflip.h:27
avfilter.h
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
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