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

Shape Adaptive Blur filter, ported from MPlayer libmpcodecs/vf_sab.c. More...

#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libswscale/swscale.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  FilterParam
 
struct  SabContext
 

Macros

#define COLOR_DIFF_COEFF_SIZE   512
 
#define RADIUS_MIN   0.1
 
#define RADIUS_MAX   4.0
 
#define PRE_FILTER_RADIUS_MIN   0.1
 
#define PRE_FILTER_RADIUS_MAX   2.0
 
#define STRENGTH_MIN   0.1
 
#define STRENGTH_MAX   100.0
 
#define OFFSET(x)   offsetof(SabContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define NB_PLANES   4
 
#define UPDATE_FACTOR
 

Functions

static int query_formats (AVFilterContext *ctx)
 
 AVFILTER_DEFINE_CLASS (sab)
 
static av_cold int init (AVFilterContext *ctx)
 
static void close_filter_param (FilterParam *f)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int open_filter_param (FilterParam *f, int width, int height, unsigned int sws_flags)
 
static int config_props (AVFilterLink *inlink)
 
static void blur (uint8_t *dst, const int dst_linesize, const uint8_t *src, const int src_linesize, const int w, const int h, FilterParam *fp)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *inpic)
 

Variables

static const AVOption sab_options []
 
static const AVFilterPad sab_inputs []
 
static const AVFilterPad sab_outputs []
 
AVFilter ff_vf_sab
 

Detailed Description

Shape Adaptive Blur filter, ported from MPlayer libmpcodecs/vf_sab.c.

Definition in file vf_sab.c.

Macro Definition Documentation

#define COLOR_DIFF_COEFF_SIZE   512

Definition at line 45 of file vf_sab.c.

Referenced by open_filter_param().

#define RADIUS_MIN   0.1

Definition at line 73 of file vf_sab.c.

Referenced by init().

#define RADIUS_MAX   4.0

Definition at line 74 of file vf_sab.c.

#define PRE_FILTER_RADIUS_MIN   0.1

Definition at line 76 of file vf_sab.c.

Referenced by init().

#define PRE_FILTER_RADIUS_MAX   2.0

Definition at line 77 of file vf_sab.c.

#define STRENGTH_MIN   0.1

Definition at line 79 of file vf_sab.c.

Referenced by init().

#define STRENGTH_MAX   100.0

Definition at line 80 of file vf_sab.c.

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

Definition at line 82 of file vf_sab.c.

Definition at line 83 of file vf_sab.c.

#define NB_PLANES   4

Definition at line 221 of file vf_sab.c.

Referenced by blur().

#define UPDATE_FACTOR
Value:
do { \
int factor; \
factor = f.color_diff_coeff[COLOR_DIFF_COEFF_SIZE/2 + pre_val - \
f.pre_filter_buf[ix + iy*f.pre_filter_linesize]] * f.dist_coeff[dx + dy*f.dist_linesize]; \
sum += src[ix + iy*src_linesize] * factor; \
div += factor; \
} while (0)

Referenced by blur().

Function Documentation

static int query_formats ( AVFilterContext ctx)
static

Definition at line 58 of file vf_sab.c.

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

Definition at line 107 of file vf_sab.c.

static void close_filter_param ( FilterParam f)
static

Definition at line 130 of file vf_sab.c.

Referenced by config_props(), and uninit().

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 140 of file vf_sab.c.

static int open_filter_param ( FilterParam f,
int  width,
int  height,
unsigned int  sws_flags 
)
static

Definition at line 148 of file vf_sab.c.

Referenced by config_props().

static int config_props ( AVFilterLink inlink)
static

Definition at line 200 of file vf_sab.c.

static void blur ( uint8_t dst,
const int  dst_linesize,
const uint8_t src,
const int  src_linesize,
const int  w,
const int  h,
FilterParam fp 
)
static

Definition at line 223 of file vf_sab.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame inpic 
)
static

Definition at line 284 of file vf_sab.c.

Variable Documentation

const AVOption sab_options[]
static
Initial value:
= {
{ "luma_radius", "set luma radius", OFFSET(luma.radius), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, RADIUS_MIN, RADIUS_MAX, .flags=FLAGS },
{ "lr" , "set luma radius", OFFSET(luma.radius), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, RADIUS_MIN, RADIUS_MAX, .flags=FLAGS },
{ "luma_pre_filter_radius", "set luma pre-filter radius", OFFSET(luma.pre_filter_radius), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, PRE_FILTER_RADIUS_MIN, PRE_FILTER_RADIUS_MAX, .flags=FLAGS },
{ "lpfr", "set luma pre-filter radius", OFFSET(luma.pre_filter_radius), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, PRE_FILTER_RADIUS_MIN, PRE_FILTER_RADIUS_MAX, .flags=FLAGS },
{ "luma_strength", "set luma strength", OFFSET(luma.strength), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, STRENGTH_MIN, STRENGTH_MAX, .flags=FLAGS },
{ "ls", "set luma strength", OFFSET(luma.strength), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, STRENGTH_MIN, STRENGTH_MAX, .flags=FLAGS },
{ "chroma_radius", "set chroma radius", OFFSET(chroma.radius), AV_OPT_TYPE_FLOAT, {.dbl=RADIUS_MIN-1}, RADIUS_MIN-1, RADIUS_MAX, .flags=FLAGS },
{ "cr", "set chroma radius", OFFSET(chroma.radius), AV_OPT_TYPE_FLOAT, {.dbl=RADIUS_MIN-1}, RADIUS_MIN-1, RADIUS_MAX, .flags=FLAGS },
{ "chroma_pre_filter_radius", "set chroma pre-filter radius", OFFSET(chroma.pre_filter_radius), AV_OPT_TYPE_FLOAT, {.dbl=PRE_FILTER_RADIUS_MIN-1},
{ "cpfr", "set chroma pre-filter radius", OFFSET(chroma.pre_filter_radius), AV_OPT_TYPE_FLOAT, {.dbl=PRE_FILTER_RADIUS_MIN-1},
{ "chroma_strength", "set chroma strength", OFFSET(chroma.strength), AV_OPT_TYPE_FLOAT, {.dbl=STRENGTH_MIN-1}, STRENGTH_MIN-1, STRENGTH_MAX, .flags=FLAGS },
{ "cs", "set chroma strength", OFFSET(chroma.strength), AV_OPT_TYPE_FLOAT, {.dbl=STRENGTH_MIN-1}, STRENGTH_MIN-1, STRENGTH_MAX, .flags=FLAGS },
{ NULL }
}

Definition at line 85 of file vf_sab.c.

const AVFilterPad sab_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_props,
},
{ NULL }
}

Definition at line 310 of file vf_sab.c.

const AVFilterPad sab_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}

Definition at line 320 of file vf_sab.c.

AVFilter ff_vf_sab
Initial value:
= {
.name = "sab",
.description = NULL_IF_CONFIG_SMALL("Apply shape adaptive blur."),
.priv_size = sizeof(SabContext),
.init = init,
.priv_class = &sab_class,
}

Definition at line 328 of file vf_sab.c.