66 char luma_radius_expr [256];
67 char chroma_radius_expr[256];
68 char alpha_radius_expr [256];
88 "Filter expects 2 or 4 or 6 arguments, none provided\n");
92 e = sscanf(args,
"%255[^:]:%d:%255[^:]:%d:%255[^:]:%d",
97 if (e != 2 && e != 4 && e != 6) {
99 "Filter expects 2 or 4 or 6 params, provided %d\n", e);
145 int w = inlink->
w, h = inlink->
h;
147 double var_values[
VARS_NB], res;
163 var_values[
VAR_W] = inlink->
w;
164 var_values[
VAR_H] = inlink->
h;
170 #define EVAL_RADIUS_EXPR(comp) \
171 expr = boxblur->comp##_radius_expr; \
172 ret = av_expr_parse_and_eval(&res, expr, var_names, var_values, \
173 NULL, NULL, NULL, NULL, NULL, 0, ctx); \
174 boxblur->comp##_param.radius = res; \
176 av_log(NULL, AV_LOG_ERROR, \
177 "Error when evaluating " #comp " radius expression '%s'\n", expr); \
185 "luma_radius:%d luma_power:%d "
186 "chroma_radius:%d chroma_power:%d "
187 "alpha_radius:%d alpha_power:%d "
188 "w:%d chroma_w:%d h:%d chroma_h:%d\n",
194 #define CHECK_RADIUS_VAL(w_, h_, comp) \
195 if (boxblur->comp##_param.radius < 0 || \
196 2*boxblur->comp##_param.radius > FFMIN(w_, h_)) { \
197 av_log(ctx, AV_LOG_ERROR, \
198 "Invalid " #comp " radius value %d, must be >= 0 and <= %d\n", \
199 boxblur->comp##_param.radius, FFMIN(w_, h_)/2); \
200 return AVERROR(EINVAL); \
234 const int length = radius*2 + 1;
235 const int inv = ((1<<16) + length/2)/length;
238 for (x = 0; x < radius; x++)
239 sum += src[x*src_step]<<1;
240 sum += src[radius*src_step];
242 for (x = 0; x <= radius; x++) {
243 sum += src[(radius+x)*src_step] - src[(radius-x)*src_step];
244 dst[x*dst_step] = (sum*inv + (1<<15))>>16;
247 for (; x < len-radius; x++) {
248 sum += src[(radius+x)*src_step] - src[(x-radius-1)*src_step];
249 dst[x*dst_step] = (sum*inv + (1<<15))>>16;
252 for (; x <
len; x++) {
253 sum += src[(2*len-radius-x-1)*src_step] - src[(x-radius-1)*src_step];
254 dst[x*dst_step] = (sum*inv + (1<<15))>>16;
259 int len,
int radius,
int power,
uint8_t *temp[2])
263 if (radius && power) {
264 blur(a, 1, src, src_step, len, radius);
265 for (; power > 2; power--) {
267 blur(b, 1, a, 1, len, radius);
271 blur(dst, dst_step, a, 1, len, radius);
274 for (i = 0; i <
len; i++)
275 dst[i*dst_step] = a[i];
279 for (i = 0; i <
len; i++)
280 dst[i*dst_step] = src[i*src_step];
285 int w,
int h,
int radius,
int power,
uint8_t *temp[2])
289 if (radius == 0 && dst == src)
292 for (y = 0; y < h; y++)
293 blur_power(dst + y*dst_linesize, 1, src + y*src_linesize, 1,
294 w, radius, power, temp);
298 int w,
int h,
int radius,
int power,
uint8_t *temp[2])
302 if (radius == 0 && dst == src)
305 for (x = 0; x < w; x++)
306 blur_power(dst + x, dst_linesize, src + x, src_linesize,
307 h, radius, power, temp);
317 int cw = inlink->
w >> boxblur->
hsub, ch = in->
video->
h >> boxblur->
vsub;
318 int w[4] = { inlink->
w, cw, cw, inlink->
w };
328 for (plane = 0; in->
data[plane] && plane < 4; plane++)
331 w[plane], h[plane], boxblur->
radius[plane], boxblur->
power[plane],
334 for (plane = 0; in->
data[plane] && plane < 4; plane++)
337 w[plane], h[plane], boxblur->
radius[plane], boxblur->
power[plane],
372 .
inputs = avfilter_vf_boxblur_inputs,
373 .
outputs = avfilter_vf_boxblur_outputs,