Commit d68ba3fe authored by Stefano Sabatini's avatar Stefano Sabatini

vf_boxblur: prefer the name "len" over "w" in the blur routines

Make more clear the meaning of the variables. They specify the length
of a (vertical or horizontal) line rather than a width.
Less confusing.
parent 1d186e9e
...@@ -206,7 +206,7 @@ static int config_input(AVFilterLink *inlink) ...@@ -206,7 +206,7 @@ static int config_input(AVFilterLink *inlink)
} }
static inline void blur(uint8_t *dst, int dst_step, const uint8_t *src, int src_step, static inline void blur(uint8_t *dst, int dst_step, const uint8_t *src, int src_step,
int w, int radius) int len, int radius)
{ {
/* Naive boxblur would sum source pixels from x-radius .. x+radius /* Naive boxblur would sum source pixels from x-radius .. x+radius
* for destination pixel x. That would be O(radius*width). * for destination pixel x. That would be O(radius*width).
...@@ -235,39 +235,39 @@ static inline void blur(uint8_t *dst, int dst_step, const uint8_t *src, int src_ ...@@ -235,39 +235,39 @@ static inline void blur(uint8_t *dst, int dst_step, const uint8_t *src, int src_
dst[x*dst_step] = (sum*inv + (1<<15))>>16; dst[x*dst_step] = (sum*inv + (1<<15))>>16;
} }
for (; x < w-radius; x++) { for (; x < len-radius; x++) {
sum += src[(radius+x)*src_step] - src[(x-radius-1)*src_step]; sum += src[(radius+x)*src_step] - src[(x-radius-1)*src_step];
dst[x*dst_step] = (sum*inv + (1<<15))>>16; dst[x*dst_step] = (sum*inv + (1<<15))>>16;
} }
for (; x < w; x++) { for (; x < len; x++) {
sum += src[(2*w-radius-x-1)*src_step] - src[(x-radius-1)*src_step]; sum += src[(2*len-radius-x-1)*src_step] - src[(x-radius-1)*src_step];
dst[x*dst_step] = (sum*inv + (1<<15))>>16; dst[x*dst_step] = (sum*inv + (1<<15))>>16;
} }
} }
static inline void blur_power(uint8_t *dst, int dst_step, const uint8_t *src, int src_step, static inline void blur_power(uint8_t *dst, int dst_step, const uint8_t *src, int src_step,
int w, int radius, int power, uint8_t *temp[2]) int len, int radius, int power, uint8_t *temp[2])
{ {
uint8_t *a = temp[0], *b = temp[1]; uint8_t *a = temp[0], *b = temp[1];
if (radius && power) { if (radius && power) {
blur(a, 1, src, src_step, w, radius); blur(a, 1, src, src_step, len, radius);
for (; power > 2; power--) { for (; power > 2; power--) {
uint8_t *c; uint8_t *c;
blur(b, 1, a, 1, w, radius); blur(b, 1, a, 1, len, radius);
c = a; a = b; b = c; c = a; a = b; b = c;
} }
if (power > 1) { if (power > 1) {
blur(dst, dst_step, a, 1, w, radius); blur(dst, dst_step, a, 1, len, radius);
} else { } else {
int i; int i;
for (i = 0; i < w; i++) for (i = 0; i < len; i++)
dst[i*dst_step] = a[i]; dst[i*dst_step] = a[i];
} }
} else { } else {
int i; int i;
for (i = 0; i < w; i++) for (i = 0; i < len; i++)
dst[i*dst_step] = src[i*src_step]; dst[i*dst_step] = src[i*src_step];
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment