FFmpeg
Data Structures | Macros | Functions | Variables
vf_boxblur.c File Reference
#include "libavutil/common.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "video.h"
#include "boxblur.h"

Go to the source code of this file.

Data Structures

struct  BoxBlurContext
 

Macros

#define BLUR(type, depth)
 
#define OFFSET(x)   offsetof(BoxBlurContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static int config_input (AVFilterLink *inlink)
 
static void blur (uint8_t *dst, int dst_step, const uint8_t *src, int src_step, int len, int radius, int pixsize)
 
static void blur_power (uint8_t *dst, int dst_step, const uint8_t *src, int src_step, int len, int radius, int power, uint8_t *temp[2], int pixsize)
 
static void hblur (uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int w, int h, int radius, int power, uint8_t *temp[2], int pixsize)
 
static void vblur (uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int w, int h, int radius, int power, uint8_t *temp[2], int pixsize)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
 AVFILTER_DEFINE_CLASS (boxblur)
 

Variables

static const AVOption boxblur_options []
 
static const AVFilterPad avfilter_vf_boxblur_inputs []
 
const AVFilter ff_vf_boxblur
 

Detailed Description

Apply a boxblur filter to the input video. Ported from MPlayer libmpcodecs/vf_boxblur.c.

Definition in file vf_boxblur.c.

Macro Definition Documentation

◆ BLUR

#define BLUR (   type,
  depth 
)
Value:
static inline void blur ## depth(type *dst, int dst_step, const type *src, \
int src_step, int len, int radius) \
{ \
const int length = radius*2 + 1; \
const int inv = ((1<<16) + length/2)/length; \
int x, sum = src[radius*src_step]; \
for (x = 0; x < radius; x++) \
sum += src[x*src_step]<<1; \
\
sum = sum*inv + (1<<15); \
for (x = 0; x <= radius; x++) { \
sum += (src[(radius+x)*src_step] - src[(radius-x)*src_step])*inv; \
dst[x*dst_step] = sum>>16; \
} \
for (; x < len-radius; x++) { \
sum += (src[(radius+x)*src_step] - src[(x-radius-1)*src_step])*inv; \
dst[x*dst_step] = sum >>16; \
} \
for (; x < len; x++) { \
sum += (src[(2*len-radius-x-1)*src_step] - src[(x-radius-1)*src_step])*inv; \
dst[x*dst_step] = sum>>16; \
} \
}

Definition at line 128 of file vf_boxblur.c.

◆ OFFSET

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

Definition at line 267 of file vf_boxblur.c.

◆ FLAGS

Definition at line 268 of file vf_boxblur.c.

Function Documentation

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 50 of file vf_boxblur.c.

◆ query_formats()

static int query_formats ( const AVFilterContext ctx,
AVFilterFormatsConfig **  cfg_in,
AVFilterFormatsConfig **  cfg_out 
)
static

Definition at line 58 of file vf_boxblur.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 77 of file vf_boxblur.c.

◆ blur()

static void blur ( uint8_t *  dst,
int  dst_step,
const uint8_t *  src,
int  src_step,
int  len,
int  radius,
int  pixsize 
)
inlinestatic

Definition at line 162 of file vf_boxblur.c.

Referenced by blur_power(), and blurdetect_filter_frame().

◆ blur_power()

static void blur_power ( uint8_t *  dst,
int  dst_step,
const uint8_t *  src,
int  src_step,
int  len,
int  radius,
int  power,
uint8_t *  temp[2],
int  pixsize 
)
inlinestatic

Definition at line 169 of file vf_boxblur.c.

Referenced by hblur(), and vblur().

◆ hblur()

static void hblur ( uint8_t *  dst,
int  dst_linesize,
const uint8_t *  src,
int  src_linesize,
int  w,
int  h,
int  radius,
int  power,
uint8_t *  temp[2],
int  pixsize 
)
static

Definition at line 203 of file vf_boxblur.c.

Referenced by filter_frame().

◆ vblur()

static void vblur ( uint8_t *  dst,
int  dst_linesize,
const uint8_t *  src,
int  src_linesize,
int  w,
int  h,
int  radius,
int  power,
uint8_t *  temp[2],
int  pixsize 
)
static

Definition at line 216 of file vf_boxblur.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 229 of file vf_boxblur.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( boxblur  )

Variable Documentation

◆ boxblur_options

const AVOption boxblur_options[]
static
Initial value:
= {
{ "luma_radius", "Radius of the luma blurring box", OFFSET(luma_param.radius_expr), AV_OPT_TYPE_STRING, {.str="2"}, .flags = FLAGS },
{ "lr", "Radius of the luma blurring box", OFFSET(luma_param.radius_expr), AV_OPT_TYPE_STRING, {.str="2"}, .flags = FLAGS },
{ "luma_power", "How many times should the boxblur be applied to luma", OFFSET(luma_param.power), AV_OPT_TYPE_INT, {.i64=2}, 0, INT_MAX, .flags = FLAGS },
{ "lp", "How many times should the boxblur be applied to luma", OFFSET(luma_param.power), AV_OPT_TYPE_INT, {.i64=2}, 0, INT_MAX, .flags = FLAGS },
{ "chroma_radius", "Radius of the chroma blurring box", OFFSET(chroma_param.radius_expr), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "cr", "Radius of the chroma blurring box", OFFSET(chroma_param.radius_expr), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "chroma_power", "How many times should the boxblur be applied to chroma", OFFSET(chroma_param.power), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, .flags = FLAGS },
{ "cp", "How many times should the boxblur be applied to chroma", OFFSET(chroma_param.power), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, .flags = FLAGS },
{ "alpha_radius", "Radius of the alpha blurring box", OFFSET(alpha_param.radius_expr), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "ar", "Radius of the alpha blurring box", OFFSET(alpha_param.radius_expr), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "alpha_power", "How many times should the boxblur be applied to alpha", OFFSET(alpha_param.power), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, .flags = FLAGS },
{ "ap", "How many times should the boxblur be applied to alpha", OFFSET(alpha_param.power), AV_OPT_TYPE_INT, {.i64=-1}, -1, INT_MAX, .flags = FLAGS },
{ NULL }
}

Definition at line 270 of file vf_boxblur.c.

◆ avfilter_vf_boxblur_inputs

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

Definition at line 291 of file vf_boxblur.c.

◆ ff_vf_boxblur

const AVFilter ff_vf_boxblur
Initial value:
= {
.name = "boxblur",
.description = NULL_IF_CONFIG_SMALL("Blur the input."),
.priv_size = sizeof(BoxBlurContext),
.priv_class = &boxblur_class,
}

Definition at line 300 of file vf_boxblur.c.

BoxBlurContext
Definition: vf_boxblur.c:38
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_boxblur.c:50
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: vf_boxblur.c:58
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
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_boxblur.c:77
NULL
#define NULL
Definition: coverity.c:32
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_boxblur.c:229
blur
static void blur(uint8_t *dst, int dst_step, const uint8_t *src, int src_step, int len, int radius, int pixsize)
Definition: vf_boxblur.c:162
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
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
OFFSET
#define OFFSET(x)
Definition: vf_boxblur.c:267
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
avfilter_vf_boxblur_inputs
static const AVFilterPad avfilter_vf_boxblur_inputs[]
Definition: vf_boxblur.c:291
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
len
int len
Definition: vorbis_enc_data.h:426
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FLAGS
#define FLAGS
Definition: vf_boxblur.c:268
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
src
#define src
Definition: vp8dsp.c:248