FFmpeg
vf_edgedetect.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2014 Clément Bœsch <u pkh me>
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 /**
22  * @file
23  * Edge detection filter
24  *
25  * @see https://en.wikipedia.org/wiki/Canny_edge_detector
26  */
27 
28 #include "libavutil/avassert.h"
29 #include "libavutil/imgutils.h"
30 #include "libavutil/opt.h"
31 #include "avfilter.h"
32 #include "formats.h"
33 #include "internal.h"
34 #include "video.h"
35 
36 #define PLANE_R 0x4
37 #define PLANE_G 0x1
38 #define PLANE_B 0x2
39 #define PLANE_Y 0x1
40 #define PLANE_U 0x2
41 #define PLANE_V 0x4
42 #define PLANE_A 0x8
43 
44 enum FilterMode {
49 };
50 
51 struct plane_info {
52  uint8_t *tmpbuf;
53  uint16_t *gradients;
54  char *directions;
55  int width, height;
56 };
57 
58 typedef struct EdgeDetectContext {
59  const AVClass *class;
60  struct plane_info planes[3];
62  int nb_planes;
63  double low, high;
64  uint8_t low_u8, high_u8;
65  int mode;
67 
68 #define OFFSET(x) offsetof(EdgeDetectContext, x)
69 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
70 static const AVOption edgedetect_options[] = {
71  { "high", "set high threshold", OFFSET(high), AV_OPT_TYPE_DOUBLE, {.dbl=50/255.}, 0, 1, FLAGS },
72  { "low", "set low threshold", OFFSET(low), AV_OPT_TYPE_DOUBLE, {.dbl=20/255.}, 0, 1, FLAGS },
73  { "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_WIRES}, 0, NB_MODE-1, FLAGS, "mode" },
74  { "wires", "white/gray wires on black", 0, AV_OPT_TYPE_CONST, {.i64=MODE_WIRES}, INT_MIN, INT_MAX, FLAGS, "mode" },
75  { "colormix", "mix colors", 0, AV_OPT_TYPE_CONST, {.i64=MODE_COLORMIX}, INT_MIN, INT_MAX, FLAGS, "mode" },
76  { "canny", "detect edges on planes", 0, AV_OPT_TYPE_CONST, {.i64=MODE_CANNY}, INT_MIN, INT_MAX, FLAGS, "mode" },
77  { "planes", "set planes to filter", OFFSET(filter_planes), AV_OPT_TYPE_FLAGS, {.i64=7}, 1, 0x7, FLAGS, "flags" },
78  { "y", "filter luma plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_Y}, 0, 0, FLAGS, "flags" },
79  { "u", "filter u plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_U}, 0, 0, FLAGS, "flags" },
80  { "v", "filter v plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_V}, 0, 0, FLAGS, "flags" },
81  { "r", "filter red plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_R}, 0, 0, FLAGS, "flags" },
82  { "g", "filter green plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_G}, 0, 0, FLAGS, "flags" },
83  { "b", "filter blue plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_B}, 0, 0, FLAGS, "flags" },
84  { NULL }
85 };
86 
88 
90 {
92 
93  edgedetect->low_u8 = edgedetect->low * 255. + .5;
94  edgedetect->high_u8 = edgedetect->high * 255. + .5;
95  return 0;
96 }
97 
99 {
100  const EdgeDetectContext *edgedetect = ctx->priv;
101  static const enum AVPixelFormat wires_pix_fmts[] = {AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE};
103  static const enum AVPixelFormat colormix_pix_fmts[] = {AV_PIX_FMT_GBRP, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE};
104  const enum AVPixelFormat *pix_fmts = NULL;
105 
106  if (edgedetect->mode == MODE_WIRES) {
107  pix_fmts = wires_pix_fmts;
108  } else if (edgedetect->mode == MODE_COLORMIX) {
109  pix_fmts = colormix_pix_fmts;
110  } else if (edgedetect->mode == MODE_CANNY) {
111  pix_fmts = canny_pix_fmts;
112  } else {
113  av_assert0(0);
114  }
116 }
117 
119 {
120  int p;
121  AVFilterContext *ctx = inlink->dst;
124 
125  edgedetect->nb_planes = inlink->format == AV_PIX_FMT_GRAY8 ? 1 : 3;
126  for (p = 0; p < edgedetect->nb_planes; p++) {
127  struct plane_info *plane = &edgedetect->planes[p];
128  int vsub = p ? desc->log2_chroma_h : 0;
129  int hsub = p ? desc->log2_chroma_w : 0;
130 
131  plane->width = AV_CEIL_RSHIFT(inlink->w, hsub);
132  plane->height = AV_CEIL_RSHIFT(inlink->h, vsub);
133  plane->tmpbuf = av_malloc(plane->width * plane->height);
134  plane->gradients = av_calloc(plane->width * plane->height, sizeof(*plane->gradients));
135  plane->directions = av_malloc(plane->width * plane->height);
136  if (!plane->tmpbuf || !plane->gradients || !plane->directions)
137  return AVERROR(ENOMEM);
138  }
139  return 0;
140 }
141 
142 static void gaussian_blur(AVFilterContext *ctx, int w, int h,
143  uint8_t *dst, int dst_linesize,
144  const uint8_t *src, int src_linesize)
145 {
146  int i, j;
147 
148  memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
149  if (h > 1) {
150  memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
151  }
152  for (j = 2; j < h - 2; j++) {
153  dst[0] = src[0];
154  if (w > 1)
155  dst[1] = src[1];
156  for (i = 2; i < w - 2; i++) {
157  /* Gaussian mask of size 5x5 with sigma = 1.4 */
158  dst[i] = ((src[-2*src_linesize + i-2] + src[2*src_linesize + i-2]) * 2
159  + (src[-2*src_linesize + i-1] + src[2*src_linesize + i-1]) * 4
160  + (src[-2*src_linesize + i ] + src[2*src_linesize + i ]) * 5
161  + (src[-2*src_linesize + i+1] + src[2*src_linesize + i+1]) * 4
162  + (src[-2*src_linesize + i+2] + src[2*src_linesize + i+2]) * 2
163 
164  + (src[ -src_linesize + i-2] + src[ src_linesize + i-2]) * 4
165  + (src[ -src_linesize + i-1] + src[ src_linesize + i-1]) * 9
166  + (src[ -src_linesize + i ] + src[ src_linesize + i ]) * 12
167  + (src[ -src_linesize + i+1] + src[ src_linesize + i+1]) * 9
168  + (src[ -src_linesize + i+2] + src[ src_linesize + i+2]) * 4
169 
170  + src[i-2] * 5
171  + src[i-1] * 12
172  + src[i ] * 15
173  + src[i+1] * 12
174  + src[i+2] * 5) / 159;
175  }
176  if (w > 2)
177  dst[i ] = src[i ];
178  if (w > 3)
179  dst[i + 1] = src[i + 1];
180 
181  dst += dst_linesize;
182  src += src_linesize;
183  }
184  if (h > 2) {
185  memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
186  }
187  if (h > 3)
188  memcpy(dst, src, w);
189 }
190 
191 enum {
196 };
197 
198 static int get_rounded_direction(int gx, int gy)
199 {
200  /* reference angles:
201  * tan( pi/8) = sqrt(2)-1
202  * tan(3pi/8) = sqrt(2)+1
203  * Gy/Gx is the tangent of the angle (theta), so Gy/Gx is compared against
204  * <ref-angle>, or more simply Gy against <ref-angle>*Gx
205  *
206  * Gx and Gy bounds = [-1020;1020], using 16-bit arithmetic:
207  * round((sqrt(2)-1) * (1<<16)) = 27146
208  * round((sqrt(2)+1) * (1<<16)) = 158218
209  */
210  if (gx) {
211  int tanpi8gx, tan3pi8gx;
212 
213  if (gx < 0)
214  gx = -gx, gy = -gy;
215  gy *= (1 << 16);
216  tanpi8gx = 27146 * gx;
217  tan3pi8gx = 158218 * gx;
218  if (gy > -tan3pi8gx && gy < -tanpi8gx) return DIRECTION_45UP;
219  if (gy > -tanpi8gx && gy < tanpi8gx) return DIRECTION_HORIZONTAL;
220  if (gy > tanpi8gx && gy < tan3pi8gx) return DIRECTION_45DOWN;
221  }
222  return DIRECTION_VERTICAL;
223 }
224 
225 static void sobel(int w, int h,
226  uint16_t *dst, int dst_linesize,
227  int8_t *dir, int dir_linesize,
228  const uint8_t *src, int src_linesize)
229 {
230  int i, j;
231 
232  for (j = 1; j < h - 1; j++) {
233  dst += dst_linesize;
234  dir += dir_linesize;
235  src += src_linesize;
236  for (i = 1; i < w - 1; i++) {
237  const int gx =
238  -1*src[-src_linesize + i-1] + 1*src[-src_linesize + i+1]
239  -2*src[ i-1] + 2*src[ i+1]
240  -1*src[ src_linesize + i-1] + 1*src[ src_linesize + i+1];
241  const int gy =
242  -1*src[-src_linesize + i-1] + 1*src[ src_linesize + i-1]
243  -2*src[-src_linesize + i ] + 2*src[ src_linesize + i ]
244  -1*src[-src_linesize + i+1] + 1*src[ src_linesize + i+1];
245 
246  dst[i] = FFABS(gx) + FFABS(gy);
247  dir[i] = get_rounded_direction(gx, gy);
248  }
249  }
250 }
251 
252 static void non_maximum_suppression(int w, int h,
253  uint8_t *dst, int dst_linesize,
254  const int8_t *dir, int dir_linesize,
255  const uint16_t *src, int src_linesize)
256 {
257  int i, j;
258 
259 #define COPY_MAXIMA(ay, ax, by, bx) do { \
260  if (src[i] > src[(ay)*src_linesize + i+(ax)] && \
261  src[i] > src[(by)*src_linesize + i+(bx)]) \
262  dst[i] = av_clip_uint8(src[i]); \
263 } while (0)
264 
265  for (j = 1; j < h - 1; j++) {
266  dst += dst_linesize;
267  dir += dir_linesize;
268  src += src_linesize;
269  for (i = 1; i < w - 1; i++) {
270  switch (dir[i]) {
271  case DIRECTION_45UP: COPY_MAXIMA( 1, -1, -1, 1); break;
272  case DIRECTION_45DOWN: COPY_MAXIMA(-1, -1, 1, 1); break;
273  case DIRECTION_HORIZONTAL: COPY_MAXIMA( 0, -1, 0, 1); break;
274  case DIRECTION_VERTICAL: COPY_MAXIMA(-1, 0, 1, 0); break;
275  }
276  }
277  }
278 }
279 
280 static void double_threshold(int low, int high, int w, int h,
281  uint8_t *dst, int dst_linesize,
282  const uint8_t *src, int src_linesize)
283 {
284  int i, j;
285 
286  for (j = 0; j < h; j++) {
287  for (i = 0; i < w; i++) {
288  if (src[i] > high) {
289  dst[i] = src[i];
290  continue;
291  }
292 
293  if (!(!i || i == w - 1 || !j || j == h - 1) &&
294  src[i] > low &&
295  (src[-src_linesize + i-1] > high ||
296  src[-src_linesize + i ] > high ||
297  src[-src_linesize + i+1] > high ||
298  src[ i-1] > high ||
299  src[ i+1] > high ||
300  src[ src_linesize + i-1] > high ||
301  src[ src_linesize + i ] > high ||
302  src[ src_linesize + i+1] > high))
303  dst[i] = src[i];
304  else
305  dst[i] = 0;
306  }
307  dst += dst_linesize;
308  src += src_linesize;
309  }
310 }
311 
312 static void color_mix(int w, int h,
313  uint8_t *dst, int dst_linesize,
314  const uint8_t *src, int src_linesize)
315 {
316  int i, j;
317 
318  for (j = 0; j < h; j++) {
319  for (i = 0; i < w; i++)
320  dst[i] = (dst[i] + src[i]) >> 1;
321  dst += dst_linesize;
322  src += src_linesize;
323  }
324 }
325 
327 {
328  AVFilterContext *ctx = inlink->dst;
330  AVFilterLink *outlink = ctx->outputs[0];
331  int p, direct = 0;
332  AVFrame *out;
333 
334  if (edgedetect->mode != MODE_COLORMIX && av_frame_is_writable(in)) {
335  direct = 1;
336  out = in;
337  } else {
338  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
339  if (!out) {
340  av_frame_free(&in);
341  return AVERROR(ENOMEM);
342  }
344  }
345 
346  for (p = 0; p < edgedetect->nb_planes; p++) {
347  struct plane_info *plane = &edgedetect->planes[p];
348  uint8_t *tmpbuf = plane->tmpbuf;
349  uint16_t *gradients = plane->gradients;
350  int8_t *directions = plane->directions;
351  const int width = plane->width;
352  const int height = plane->height;
353 
354  if (!((1 << p) & edgedetect->filter_planes)) {
355  if (!direct)
356  av_image_copy_plane(out->data[p], out->linesize[p],
357  in->data[p], in->linesize[p],
358  width, height);
359  continue;
360  }
361 
362  /* gaussian filter to reduce noise */
364  tmpbuf, width,
365  in->data[p], in->linesize[p]);
366 
367  /* compute the 16-bits gradients and directions for the next step */
368  sobel(width, height,
369  gradients, width,
371  tmpbuf, width);
372 
373  /* non_maximum_suppression() will actually keep & clip what's necessary and
374  * ignore the rest, so we need a clean output buffer */
375  memset(tmpbuf, 0, width * height);
377  tmpbuf, width,
379  gradients, width);
380 
381  /* keep high values, or low values surrounded by high values */
382  double_threshold(edgedetect->low_u8, edgedetect->high_u8,
383  width, height,
384  out->data[p], out->linesize[p],
385  tmpbuf, width);
386 
387  if (edgedetect->mode == MODE_COLORMIX) {
389  out->data[p], out->linesize[p],
390  in->data[p], in->linesize[p]);
391  }
392  }
393 
394  if (!direct)
395  av_frame_free(&in);
396  return ff_filter_frame(outlink, out);
397 }
398 
400 {
401  int p;
403 
404  for (p = 0; p < edgedetect->nb_planes; p++) {
405  struct plane_info *plane = &edgedetect->planes[p];
406  av_freep(&plane->tmpbuf);
407  av_freep(&plane->gradients);
408  av_freep(&plane->directions);
409  }
410 }
411 
412 static const AVFilterPad edgedetect_inputs[] = {
413  {
414  .name = "default",
415  .type = AVMEDIA_TYPE_VIDEO,
416  .config_props = config_props,
417  .filter_frame = filter_frame,
418  },
419 };
420 
421 static const AVFilterPad edgedetect_outputs[] = {
422  {
423  .name = "default",
424  .type = AVMEDIA_TYPE_VIDEO,
425  },
426 };
427 
429  .name = "edgedetect",
430  .description = NULL_IF_CONFIG_SMALL("Detect and draw edge."),
431  .priv_size = sizeof(EdgeDetectContext),
432  .init = init,
433  .uninit = uninit,
437  .priv_class = &edgedetect_class,
439 };
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:98
direct
static void direct(const float *in, const FFTComplex *ir, int len, float *out)
Definition: af_afir.c:61
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
DIRECTION_45DOWN
@ DIRECTION_45DOWN
Definition: vf_edgedetect.c:193
out
FILE * out
Definition: movenc.c:54
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
PLANE_B
#define PLANE_B
Definition: vf_edgedetect.c:38
edgedetect
This document is a tutorial initiation for writing simple filters in libavfilter libavfilter is which means that it is highly recommended that you submit your filters to the FFmpeg development mailing list and make sure that they are applied your filters are likely to have a very short lifetime due to more or less regular internal API and a limited and testing changes the pixels in whatever fashion you and outputs the modified frame The most simple way of doing this is to take a similar filter We ll pick edgedetect
Definition: writing_filters.txt:16
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
gaussian_blur
static void gaussian_blur(AVFilterContext *ctx, int w, int h, uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize)
Definition: vf_edgedetect.c:142
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:247
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:168
get_rounded_direction
static int get_rounded_direction(int gx, int gy)
Definition: vf_edgedetect.c:198
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
video.h
sobel
static void sobel(int w, int h, uint16_t *dst, int dst_linesize, int8_t *dir, int dir_linesize, const uint8_t *src, int src_linesize)
Definition: vf_edgedetect.c:225
non_maximum_suppression
static void non_maximum_suppression(int w, int h, uint8_t *dst, int dst_linesize, const int8_t *dir, int dir_linesize, const uint16_t *src, int src_linesize)
Definition: vf_edgedetect.c:252
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:338
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
av_image_copy_plane
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:374
hsub
static void hsub(htype *dst, const htype *src, int bins)
Definition: vf_median.c:74
formats.h
double_threshold
static void double_threshold(int low, int high, int w, int h, uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize)
Definition: vf_edgedetect.c:280
DIRECTION_45UP
@ DIRECTION_45UP
Definition: vf_edgedetect.c:192
plane_info::height
int height
Definition: vf_edgedetect.c:55
FilterMode
FilterMode
Definition: vp9.h:64
MODE_COLORMIX
@ MODE_COLORMIX
Definition: vf_edgedetect.c:46
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
PLANE_V
#define PLANE_V
Definition: vf_edgedetect.c:41
avassert.h
av_cold
#define av_cold
Definition: attributes.h:90
width
#define width
COPY_MAXIMA
#define COPY_MAXIMA(ay, ax, by, bx)
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:51
DIRECTION_VERTICAL
@ DIRECTION_VERTICAL
Definition: vf_edgedetect.c:195
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:226
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:705
MODE_CANNY
@ MODE_CANNY
Definition: vf_edgedetect.c:47
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
MODE_WIRES
@ MODE_WIRES
Definition: vf_edgedetect.c:45
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
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
edgedetect_inputs
static const AVFilterPad edgedetect_inputs[]
Definition: vf_edgedetect.c:412
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:65
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_edgedetect.c:89
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:537
EdgeDetectContext::high
double high
Definition: vf_edgedetect.c:63
PLANE_G
#define PLANE_G
Definition: vf_edgedetect.c:37
ff_vf_edgedetect
const AVFilter ff_vf_edgedetect
Definition: vf_edgedetect.c:428
src
#define src
Definition: vp8dsp.c:255
plane_info::directions
char * directions
Definition: vf_edgedetect.c:54
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_edgedetect.c:326
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_edgedetect.c:399
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
EdgeDetectContext::mode
int mode
Definition: vf_edgedetect.c:65
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:473
height
#define height
plane_info::gradients
uint16_t * gradients
Definition: vf_edgedetect.c:53
plane_info::width
int width
Definition: vf_edgedetect.c:55
DIRECTION_HORIZONTAL
@ DIRECTION_HORIZONTAL
Definition: vf_edgedetect.c:194
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
EdgeDetectContext::low
double low
Definition: vf_edgedetect.c:63
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
PLANE_R
#define PLANE_R
Definition: vf_edgedetect.c:36
EdgeDetectContext::planes
struct plane_info planes[3]
Definition: vf_edgedetect.c:60
EdgeDetectContext::filter_planes
int filter_planes
Definition: vf_edgedetect.c:61
plane_info
Definition: vf_edgedetect.c:51
EdgeDetectContext::low_u8
uint8_t low_u8
Definition: vf_edgedetect.c:64
plane_info::tmpbuf
uint8_t * tmpbuf
Definition: vf_edgedetect.c:52
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
config_props
static int config_props(AVFilterLink *inlink)
Definition: vf_edgedetect.c:118
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:271
AVFilter
Filter definition.
Definition: avfilter.h:165
EdgeDetectContext::high_u8
uint8_t high_u8
Definition: vf_edgedetect.c:64
edgedetect_options
static const AVOption edgedetect_options[]
Definition: vf_edgedetect.c:70
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_edgedetect.c:98
PLANE_Y
#define PLANE_Y
Definition: vf_edgedetect.c:39
mode
mode
Definition: ebur128.h:83
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
EdgeDetectContext::nb_planes
int nb_planes
Definition: vf_edgedetect.c:62
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(edgedetect)
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
OFFSET
#define OFFSET(x)
Definition: vf_edgedetect.c:68
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
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
FLAGS
#define FLAGS
Definition: vf_edgedetect.c:69
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
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
PLANE_U
#define PLANE_U
Definition: vf_edgedetect.c:40
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:223
imgutils.h
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:362
NB_MODE
@ NB_MODE
Definition: vf_edgedetect.c:48
h
h
Definition: vp9dsp_template.c:2038
edgedetect_outputs
static const AVFilterPad edgedetect_outputs[]
Definition: vf_edgedetect.c:421
color_mix
static void color_mix(int w, int h, uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize)
Definition: vf_edgedetect.c:312
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
EdgeDetectContext
Definition: vf_edgedetect.c:58