FFmpeg
Data Structures | Macros | Functions | Variables
vf_smartblur.c File Reference
#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  SmartblurContext
 

Macros

#define RADIUS_MIN   0.1
 
#define RADIUS_MAX   5.0
 
#define STRENGTH_MIN   -1.0
 
#define STRENGTH_MAX   1.0
 
#define THRESHOLD_MIN   -30
 
#define THRESHOLD_MAX   30
 
#define OFFSET(x)   offsetof(SmartblurContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 

Functions

 AVFILTER_DEFINE_CLASS (smartblur)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int alloc_sws_context (FilterParam *f, int width, int height, unsigned int 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, const int threshold, struct SwsContext *filter_context)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *inpic)
 

Variables

static const AVOption smartblur_options []
 
static enum AVPixelFormat pix_fmts []
 
static const AVFilterPad smartblur_inputs []
 
static const AVFilterPad smartblur_outputs []
 
const AVFilter ff_vf_smartblur
 

Detailed Description

Apply a smartblur filter to the input video Ported from MPlayer libmpcodecs/vf_smartblur.c by Michael Niedermayer.

Definition in file vf_smartblur.c.

Macro Definition Documentation

◆ RADIUS_MIN

#define RADIUS_MIN   0.1

Definition at line 36 of file vf_smartblur.c.

◆ RADIUS_MAX

#define RADIUS_MAX   5.0

Definition at line 37 of file vf_smartblur.c.

◆ STRENGTH_MIN

#define STRENGTH_MIN   -1.0

Definition at line 39 of file vf_smartblur.c.

◆ STRENGTH_MAX

#define STRENGTH_MAX   1.0

Definition at line 40 of file vf_smartblur.c.

◆ THRESHOLD_MIN

#define THRESHOLD_MIN   -30

Definition at line 42 of file vf_smartblur.c.

◆ THRESHOLD_MAX

#define THRESHOLD_MAX   30

Definition at line 43 of file vf_smartblur.c.

◆ OFFSET

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

Definition at line 62 of file vf_smartblur.c.

◆ FLAGS

Definition at line 63 of file vf_smartblur.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( smartblur  )

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 85 of file vf_smartblur.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 109 of file vf_smartblur.c.

◆ alloc_sws_context()

static int alloc_sws_context ( FilterParam f,
int  width,
int  height,
unsigned int  flags 
)
static

Definition at line 125 of file vf_smartblur.c.

Referenced by config_props().

◆ config_props()

static int config_props ( AVFilterLink inlink)
static

Definition at line 152 of file vf_smartblur.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,
const int  threshold,
struct SwsContext filter_context 
)
static

Definition at line 169 of file vf_smartblur.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame inpic 
)
static

Definition at line 233 of file vf_smartblur.c.

Variable Documentation

◆ smartblur_options

const AVOption smartblur_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_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 },
{ "luma_threshold", "set luma threshold", OFFSET(luma.threshold), AV_OPT_TYPE_INT, {.i64=0}, THRESHOLD_MIN, THRESHOLD_MAX, .flags=FLAGS },
{ "lt", "set luma threshold", OFFSET(luma.threshold), AV_OPT_TYPE_INT, {.i64=0}, THRESHOLD_MIN, THRESHOLD_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_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 },
{ "chroma_threshold", "set chroma threshold", OFFSET(chroma.threshold), AV_OPT_TYPE_INT, {.i64=THRESHOLD_MIN-1}, THRESHOLD_MIN-1, THRESHOLD_MAX, .flags=FLAGS },
{ "ct", "set chroma threshold", OFFSET(chroma.threshold), AV_OPT_TYPE_INT, {.i64=THRESHOLD_MIN-1}, THRESHOLD_MIN-1, THRESHOLD_MAX, .flags=FLAGS },
{ NULL }
}

Definition at line 65 of file vf_smartblur.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ smartblur_inputs

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

Definition at line 268 of file vf_smartblur.c.

◆ smartblur_outputs

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

Definition at line 277 of file vf_smartblur.c.

◆ ff_vf_smartblur

const AVFilter ff_vf_smartblur
Initial value:
= {
.name = "smartblur",
.description = NULL_IF_CONFIG_SMALL("Blur the input video without impacting the outlines."),
.priv_size = sizeof(SmartblurContext),
.init = init,
.priv_class = &smartblur_class,
}

Definition at line 284 of file vf_smartblur.c.

config_props
static int config_props(AVFilterLink *inlink)
Definition: vf_smartblur.c:152
RADIUS_MAX
#define RADIUS_MAX
Definition: vf_smartblur.c:37
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:170
OFFSET
#define OFFSET(x)
Definition: vf_smartblur.c:62
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:1635
RADIUS_MIN
#define RADIUS_MIN
Definition: vf_smartblur.c:36
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_smartblur.c:117
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_smartblur.c:85
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:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
NULL
#define NULL
Definition: coverity.c:32
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
Definition: vf_smartblur.c:233
THRESHOLD_MIN
#define THRESHOLD_MIN
Definition: vf_smartblur.c:42
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
STRENGTH_MIN
#define STRENGTH_MIN
Definition: vf_smartblur.c:39
smartblur_inputs
static const AVFilterPad smartblur_inputs[]
Definition: vf_smartblur.c:268
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:115
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_smartblur.c:109
FLAGS
#define FLAGS
Definition: vf_smartblur.c:63
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:152
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
smartblur_outputs
static const AVFilterPad smartblur_outputs[]
Definition: vf_smartblur.c:277
THRESHOLD_MAX
#define THRESHOLD_MAX
Definition: vf_smartblur.c:43
STRENGTH_MAX
#define STRENGTH_MAX
Definition: vf_smartblur.c:40
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
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:71
SmartblurContext
Definition: vf_smartblur.c:53
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:70
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
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:73
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:72