FFmpeg
vf_hsvkey.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 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 <float.h>
22 
23 #include "libavutil/opt.h"
24 #include "libavutil/imgutils.h"
25 #include "libavutil/intreadwrite.h"
26 #include "avfilter.h"
27 #include "formats.h"
28 #include "internal.h"
29 #include "video.h"
30 
31 typedef struct HSVKeyContext {
32  const AVClass *class;
33 
34  float hue, hue_opt, sat, val;
35  float similarity;
36  float blend;
37 
38  float scale;
39 
40  float half;
41 
42  int depth;
43  int max;
44 
45  int hsub_log2;
46  int vsub_log2;
47 
49  int jobnr, int nb_jobs);
51 
52 #define SQR(x) ((x)*(x))
53 
54 static int do_hsvkey_pixel(HSVKeyContext *s, int y, int u, int v,
55  float hue_key, float sat_key, float val_key)
56 {
57  const float similarity = s->similarity;
58  const float scale = s->scale;
59  const float blend = s->blend;
60  const int imax = s->max;
61  const float max = imax;
62  const float half = s->half;
63  const float uf = u - half;
64  const float vf = v - half;
65  const float hue = hue_key < 0.f ? -hue_key : atan2f(uf, vf) + M_PI;
66  const float sat = sat_key < 0.f ? -sat_key : sqrtf((uf * uf + vf * vf) / (half * half * 2.f));
67  const float val = val_key < 0.f ? -val_key : scale * y;
68  float diff;
69 
70  hue_key = fabsf(hue_key);
71  sat_key = fabsf(sat_key);
72  val_key = fabsf(val_key);
73 
74  diff = sqrtf(fmaxf(SQR(sat) * SQR(val) +
75  SQR(sat_key) * SQR(val_key) -
76  2.f * sat * val * sat_key * val_key * cosf(hue_key - hue) +
77  SQR(val - val_key), 0.f));
78  if (diff < similarity) {
79  return 0;
80  } else if (blend > FLT_MIN) {
81  return av_clipf((diff - similarity) / blend, 0.f, 1.f) * max;
82  } else {
83  return imax;
84  }
85 
86  return 0;
87 }
88 
89 static int do_hsvkey_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
90 {
91  HSVKeyContext *s = avctx->priv;
92  AVFrame *frame = arg;
93  const int slice_start = (frame->height * jobnr) / nb_jobs;
94  const int slice_end = (frame->height * (jobnr + 1)) / nb_jobs;
95  const int hsub_log2 = s->hsub_log2;
96  const int vsub_log2 = s->vsub_log2;
97  const float hue = s->hue;
98  const float sat = s->sat;
99  const float val = s->val;
100 
101  for (int y = slice_start; y < slice_end; y++) {
102  for (int x = 0; x < frame->width; x++) {
103  int Y = frame->data[0][frame->linesize[0] * y + x];
104  int u = frame->data[1][frame->linesize[1] * (y >> vsub_log2) + (x >> hsub_log2)];
105  int v = frame->data[2][frame->linesize[2] * (y >> vsub_log2) + (x >> hsub_log2)];
106 
107  frame->data[3][frame->linesize[3] * y + x] = do_hsvkey_pixel(s, Y, u, v, hue, sat, val);
108  }
109  }
110 
111  return 0;
112 }
113 
114 static int do_hsvkey16_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
115 {
116  HSVKeyContext *s = avctx->priv;
117  AVFrame *frame = arg;
118  const int slice_start = (frame->height * jobnr) / nb_jobs;
119  const int slice_end = (frame->height * (jobnr + 1)) / nb_jobs;
120  const int hsub_log2 = s->hsub_log2;
121  const int vsub_log2 = s->vsub_log2;
122  const float hue = s->hue;
123  const float sat = s->sat;
124  const float val = s->val;
125 
126  for (int y = slice_start; y < slice_end; ++y) {
127  for (int x = 0; x < frame->width; ++x) {
128  uint16_t *dst = (uint16_t *)(frame->data[3] + frame->linesize[3] * y);
129  int Y = AV_RN16(&frame->data[0][frame->linesize[0] * y + 2 * x]);
130  int u = AV_RN16(&frame->data[1][frame->linesize[1] * (y >> vsub_log2) + 2 * (x >> hsub_log2)]);
131  int v = AV_RN16(&frame->data[2][frame->linesize[2] * (y >> vsub_log2) + 2 * (x >> hsub_log2)]);
132 
133  dst[x] = do_hsvkey_pixel(s, Y, u, v, hue, sat, val);
134  }
135  }
136 
137  return 0;
138 }
139 
140 static int do_hsvhold_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
141 {
142  HSVKeyContext *s = avctx->priv;
143  AVFrame *frame = arg;
144  const int hsub_log2 = s->hsub_log2;
145  const int vsub_log2 = s->vsub_log2;
146  const int width = frame->width >> hsub_log2;
147  const int height = frame->height >> vsub_log2;
148  const int slice_start = (height * jobnr) / nb_jobs;
149  const int slice_end = (height * (jobnr + 1)) / nb_jobs;
150  const float scale = s->scale;
151  const float hue = s->hue;
152  const float sat = s->sat;
153  const float val = s->val;
154 
155  for (int y = slice_start; y < slice_end; ++y) {
156  for (int x = 0; x < width; ++x) {
157  uint8_t *dstu = frame->data[1] + frame->linesize[1] * y;
158  uint8_t *dstv = frame->data[2] + frame->linesize[2] * y;
159  int Y = frame->data[0][frame->linesize[0] * (y << vsub_log2) + (x << hsub_log2)];
160  int u = frame->data[1][frame->linesize[1] * y + x];
161  int v = frame->data[2][frame->linesize[2] * y + x];
162  int t = do_hsvkey_pixel(s, Y, u, v, hue, sat, val);
163 
164  if (t > 0) {
165  float f = 1.f - t * scale;
166 
167  dstu[x] = 128 + (u - 128) * f;
168  dstv[x] = 128 + (v - 128) * f;
169  }
170  }
171  }
172 
173  return 0;
174 }
175 
176 static int do_hsvhold16_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
177 {
178  HSVKeyContext *s = avctx->priv;
179  AVFrame *frame = arg;
180  const int hsub_log2 = s->hsub_log2;
181  const int vsub_log2 = s->vsub_log2;
182  const int width = frame->width >> hsub_log2;
183  const int height = frame->height >> vsub_log2;
184  const int slice_start = (height * jobnr) / nb_jobs;
185  const int slice_end = (height * (jobnr + 1)) / nb_jobs;
186  const float scale = s->scale;
187  const float half = s->half;
188  const float hue = s->hue;
189  const float sat = s->sat;
190  const float val = s->val;
191 
192  for (int y = slice_start; y < slice_end; ++y) {
193  for (int x = 0; x < width; ++x) {
194  uint16_t *dstu = (uint16_t *)(frame->data[1] + frame->linesize[1] * y);
195  uint16_t *dstv = (uint16_t *)(frame->data[2] + frame->linesize[2] * y);
196  int Y = AV_RN16(&frame->data[0][frame->linesize[0] * (y << vsub_log2) + 2 * (x << hsub_log2)]);
197  int u = AV_RN16(&frame->data[1][frame->linesize[1] * y + 2 * x]);
198  int v = AV_RN16(&frame->data[2][frame->linesize[2] * y + 2 * x]);
199  int t = do_hsvkey_pixel(s, Y, u, v, hue, sat, val);
200 
201  if (t > 0) {
202  float f = 1.f - t * scale;
203 
204  dstu[x] = half + (u - half) * f;
205  dstv[x] = half + (v - half) * f;
206  }
207  }
208  }
209 
210  return 0;
211 }
212 
214 {
215  AVFilterContext *avctx = link->dst;
216  HSVKeyContext *s = avctx->priv;
217  int res;
218 
219  s->hue = FFSIGN(s->hue_opt) *M_PI * fmodf(526.f - fabsf(s->hue_opt), 360.f) / 180.f;
220  if (res = ff_filter_execute(avctx, s->do_slice, frame, NULL,
221  FFMIN(frame->height, ff_filter_get_nb_threads(avctx))))
222  return res;
223 
224  return ff_filter_frame(avctx->outputs[0], frame);
225 }
226 
227 static av_cold int config_output(AVFilterLink *outlink)
228 {
230  AVFilterContext *avctx = outlink->src;
231  HSVKeyContext *s = avctx->priv;
232 
233  s->depth = desc->comp[0].depth;
234  s->max = (1 << s->depth) - 1;
235  s->half = 0.5f * s->max;
236  s->scale = 1.f / s->max;
237 
238  if (!strcmp(avctx->filter->name, "hsvkey")) {
239  s->do_slice = s->depth <= 8 ? do_hsvkey_slice : do_hsvkey16_slice;
240  } else {
241  s->do_slice = s->depth <= 8 ? do_hsvhold_slice: do_hsvhold16_slice;
242  }
243 
244  return 0;
245 }
246 
248 {
249  AVFilterContext *avctx = inlink->dst;
250  HSVKeyContext *s = avctx->priv;
252 
253  s->hsub_log2 = desc->log2_chroma_w;
254  s->vsub_log2 = desc->log2_chroma_h;
255 
256  return 0;
257 }
258 
259 static const enum AVPixelFormat key_pixel_fmts[] = {
268 };
269 
270 static const AVFilterPad hsvkey_inputs[] = {
271  {
272  .name = "default",
273  .type = AVMEDIA_TYPE_VIDEO,
275  .filter_frame = filter_frame,
276  .config_props = config_input,
277  },
278 };
279 
280 static const AVFilterPad hsvkey_outputs[] = {
281  {
282  .name = "default",
283  .type = AVMEDIA_TYPE_VIDEO,
284  .config_props = config_output,
285  },
286 };
287 
288 #define OFFSET(x) offsetof(HSVKeyContext, x)
289 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
290 
291 static const AVOption hsvkey_options[] = {
292  { "hue", "set the hue value", OFFSET(hue_opt), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -360, 360, FLAGS },
293  { "sat", "set the saturation value", OFFSET(sat), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -1, 1, FLAGS },
294  { "val", "set the value value", OFFSET(val), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -1, 1, FLAGS },
295  { "similarity", "set the hsvkey similarity value", OFFSET(similarity), AV_OPT_TYPE_FLOAT, { .dbl = 0.01}, 0.00001, 1.0, FLAGS },
296  { "blend", "set the hsvkey blend value", OFFSET(blend), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, 0.0, 1.0, FLAGS },
297  { NULL }
298 };
299 
300 AVFILTER_DEFINE_CLASS(hsvkey);
301 
303  .name = "hsvkey",
304  .description = NULL_IF_CONFIG_SMALL("Turns a certain HSV range into transparency. Operates on YUV colors."),
305  .priv_size = sizeof(HSVKeyContext),
306  .priv_class = &hsvkey_class,
311  .process_command = ff_filter_process_command,
312 };
313 
314 static const enum AVPixelFormat hold_pixel_fmts[] = {
331 };
332 
333 static const AVOption hsvhold_options[] = {
334  { "hue", "set the hue value", OFFSET(hue_opt), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -360, 360, FLAGS },
335  { "sat", "set the saturation value", OFFSET(sat), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -1, 1, FLAGS },
336  { "val", "set the value value", OFFSET(val), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, -1, 1, FLAGS },
337  { "similarity", "set the hsvhold similarity value", OFFSET(similarity), AV_OPT_TYPE_FLOAT, { .dbl = 0.01 }, 0.00001, 1.0, FLAGS },
338  { "blend", "set the hsvhold blend value", OFFSET(blend), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, 0.0, 1.0, FLAGS },
339  { NULL }
340 };
341 
342 static const AVFilterPad hsvhold_inputs[] = {
343  {
344  .name = "default",
345  .type = AVMEDIA_TYPE_VIDEO,
347  .filter_frame = filter_frame,
348  .config_props = config_input,
349  },
350 };
351 
352 static const AVFilterPad hsvhold_outputs[] = {
353  {
354  .name = "default",
355  .type = AVMEDIA_TYPE_VIDEO,
356  .config_props = config_output,
357  },
358 };
359 
360 AVFILTER_DEFINE_CLASS(hsvhold);
361 
363  .name = "hsvhold",
364  .description = NULL_IF_CONFIG_SMALL("Turns a certain HSV range into gray."),
365  .priv_size = sizeof(HSVKeyContext),
366  .priv_class = &hsvhold_class,
371  .process_command = ff_filter_process_command,
372 };
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:447
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
opt.h
HSVKeyContext::half
float half
Definition: vf_hsvkey.c:40
u
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:264
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2660
HSVKeyContext::hue_opt
float hue_opt
Definition: vf_hsvkey.c:34
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
atan2f
#define atan2f(y, x)
Definition: libm.h:45
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
AV_RN16
#define AV_RN16(p)
Definition: intreadwrite.h:360
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:439
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:446
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:441
AVOption
AVOption.
Definition: opt.h:247
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:404
half
static uint8_t half(int a, int b)
Definition: mobiclip.c:540
float.h
max
#define max(a, b)
Definition: cuda_runtime.h:33
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
video.h
HSVKeyContext::hsub_log2
int hsub_log2
Definition: vf_hsvkey.c:45
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:442
formats.h
config_input
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_hsvkey.c:247
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:438
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(hsvkey)
do_hsvhold_slice
static int do_hsvhold_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_hsvkey.c:140
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:417
cosf
#define cosf(x)
Definition: libm.h:78
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:448
FFSIGN
#define FFSIGN(a)
Definition: common.h:66
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:402
SQR
#define SQR(x)
Definition: vf_hsvkey.c:52
HSVKeyContext::similarity
float similarity
Definition: vf_hsvkey.c:35
HSVKeyContext::scale
float scale
Definition: vf_hsvkey.c:38
val
static double val(void *priv, double ch)
Definition: aeval.c:76
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1388
fabsf
static __device__ float fabsf(float a)
Definition: cuda_runtime.h:181
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:407
config_output
static av_cold int config_output(AVFilterLink *outlink)
Definition: vf_hsvkey.c:227
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:416
HSVKeyContext::depth
int depth
Definition: vf_hsvkey.c:42
width
#define width
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
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:101
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:417
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: vf_hsvkey.c:213
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2042
do_hsvkey_pixel
static int do_hsvkey_pixel(HSVKeyContext *s, int y, int u, int v, float hue_key, float sat_key, float val_key)
Definition: vf_hsvkey.c:54
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:445
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:401
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:415
ctx
AVFormatContext * ctx
Definition: movenc.c:48
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:66
f
#define f(width, name)
Definition: cbs_vp9.c:255
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
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
HSVKeyContext::vsub_log2
int vsub_log2
Definition: vf_hsvkey.c:46
arg
const char * arg
Definition: jacosubdec.c:67
hsvhold_inputs
static const AVFilterPad hsvhold_inputs[]
Definition: vf_hsvkey.c:342
HSVKeyContext::sat
float sat
Definition: vf_hsvkey.c:34
hsvkey_outputs
static const AVFilterPad hsvkey_outputs[]
Definition: vf_hsvkey.c:280
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
do_hsvhold16_slice
static int do_hsvhold16_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_hsvkey.c:176
hsvkey_options
static const AVOption hsvkey_options[]
Definition: vf_hsvkey.c:291
av_clipf
#define av_clipf
Definition: common.h:144
do_hsvkey16_slice
static int do_hsvkey16_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_hsvkey.c:114
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:405
FLAGS
#define FLAGS
Definition: vf_hsvkey.c:289
hsvhold_options
static const AVOption hsvhold_options[]
Definition: vf_hsvkey.c:333
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:117
HSVKeyContext::val
float val
Definition: vf_hsvkey.c:34
fmaxf
float fmaxf(float, float)
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:409
ff_vf_hsvkey
const AVFilter ff_vf_hsvkey
Definition: vf_hsvkey.c:302
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:411
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:882
do_hsvkey_slice
static int do_hsvkey_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_hsvkey.c:89
height
#define height
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:167
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:443
M_PI
#define M_PI
Definition: mathematics.h:52
Y
#define Y
Definition: boxblur.h:37
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:146
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
HSVKeyContext::do_slice
int(* do_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_hsvkey.c:48
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:803
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
ff_vf_hsvhold
const AVFilter ff_vf_hsvhold
Definition: vf_hsvkey.c:362
HSVKeyContext
Definition: vf_hsvkey.c:31
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:403
key_pixel_fmts
static enum AVPixelFormat key_pixel_fmts[]
Definition: vf_hsvkey.c:259
AVFilter
Filter definition.
Definition: avfilter.h:165
hsvkey_inputs
static const AVFilterPad hsvkey_inputs[]
Definition: vf_hsvkey.c:270
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
HSVKeyContext::hue
float hue
Definition: vf_hsvkey.c:34
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:440
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:408
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:413
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:444
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:71
HSVKeyContext::max
int max
Definition: vf_hsvkey.c:43
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
OFFSET
#define OFFSET(x)
Definition: vf_hsvkey.c:288
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:121
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
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:70
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
diff
static av_always_inline int diff(const uint32_t a, const uint32_t b)
Definition: vf_palettegen.c:139
hold_pixel_fmts
static enum AVPixelFormat hold_pixel_fmts[]
Definition: vf_hsvkey.c:314
HSVKeyContext::blend
float blend
Definition: vf_hsvkey.c:36
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
hsvhold_outputs
static const AVFilterPad hsvhold_outputs[]
Definition: vf_hsvkey.c:352
imgutils.h
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:414
AVFilterContext::filter
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:405
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:143
int
int
Definition: ffmpeg_filter.c:153
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:166
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:412
AVFilterContext::outputs
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:414
AVFILTERPAD_FLAG_NEEDS_WRITABLE
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
Definition: internal.h:69