FFmpeg
vf_displace.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Paul B Mahol
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 #include "libavutil/pixdesc.h"
22 #include "libavutil/opt.h"
23 #include "avfilter.h"
24 #include "filters.h"
25 #include "framesync.h"
26 #include "video.h"
27 
28 enum EdgeMode {
34 };
35 
36 typedef struct DisplaceContext {
37  const AVClass *class;
38  int width[4], height[4];
39  enum EdgeMode edge;
40  int nb_planes;
42  int step;
43  uint8_t blank[4];
45 
46  int (*displace_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
48 
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
51 
52 static const AVOption displace_options[] = {
53  { "edge", "set edge mode", OFFSET(edge), AV_OPT_TYPE_INT, {.i64=EDGE_SMEAR}, 0, EDGE_NB-1, FLAGS, .unit = "edge" },
54  { "blank", "", 0, AV_OPT_TYPE_CONST, {.i64=EDGE_BLANK}, 0, 0, FLAGS, .unit = "edge" },
55  { "smear", "", 0, AV_OPT_TYPE_CONST, {.i64=EDGE_SMEAR}, 0, 0, FLAGS, .unit = "edge" },
56  { "wrap" , "", 0, AV_OPT_TYPE_CONST, {.i64=EDGE_WRAP}, 0, 0, FLAGS, .unit = "edge" },
57  { "mirror" , "", 0, AV_OPT_TYPE_CONST, {.i64=EDGE_MIRROR}, 0, 0, FLAGS, .unit = "edge" },
58  { NULL }
59 };
60 
61 AVFILTER_DEFINE_CLASS(displace);
62 
63 static const enum AVPixelFormat pix_fmts[] = {
74 };
75 
76 typedef struct ThreadData {
77  AVFrame *in, *xin, *yin, *out;
78 } ThreadData;
79 
80 static int displace_planar(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
81 {
82  DisplaceContext *s = ctx->priv;
83  const ThreadData *td = arg;
84  const AVFrame *in = td->in;
85  const AVFrame *xin = td->xin;
86  const AVFrame *yin = td->yin;
87  const AVFrame *out = td->out;
88 
89  for (int plane = 0; plane < s->nb_planes; plane++) {
90  const int h = s->height[plane];
91  const int w = s->width[plane];
92  const int slice_start = (h * jobnr ) / nb_jobs;
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];
99  const uint8_t *ysrc = yin->data[plane] + slice_start * ylinesize;
100  const uint8_t *xsrc = xin->data[plane] + slice_start * xlinesize;
101  uint8_t *dst = out->data[plane] + slice_start * dlinesize;
102  const uint8_t blank = s->blank[plane];
103 
104  for (int y = slice_start; y < slice_end; y++) {
105  switch (s->edge) {
106  case EDGE_BLANK:
107  for (int x = 0; x < w; x++) {
108  int Y = y + ysrc[x] - 128;
109  int X = x + xsrc[x] - 128;
110 
111  if (Y < 0 || Y >= h || X < 0 || X >= w)
112  dst[x] = blank;
113  else
114  dst[x] = src[Y * slinesize + X];
115  }
116  break;
117  case EDGE_SMEAR:
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);
121  dst[x] = src[Y * slinesize + X];
122  }
123  break;
124  case EDGE_WRAP:
125  for (int x = 0; x < w; x++) {
126  int Y = (y + ysrc[x] - 128) % h;
127  int X = (x + xsrc[x] - 128) % w;
128 
129  if (Y < 0)
130  Y += h;
131  if (X < 0)
132  X += w;
133  dst[x] = src[Y * slinesize + X];
134  }
135  break;
136  case EDGE_MIRROR:
137  for (int x = 0; x < w; x++) {
138  int Y = y + ysrc[x] - 128;
139  int X = x + xsrc[x] - 128;
140 
141  if (Y < 0)
142  Y = (-Y) % h;
143  if (X < 0)
144  X = (-X) % w;
145  if (Y >= h)
146  Y = h - (Y % h) - 1;
147  if (X >= w)
148  X = w - (X % w) - 1;
149  dst[x] = src[Y * slinesize + X];
150  }
151  break;
152  }
153 
154  ysrc += ylinesize;
155  xsrc += xlinesize;
156  dst += dlinesize;
157  }
158  }
159  return 0;
160 }
161 
162 static int displace_packed(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
163 {
164  DisplaceContext *s = ctx->priv;
165  const ThreadData *td = arg;
166  const AVFrame *in = td->in;
167  const AVFrame *xin = td->xin;
168  const AVFrame *yin = td->yin;
169  const AVFrame *out = td->out;
170  const int step = s->step;
171  const int h = s->height[0];
172  const int w = s->width[0];
173  const int slice_start = (h * jobnr ) / nb_jobs;
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];
180  const uint8_t *ysrc = yin->data[0] + slice_start * ylinesize;
181  const uint8_t *xsrc = xin->data[0] + slice_start * xlinesize;
182  uint8_t *dst = out->data[0] + slice_start * dlinesize;
183  const uint8_t *blank = s->blank;
184 
185  for (int y = slice_start; y < slice_end; y++) {
186  switch (s->edge) {
187  case EDGE_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);
192 
193  if (Y < 0 || Y >= h || X < 0 || X >= w)
194  dst[x * step + c] = blank[c];
195  else
196  dst[x * step + c] = src[Y * slinesize + X * step + c];
197  }
198  }
199  break;
200  case EDGE_SMEAR:
201  for (int x = 0; x < w; x++) {
202  for (int c = 0; c < s->nb_components; c++) {
203  int Y = av_clip(y + (ysrc[x * step + c] - 128), 0, h - 1);
204  int X = av_clip(x + (xsrc[x * step + c] - 128), 0, w - 1);
205 
206  dst[x * step + c] = src[Y * slinesize + X * step + c];
207  }
208  }
209  break;
210  case EDGE_WRAP:
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;
215 
216  if (Y < 0)
217  Y += h;
218  if (X < 0)
219  X += w;
220  dst[x * step + c] = src[Y * slinesize + X * step + c];
221  }
222  }
223  break;
224  case EDGE_MIRROR:
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;
229 
230  if (Y < 0)
231  Y = (-Y) % h;
232  if (X < 0)
233  X = (-X) % w;
234  if (Y >= h)
235  Y = h - (Y % h) - 1;
236  if (X >= w)
237  X = w - (X % w) - 1;
238  dst[x * step + c] = src[Y * slinesize + X * step + c];
239  }
240  }
241  break;
242  }
243 
244  ysrc += ylinesize;
245  xsrc += xlinesize;
246  dst += dlinesize;
247  }
248  return 0;
249 }
250 
252 {
253  AVFilterContext *ctx = fs->parent;
254  DisplaceContext *s = fs->opaque;
255  AVFilterLink *outlink = ctx->outputs[0];
256  AVFrame *out, *in, *xin, *yin;
257  int ret;
258 
259  if ((ret = ff_framesync_get_frame(&s->fs, 0, &in, 0)) < 0 ||
260  (ret = ff_framesync_get_frame(&s->fs, 1, &xin, 0)) < 0 ||
261  (ret = ff_framesync_get_frame(&s->fs, 2, &yin, 0)) < 0)
262  return ret;
263 
264  if (ctx->is_disabled) {
265  out = av_frame_clone(in);
266  if (!out)
267  return AVERROR(ENOMEM);
268  } else {
269  ThreadData td;
270 
271  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
272  if (!out)
273  return AVERROR(ENOMEM);
275 
276  td.in = in;
277  td.xin = xin;
278  td.yin = yin;
279  td.out = out;
280  ff_filter_execute(ctx, s->displace_slice, &td, NULL,
281  FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
282  }
283  out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
284 
285  return ff_filter_frame(outlink, out);
286 }
287 
289 {
290  AVFilterContext *ctx = inlink->dst;
291  DisplaceContext *s = ctx->priv;
293  int vsub, hsub;
294 
295  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
296  s->nb_components = desc->nb_components;
297 
298  if (s->nb_planes > 1 || s->nb_components == 1)
299  s->displace_slice = displace_planar;
300  else
301  s->displace_slice = displace_packed;
302 
303  if (!(desc->flags & AV_PIX_FMT_FLAG_RGB)) {
304  s->blank[1] = s->blank[2] = 128;
305  s->blank[0] = 16;
306  }
307 
308  s->step = av_get_padded_bits_per_pixel(desc) >> 3;
309  hsub = desc->log2_chroma_w;
310  vsub = desc->log2_chroma_h;
311  s->height[1] = s->height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
312  s->height[0] = s->height[3] = inlink->h;
313  s->width[1] = s->width[2] = AV_CEIL_RSHIFT(inlink->w, hsub);
314  s->width[0] = s->width[3] = inlink->w;
315 
316  return 0;
317 }
318 
319 static int config_output(AVFilterLink *outlink)
320 {
321  FilterLink *outl = ff_filter_link(outlink);
322  AVFilterContext *ctx = outlink->src;
323  DisplaceContext *s = ctx->priv;
324  AVFilterLink *srclink = ctx->inputs[0];
325  FilterLink *sl = ff_filter_link(srclink);
326  AVFilterLink *xlink = ctx->inputs[1];
327  AVFilterLink *ylink = ctx->inputs[2];
328  FFFrameSyncIn *in;
329  int ret;
330 
331  if (srclink->w != xlink->w ||
332  srclink->h != xlink->h ||
333  srclink->w != ylink->w ||
334  srclink->h != ylink->h) {
335  av_log(ctx, AV_LOG_ERROR, "First input link %s parameters "
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);
342  return AVERROR(EINVAL);
343  }
344 
345  outlink->w = srclink->w;
346  outlink->h = srclink->h;
347  outlink->sample_aspect_ratio = srclink->sample_aspect_ratio;
348  outl->frame_rate = sl->frame_rate;
349 
350  ret = ff_framesync_init(&s->fs, ctx, 3);
351  if (ret < 0)
352  return ret;
353 
354  in = s->fs.in;
355  in[0].time_base = srclink->time_base;
356  in[1].time_base = xlink->time_base;
357  in[2].time_base = ylink->time_base;
358  in[0].sync = 2;
359  in[0].before = EXT_STOP;
360  in[0].after = EXT_STOP;
361  in[1].sync = 1;
362  in[1].before = EXT_NULL;
363  in[1].after = EXT_INFINITY;
364  in[2].sync = 1;
365  in[2].before = EXT_NULL;
366  in[2].after = EXT_INFINITY;
367  s->fs.opaque = s;
368  s->fs.on_event = process_frame;
369 
370  ret = ff_framesync_configure(&s->fs);
371  outlink->time_base = s->fs.time_base;
372 
373  return ret;
374 }
375 
377 {
378  DisplaceContext *s = ctx->priv;
379  return ff_framesync_activate(&s->fs);
380 }
381 
383 {
384  DisplaceContext *s = ctx->priv;
385 
386  ff_framesync_uninit(&s->fs);
387 }
388 
389 static const AVFilterPad displace_inputs[] = {
390  {
391  .name = "source",
392  .type = AVMEDIA_TYPE_VIDEO,
393  .config_props = config_input,
394  },
395  {
396  .name = "xmap",
397  .type = AVMEDIA_TYPE_VIDEO,
398  },
399  {
400  .name = "ymap",
401  .type = AVMEDIA_TYPE_VIDEO,
402  },
403 };
404 
405 static const AVFilterPad displace_outputs[] = {
406  {
407  .name = "default",
408  .type = AVMEDIA_TYPE_VIDEO,
409  .config_props = config_output,
410  },
411 };
412 
414  .name = "displace",
415  .description = NULL_IF_CONFIG_SMALL("Displace pixels."),
416  .priv_size = sizeof(DisplaceContext),
417  .uninit = uninit,
418  .activate = activate,
422  .priv_class = &displace_class,
425  .process_command = ff_filter_process_command,
426 };
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:116
FFFrameSyncIn::time_base
AVRational time_base
Time base for the incoming frames.
Definition: framesync.h:117
ff_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:137
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
av_clip
#define av_clip
Definition: common.h:100
AVERROR
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
opt.h
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
ff_framesync_uninit
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:301
out
FILE * out
Definition: movenc.c:55
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1062
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3170
ff_framesync_get_frame
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
Definition: framesync.c:269
inlink
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
Definition: filter_design.txt:212
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
pixdesc.h
step
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
Definition: rate_distortion.txt:58
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:429
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:102
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
FFFrameSync
Frame sync structure.
Definition: framesync.h:168
EXT_INFINITY
@ EXT_INFINITY
Extend the frame to infinity.
Definition: framesync.h:75
ThreadData::out
AVFrame * out
Definition: af_adeclick.c:526
DisplaceContext::nb_planes
int nb_planes
Definition: vf_displace.c:40
ThreadData::xin
AVFrame * xin
Definition: vf_displace.c:77
video.h
ThreadData::in
AVFrame * in
Definition: af_adecorrelate.c:155
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:410
hsub
static void hsub(htype *dst, const htype *src, int bins)
Definition: vf_median.c:74
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3210
EXT_STOP
@ EXT_STOP
Completely stop all streams with this one.
Definition: framesync.h:65
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
Definition: mpeg12dec.c:1719
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
FFFrameSyncIn
Input stream structure.
Definition: framesync.h:102
EXT_NULL
@ EXT_NULL
Ignore this stream and continue processing the other ones.
Definition: framesync.h:70
DisplaceContext
Definition: vf_displace.c:36
FFFrameSyncIn::sync
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events.
Definition: framesync.h:160
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(displace)
DisplaceContext::edge
enum EdgeMode edge
Definition: vf_displace.c:39
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:283
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
av_cold
#define av_cold
Definition: attributes.h:90
DisplaceContext::fs
FFFrameSync fs
Definition: vf_displace.c:44
displace_options
static const AVOption displace_options[]
Definition: vf_displace.c:52
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:86
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
DisplaceContext::blank
uint8_t blank[4]
Definition: vf_displace.c:43
filters.h
ctx
AVFormatContext * ctx
Definition: movenc.c:49
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:609
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
displace_inputs
static const AVFilterPad displace_inputs[]
Definition: vf_displace.c:389
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:87
arg
const char * arg
Definition: jacosubdec.c:67
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_displace.c:63
ThreadData::yin
AVFrame * yin
Definition: vf_displace.c:77
DisplaceContext::displace_slice
int(* displace_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_displace.c:46
ff_vf_displace
const AVFilter ff_vf_displace
Definition: vf_displace.c:413
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:725
DisplaceContext::step
int step
Definition: vf_displace.c:42
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:200
displace_outputs
static const AVFilterPad displace_outputs[]
Definition: vf_displace.c:405
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:85
EDGE_MIRROR
@ EDGE_MIRROR
Definition: vf_displace.c:32
displace_packed
static int displace_packed(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_displace.c:162
displace_planar
static int displace_planar(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_displace.c:80
activate
static int activate(AVFilterContext *ctx)
Definition: vf_displace.c:376
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_displace.c:288
EDGE_SMEAR
@ EDGE_SMEAR
Definition: vf_displace.c:30
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:265
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:101
EDGE_NB
@ EDGE_NB
Definition: vf_displace.c:33
c
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
Definition: undefined.txt:32
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:197
FLAGS
#define FLAGS
Definition: vf_displace.c:50
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
DisplaceContext::nb_components
int nb_components
Definition: vf_displace.c:41
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:94
av_get_padded_bits_per_pixel
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 ...
Definition: pixdesc.c:3135
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:136
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
EDGE_WRAP
@ EDGE_WRAP
Definition: vf_displace.c:31
ff_filter_process_command
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.
Definition: avfilter.c:901
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:263
Y
#define Y
Definition: boxblur.h:37
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:99
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:841
ThreadData
Used for passing data between threads.
Definition: dsddec.c:71
process_frame
static int process_frame(FFFrameSync *fs)
Definition: vf_displace.c:251
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_displace.c:319
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:107
EDGE_BLANK
@ EDGE_BLANK
Definition: vf_displace.c:29
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
slice_start
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
Definition: dec.c:738
AVFilter
Filter definition.
Definition: avfilter.h:201
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:264
ff_framesync_init
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
Definition: framesync.c:86
FFFrameSyncIn::before
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
Definition: framesync.h:107
framesync.h
ff_filter_execute
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: avfilter.c:1667
EdgeMode
EdgeMode
Definition: vf_displace.c:28
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
DisplaceContext::width
int width[4]
Definition: vf_displace.c:38
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
X
@ X
Definition: vf_addroi.c:27
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:152
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
OFFSET
#define OFFSET(x)
Definition: vf_displace.c:49
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
DisplaceContext::height
int height[4]
Definition: vf_displace.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:69
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:190
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:434
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:262
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
FFFrameSyncIn::after
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
Definition: framesync.h:112
h
h
Definition: vp9dsp_template.c:2070
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_displace.c:382
ff_framesync_activate
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:352
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
src
#define src
Definition: vp8dsp.c:248
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:173