vf_edgedetect.c File Reference

Edge detection filter. More...

#include "libavutil/opt.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
Include dependency graph for vf_edgedetect.c:

Go to the source code of this file.

Data Structures

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  { 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 (AVFilterContext *ctx, int w, int h, uint16_t *dst, int dst_linesize, const uint8_t *src, int src_linesize)
 
static void non_maximum_suppression (AVFilterContext *ctx, int w, int h, uint8_t *dst, int dst_linesize, const uint16_t *src, int src_linesize)
 
static void double_threshold (AVFilterContext *ctx, 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 avfilter_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 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)
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
AVS_Value src
Definition: avisynth_c.h:523
synthesis window for stochastic i
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160

Referenced by non_maximum_suppression().

Definition at line 44 of file vf_edgedetect.c.

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

Definition at line 43 of file vf_edgedetect.c.

Enumeration Type Documentation

anonymous enum
Enumerator
DIRECTION_45UP 
DIRECTION_45DOWN 
DIRECTION_HORIZONTAL 
DIRECTION_VERTICAL 

Definition at line 123 of file vf_edgedetect.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( edgedetect  )
static int config_props ( AVFilterLink inlink)
static

Definition at line 69 of file vf_edgedetect.c.

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

Definition at line 210 of file vf_edgedetect.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 245 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 82 of file vf_edgedetect.c.

Referenced by filter_frame().

static int get_rounded_direction ( int  gx,
int  gy 
)
static

Definition at line 130 of file vf_edgedetect.c.

Referenced by sobel().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 53 of file vf_edgedetect.c.

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

Definition at line 183 of file vf_edgedetect.c.

Referenced by filter_frame().

static int query_formats ( AVFilterContext ctx)
static

Definition at line 62 of file vf_edgedetect.c.

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

Definition at line 157 of file vf_edgedetect.c.

Referenced by filter_frame().

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 294 of file vf_edgedetect.c.

Variable Documentation

AVFilter avfilter_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)
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
static int query_formats(AVFilterContext *ctx)
Definition: vf_edgedetect.c:62
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static const AVFilterPad edgedetect_inputs[]
static av_cold int init(AVFilterContext *ctx)
Definition: vf_edgedetect.c:53
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 at line 320 of file vf_edgedetect.c.

const AVFilterPad edgedetect_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_props,
.filter_frame = filter_frame,
},
{ NULL }
}
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int config_props(AVFilterLink *inlink)
Definition: vf_edgedetect.c:69
NULL
Definition: eval.c:55

Definition at line 302 of file vf_edgedetect.c.

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 },
{ NULL },
}
#define FLAGS
Definition: vf_edgedetect.c:44
NULL
Definition: eval.c:55
#define OFFSET(x)
Definition: vf_edgedetect.c:43

Definition at line 45 of file vf_edgedetect.c.

const AVFilterPad edgedetect_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
NULL
Definition: eval.c:55

Definition at line 312 of file vf_edgedetect.c.