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

◆ RADIUS_MIN

#define RADIUS_MIN   0.1

Definition at line 67 of file vf_sab.c.

◆ RADIUS_MAX

#define RADIUS_MAX   4.0

Definition at line 68 of file vf_sab.c.

◆ PRE_FILTER_RADIUS_MIN

#define PRE_FILTER_RADIUS_MIN   0.1

Definition at line 70 of file vf_sab.c.

◆ PRE_FILTER_RADIUS_MAX

#define PRE_FILTER_RADIUS_MAX   2.0

Definition at line 71 of file vf_sab.c.

◆ STRENGTH_MIN

#define STRENGTH_MIN   0.1

Definition at line 73 of file vf_sab.c.

◆ STRENGTH_MAX

#define STRENGTH_MAX   100.0

Definition at line 74 of file vf_sab.c.

◆ OFFSET

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

Definition at line 76 of file vf_sab.c.

◆ FLAGS

Definition at line 77 of file vf_sab.c.

◆ NB_PLANES

#define NB_PLANES   4

Definition at line 215 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 101 of file vf_sab.c.

◆ close_filter_param()

static void close_filter_param ( FilterParam f)
static

Definition at line 124 of file vf_sab.c.

Referenced by config_props(), and uninit().

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 134 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 142 of file vf_sab.c.

Referenced by config_props().

◆ config_props()

static int config_props ( AVFilterLink inlink)
static

Definition at line 194 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 217 of file vf_sab.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame inpic 
)
static

Definition at line 275 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 79 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 301 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 310 of file vf_sab.c.

PRE_FILTER_RADIUS_MAX
#define PRE_FILTER_RADIUS_MAX
Definition: vf_sab.c:71
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_sab.c:58
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:162
OFFSET
#define OFFSET(x)
Definition: vf_sab.c:76
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:70
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:45
RADIUS_MIN
#define RADIUS_MIN
Definition: vf_sab.c:67
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_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
NULL
#define NULL
Definition: coverity.c:32
sab_inputs
static const AVFilterPad sab_inputs[]
Definition: vf_sab.c:301
SabContext
Definition: vf_sab.c:49
FLAGS
#define FLAGS
Definition: vf_sab.c:77
f
f
Definition: af_crystalizer.c:121
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:106
config_props
static int config_props(AVFilterLink *inlink)
Definition: vf_sab.c:194
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:147
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:238
RADIUS_MAX
#define RADIUS_MAX
Definition: vf_sab.c:68
STRENGTH_MAX
#define STRENGTH_MAX
Definition: vf_sab.c:74
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:78
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:275
STRENGTH_MIN
#define STRENGTH_MIN
Definition: vf_sab.c:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
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:101
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_sab.c:134