Libav
Data Structures | Macros | Enumerations | 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/eval.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  FilterParam
 
struct  BoxBlurContext
 

Macros

#define Y   0
 
#define U   1
 
#define V   2
 
#define A   3
 
#define EVAL_RADIUS_EXPR(comp)
 
#define CHECK_RADIUS_VAL(w_, h_, comp)
 
#define OFFSET(x)   offsetof(BoxBlurContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM
 

Enumerations

enum  var_name {
  VAR_E, VAR_INTERLACED, VAR_N, VAR_PHI,
  VAR_PI, VAR_PREV_INPTS, VAR_PREV_OUTPTS, VAR_PTS,
  VAR_STARTPTS, VAR_TB, VAR_RTCTIME, VAR_RTCSTART,
  VAR_S, VAR_SR, VAR_VARS_NB, VAR_PI,
  VAR_PHI, VAR_E, VAR_W, VAR_H,
  VAR_A, VAR_DAR, VAR_SAR, VAR_HSUB,
  VAR_VSUB, VARS_NB, VAR_W, VAR_H,
  VAR_CW, VAR_CH, VAR_HSUB, VAR_VSUB,
  VARS_NB, VAR_E, VAR_PHI, VAR_PI,
  VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH,
  VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH,
  VAR_X, VAR_Y, VAR_N, VAR_T,
  VAR_VARS_NB, VAR_E, VAR_PHI, VAR_PI,
  VAR_MAIN_W, VAR_MW, VAR_MAIN_H, VAR_MH,
  VAR_TEXT_W, VAR_TW, VAR_TEXT_H, VAR_TH,
  VAR_X, VAR_Y, VAR_N, VAR_T,
  VAR_VARS_NB, VAR_E, VAR_PHI, VAR_PI,
  VAR_W, VAR_H, VAR_VAL, VAR_MAXVAL,
  VAR_MINVAL, VAR_NEGVAL, VAR_CLIPVAL, VAR_VARS_NB,
  VAR_E, VAR_PHI, VAR_PI, VAR_MAIN_W,
  VAR_MW, VAR_MAIN_H, VAR_MH, VAR_OVERLAY_W,
  VAR_OW, VAR_OVERLAY_H, VAR_OH, VAR_VARS_NB,
  VAR_PI, VAR_PHI, VAR_E, VAR_IN_W,
  VAR_IW, VAR_IN_H, VAR_IH, VAR_OUT_W,
  VAR_OW, VAR_OUT_H, VAR_OH, VAR_X,
  VAR_Y, VAR_A, VAR_HSUB, VAR_VSUB,
  VARS_NB, VAR_PI, VAR_PHI, VAR_E,
  VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH,
  VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH,
  VAR_A, VAR_DAR, VAR_SAR, VAR_HSUB,
  VAR_VSUB, VARS_NB, VAR_E, VAR_PHI,
  VAR_PI, VAR_TB, VAR_PTS, VAR_START_PTS,
  VAR_PREV_PTS, VAR_PREV_SELECTED_PTS, VAR_T, VAR_START_T,
  VAR_PREV_T, VAR_PREV_SELECTED_T, VAR_PICT_TYPE, VAR_PICT_TYPE_I,
  VAR_PICT_TYPE_P, VAR_PICT_TYPE_B, VAR_PICT_TYPE_S, VAR_PICT_TYPE_SI,
  VAR_PICT_TYPE_SP, VAR_PICT_TYPE_BI, VAR_INTERLACE_TYPE, VAR_INTERLACE_TYPE_P,
  VAR_INTERLACE_TYPE_T, VAR_INTERLACE_TYPE_B, VAR_N, VAR_SELECTED_N,
  VAR_PREV_SELECTED_N, VAR_KEY, VAR_VARS_NB, VAR_E,
  VAR_PHI, VAR_PI, VAR_AVTB, VAR_INTB,
  VAR_VARS_NB, VAR_E, VAR_PHI, VAR_PI,
  VAR_AVTB, VAR_VARS_NB
}
 

Functions

static av_cold int init (AVFilterContext *ctx)
 
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)
 
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])
 
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])
 
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])
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 

Variables

static const char *const var_names []
 
static const AVOption options []
 
static const AVClass boxblur_class
 
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 Y   0

Definition at line 78 of file vf_boxblur.c.

Referenced by config_input().

#define U   1

Definition at line 79 of file vf_boxblur.c.

Referenced by config_input().

#define V   2

Definition at line 80 of file vf_boxblur.c.

Referenced by config_input().

#define A   3

Definition at line 81 of file vf_boxblur.c.

Referenced by config_input().

#define EVAL_RADIUS_EXPR (   comp)
Value:
expr = s->comp##_radius_expr; \
ret = av_expr_parse_and_eval(&res, expr, var_names, var_values, \
NULL, NULL, NULL, NULL, NULL, 0, ctx); \
s->comp##_param.radius = res; \
if (ret < 0) { \
"Error when evaluating " #comp " radius expression '%s'\n", expr); \
return ret; \
}
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
Definition: eval.c:551
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:123
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:148
return
static const char *const var_names[]
Definition: vf_boxblur.c:38
if(ac->has_optimized_func)
NULL
Definition: eval.c:55
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
Definition: eamad.c:76

