FFmpeg  4.4.8
vf_chromakey.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Timo Rothenpieler <timo@rothenpieler.org>
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/opt.h"
22 #include "libavutil/imgutils.h"
23 #include "libavutil/intreadwrite.h"
24 #include "avfilter.h"
25 #include "filters.h"
26 #include "formats.h"
27 #include "internal.h"
28 #include "video.h"
29 
30 typedef struct ChromakeyContext {
31  const AVClass *class;
32 
34  uint16_t chromakey_uv[2];
35 
36  float similarity;
37  float blend;
38 
39  int is_yuv;
40  int depth;
41  int mid;
42  int max;
43 
44  int hsub_log2;
45  int vsub_log2;
46 
48  int jobnr, int nb_jobs);
50 
52 {
53  double diff = 0.0;
54  int du, dv, i;
55 
56  for (i = 0; i < 9; ++i) {
57  du = (int)u[i] - ctx->chromakey_uv[0];
58  dv = (int)v[i] - ctx->chromakey_uv[1];
59 
60  diff += sqrt((du * du + dv * dv) / (255.0 * 255.0 * 2));
61  }
62 
63  diff /= 9.0;
64 
65  if (ctx->blend > 0.0001) {
66  return av_clipd((diff - ctx->similarity) / ctx->blend, 0.0, 1.0) * 255.0;
67  } else {
68  return (diff > ctx->similarity) ? 255 : 0;
69  }
70 }
71 
72 static uint16_t do_chromakey_pixel16(ChromakeyContext *ctx, uint16_t u[9], uint16_t v[9])
73 {
74  double max = ctx->max;
75  double diff = 0.0;
76  int du, dv, i;
77 
78  for (i = 0; i < 9; ++i) {
79  du = (int)u[i] - ctx->chromakey_uv[0];
80  dv = (int)v[i] - ctx->chromakey_uv[1];
81 
82  diff += sqrt((du * du + dv * dv) / (max * max * 2));
83  }
84 
85  diff /= 9.0;
86 
87  if (ctx->blend > 0.0001) {
88  return av_clipd((diff - ctx->similarity) / ctx->blend, 0.0, 1.0) * max;
89  } else {
90  return (diff > ctx->similarity) ? max : 0;
91  }
92 }
93 
94 static av_always_inline void get_pixel_uv(AVFrame *frame, int hsub_log2, int vsub_log2, int x, int y, uint8_t *u, uint8_t *v)
95 {
96  if (x < 0 || x >= frame->width || y < 0 || y >= frame->height)
97  return;
98 
99  x >>= hsub_log2;
100  y >>= vsub_log2;
101 
102  *u = frame->data[1][frame->linesize[1] * y + x];
103  *v = frame->data[2][frame->linesize[2] * y + x];
104 }
105 
106 static av_always_inline void get_pixel16_uv(AVFrame *frame, int hsub_log2, int vsub_log2, int x, int y, uint16_t *u, uint16_t *v)
107 {
108  if (x < 0 || x >= frame->width || y < 0 || y >= frame->height)
109  return;
110 
111  x >>= hsub_log2;
112  y >>= vsub_log2;
113 
114  *u = AV_RN16(&frame->data[1][frame->linesize[1] * y + 2 * x]);
115  *v = AV_RN16(&frame->data[2][frame->linesize[2] * y + 2 * x]);
116 }
117 
118 static int do_chromakey_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
119 {
120  AVFrame *frame = arg;
121 
122  const int slice_start = ff_slice_pos(frame->height, jobnr, nb_jobs);
123  const int slice_end = ff_slice_pos(frame->height, jobnr + 1, nb_jobs);
124 
125  ChromakeyContext *ctx = avctx->priv;
126 
127  int x, y, xo, yo;
128  uint8_t u[9], v[9];
129 
130  memset(u, ctx->chromakey_uv[0], sizeof(u));
131  memset(v, ctx->chromakey_uv[1], sizeof(v));
132 
133  for (y = slice_start; y < slice_end; ++y) {
134  for (x = 0; x < frame->width; ++x) {
135  for (yo = 0; yo < 3; ++yo) {
136  for (xo = 0; xo < 3; ++xo) {
137  get_pixel_uv(frame, ctx->hsub_log2, ctx->vsub_log2, x + xo - 1, y + yo - 1, &u[yo * 3 + xo], &v[yo * 3 + xo]);
138  }
139  }
140 
141  frame->data[3][frame->linesize[3] * y + x] = do_chromakey_pixel(ctx, u, v);
142  }
143  }
144 
145  return 0;
146 }
147 
148 static int do_chromakey16_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
149 {
150  AVFrame *frame = arg;
151 
152  const int slice_start = ff_slice_pos(frame->height, jobnr, nb_jobs);
153  const int slice_end = ff_slice_pos(frame->height, jobnr + 1, nb_jobs);
154 
155  ChromakeyContext *ctx = avctx->priv;
156 
157  int x, y, xo, yo;
158  uint16_t u[9], v[9];
159 
160  for (int i = 0; i < 9; i++) {
161  u[i] = ctx->chromakey_uv[0];
162  v[i] = ctx->chromakey_uv[1];
163  }
164 
165  for (y = slice_start; y < slice_end; ++y) {
166  for (x = 0; x < frame->width; ++x) {
167  uint16_t *dst = (uint16_t *)(frame->data[3] + frame->linesize[3] * y);
168 
169  for (yo = 0; yo < 3; ++yo) {
170  for (xo = 0; xo < 3; ++xo) {
171  get_pixel16_uv(frame, ctx->hsub_log2, ctx->vsub_log2, x + xo - 1, y + yo - 1, &u[yo * 3 + xo], &v[yo * 3 + xo]);
172  }
173  }
174 
175  dst[x] = do_chromakey_pixel16(ctx, u, v);
176  }
177  }
178 
179  return 0;
180 }
181 
182 static int do_chromahold_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
183 {
184  ChromakeyContext *ctx = avctx->priv;
185  AVFrame *frame = arg;
186  const int slice_start = ff_slice_pos(frame->height >> ctx->vsub_log2, jobnr, nb_jobs);
187  const int slice_end = ff_slice_pos(frame->height >> ctx->vsub_log2, jobnr + 1, nb_jobs);
188 
189  int x, y, alpha;
190 
191  for (y = slice_start; y < slice_end; ++y) {
192  for (x = 0; x < frame->width >> ctx->hsub_log2; ++x) {
193  int u = frame->data[1][frame->linesize[1] * y + x];
194  int v = frame->data[2][frame->linesize[2] * y + x];
195  double diff;
196  int du, dv;
197 
198  du = u - ctx->chromakey_uv[0];
199  dv = v - ctx->chromakey_uv[1];
200 
201  diff = sqrt((du * du + dv * dv) / (255.0 * 255.0));
202 
203  alpha = diff > ctx->similarity;
204  if (ctx->blend > 0.0001) {
205  double f = 1. - av_clipd((diff - ctx->similarity) / ctx->blend, 0.0, 1.0);
206 
207  frame->data[1][frame->linesize[1] * y + x] = 128 + (u - 128) * f;
208  frame->data[2][frame->linesize[2] * y + x] = 128 + (v - 128) * f;
209  } else if (alpha) {
210  frame->data[1][frame->linesize[1] * y + x] = 128;
211  frame->data[2][frame->linesize[2] * y + x] = 128;
212  }
213  }
214  }
215 
216  return 0;
217 }
218 
219 static int do_chromahold16_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
220 {
221  ChromakeyContext *ctx = avctx->priv;
222  AVFrame *frame = arg;
223  const int slice_start = ff_slice_pos(frame->height >> ctx->vsub_log2, jobnr, nb_jobs);
224  const int slice_end = ff_slice_pos(frame->height >> ctx->vsub_log2, jobnr + 1, nb_jobs);
225  const int mid = ctx->mid;
226  double max = ctx->max;
227 
228  int x, y, alpha;
229 
230  for (y = slice_start; y < slice_end; ++y) {
231  for (x = 0; x < frame->width >> ctx->hsub_log2; ++x) {
232  int u = AV_RN16(&frame->data[1][frame->linesize[1] * y + 2 * x]);
233  int v = AV_RN16(&frame->data[2][frame->linesize[2] * y + 2 * x]);
234  double diff;
235  int du, dv;
236 
237  du = u - ctx->chromakey_uv[0];
238  dv = v - ctx->chromakey_uv[1];
239 
240  diff = sqrt((du * du + dv * dv) / (max * max));
241 
242  alpha = diff > ctx->similarity;
243  if (ctx->blend > 0.0001) {
244  double f = 1. - av_clipd((diff - ctx->similarity) / ctx->blend, 0.0, 1.0);
245 
246  AV_WN16(&frame->data[1][frame->linesize[1] * y + 2 * x], mid + (u - mid) * f);
247  AV_WN16(&frame->data[2][frame->linesize[2] * y + 2 * x], mid + (v - mid) * f);
248  } else if (alpha) {
249  AV_WN16(&frame->data[1][frame->linesize[1] * y + 2 * x], mid);
250  AV_WN16(&frame->data[2][frame->linesize[2] * y + 2 * x], mid);
251  }
252  }
253  }
254 
255  return 0;
256 }
257 
259 {
260  AVFilterContext *avctx = link->dst;
261  ChromakeyContext *ctx = avctx->priv;
262  int res;
263 
264  if (res = avctx->internal->execute(avctx, ctx->do_slice, frame, NULL, FFMIN(frame->height, ff_filter_get_nb_threads(avctx))))
265  return res;
266 
267  return ff_filter_frame(avctx->outputs[0], frame);
268 }
269 
270 #define FIXNUM(x) lrint((x) * (1 << 10))
271 #define RGB_TO_U(rgb) (((- FIXNUM(0.16874) * rgb[0] - FIXNUM(0.33126) * rgb[1] + FIXNUM(0.50000) * rgb[2] + (1 << 9) - 1) >> 10) + 128)
272 #define RGB_TO_V(rgb) ((( FIXNUM(0.50000) * rgb[0] - FIXNUM(0.41869) * rgb[1] - FIXNUM(0.08131) * rgb[2] + (1 << 9) - 1) >> 10) + 128)
273 
274 static av_cold int config_output(AVFilterLink *outlink)
275 {
277  AVFilterContext *avctx = outlink->src;
278  ChromakeyContext *ctx = avctx->priv;
279  int factor;
280 
281  ctx->depth = desc->comp[0].depth;
282  ctx->mid = 1 << (ctx->depth - 1);
283  ctx->max = (1 << ctx->depth) - 1;
284 
285  factor = 1 << (ctx->depth - 8);
286 
287  if (ctx->is_yuv) {
288  ctx->chromakey_uv[0] = ctx->chromakey_rgba[1] * factor;
289  ctx->chromakey_uv[1] = ctx->chromakey_rgba[2] * factor;
290  } else {
291  ctx->chromakey_uv[0] = RGB_TO_U(ctx->chromakey_rgba) * factor;
292  ctx->chromakey_uv[1] = RGB_TO_V(ctx->chromakey_rgba) * factor;
293  }
294 
295  if (!strcmp(avctx->filter->name, "chromakey")) {
296  ctx->do_slice = ctx->depth <= 8 ? do_chromakey_slice : do_chromakey16_slice;
297  } else {
298  ctx->do_slice = ctx->depth <= 8 ? do_chromahold_slice: do_chromahold16_slice;
299  }
300 
301  return 0;
302 }
303 
305 {
306  static const enum AVPixelFormat pixel_fmts[] = {
315  };
316 
317  static const enum AVPixelFormat hold_pixel_fmts[] = {
334  };
335 
337 
338  formats = ff_make_format_list(!strcmp(avctx->filter->name, "chromahold") ? hold_pixel_fmts : pixel_fmts);
339  if (!formats)
340  return AVERROR(ENOMEM);
341 
342  return ff_set_common_formats(avctx, formats);
343 }
344 
345 static av_cold int config_input(AVFilterLink *inlink)
346 {
347  AVFilterContext *avctx = inlink->dst;
348  ChromakeyContext *ctx = avctx->priv;
350 
351  ctx->hsub_log2 = desc->log2_chroma_w;
352  ctx->vsub_log2 = desc->log2_chroma_h;
353 
354  return 0;
355 }
356 
357 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
358  char *res, int res_len, int flags)
359 {
360  int ret;
361 
362  ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
363  if (ret < 0)
364  return ret;
365 
366  return config_output(ctx->outputs[0]);
367 }
368 
369 static const AVFilterPad chromakey_inputs[] = {
370  {
371  .name = "default",
372  .type = AVMEDIA_TYPE_VIDEO,
373  .needs_writable = 1,
374  .filter_frame = filter_frame,
375  .config_props = config_input,
376  },
377  { NULL }
378 };
379 
380 static const AVFilterPad chromakey_outputs[] = {
381  {
382  .name = "default",
383  .type = AVMEDIA_TYPE_VIDEO,
384  .config_props = config_output,
385  },
386  { NULL }
387 };
388 
389 #define OFFSET(x) offsetof(ChromakeyContext, x)
390 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
391 
392 static const AVOption chromakey_options[] = {
393  { "color", "set the chromakey key color", OFFSET(chromakey_rgba), AV_OPT_TYPE_COLOR, { .str = "black" }, 0, 0, FLAGS },
394  { "similarity", "set the chromakey similarity value", OFFSET(similarity), AV_OPT_TYPE_FLOAT, { .dbl = 0.01 }, 0.01, 1.0, FLAGS },
395  { "blend", "set the chromakey key blend value", OFFSET(blend), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, 0.0, 1.0, FLAGS },
396  { "yuv", "color parameter is in yuv instead of rgb", OFFSET(is_yuv), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
397  { NULL }
398 };
399 
401 
403  .name = "chromakey",
404  .description = NULL_IF_CONFIG_SMALL("Turns a certain color into transparency. Operates on YUV colors."),
405  .priv_size = sizeof(ChromakeyContext),
406  .priv_class = &chromakey_class,
412 };
413 
414 static const AVOption chromahold_options[] = {
415  { "color", "set the chromahold key color", OFFSET(chromakey_rgba), AV_OPT_TYPE_COLOR, { .str = "black" }, 0, 0, FLAGS },
416  { "similarity", "set the chromahold similarity value", OFFSET(similarity), AV_OPT_TYPE_FLOAT, { .dbl = 0.01 }, 0.01, 1.0, FLAGS },
417  { "blend", "set the chromahold blend value", OFFSET(blend), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, 0.0, 1.0, FLAGS },
418  { "yuv", "color parameter is in yuv instead of rgb", OFFSET(is_yuv), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
419  { NULL }
420 };
421 
422 static const AVFilterPad chromahold_inputs[] = {
423  {
424  .name = "default",
425  .type = AVMEDIA_TYPE_VIDEO,
426  .needs_writable = 1,
427  .filter_frame = filter_frame,
428  .config_props = config_input,
429  },
430  { NULL }
431 };
432 
433 static const AVFilterPad chromahold_outputs[] = {
434  {
435  .name = "default",
436  .type = AVMEDIA_TYPE_VIDEO,
437  .config_props = config_output,
438  },
439  { NULL }
440 };
441 
443 
445  .name = "chromahold",
446  .description = NULL_IF_CONFIG_SMALL("Turns a certain color range into gray."),
447  .priv_size = sizeof(ChromakeyContext),
448  .priv_class = &chromahold_class,
454 };
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
#define av_always_inline
Definition: attributes.h:45
#define av_cold
Definition: attributes.h:88
uint8_t
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1096
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:882
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:802
Main libavfilter public API header.
#define flags(name, subs,...)
Definition: cbs_av1.c:572
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:264
#define f(width, name)
Definition: cbs_vp9.c:255
#define FFMIN(a, b)
Definition: common.h:105
#define av_clipd
Definition: common.h:173
#define NULL
Definition: coverity.c:32
#define max(a, b)
Definition: cuda_runtime.h:33
static AVFrame * frame
int
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
Definition: filters.h:271
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:587
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
@ AV_OPT_TYPE_COLOR
Definition: opt.h:240
#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:126
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
#define AVERROR(e)
Definition: error.h:43
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
static const int16_t alpha[]
Definition: ilbcdata.h:55
misc image utilities
int i
Definition: input.c:407
#define AV_WN16(p, v)
Definition: intreadwrite.h:372
#define AV_RN16(p)
Definition: intreadwrite.h:360
const char * arg
Definition: jacosubdec.c:66
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
const char * desc
Definition: libsvtav1.c:79
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2033
AVOptions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:410
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:406
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:398
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:399
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:397
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:438
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:441
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:403
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:436
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:434
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:404
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:400
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:396
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:433
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:437
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:407
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:177
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:176
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:439
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:408
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:411
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:443
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:442
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:409
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:435
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:440
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:412
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:402
formats
Definition: signature.h:48
Describe the class of an AVClass context structure.
Definition: log.h:67
An instance of a filter.
Definition: avfilter.h:341
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:344
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:381
void * priv
private data for use by the filter
Definition: avfilter.h:356
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:353
A list of supported formats for one end of a filter link.
Definition: formats.h:65
avfilter_execute_func * execute
Definition: internal.h:136
A filter pad used for either input or output.
Definition: internal.h:54
const char * name
Pad name.
Definition: internal.h:60
Filter definition.
Definition: avfilter.h:145
const char * name
Filter name.
Definition: avfilter.h:149
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:332
int width
Definition: frame.h:376
int height
Definition: frame.h:376
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:349
AVOption.
Definition: opt.h:248
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
uint16_t chromakey_uv[2]
Definition: vf_chromakey.c:34
int(* do_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_chromakey.c:47
uint8_t chromakey_rgba[4]
Definition: vf_chromakey.c:33
AVFormatContext * ctx
Definition: movenc.c:48
static const AVOption chromahold_options[]
Definition: vf_chromakey.c:414
static av_always_inline void get_pixel_uv(AVFrame *frame, int hsub_log2, int vsub_log2, int x, int y, uint8_t *u, uint8_t *v)
Definition: vf_chromakey.c:94
static uint8_t do_chromakey_pixel(ChromakeyContext *ctx, uint8_t u[9], uint8_t v[9])
Definition: vf_chromakey.c:51
AVFilter ff_vf_chromahold
Definition: vf_chromakey.c:444
static const AVOption chromakey_options[]
Definition: vf_chromakey.c:392
static av_cold int query_formats(AVFilterContext *avctx)
Definition: vf_chromakey.c:304
AVFilter ff_vf_chromakey
Definition: vf_chromakey.c:402
static int do_chromahold_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_chromakey.c:182
#define RGB_TO_V(rgb)
Definition: vf_chromakey.c:272
#define FLAGS
Definition: vf_chromakey.c:390
static const AVFilterPad chromahold_inputs[]
Definition: vf_chromakey.c:422
static av_cold int config_output(AVFilterLink *outlink)
Definition: vf_chromakey.c:274
static const AVFilterPad chromakey_outputs[]
Definition: vf_chromakey.c:380
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_chromakey.c:345
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: vf_chromakey.c:258
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_chromakey.c:357
#define RGB_TO_U(rgb)
Definition: vf_chromakey.c:271
static const AVFilterPad chromahold_outputs[]
Definition: vf_chromakey.c:433
static int do_chromahold16_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_chromakey.c:219
static const AVFilterPad chromakey_inputs[]
Definition: vf_chromakey.c:369
#define OFFSET(x)
Definition: vf_chromakey.c:389
AVFILTER_DEFINE_CLASS(chromakey)
static uint16_t do_chromakey_pixel16(ChromakeyContext *ctx, uint16_t u[9], uint16_t v[9])
Definition: vf_chromakey.c:72
static int do_chromakey16_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_chromakey.c:148
static int do_chromakey_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_chromakey.c:118
static av_always_inline void get_pixel16_uv(AVFrame *frame, int hsub_log2, int vsub_log2, int x, int y, uint16_t *u, uint16_t *v)
Definition: vf_chromakey.c:106
static av_always_inline int diff(const uint32_t a, const uint32_t b)
static const int factor[16]
Definition: vf_pp7.c:77