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