FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
vf_edgedetect.c File Reference

Edge detection filter. More...

#include "libavutil/avassert.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  plane_info
 
struct  EdgeDetectContext
 

Macros

#define OFFSET(x)   offsetof(EdgeDetectContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define COPY_MAXIMA(ay, ax, by, bx)
 

Enumerations

enum  FilterMode {
  FILTER_8TAP_SMOOTH, FILTER_8TAP_REGULAR, FILTER_8TAP_SHARP, FILTER_BILINEAR,
  FILTER_SWITCHABLE, MODE_WIRES, MODE_COLORMIX, NB_MODE,
  MODE_NONE, MODE_INTERLEAVE, MODE_DEINTERLEAVE, FILTER_NONE = -1,
  FILTER_TOUT, FILTER_VREP, FILTER_BRNG, FILT_NUMB
}
 
enum  { DIRECTION_45UP, DIRECTION_45DOWN, DIRECTION_HORIZONTAL, DIRECTION_VERTICAL }
 

Functions

 AVFILTER_DEFINE_CLASS (edgedetect)
 
static av_cold int init (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_props (AVFilterLink *inlink)
 
static void gaussian_blur (AVFilterContext *ctx, int w, int h, uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize)
 
static int get_rounded_direction (int gx, int gy)
 
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)
 
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)
 
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)
 
static void color_mix (int w, int h, uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption edgedetect_options []
 
static const AVFilterPad edgedetect_inputs []
 
static const AVFilterPad edgedetect_outputs []
 
AVFilter ff_vf_edgedetect
 

Detailed Description

Edge detection filter.

See Also
https://en.wikipedia.org/wiki/Canny_edge_detector

Definition in file vf_edgedetect.c.

Macro Definition Documentation

#define OFFSET (   x)    offsetof(EdgeDetectContext, x)

Definition at line 56 of file vf_edgedetect.c.

Definition at line 57 of file vf_edgedetect.c.

#define COPY_MAXIMA (   ay,
  ax,
  by,
  bx 
)
Value:
do { \
if (src[i] > src[(ay)*src_linesize + i+(ax)] && \
src[i] > src[(by)*src_linesize + i+(bx)]) \
dst[i] = av_clip_uint8(src[i]); \
} while (0)
#define src
Definition: vp9dsp.c:530
if(ret< 0)
Definition: vf_mcdeint.c:282

Referenced by non_maximum_suppression().

Enumeration Type Documentation

enum FilterMode
Enumerator
FILTER_8TAP_SMOOTH 
FILTER_8TAP_REGULAR 
FILTER_8TAP_SHARP 
FILTER_BILINEAR 
FILTER_SWITCHABLE 
MODE_WIRES 
MODE_COLORMIX 
NB_MODE 
MODE_NONE 
MODE_INTERLEAVE 
MODE_DEINTERLEAVE 
FILTER_NONE 
FILTER_TOUT 
FILTER_VREP 
FILTER_BRNG 
FILT_NUMB 

Definition at line 35 of file vf_edgedetect.c.

anonymous enum
Enumerator
DIRECTION_45UP 
DIRECTION_45DOWN 
DIRECTION_HORIZONTAL 
DIRECTION_VERTICAL 

Definition at line 159 of file vf_edgedetect.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( edgedetect  )
static av_cold int init ( AVFilterContext ctx)
static

Definition at line 69 of file vf_edgedetect.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 78 of file vf_edgedetect.c.

static int config_props ( AVFilterLink inlink)
static

Definition at line 99 of file vf_edgedetect.c.

static void gaussian_blur ( AVFilterContext ctx,
int  w,
int  h,
uint8_t dst,
int  dst_linesize,
const uint8_t src,
int  src_linesize 
)
static

Definition at line 118 of file vf_edgedetect.c.

Referenced by filter_frame().

static int get_rounded_direction ( int  gx,
int  gy 
)
static

Definition at line 166 of file vf_edgedetect.c.

Referenced by 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 
)
static

Definition at line 193 of file vf_edgedetect.c.

Referenced by filter_frame().

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 
)
static

Definition at line 220 of file vf_edgedetect.c.

Referenced by filter_frame().

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 
)
static

Definition at line 248 of file vf_edgedetect.c.

Referenced by filter_frame().

static void color_mix ( int  w,
int  h,
uint8_t dst,
int  dst_linesize,
const uint8_t src,
int  src_linesize 
)
static

Definition at line 280 of file vf_edgedetect.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 294 of file vf_edgedetect.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 357 of file vf_edgedetect.c.

Variable Documentation

const AVOption edgedetect_options[]
static
Initial value:
= {
{ "high", "set high threshold", OFFSET(high), AV_OPT_TYPE_DOUBLE, {.dbl=50/255.}, 0, 1, FLAGS },
{ "low", "set low threshold", OFFSET(low), AV_OPT_TYPE_DOUBLE, {.dbl=20/255.}, 0, 1, FLAGS },
{ "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_WIRES}, 0, NB_MODE-1, FLAGS, "mode" },
{ "wires", "white/gray wires on black", 0, AV_OPT_TYPE_CONST, {.i64=MODE_WIRES}, INT_MIN, INT_MAX, FLAGS, "mode" },
{ "colormix", "mix colors", 0, AV_OPT_TYPE_CONST, {.i64=MODE_COLORMIX}, INT_MIN, INT_MAX, FLAGS, "mode" },
{ NULL }
}
#define NULL
Definition: coverity.c:32
mode
Definition: f_perms.c:27
#define FLAGS
Definition: vf_edgedetect.c:57
#define OFFSET(x)
Definition: vf_edgedetect.c:56

Definition at line 58 of file vf_edgedetect.c.

const AVFilterPad edgedetect_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_props,
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int config_props(AVFilterLink *inlink)
Definition: vf_edgedetect.c:99

Definition at line 370 of file vf_edgedetect.c.

const AVFilterPad edgedetect_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 380 of file vf_edgedetect.c.

AVFilter ff_vf_edgedetect
Initial value:
= {
.name = "edgedetect",
.description = NULL_IF_CONFIG_SMALL("Detect and draw edge."),
.priv_size = sizeof(EdgeDetectContext),
.init = init,
.priv_class = &edgedetect_class,
}
static const AVFilterPad edgedetect_outputs[]
static av_cold void uninit(AVFilterContext *ctx)
#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:123
static int query_formats(AVFilterContext *ctx)
Definition: vf_edgedetect.c:78
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:386
static const AVFilterPad edgedetect_inputs[]
static av_cold int init(AVFilterContext *ctx)
Definition: vf_edgedetect.c:69
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:376
static int flags
Definition: cpu.c:47

Definition at line 388 of file vf_edgedetect.c.