76 #define OFFSET(x) offsetof(BoxBlurContext, x)
77 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
108 static const char *shorthand[] = {
109 "luma_radius",
"luma_power",
110 "chroma_radius",
"chroma_power",
111 "alpha_radius",
"alpha_power",
116 boxblur->
class = &boxblur_class;
171 int w = inlink->
w, h = inlink->
h;
173 double var_values[
VARS_NB], res;
184 var_values[
VAR_W] = inlink->
w;
185 var_values[
VAR_H] = inlink->
h;
191 #define EVAL_RADIUS_EXPR(comp) \
192 expr = boxblur->comp##_param.radius_expr; \
193 ret = av_expr_parse_and_eval(&res, expr, var_names, var_values, \
194 NULL, NULL, NULL, NULL, NULL, 0, ctx); \
195 boxblur->comp##_param.radius = res; \
197 av_log(NULL, AV_LOG_ERROR, \
198 "Error when evaluating " #comp " radius expression '%s'\n", expr); \
206 "luma_radius:%d luma_power:%d "
207 "chroma_radius:%d chroma_power:%d "
208 "alpha_radius:%d alpha_power:%d "
209 "w:%d chroma_w:%d h:%d chroma_h:%d\n",
215 #define CHECK_RADIUS_VAL(w_, h_, comp) \
216 if (boxblur->comp##_param.radius < 0 || \
217 2*boxblur->comp##_param.radius > FFMIN(w_, h_)) { \
218 av_log(ctx, AV_LOG_ERROR, \
219 "Invalid " #comp " radius value %d, must be >= 0 and <= %d\n", \
220 boxblur->comp##_param.radius, FFMIN(w_, h_)/2); \
221 return AVERROR(EINVAL); \
255 const int length = radius*2 + 1;
256 const int inv = ((1<<16) + length/2)/length;
259 for (x = 0; x < radius; x++)
260 sum += src[x*src_step]<<1;
261 sum += src[radius*src_step];
263 for (x = 0; x <= radius; x++) {
264 sum += src[(radius+x)*src_step] - src[(radius-x)*src_step];
265 dst[x*dst_step] = (sum*inv + (1<<15))>>16;
268 for (; x < len-radius; x++) {
269 sum += src[(radius+x)*src_step] - src[(x-radius-1)*src_step];
270 dst[x*dst_step] = (sum*inv + (1<<15))>>16;
273 for (; x <
len; x++) {
274 sum += src[(2*len-radius-x-1)*src_step] - src[(x-radius-1)*src_step];
275 dst[x*dst_step] = (sum*inv + (1<<15))>>16;
284 if (radius && power) {
285 blur(a, 1, src, src_step, len, radius);
286 for (; power > 2; power--) {
288 blur(b, 1, a, 1, len, radius);
292 blur(dst, dst_step, a, 1, len, radius);
295 for (i = 0; i <
len; i++)
296 dst[i*dst_step] = a[i];
300 for (i = 0; i <
len; i++)
301 dst[i*dst_step] = src[i*src_step];
306 int w,
int h,
int radius,
int power,
uint8_t *
temp[2])
310 if (radius == 0 && dst == src)
313 for (y = 0; y < h; y++)
314 blur_power(dst + y*dst_linesize, 1, src + y*src_linesize, 1,
315 w, radius, power, temp);
319 int w,
int h,
int radius,
int power,
uint8_t *
temp[2])
323 if (radius == 0 && dst == src)
326 for (x = 0; x < w; x++)
327 blur_power(dst + x, dst_linesize, src + x, src_linesize,
328 h, radius, power, temp);
338 int cw = inlink->
w >> boxblur->
hsub, ch = in->
video->
h >> boxblur->
vsub;
339 int w[4] = { inlink->
w, cw, cw, inlink->
w };
349 for (plane = 0; in->
data[plane] && plane < 4; plane++)
352 w[plane], h[plane], boxblur->
radius[plane], boxblur->
power[plane],
355 for (plane = 0; in->
data[plane] && plane < 4; plane++)
358 w[plane], h[plane], boxblur->
radius[plane], boxblur->
power[plane],
393 .
inputs = avfilter_vf_boxblur_inputs,
394 .
outputs = avfilter_vf_boxblur_outputs,
396 .priv_class = &boxblur_class,