span1 = alloca(len);
span2 = alloca(len);
+ memset(span1, 0, len);
+ memset(span2, 0, len);
// For each line, apply as many blurs as requested
for (int l = 0; l < loops; l++)
{
const int radius = radii[run];
const int left = MIN(radius, len);
- const int right = MIN(radius, (len - radius));
- int acc = 0;
#if DIV_USING_BITSHIFT
const int pow2 = pow2_shifts[run];
const int divider = 2 * radius + 1;
#endif
- const DATA8* restrict sr = src;
const DATA8* restrict sl = src;
+ const DATA8* restrict sr = src;
+ const DATA8* restrict sre = src + len;
+ const DATA8* restrict sle = src + len - radius;
DATA8* restrict d = dst;
+ int acc = 0, count = 0;
// Read-ahead & accumulate
- for (int k = left; k; k--)
+ for (int x = left; x > 0; x--)
{
- acc += *sr;
- sr += 1;
+ acc += *sr++;
+ count++;
}
// Left edge
- for (int k = 0; k < left; k++)
+ for (int x = left; x > 0; x--)
{
- acc += *sr;
- *d = acc / (k + left + 1);
- sr += 1;
- d += 1;
+ if (sr < sre)
+ {
+ acc += *sr++;
+ count++;
+ }
+
+ *d++ = acc / count;
}
// Middle part, normal blur
- for (int k = len - (2 * radius); k; k--)
+ while (sr < sre)
{
- acc += *sr;
- *d = DIVIDE(acc);
- acc -= *sl;
- sl += 1;
- sr += 1;
- d += 1;
+ acc += *sr++;
+ *d++ = DIVIDE(acc);
+ acc -= *sl++;
}
// Right edge
- for (int k = right; k; k--)
+ count = 2 * radius + 1;
+ while (sl < sle)
{
- *d = acc / (k + right);
- acc -= *sl;
- d += 1;
- sl += 1;
+ *d++ = acc / (--count);
+ acc -= *sl++;
}
// More runs to go: swap spans
{
const int radius = radii[run];
const int left = MIN(radius, len);
- const int right = MIN(radius, (len - radius));
- int acc = 0;
#if DIV_USING_BITSHIFT
const int pow2 = pow2_shifts[run];
const int divider = 2 * radius + 1;
#endif
- const DATA8* restrict sr = src;
const DATA8* restrict sl = src;
+ const DATA8* restrict sr = src;
+ const DATA8* restrict sre = src + len;
+ const DATA8* restrict sle = src + len - radius;
DATA8* restrict d = dst;
+ int acc = 0, count = 0;
// Read-ahead & accumulate
- for (int k = left; k; k--)
+ for (int x = left; x > 0; x--)
{
- acc += *sr;
- sr += 1;
+ acc += *sr++;
+ count++;
}
// Left edge
- for (int k = 0; k < left; k++)
+ for (int x = left; x > 0; x--)
{
- acc += *sr;
- *d = acc / (k + left + 1);
- sr += 1;
- d += 1;
+ if (sr < sre)
+ {
+ acc += *sr++;
+ count++;
+ }
+
+ *d++ = acc / count;
}
// Middle part, normal blur
- for (int k = len - (2 * radius); k; k--)
+ while (sr < sre)
{
- acc += *sr;
- *d = DIVIDE(acc);
- acc -= *sl;
- sl += 1;
- sr += 1;
- d += 1;
+ acc += *sr++;
+ *d++ = DIVIDE(acc);
+ acc -= *sl++;
}
// Right edge
- for (int k = right; k; k--)
+ count = 2 * radius + 1;
+ while (sl < sle)
{
- *d = acc / (k + right);
- acc -= *sl;
- d += 1;
- sl += 1;
+ *d++ = acc / (--count);
+ acc -= *sl++;
}
// More runs to go: swap spans
span1 = alloca(len * sizeof(DATA32));
span2 = alloca(len * sizeof(DATA32));
+ memset(span1, 0, len * sizeof(DATA32));
+ memset(span2, 0, len * sizeof(DATA32));
// For each line, apply as many blurs as requested
for (int l = 0; l < loops; l++)
{
const int radius = radii[run];
const int left = MIN(radius, len);
- const int right = MIN(radius, (len - radius));
#if DIV_USING_BITSHIFT
const int pow2 = pow2_shifts[run];
const DATA8* restrict sl = (DATA8 *) src;
const DATA8* restrict sr = (DATA8 *) src;
+ const DATA8* restrict sre = (DATA8 *) (src + len);
+ const DATA8* restrict sle = (DATA8 *) (src + len - radius);
DATA8* restrict d = (DATA8 *) dst;
int acc[4] = {0};
- int x, k;
+ int count = 0;
// Read-ahead
- for (x = left; x; x--)
+ for (int x = left; x > 0; x--)
{
- for (k = 0; k < 4; k++)
+ for (int k = 0; k < 4; k++)
acc[k] += sr[k];
sr += sizeof(DATA32);
+ count++;
}
// Left
- for (x = 0; x < left; x++)
+ for (int x = left; x > 0; x--)
{
- for (k = 0; k < 4; k++)
- acc[k] += sr[k];
- sr += sizeof(DATA32);
+ if (sr < sre)
+ {
+ for (int k = 0; k < 4; k++)
+ acc[k] += sr[k];
+ sr += sizeof(DATA32);
+ count++;
+ }
- const int divider = x + left + 1;
- d[ALPHA] = acc[ALPHA] / divider;
- d[RED] = acc[RED] / divider;
- d[GREEN] = acc[GREEN] / divider;
- d[BLUE] = acc[BLUE] / divider;
+ d[ALPHA] = acc[ALPHA] / count;
+ d[RED] = acc[RED] / count;
+ d[GREEN] = acc[GREEN] / count;
+ d[BLUE] = acc[BLUE] / count;
d += sizeof(DATA32);
}
// Main part
- for (x = len - (2 * radius); x > 0; x--)
+ for (; sr < sre; sr += sizeof(DATA32), sl += sizeof(DATA32))
{
- for (k = 0; k < 4; k++)
+ for (int k = 0; k < 4; k++)
acc[k] += sr[k];
- sr += sizeof(DATA32);
d[ALPHA] = DIVIDE(acc[ALPHA]);
d[RED] = DIVIDE(acc[RED]);
d[BLUE] = DIVIDE(acc[BLUE]);
d += sizeof(DATA32);
- for (k = 0; k < 4; k++)
+ for (int k = 0; k < 4; k++)
acc[k] -= sl[k];
- sl += sizeof(DATA32);
}
// Right part
- for (x = right; x; x--)
+ count = 2 * radius + 1;
+ for (; sl < sle; sl += sizeof(DATA32))
{
- const int divider = x + right;
+ const int divider = --count;
d[ALPHA] = acc[ALPHA] / divider;
d[RED] = acc[RED] / divider;
d[GREEN] = acc[GREEN] / divider;
d[BLUE] = acc[BLUE] / divider;
d += sizeof(DATA32);
- for (k = 0; k < 4; k++)
+ for (int k = 0; k < 4; k++)
acc[k] -= sl[k];
- sl += sizeof(DATA32);
}
// More runs to go: swap spans
span1 = alloca(len * sizeof(DATA32));
span2 = alloca(len * sizeof(DATA32));
+ memset(span1, 0, len * sizeof(DATA32));
+ memset(span2, 0, len * sizeof(DATA32));
// For each line, apply as many blurs as requested
for (int l = 0; l < loops; l++)
{
const int radius = radii[run];
const int left = MIN(radius, len);
- const int right = MIN(radius, (len - radius));
#if DIV_USING_BITSHIFT
const int pow2 = pow2_shifts[run];
const DATA8* restrict sl = (DATA8 *) src;
const DATA8* restrict sr = (DATA8 *) src;
+ const DATA8* restrict sre = (DATA8 *) (src + len);
+ const DATA8* restrict sle = (DATA8 *) (src + len - radius);
DATA8* restrict d = (DATA8 *) dst;
int acc[4] = {0};
- int x, k;
+ int count = 0;
// Read-ahead
- for (x = left; x; x--)
+ for (int x = left; x > 0; x--)
{
- for (k = 0; k < 4; k++)
+ for (int k = 0; k < 4; k++)
acc[k] += sr[k];
sr += sizeof(DATA32);
+ count++;
}
// Left
- for (x = 0; x < left; x++)
+ for (int x = left; x > 0; x--)
{
- for (k = 0; k < 4; k++)
- acc[k] += sr[k];
- sr += sizeof(DATA32);
+ if (sr < sre)
+ {
+ for (int k = 0; k < 4; k++)
+ acc[k] += sr[k];
+ sr += sizeof(DATA32);
+ count++;
+ }
- const int divider = x + left + 1;
- d[ALPHA] = acc[ALPHA] / divider;
- d[RED] = acc[RED] / divider;
- d[GREEN] = acc[GREEN] / divider;
- d[BLUE] = acc[BLUE] / divider;
+ d[ALPHA] = acc[ALPHA] / count;
+ d[RED] = acc[RED] / count;
+ d[GREEN] = acc[GREEN] / count;
+ d[BLUE] = acc[BLUE] / count;
d += sizeof(DATA32);
}
// Main part
- for (x = len - (2 * radius); x > 0; x--)
+ for (; sr < sre; sr += sizeof(DATA32), sl += sizeof(DATA32))
{
- for (k = 0; k < 4; k++)
+ for (int k = 0; k < 4; k++)
acc[k] += sr[k];
- sr += sizeof(DATA32);
d[ALPHA] = DIVIDE(acc[ALPHA]);
d[RED] = DIVIDE(acc[RED]);
d[BLUE] = DIVIDE(acc[BLUE]);
d += sizeof(DATA32);
- for (k = 0; k < 4; k++)
+ for (int k = 0; k < 4; k++)
acc[k] -= sl[k];
- sl += sizeof(DATA32);
}
// Right part
- for (x = right; x; x--)
+ count = 2 * radius + 1;
+ for (; sl < sle; sl += sizeof(DATA32))
{
- const int divider = x + right;
+ const int divider = --count;
d[ALPHA] = acc[ALPHA] / divider;
d[RED] = acc[RED] / divider;
d[GREEN] = acc[GREEN] / divider;
d[BLUE] = acc[BLUE] / divider;
d += sizeof(DATA32);
- for (k = 0; k < 4; k++)
+ for (int k = 0; k < 4; k++)
acc[k] -= sl[k];
- sl += sizeof(DATA32);
}
// More runs to go: swap spans
EINA_SAFETY_ON_NULL_RETURN_VAL(in->image.data, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(out->image.data, EINA_FALSE);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(out->cache_entry.w >= (2*r + 1), EINA_FALSE);
_box_blur_horiz_rgba(in->image.data, out->image.data, radii,
in->cache_entry.w, in->cache_entry.h);
EINA_SAFETY_ON_NULL_RETURN_VAL(in->image.data, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(out->image.data, EINA_FALSE);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(out->cache_entry.h >= (2*r + 1), EINA_FALSE);
_box_blur_vert_rgba(in->image.data, out->image.data, radii,
in->cache_entry.w, in->cache_entry.h);
EINA_SAFETY_ON_NULL_RETURN_VAL(in->image.data8, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(out->image.data8, EINA_FALSE);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(out->cache_entry.w >= (2*r + 1), EINA_FALSE);
_box_blur_horiz_alpha(in->image.data8, out->image.data8, radii,
in->cache_entry.w, in->cache_entry.h);
EINA_SAFETY_ON_NULL_RETURN_VAL(in->image.data8, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(out->image.data8, EINA_FALSE);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(out->cache_entry.h >= (2*r + 1), EINA_FALSE);
_box_blur_vert_alpha(in->image.data8, out->image.data8, radii,
in->cache_entry.w, in->cache_entry.h);
EINA_SAFETY_ON_NULL_RETURN_VAL(in->image.data8, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(out->image.data8, EINA_FALSE);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(out->cache_entry.w >= (2*r + 1), EINA_FALSE);
_gaussian_blur_horiz_alpha(in->image.data8, out->image.data8, r,
in->cache_entry.w, in->cache_entry.h);
EINA_SAFETY_ON_NULL_RETURN_VAL(in->image.data8, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(out->image.data8, EINA_FALSE);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(out->cache_entry.h >= (2*r + 1), EINA_FALSE);
_gaussian_blur_vert_alpha(in->image.data8, out->image.data8, r,
in->cache_entry.w, in->cache_entry.h);
EINA_SAFETY_ON_NULL_RETURN_VAL(in->image.data, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(out->image.data, EINA_FALSE);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(out->cache_entry.w >= (2*r + 1), EINA_FALSE);
_gaussian_blur_horiz_rgba(in->image.data, out->image.data, r,
in->cache_entry.w, in->cache_entry.h);
EINA_SAFETY_ON_NULL_RETURN_VAL(in->image.data, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(out->image.data, EINA_FALSE);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(out->cache_entry.h >= (2*r + 1), EINA_FALSE);
_gaussian_blur_vert_rgba(in->image.data, out->image.data, r,
in->cache_entry.w, in->cache_entry.h);