136 int w = inlink->
w, h = inlink->
h;
138 double var_values[
VARS_NB], res;
154 var_values[
VAR_W] = inlink->
w;
155 var_values[
VAR_H] = inlink->
h;
161 #define EVAL_RADIUS_EXPR(comp) \
162 expr = s->comp##_radius_expr; \
163 ret = av_expr_parse_and_eval(&res, expr, var_names, var_values, \
164 NULL, NULL, NULL, NULL, NULL, 0, ctx); \
165 s->comp##_param.radius = res; \
167 av_log(NULL, AV_LOG_ERROR, \
168 "Error when evaluating " #comp " radius expression '%s'\n", expr); \
176 "luma_radius:%d luma_power:%d "
177 "chroma_radius:%d chroma_power:%d "
178 "alpha_radius:%d alpha_power:%d "
179 "w:%d chroma_w:%d h:%d chroma_h:%d\n",
185 #define CHECK_RADIUS_VAL(w_, h_, comp) \
186 if (s->comp##_param.radius < 0 || \
187 2*s->comp##_param.radius > FFMIN(w_, h_)) { \
188 av_log(ctx, AV_LOG_ERROR, \
189 "Invalid " #comp " radius value %d, must be >= 0 and <= %d\n", \
190 s->comp##_param.radius, FFMIN(w_, h_)/2); \
191 return AVERROR(EINVAL); \
225 const int length = radius*2 + 1;
226 const int inv = ((1<<16) + length/2)/length;
229 for (x = 0; x < radius; x++)
230 sum += src[x*src_step]<<1;
231 sum += src[radius*src_step];
233 for (x = 0; x <= radius; x++) {
234 sum += src[(radius+x)*src_step] - src[(radius-x)*src_step];
235 dst[x*dst_step] = (sum*inv + (1<<15))>>16;
238 for (; x < len-radius; x++) {
239 sum += src[(radius+x)*src_step] - src[(x-radius-1)*src_step];
240 dst[x*dst_step] = (sum*inv + (1<<15))>>16;
243 for (; x <
len; x++) {
244 sum += src[(2*len-radius-x-1)*src_step] - src[(x-radius-1)*src_step];
245 dst[x*dst_step] = (sum*inv + (1<<15))>>16;
250 int len,
int radius,
int power,
uint8_t *temp[2])
254 if (radius && power) {
255 blur(a, 1, src, src_step, len, radius);
256 for (; power > 2; power--) {
258 blur(b, 1, a, 1, len, radius);
262 blur(dst, dst_step, a, 1, len, radius);
265 for (i = 0; i <
len; i++)
266 dst[i*dst_step] = a[i];
270 for (i = 0; i <
len; i++)
271 dst[i*dst_step] = src[i*src_step];
276 int w,
int h,
int radius,
int power,
uint8_t *temp[2])
280 if (radius == 0 && dst == src)
283 for (y = 0; y < h; y++)
284 blur_power(dst + y*dst_linesize, 1, src + y*src_linesize, 1,
285 w, radius, power, temp);
289 int w,
int h,
int radius,
int power,
uint8_t *temp[2])
293 if (radius == 0 && dst == src)
296 for (x = 0; x < w; x++)
297 blur_power(dst + x, dst_linesize, src + x, src_linesize,
298 h, radius, power, temp);
309 int w[4] = { inlink->
w, cw, cw, inlink->
w };
319 for (plane = 0; in->
data[plane] && plane < 4; plane++)
322 w[plane], h[plane], s->
radius[plane], s->
power[plane],
325 for (plane = 0; in->
data[plane] && plane < 4; plane++)
328 w[plane], h[plane], s->
radius[plane], s->
power[plane],
336 #define OFFSET(x) offsetof(BoxBlurContext, x)
337 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
340 {
"luma_power",
"How many times should the boxblur be applied to luma",
343 {
"chroma_power",
"How many times should the boxblur be applied to chroma",
346 {
"alpha_power",
"How many times should the boxblur be applied to alpha",
380 .priv_class = &boxblur_class,
385 .
inputs = avfilter_vf_boxblur_inputs,
386 .
outputs = avfilter_vf_boxblur_outputs,