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;
158 var_values[
VAR_W] = inlink->
w;
159 var_values[
VAR_H] = inlink->
h;
165 #define EVAL_RADIUS_EXPR(comp) \
166 expr = boxblur->comp##_radius_expr; \
167 ret = av_expr_parse_and_eval(&res, expr, var_names, var_values, \
168 NULL, NULL, NULL, NULL, NULL, 0, ctx); \
169 boxblur->comp##_param.radius = res; \
171 av_log(NULL, AV_LOG_ERROR, \
172 "Error when evaluating " #comp " radius expression '%s'\n", expr); \
180 "luma_radius:%d luma_power:%d "
181 "chroma_radius:%d chroma_power:%d "
182 "alpha_radius:%d alpha_power:%d "
183 "w:%d chroma_w:%d h:%d chroma_h:%d\n",
189 #define CHECK_RADIUS_VAL(w_, h_, comp) \
190 if (boxblur->comp##_param.radius < 0 || \
191 2*boxblur->comp##_param.radius > FFMIN(w_, h_)) { \
192 av_log(ctx, AV_LOG_ERROR, \
193 "Invalid " #comp " radius value %d, must be >= 0 and <= %d\n", \
194 boxblur->comp##_param.radius, FFMIN(w_, h_)/2); \
195 return AVERROR(EINVAL); \
229 const int length = radius*2 + 1;
230 const int inv = ((1<<16) + length/2)/length;
233 for (x = 0; x < radius; x++)
234 sum += src[x*src_step]<<1;
235 sum += src[radius*src_step];
237 for (x = 0; x <= radius; x++) {
238 sum += src[(radius+x)*src_step] - src[(radius-x)*src_step];
239 dst[x*dst_step] = (sum*inv + (1<<15))>>16;
242 for (; x < len-radius; x++) {
243 sum += src[(radius+x)*src_step] - src[(x-radius-1)*src_step];
244 dst[x*dst_step] = (sum*inv + (1<<15))>>16;
247 for (; x <
len; x++) {
248 sum += src[(2*len-radius-x-1)*src_step] - src[(x-radius-1)*src_step];
249 dst[x*dst_step] = (sum*inv + (1<<15))>>16;
258 if (radius && power) {
259 blur(a, 1, src, src_step, len, radius);
260 for (; power > 2; power--) {
262 blur(b, 1, a, 1, len, radius);
266 blur(dst, dst_step, a, 1, len, radius);
269 for (i = 0; i <
len; i++)
270 dst[i*dst_step] = a[i];
274 for (i = 0; i <
len; i++)
275 dst[i*dst_step] = src[i*src_step];
280 int w,
int h,
int radius,
int power,
uint8_t *
temp[2])
284 if (radius == 0 && dst == src)
287 for (y = 0; y < h; y++)
288 blur_power(dst + y*dst_linesize, 1, src + y*src_linesize, 1,
289 w, radius, power, temp);
293 int w,
int h,
int radius,
int power,
uint8_t *
temp[2])
297 if (radius == 0 && dst == src)
300 for (x = 0; x < w; x++)
301 blur_power(dst + x, dst_linesize, src + x, src_linesize,
302 h, radius, power, temp);
312 int cw = inlink->
w >> boxblur->
hsub, ch = in->
video->
h >> boxblur->
vsub;
313 int w[4] = { inlink->
w, cw, cw, inlink->
w };
323 for (plane = 0; in->
data[plane] && plane < 4; plane++)
326 w[plane], h[plane], boxblur->
radius[plane], boxblur->
power[plane],
329 for (plane = 0; in->
data[plane] && plane < 4; plane++)
332 w[plane], h[plane], boxblur->
radius[plane], boxblur->
power[plane],
367 .
inputs = avfilter_vf_boxblur_inputs,
368 .
outputs = avfilter_vf_boxblur_outputs,