FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
vf_boxblur.c File Reference

Apply a boxblur filter to the input video. More...

#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 []
 
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

#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; \
} \
}
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
#define src
Definition: vp8dsp.c:254
GLsizei GLsizei * length
Definition: opengl_enc.c:115
GLint GLenum type
Definition: opengl_enc.c:105
int
int len
for(j=16;j >0;--j)

Definition at line 126 of file vf_boxblur.c.

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

Definition at line 265 of file vf_boxblur.c.

Definition at line 266 of file vf_boxblur.c.

Function Documentation

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 50 of file vf_boxblur.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 58 of file vf_boxblur.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 75 of file vf_boxblur.c.

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().

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().

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().

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().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 227 of file vf_boxblur.c.

AVFILTER_DEFINE_CLASS ( boxblur  )

Variable Documentation

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 }
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
Definition: vf_boxblur.c:265
#define FLAGS
Definition: vf_boxblur.c:266

Definition at line 268 of file vf_boxblur.c.

const AVFilterPad avfilter_vf_boxblur_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_input(AVFilterLink *inlink)
Definition: vf_boxblur.c:75
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_boxblur.c:227

Definition at line 289 of file vf_boxblur.c.

const AVFilterPad avfilter_vf_boxblur_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 299 of file vf_boxblur.c.

AVFilter ff_vf_boxblur
Initial value:
= {
.name = "boxblur",
.description = NULL_IF_CONFIG_SMALL("Blur the input."),
.priv_size = sizeof(BoxBlurContext),
.priv_class = &boxblur_class,
}
#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:125
static const AVFilterPad avfilter_vf_boxblur_outputs[]
Definition: vf_boxblur.c:299
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static int query_formats(AVFilterContext *ctx)
Definition: vf_boxblur.c:58
static const AVFilterPad avfilter_vf_boxblur_inputs[]
Definition: vf_boxblur.c:289
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_boxblur.c:50
#define flags(name, subs,...)
Definition: cbs_av1.c:596

Definition at line 307 of file vf_boxblur.c.