FFmpeg
Data Structures | Macros | Functions | Variables
vf_sab.c File Reference
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libswscale/swscale.h"
#include "avfilter.h"
#include "filters.h"
#include "video.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

 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 enum AVPixelFormat pix_fmts []
 
static const AVOption sab_options []
 
static const AVFilterPad sab_inputs []
 
const 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

◆ COLOR_DIFF_COEFF_SIZE

#define COLOR_DIFF_COEFF_SIZE   512

Definition at line 46 of file vf_sab.c.

◆ RADIUS_MIN

#define RADIUS_MIN   0.1

Definition at line 68 of file vf_sab.c.

◆ RADIUS_MAX

#define RADIUS_MAX   4.0

Definition at line 69 of file vf_sab.c.

◆ PRE_FILTER_RADIUS_MIN

#define PRE_FILTER_RADIUS_MIN   0.1

Definition at line 71 of file vf_sab.c.

◆ PRE_FILTER_RADIUS_MAX

#define PRE_FILTER_RADIUS_MAX   2.0

Definition at line 72 of file vf_sab.c.

◆ STRENGTH_MIN

#define STRENGTH_MIN   0.1

Definition at line 74 of file vf_sab.c.

◆ STRENGTH_MAX

#define STRENGTH_MAX   100.0

Definition at line 75 of file vf_sab.c.

◆ OFFSET

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

Definition at line 77 of file vf_sab.c.

◆ FLAGS

Definition at line 78 of file vf_sab.c.

◆ NB_PLANES

#define NB_PLANES   4

Definition at line 216 of file vf_sab.c.

◆ UPDATE_FACTOR

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

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( sab  )

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 102 of file vf_sab.c.

◆ close_filter_param()

static void close_filter_param ( FilterParam f)
static

Definition at line 125 of file vf_sab.c.

Referenced by config_props(), and uninit().

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 135 of file vf_sab.c.

◆ open_filter_param()

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

Definition at line 143 of file vf_sab.c.

Referenced by config_props().

◆ config_props()

static int config_props ( AVFilterLink inlink)
static

Definition at line 195 of file vf_sab.c.

◆ blur()

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 218 of file vf_sab.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame inpic 
)
static

Definition at line 276 of file vf_sab.c.

Variable Documentation

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ sab_options

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 80 of file vf_sab.c.

◆ sab_inputs

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

Definition at line 302 of file vf_sab.c.

◆ ff_vf_sab

const 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 311 of file vf_sab.c.

PRE_FILTER_RADIUS_MAX
#define PRE_FILTER_RADIUS_MAX
Definition: vf_sab.c:72
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_sab.c:59
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
OFFSET
#define OFFSET(x)
Definition: vf_sab.c:77
chroma
static av_always_inline void chroma(WaveformContext *s, AVFrame *in, AVFrame *out, int component, int intensity, int offset_y, int offset_x, int column, int mirror, int jobnr, int nb_jobs)
Definition: vf_waveform.c:1639
PRE_FILTER_RADIUS_MIN
#define PRE_FILTER_RADIUS_MIN
Definition: vf_sab.c:71
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
COLOR_DIFF_COEFF_SIZE
#define COLOR_DIFF_COEFF_SIZE
Definition: vf_sab.c:46
RADIUS_MIN
#define RADIUS_MIN
Definition: vf_sab.c:68
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:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NULL
#define NULL
Definition: coverity.c:32
sab_inputs
static const AVFilterPad sab_inputs[]
Definition: vf_sab.c:302
SabContext
Definition: vf_sab.c:50
FLAGS
#define FLAGS
Definition: vf_sab.c:78
f
f
Definition: af_crystalizer.c:122
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
config_props
static int config_props(AVFilterLink *inlink)
Definition: vf_sab.c:195
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:182
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
RADIUS_MAX
#define RADIUS_MAX
Definition: vf_sab.c:69
STRENGTH_MAX
#define STRENGTH_MAX
Definition: vf_sab.c:75
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
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
factor
static const int factor[16]
Definition: vf_pp7.c:80
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
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:77
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
Definition: vf_sab.c:276
STRENGTH_MIN
#define STRENGTH_MIN
Definition: vf_sab.c:74
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_sab.c:102
src
#define src
Definition: vp8dsp.c:248
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_sab.c:135