FFmpeg
vf_floodfill.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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/opt.h"
22 #include "libavutil/imgutils.h"
23 #include "libavutil/intreadwrite.h"
24 #include "avfilter.h"
25 #include "formats.h"
26 #include "internal.h"
27 #include "video.h"
28 
29 typedef struct Points {
30  uint16_t x, y;
31 } Points;
32 
33 typedef struct FloodfillContext {
34  const AVClass *class;
35 
36  int x, y;
37  int s[4];
38  int S[4];
39  int d[4];
40 
41  int nb_planes;
42  int back, front;
44 
45  int (*is_same)(const AVFrame *frame, int x, int y,
46  unsigned s0, unsigned s1, unsigned s2, unsigned s3);
47  void (*set_pixel)(AVFrame *frame, int x, int y,
48  unsigned d0, unsigned d1, unsigned d2, unsigned d3);
49  void (*pick_pixel)(const AVFrame *frame, int x, int y,
50  int *s0, int *s1, int *s2, int *s3);
52 
53 static int is_inside(int x, int y, int w, int h)
54 {
55  if (x >= 0 && x < w && y >= 0 && y < h)
56  return 1;
57  return 0;
58 }
59 
60 static int is_same4(const AVFrame *frame, int x, int y,
61  unsigned s0, unsigned s1, unsigned s2, unsigned s3)
62 {
63  unsigned c0 = frame->data[0][y * frame->linesize[0] + x];
64  unsigned c1 = frame->data[1][y * frame->linesize[1] + x];
65  unsigned c2 = frame->data[2][y * frame->linesize[2] + x];
66  unsigned c3 = frame->data[3][y * frame->linesize[3] + x];
67 
68  if (s0 == c0 && s1 == c1 && s2 == c2 && s3 == c3)
69  return 1;
70  return 0;
71 }
72 
73 static int is_same4_16(const AVFrame *frame, int x, int y,
74  unsigned s0, unsigned s1, unsigned s2, unsigned s3)
75 {
76  unsigned c0 = AV_RN16(frame->data[0] + y * frame->linesize[0] + 2 * x);
77  unsigned c1 = AV_RN16(frame->data[1] + y * frame->linesize[1] + 2 * x);
78  unsigned c2 = AV_RN16(frame->data[2] + y * frame->linesize[2] + 2 * x);
79  unsigned c3 = AV_RN16(frame->data[3] + y * frame->linesize[3] + 2 * x);
80 
81  if (s0 == c0 && s1 == c1 && s2 == c2 && s3 == c3)
82  return 1;
83  return 0;
84 }
85 
86 static int is_same3(const AVFrame *frame, int x, int y,
87  unsigned s0, unsigned s1, unsigned s2, unsigned s3)
88 {
89  unsigned c0 = frame->data[0][y * frame->linesize[0] + x];
90  unsigned c1 = frame->data[1][y * frame->linesize[1] + x];
91  unsigned c2 = frame->data[2][y * frame->linesize[2] + x];
92 
93  if (s0 == c0 && s1 == c1 && s2 == c2)
94  return 1;
95  return 0;
96 }
97 
98 static int is_same3_16(const AVFrame *frame, int x, int y,
99  unsigned s0, unsigned s1, unsigned s2, unsigned s3)
100 {
101  unsigned c0 = AV_RN16(frame->data[0] + y * frame->linesize[0] + 2 * x);
102  unsigned c1 = AV_RN16(frame->data[1] + y * frame->linesize[1] + 2 * x);
103  unsigned c2 = AV_RN16(frame->data[2] + y * frame->linesize[2] + 2 * x);
104 
105  if (s0 == c0 && s1 == c1 && s2 == c2)
106  return 1;
107  return 0;
108 }
109 
110 static int is_same1(const AVFrame *frame, int x, int y,
111  unsigned s0, unsigned s1, unsigned s2, unsigned s3)
112 {
113  unsigned c0 = frame->data[0][y * frame->linesize[0] + x];
114 
115  if (s0 == c0)
116  return 1;
117  return 0;
118 }
119 
120 static int is_same1_16(const AVFrame *frame, int x, int y,
121  unsigned s0, unsigned s1, unsigned s2, unsigned s3)
122 {
123  unsigned c0 = AV_RN16(frame->data[0] + y * frame->linesize[0] + 2 * x);
124 
125  if (s0 == c0)
126  return 1;
127  return 0;
128 }
129 
130 static void set_pixel1(AVFrame *frame, int x, int y,
131  unsigned d0, unsigned d1, unsigned d2, unsigned d3)
132 {
133  frame->data[0][y * frame->linesize[0] + x] = d0;
134 }
135 
136 static void set_pixel1_16(AVFrame *frame, int x, int y,
137  unsigned d0, unsigned d1, unsigned d2, unsigned d3)
138 {
139  AV_WN16(frame->data[0] + y * frame->linesize[0] + 2 * x, d0);
140 }
141 
142 static void set_pixel3(AVFrame *frame, int x, int y,
143  unsigned d0, unsigned d1, unsigned d2, unsigned d3)
144 {
145  frame->data[0][y * frame->linesize[0] + x] = d0;
146  frame->data[1][y * frame->linesize[1] + x] = d1;
147  frame->data[2][y * frame->linesize[2] + x] = d2;
148 }
149 
150 static void set_pixel3_16(AVFrame *frame, int x, int y,
151  unsigned d0, unsigned d1, unsigned d2, unsigned d3)
152 {
153  AV_WN16(frame->data[0] + y * frame->linesize[0] + 2 * x, d0);
154  AV_WN16(frame->data[1] + y * frame->linesize[1] + 2 * x, d1);
155  AV_WN16(frame->data[2] + y * frame->linesize[2] + 2 * x, d2);
156 }
157 
158 static void set_pixel4(AVFrame *frame, int x, int y,
159  unsigned d0, unsigned d1, unsigned d2, unsigned d3)
160 {
161  frame->data[0][y * frame->linesize[0] + x] = d0;
162  frame->data[1][y * frame->linesize[1] + x] = d1;
163  frame->data[2][y * frame->linesize[2] + x] = d2;
164  frame->data[3][y * frame->linesize[3] + x] = d3;
165 }
166 
167 static void set_pixel4_16(AVFrame *frame, int x, int y,
168  unsigned d0, unsigned d1, unsigned d2, unsigned d3)
169 {
170  AV_WN16(frame->data[0] + y * frame->linesize[0] + 2 * x, d0);
171  AV_WN16(frame->data[1] + y * frame->linesize[1] + 2 * x, d1);
172  AV_WN16(frame->data[2] + y * frame->linesize[2] + 2 * x, d2);
173  AV_WN16(frame->data[3] + y * frame->linesize[3] + 2 * x, d3);
174 }
175 
176 static void pick_pixel1(const AVFrame *frame, int x, int y,
177  int *s0, int *s1, int *s2, int *s3)
178 {
179  if (*s0 < 0)
180  *s0 = frame->data[0][y * frame->linesize[0] + x];
181 }
182 
183 static void pick_pixel1_16(const AVFrame *frame, int x, int y,
184  int *s0, int *s1, int *s2, int *s3)
185 {
186  if (*s0 < 0)
187  *s0 = AV_RN16(frame->data[0] + y * frame->linesize[0] + 2 * x);
188 }
189 
190 static void pick_pixel3(const AVFrame *frame, int x, int y,
191  int *s0, int *s1, int *s2, int *s3)
192 {
193  if (*s0 < 0)
194  *s0 = frame->data[0][y * frame->linesize[0] + x];
195  if (*s1 < 0)
196  *s1 = frame->data[1][y * frame->linesize[1] + x];
197  if (*s2 < 0)
198  *s2 = frame->data[2][y * frame->linesize[2] + x];
199 }
200 
201 static void pick_pixel3_16(const AVFrame *frame, int x, int y,
202  int *s0, int *s1, int *s2, int *s3)
203 {
204  if (*s0 < 0)
205  *s0 = AV_RN16(frame->data[0] + y * frame->linesize[0] + 2 * x);
206  if (*s1 < 0)
207  *s1 = AV_RN16(frame->data[1] + y * frame->linesize[1] + 2 * x);
208  if (*s2 < 0)
209  *s2 = AV_RN16(frame->data[2] + y * frame->linesize[2] + 2 * x);
210 }
211 
212 static void pick_pixel4(const AVFrame *frame, int x, int y,
213  int *s0, int *s1, int *s2, int *s3)
214 {
215  if (*s0 < 0)
216  *s0 = frame->data[0][y * frame->linesize[0] + x];
217  if (*s1 < 0)
218  *s1 = frame->data[1][y * frame->linesize[1] + x];
219  if (*s2 < 0)
220  *s2 = frame->data[2][y * frame->linesize[2] + x];
221  if (*s3 < 0)
222  *s3 = frame->data[3][y * frame->linesize[3] + x];
223 }
224 
225 static void pick_pixel4_16(const AVFrame *frame, int x, int y,
226  int *s0, int *s1, int *s2, int *s3)
227 {
228  if (*s0 < 0)
229  *s0 = AV_RN16(frame->data[0] + y * frame->linesize[0] + 2 * x);
230  if (*s1 < 0)
231  *s1 = AV_RN16(frame->data[1] + y * frame->linesize[1] + 2 * x);
232  if (*s2 < 0)
233  *s2 = AV_RN16(frame->data[2] + y * frame->linesize[2] + 2 * x);
234  if (*s3 < 0)
235  *s3 = AV_RN16(frame->data[3] + y * frame->linesize[3] + 2 * x);
236 }
237 
239 {
241  AVFilterContext *ctx = inlink->dst;
242  FloodfillContext *s = ctx->priv;
243  int depth;
244 
245  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
246  depth = desc->comp[0].depth;
247  if (depth == 8) {
248  switch (s->nb_planes) {
249  case 1: s->set_pixel = set_pixel1;
250  s->is_same = is_same1;
251  s->pick_pixel = pick_pixel1; break;
252  case 3: s->set_pixel = set_pixel3;
253  s->is_same = is_same3;
254  s->pick_pixel = pick_pixel3; break;
255  case 4: s->set_pixel = set_pixel4;
256  s->is_same = is_same4;
257  s->pick_pixel = pick_pixel4; break;
258  }
259  } else {
260  switch (s->nb_planes) {
261  case 1: s->set_pixel = set_pixel1_16;
262  s->is_same = is_same1_16;
263  s->pick_pixel = pick_pixel1_16; break;
264  case 3: s->set_pixel = set_pixel3_16;
265  s->is_same = is_same3_16;
266  s->pick_pixel = pick_pixel3_16; break;
267  case 4: s->set_pixel = set_pixel4_16;
268  s->is_same = is_same4_16;
269  s->pick_pixel = pick_pixel4_16; break;
270  }
271  }
272 
273  s->front = s->back = 0;
274  s->points = av_calloc(inlink->w * inlink->h, 4 * sizeof(Points));
275  if (!s->points)
276  return AVERROR(ENOMEM);
277 
278  return 0;
279 }
280 
282 {
283  AVFilterContext *ctx = link->dst;
284  FloodfillContext *s = ctx->priv;
285  const unsigned d0 = s->d[0];
286  const unsigned d1 = s->d[1];
287  const unsigned d2 = s->d[2];
288  const unsigned d3 = s->d[3];
289  int s0 = s->s[0];
290  int s1 = s->s[1];
291  int s2 = s->s[2];
292  int s3 = s->s[3];
293  const int w = frame->width;
294  const int h = frame->height;
295  int i, ret;
296 
297  if (is_inside(s->x, s->y, w, h)) {
298  s->pick_pixel(frame, s->x, s->y, &s0, &s1, &s2, &s3);
299 
300  s->S[0] = s0;
301  s->S[1] = s1;
302  s->S[2] = s2;
303  s->S[3] = s3;
304  for (i = 0; i < s->nb_planes; i++) {
305  if (s->S[i] != s->d[i])
306  break;
307  }
308 
309  if (i == s->nb_planes)
310  goto end;
311 
312  if (s->is_same(frame, s->x, s->y, s0, s1, s2, s3)) {
313  s->points[s->front].x = s->x;
314  s->points[s->front].y = s->y;
315  s->front++;
316  }
317 
319  return ret;
320 
321  while (s->front > s->back) {
322  int x, y;
323 
324  s->front--;
325  x = s->points[s->front].x;
326  y = s->points[s->front].y;
327 
328  if (s->is_same(frame, x, y, s0, s1, s2, s3)) {
329  s->set_pixel(frame, x, y, d0, d1, d2, d3);
330 
331  if (is_inside(x + 1, y, w, h)) {
332  s->points[s->front] .x = x + 1;
333  s->points[s->front++].y = y;
334  }
335 
336  if (is_inside(x - 1, y, w, h)) {
337  s->points[s->front] .x = x - 1;
338  s->points[s->front++].y = y;
339  }
340 
341  if (is_inside(x, y + 1, w, h)) {
342  s->points[s->front] .x = x;
343  s->points[s->front++].y = y + 1;
344  }
345 
346  if (is_inside(x, y - 1, w, h)) {
347  s->points[s->front] .x = x;
348  s->points[s->front++].y = y - 1;
349  }
350  }
351  }
352  }
353 
354 end:
355  return ff_filter_frame(ctx->outputs[0], frame);
356 }
357 
358 static const enum AVPixelFormat pixel_fmts[] = {
367 };
368 
370 {
371  FloodfillContext *s = ctx->priv;
372 
373  av_freep(&s->points);
374 }
375 
376 static const AVFilterPad floodfill_inputs[] = {
377  {
378  .name = "default",
379  .type = AVMEDIA_TYPE_VIDEO,
380  .filter_frame = filter_frame,
381  .config_props = config_input,
382  },
383 };
384 
385 static const AVFilterPad floodfill_outputs[] = {
386  {
387  .name = "default",
388  .type = AVMEDIA_TYPE_VIDEO,
389  },
390 };
391 
392 #define OFFSET(x) offsetof(FloodfillContext, x)
393 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
394 
395 static const AVOption floodfill_options[] = {
396  { "x", "set pixel x coordinate", OFFSET(x), AV_OPT_TYPE_INT, {.i64=0}, 0, UINT16_MAX, FLAGS },
397  { "y", "set pixel y coordinate", OFFSET(y), AV_OPT_TYPE_INT, {.i64=0}, 0, UINT16_MAX, FLAGS },
398  { "s0", "set source #0 component value", OFFSET(s[0]), AV_OPT_TYPE_INT, {.i64=0},-1, UINT16_MAX, FLAGS },
399  { "s1", "set source #1 component value", OFFSET(s[1]), AV_OPT_TYPE_INT, {.i64=0},-1, UINT16_MAX, FLAGS },
400  { "s2", "set source #2 component value", OFFSET(s[2]), AV_OPT_TYPE_INT, {.i64=0},-1, UINT16_MAX, FLAGS },
401  { "s3", "set source #3 component value", OFFSET(s[3]), AV_OPT_TYPE_INT, {.i64=0},-1, UINT16_MAX, FLAGS },
402  { "d0", "set destination #0 component value", OFFSET(d[0]), AV_OPT_TYPE_INT, {.i64=0}, 0, UINT16_MAX, FLAGS },
403  { "d1", "set destination #1 component value", OFFSET(d[1]), AV_OPT_TYPE_INT, {.i64=0}, 0, UINT16_MAX, FLAGS },
404  { "d2", "set destination #2 component value", OFFSET(d[2]), AV_OPT_TYPE_INT, {.i64=0}, 0, UINT16_MAX, FLAGS },
405  { "d3", "set destination #3 component value", OFFSET(d[3]), AV_OPT_TYPE_INT, {.i64=0}, 0, UINT16_MAX, FLAGS },
406  { NULL }
407 };
408 
409 AVFILTER_DEFINE_CLASS(floodfill);
410 
412  .name = "floodfill",
413  .description = NULL_IF_CONFIG_SMALL("Fill area with same color with another color."),
414  .priv_size = sizeof(FloodfillContext),
415  .priv_class = &floodfill_class,
416  .uninit = uninit,
421 };
is_inside
static int is_inside(int x, int y, int w, int h)
Definition: vf_floodfill.c:53
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:426
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
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
is_same1
static int is_same1(const AVFrame *frame, int x, int y, unsigned s0, unsigned s1, unsigned s2, unsigned s3)
Definition: vf_floodfill.c:110
pixel_fmts
static enum AVPixelFormat pixel_fmts[]
Definition: vf_floodfill.c:358
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
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
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
floodfill_inputs
static const AVFilterPad floodfill_inputs[]
Definition: vf_floodfill.c:376
AV_RN16
#define AV_RN16(p)
Definition: intreadwrite.h:360
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
av_frame_make_writable
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
Definition: frame.c:490
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:247
is_same1_16
static int is_same1_16(const AVFrame *frame, int x, int y, unsigned s0, unsigned s1, unsigned s2, unsigned s3)
Definition: vf_floodfill.c:120
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_floodfill.c:369
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
c1
static const uint64_t c1
Definition: murmur3.c:51
FloodfillContext::pick_pixel
void(* pick_pixel)(const AVFrame *frame, int x, int y, int *s0, int *s1, int *s2, int *s3)
Definition: vf_floodfill.c:49
video.h
is_same4
static int is_same4(const AVFrame *frame, int x, int y, unsigned s0, unsigned s1, unsigned s2, unsigned s3)
Definition: vf_floodfill.c:60
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:384
formats.h
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2700
set_pixel4_16
static void set_pixel4_16(AVFrame *frame, int x, int y, unsigned d0, unsigned d1, unsigned d2, unsigned d3)
Definition: vf_floodfill.c:167
s3
#define s3
Definition: regdef.h:40
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:422
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
pick_pixel4
static void pick_pixel4(const AVFrame *frame, int x, int y, int *s0, int *s1, int *s2, int *s3)
Definition: vf_floodfill.c:212
is_same3_16
static int is_same3_16(const AVFrame *frame, int x, int y, unsigned s0, unsigned s1, unsigned s2, unsigned s3)
Definition: vf_floodfill.c:98
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:420
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:448
FloodfillContext::front
int front
Definition: vf_floodfill.c:42
set_pixel4
static void set_pixel4(AVFrame *frame, int x, int y, unsigned d0, unsigned d1, unsigned d2, unsigned d3)
Definition: vf_floodfill.c:158
FloodfillContext::y
int y
Definition: vf_floodfill.c:36
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:388
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
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:424
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
is_same3
static int is_same3(const AVFrame *frame, int x, int y, unsigned s0, unsigned s1, unsigned s2, unsigned s3)
Definition: vf_floodfill.c:86
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:425
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:417
s1
#define s1
Definition: regdef.h:38
FloodfillContext::x
int x
Definition: vf_floodfill.c:36
FloodfillContext::points
Points * points
Definition: vf_floodfill.c:43
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:387
is_same4_16
static int is_same4_16(const AVFrame *frame, int x, int y, unsigned s0, unsigned s1, unsigned s2, unsigned s3)
Definition: vf_floodfill.c:73
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_floodfill.c:238
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
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:385
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:423
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
FloodfillContext::d
int d[4]
Definition: vf_floodfill.c:39
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: vf_floodfill.c:281
FloodfillContext::S
int S[4]
Definition: vf_floodfill.c:38
FloodfillContext::set_pixel
void(* set_pixel)(AVFrame *frame, int x, int y, unsigned d0, unsigned d1, unsigned d2, unsigned d3)
Definition: vf_floodfill.c:47
pick_pixel4_16
static void pick_pixel4_16(const AVFrame *frame, int x, int y, int *s0, int *s1, int *s2, int *s3)
Definition: vf_floodfill.c:225
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:419
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(floodfill)
FLAGS
#define FLAGS
Definition: vf_floodfill.c:393
FloodfillContext::nb_planes
int nb_planes
Definition: vf_floodfill.c:41
s2
#define s2
Definition: regdef.h:39
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
pick_pixel1
static void pick_pixel1(const AVFrame *frame, int x, int y, int *s0, int *s1, int *s2, int *s3)
Definition: vf_floodfill.c:176
FloodfillContext::is_same
int(* is_same)(const AVFrame *frame, int x, int y, unsigned s0, unsigned s1, unsigned s2, unsigned s3)
Definition: vf_floodfill.c:45
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:411
pick_pixel3_16
static void pick_pixel3_16(const AVFrame *frame, int x, int y, int *s0, int *s1, int *s2, int *s3)
Definition: vf_floodfill.c:201
pick_pixel1_16
static void pick_pixel1_16(const AVFrame *frame, int x, int y, int *s0, int *s1, int *s2, int *s3)
Definition: vf_floodfill.c:183
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
set_pixel1
static void set_pixel1(AVFrame *frame, int x, int y, unsigned d0, unsigned d1, unsigned d2, unsigned d3)
Definition: vf_floodfill.c:130
set_pixel3
static void set_pixel3(AVFrame *frame, int x, int y, unsigned d0, unsigned d1, unsigned d2, unsigned d3)
Definition: vf_floodfill.c:142
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
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
pick_pixel3
static void pick_pixel3(const AVFrame *frame, int x, int y, int *s0, int *s1, int *s2, int *s3)
Definition: vf_floodfill.c:190
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:421
FloodfillContext::s
int s[4]
Definition: vf_floodfill.c:37
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:271
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:403
AVFilter
Filter definition.
Definition: avfilter.h:165
Points::x
uint16_t x
Definition: vf_floodfill.c:30
ff_vf_floodfill
const AVFilter ff_vf_floodfill
Definition: vf_floodfill.c:411
ret
ret
Definition: filter_design.txt:187
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
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:440
OFFSET
#define OFFSET(x)
Definition: vf_floodfill.c:392
c2
static const uint64_t c2
Definition: murmur3.c:52
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
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
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
Points
Definition: vf_floodfill.c:29
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
s0
#define s0
Definition: regdef.h:37
set_pixel1_16
static void set_pixel1_16(AVFrame *frame, int x, int y, unsigned d0, unsigned d1, unsigned d2, unsigned d3)
Definition: vf_floodfill.c:136
set_pixel3_16
static void set_pixel3_16(AVFrame *frame, int x, int y, unsigned d0, unsigned d1, unsigned d2, unsigned d3)
Definition: vf_floodfill.c:150
floodfill_options
static const AVOption floodfill_options[]
Definition: vf_floodfill.c:395
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
d
d
Definition: ffmpeg_filter.c:153
imgutils.h
FloodfillContext::back
int back
Definition: vf_floodfill.c:42
h
h
Definition: vp9dsp_template.c:2038
floodfill_outputs
static const AVFilterPad floodfill_outputs[]
Definition: vf_floodfill.c:385
FloodfillContext
Definition: vf_floodfill.c:33
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:414
int
int
Definition: ffmpeg_filter.c:153
Points::y
uint16_t y
Definition: vf_floodfill.c:30
AV_WN16
#define AV_WN16(p, v)
Definition: intreadwrite.h:372