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