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

◆ 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,
},
{ NULL }
}

Definition at line 289 of file vf_boxblur.c.

◆ avfilter_vf_boxblur_outputs

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

Definition at line 299 of file vf_boxblur.c.

◆ ff_vf_boxblur

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 307 of file vf_boxblur.c.

BoxBlurContext
Definition: vf_boxblur.c:38
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_boxblur.c:58
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
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_boxblur.c:75
NULL
#define NULL
Definition: coverity.c:32
src
#define src
Definition: vp8dsp.c:255
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_boxblur.c:227
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
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
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:126
avfilter_vf_boxblur_inputs
static const AVFilterPad avfilter_vf_boxblur_inputs[]
Definition: vf_boxblur.c:289
len
int len
Definition: vorbis_enc_data.h:452
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FLAGS
#define FLAGS
Definition: vf_boxblur.c:266
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
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:299