FFmpeg
Data Structures | Macros | Functions | Variables
vf_boxblur.c File Reference
#include "libavutil/avstring.h"
#include "libavutil/common.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.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 (AVFilterContext *ctx)
 
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 []
 
static const AVFilterPad avfilter_vf_boxblur_outputs []
 
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 126 of file vf_boxblur.c.

◆ OFFSET

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

Definition at line 265 of file vf_boxblur.c.

◆ FLAGS

Definition at line 266 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 ( AVFilterContext ctx)
static

Definition at line 58 of file vf_boxblur.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 75 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 160 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 167 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 201 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 214 of file vf_boxblur.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 227 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 268 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 289 of file vf_boxblur.c.

◆ avfilter_vf_boxblur_outputs

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

Definition at line 298 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 305 of file vf_boxblur.c.

BoxBlurContext
Definition: vf_boxblur.c:38
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_boxblur.c:58
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:167
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
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_boxblur.c:75
NULL
#define NULL
Definition: coverity.c:32
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_boxblur.c:227
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:160
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:117
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
OFFSET
#define OFFSET(x)
Definition: vf_boxblur.c:265
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
avfilter_vf_boxblur_inputs
static const AVFilterPad avfilter_vf_boxblur_inputs[]
Definition: vf_boxblur.c:289
len
int len
Definition: vorbis_enc_data.h:426
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
FLAGS
#define FLAGS
Definition: vf_boxblur.c:266
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
avfilter_vf_boxblur_outputs
static const AVFilterPad avfilter_vf_boxblur_outputs[]
Definition: vf_boxblur.c:298