Opt imlib_integral_image

This commit is contained in:
iabdalkader 2014-08-30 19:19:07 +02:00
parent 19121dec9f
commit b621643763

View File

@ -5,21 +5,22 @@
void imlib_integral_image(struct image *src, struct integral_image *sum)
{
int x, y, s,t;
unsigned char *data = src->pixels;
typeof(*src->data) *data = src->data;
typeof(*sum->data) *sumData = sum->data;
for (y=0; y<src->h; y++) {
s = 0;
/* loop over the number of columns */
for (x=0; x<src->w; x++) {
/* sum of the current row (integer)*/
s += data[y*src->w+x];
t = s;
if (y != 0) {
t += sumData[(y-1)*src->w+x];
// Compute first column to avoid branching
for (int s=0, x=0; x<src->w; x++) {
/* sum of the current row (integer) */
s += data[src->w+x];
sumData[src->w+x] = s;
}
sumData[y*src->w+x]=t;
for (int y=1; y<src->h; y++) {
/* loop over the number of columns */
for (int s=0, x=0; x<src->w; x++) {
/* sum of the current row (integer) */
s += data[y*src->w+x];
sumData[y*src->w+x] = s+sumData[(y-1)*src->w+x];
}
}
}