Go to the documentation of this file.
49 #define OFFSET(x) offsetof(DisplaceContext, x)
50 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
89 for (
int plane = 0; plane <
s->nb_planes; plane++) {
90 const int h =
s->height[plane];
91 const int w =
s->width[plane];
93 const int slice_end = (
h * (jobnr+1)) / nb_jobs;
94 const int dlinesize =
out->linesize[plane];
95 const int slinesize = in->
linesize[plane];
96 const int xlinesize = xin->
linesize[plane];
97 const int ylinesize = yin->
linesize[plane];
98 const uint8_t *
src = in->
data[plane];
102 const uint8_t blank =
s->blank[plane];
107 for (
int x = 0; x <
w; x++) {
108 int Y = y + ysrc[x] - 128;
109 int X = x + xsrc[x] - 128;
111 if (Y < 0 || Y >=
h || X < 0 || X >=
w)
118 for (
int x = 0; x <
w; x++) {
119 int Y =
av_clip(y + ysrc[x] - 128, 0,
h - 1);
120 int X =
av_clip(x + xsrc[x] - 128, 0,
w - 1);
125 for (
int x = 0; x <
w; x++) {
126 int Y = (y + ysrc[x] - 128) %
h;
127 int X = (x + xsrc[x] - 128) %
w;
137 for (
int x = 0; x <
w; x++) {
138 int Y = y + ysrc[x] - 128;
139 int X = x + xsrc[x] - 128;
170 const int step =
s->step;
171 const int h =
s->height[0];
172 const int w =
s->width[0];
174 const int slice_end = (
h * (jobnr+1)) / nb_jobs;
175 const int dlinesize =
out->linesize[0];
176 const int slinesize = in->
linesize[0];
177 const int xlinesize = xin->
linesize[0];
178 const int ylinesize = yin->
linesize[0];
179 const uint8_t *
src = in->
data[0];
183 const uint8_t *blank =
s->blank;
188 for (
int x = 0; x <
w; x++) {
189 for (
int c = 0;
c <
s->nb_components;
c++) {
190 int Y = y + (ysrc[x *
step +
c] - 128);
191 int X = x + (xsrc[x *
step +
c] - 128);
193 if (Y < 0 || Y >=
h || X < 0 || X >=
w)
201 for (
int x = 0; x <
w; x++) {
202 for (
int c = 0;
c <
s->nb_components;
c++) {
211 for (
int x = 0; x <
w; x++) {
212 for (
int c = 0;
c <
s->nb_components;
c++) {
213 int Y = (y + (ysrc[x *
step +
c] - 128)) %
h;
214 int X = (x + (xsrc[x *
step +
c] - 128)) %
w;
225 for (
int x = 0; x <
w; x++) {
226 for (
int c = 0;
c <
s->nb_components;
c++) {
227 int Y = y + ysrc[x *
step +
c] - 128;
228 int X = x + xsrc[x *
step +
c] - 128;
264 if (
ctx->is_disabled) {
296 s->nb_components =
desc->nb_components;
298 if (
s->nb_planes > 1 ||
s->nb_components == 1)
304 s->blank[1] =
s->blank[2] = 128;
310 vsub =
desc->log2_chroma_h;
312 s->height[0] =
s->height[3] =
inlink->h;
314 s->width[0] =
s->width[3] =
inlink->w;
331 if (srclink->
w != xlink->
w ||
332 srclink->
h != xlink->
h ||
333 srclink->
w != ylink->
w ||
334 srclink->
h != ylink->
h) {
336 "(size %dx%d) do not match the corresponding "
337 "second input link %s parameters (%dx%d) "
338 "and/or third input link %s parameters (%dx%d)\n",
339 ctx->input_pads[0].name, srclink->
w, srclink->
h,
340 ctx->input_pads[1].name, xlink->
w, xlink->
h,
341 ctx->input_pads[2].name, ylink->
w, ylink->
h);
345 outlink->
w = srclink->
w;
346 outlink->
h = srclink->
h;
422 .priv_class = &displace_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
AVRational time_base
Time base for the incoming frames.
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
AVPixelFormat
Pixel format.
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 all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define FILTER_PIXFMTS_ARRAY(array)
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * name
Filter name.
@ EXT_INFINITY
Extend the frame to infinity.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Link properties exposed to filter code, but not external callers.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
@ EXT_STOP
Completely stop all streams with this one.
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
@ EXT_NULL
Ignore this stream and continue processing the other ones.
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events.
AVFILTER_DEFINE_CLASS(displace)
A filter pad used for either input or output.
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const AVOption displace_options[]
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_CEIL_RSHIFT(a, b)
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static const AVFilterPad displace_inputs[]
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
static enum AVPixelFormat pix_fmts[]
int(* displace_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
const AVFilter ff_vf_displace
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define fs(width, name, subs,...)
static const AVFilterPad displace_outputs[]
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
static int displace_packed(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int displace_planar(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int activate(AVFilterContext *ctx)
static int config_input(AVFilterLink *inlink)
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static FilterLink * ff_filter_link(AVFilterLink *link)
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel for the pixel format described by pixdesc, including any padding ...
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
AVFilterContext * src
source filter
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
int w
agreed upon image width
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Used for passing data between threads.
static int process_frame(FFFrameSync *fs)
static int config_output(AVFilterLink *outlink)
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
const char * name
Pad name.
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
int h
agreed upon image height
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
@ AV_OPT_TYPE_INT
Underlying C type is int.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
static av_cold void uninit(AVFilterContext *ctx)
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)