Referenced by config_input().

#define CHECK_RADIUS_VAL (   w_,
  h_,
  comp 
)
Value:
if (s->comp##_param.radius < 0 || \
2*s->comp##_param.radius > FFMIN(w_, h_)) { \
"Invalid " #comp " radius value %d, must be >= 0 and <= %d\n", \
s->comp##_param.radius, FFMIN(w_, h_)/2); \
return AVERROR(EINVAL); \
}
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:123
#define AVERROR(e)
Definition: error.h:43
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:148
return
#define FFMIN(a, b)
Definition: common.h:57
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
Definition: eamad.c:76

Referenced by config_input().

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

Definition at line 336 of file vf_boxblur.c.

#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM

Definition at line 337 of file vf_boxblur.c.

Enumeration Type Documentation

enum var_name
Enumerator
VAR_E 
VAR_INTERLACED 
VAR_N 
VAR_PHI 
VAR_PI 
VAR_PREV_INPTS 
VAR_PREV_OUTPTS 
VAR_PTS 
VAR_STARTPTS 
VAR_TB 
VAR_RTCTIME 
VAR_RTCSTART 
VAR_S 
VAR_SR 
VAR_VARS_NB 
VAR_PI 
VAR_PHI 
VAR_E 
VAR_W 
VAR_H 
VAR_A 
VAR_DAR 
VAR_SAR 
VAR_HSUB 
VAR_VSUB 
VARS_NB 
VAR_W 
VAR_H 
VAR_CW 
VAR_CH 
VAR_HSUB 
VAR_VSUB 
VARS_NB 
VAR_E 
VAR_PHI 
VAR_PI 
VAR_IN_W 
VAR_IW 
VAR_IN_H 
VAR_IH 
VAR_OUT_W 
VAR_OW 
VAR_OUT_H 
VAR_OH 
VAR_X 
VAR_Y 
VAR_N 
VAR_T 
VAR_VARS_NB 
VAR_E 
VAR_PHI 
VAR_PI 
VAR_MAIN_W 
VAR_MW 
VAR_MAIN_H 
VAR_MH 
VA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TB 
VAR_INTB 
VAR_VARS_NB 
VAR_E 
VAR_PHI 
VAR_PI 
VAR_AVTB 
VAR_VARS_NB 

Definition at line 48 of file vf_boxblur.c.

Function Documentation

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 83 of file vf_boxblur.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 108 of file vf_boxblur.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 116 of file vf_boxblur.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 131 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 
)
inlinestatic

Definition at line 208 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] 
)
inlinestatic

Definition at line 249 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] 
)
static

Definition at line 275 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] 
)
static

Definition at line 288 of file vf_boxblur.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 301 of file vf_boxblur.c.

Variable Documentation

const char* const var_names[]
static
Initial value:
= {
"w",
"h",
"cw",
"ch",
"hsub",
"vsub",
}
NULL
Definition: eval.c:55

Definition at line 38 of file vf_boxblur.c.

const AVOption options[]
static
Initial value:
= {
{ "luma_radius", "Radius of the luma blurring box", OFFSET(luma_radius_expr), AV_OPT_TYPE_STRING, .flags = FLAGS },
{ "luma_power", "How many times should the boxblur be applied to luma",
OFFSET(luma_param.power), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, FLAGS },
{ "chroma_radius", "Radius of the chroma blurring box", OFFSET(chroma_radius_expr), AV_OPT_TYPE_STRING, .flags = FLAGS },
{ "chroma_power", "How many times should the boxblur be applied to chroma",
OFFSET(chroma_param.power), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, FLAGS },
{ "alpha_radius", "Radius of the alpha blurring box", OFFSET(alpha_radius_expr), AV_OPT_TYPE_STRING, .flags = FLAGS },
{ "alpha_power", "How many times should the boxblur be applied to alpha",
OFFSET(alpha_param.power), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, FLAGS },
{ NULL },
}
#define OFFSET(x)
Definition: vf_boxblur.c:336
#define FLAGS
Definition: vf_boxblur.c:337
NULL
Definition: eval.c:55

Definition at line 338 of file vf_boxblur.c.

const AVClass boxblur_class
static
Initial value:
= {
.class_name = "boxblur",
.item_name = av_default_item_name,
.option = options,
}
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
av_default_item_name
Definition: dnxhdenc.c:45
static const AVOption options[]
Definition: vf_boxblur.c:338

Definition at line 351 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 }
}
static int config_input(AVFilterLink *inlink)
Definition: vf_boxblur.c:131
NULL
Definition: eval.c:55
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_boxblur.c:301

Definition at line 358 of file vf_boxblur.c.

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

Definition at line 368 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,
.init = init,
}
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:122
static av_cold int init(AVFilterContext *ctx)
Definition: vf_boxblur.c:83
static const AVFilterPad avfilter_vf_boxblur_outputs[]
Definition: vf_boxblur.c:368
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:142
static int query_formats(AVFilterContext *ctx)
Definition: vf_boxblur.c:116
static const AVFilterPad avfilter_vf_boxblur_inputs[]
Definition: vf_boxblur.c:358
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:111
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_boxblur.c:108
static const AVClass boxblur_class
Definition: vf_boxblur.c:351

Definition at line 376 of file vf_boxblur.c.