Browse Source

de-kluging some funcs

tth 1 month ago
parent
commit
59cbb3c1e0
1 changed files with 19 additions and 14 deletions
  1. 19
    14
      lib/operators.c

+ 19
- 14
lib/operators.c View File

@@ -63,12 +63,13 @@ if (FIMG_TYPE_RGB != a->type || FIMG_TYPE_RGB != b->type) {
63 63
 
64 64
 nbpixels = a->width * a->height;
65 65
 
66
+	/*   are we cache-friendly here ? 
67
+	 *   we need an accurate benchmarking... */
68
+
66 69
 for (idx=0; idx<nbpixels; idx++) {
67 70
 	b->R[idx] += a->R[idx];
68 71
 	b->G[idx] += a->G[idx];
69 72
 	b->B[idx] += a->B[idx];
70
-	/*   are we cache-friendly here ? 
71
-	 *   we need an accurate benchmarking... */
72 73
 	}
73 74
 
74 75
 return 0;
@@ -85,8 +86,8 @@ int		idx, nbpixels;
85 86
 fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, a, b, d);
86 87
 #endif
87 88
 
88
-if (FIMG_TYPE_RGB != a->type ||
89
-	FIMG_TYPE_RGB != b->type ||
89
+if (	FIMG_TYPE_RGB != a->type  ||
90
+	FIMG_TYPE_RGB != b->type  ||
90 91
 	FIMG_TYPE_RGB != d->type) {
91 92
 	fprintf(stderr, "%s : got a bad type fimg\n", __func__);
92 93
 	return -8;
@@ -175,13 +176,15 @@ if (FIMG_TYPE_RGB != a->type || FIMG_TYPE_RGB != b->type ||
175 176
 	return -8;
176 177
 	}
177 178
 
178
-nbiter = a->width * a->height * 3;
179
+nbiter = a->width * a->height;
179 180
 
180 181
 for (idx=0; idx<nbiter; idx++) {
181
-	if (a->R[idx] > b->R[idx])
182
-			d->R[idx] = a->R[idx];
183
-	else
184
-			d->R[idx] = b->R[idx];
182
+	if (a->R[idx] > b->R[idx])	d->R[idx] = a->R[idx];
183
+	else				d->R[idx] = b->R[idx];
184
+	if (a->G[idx] > b->G[idx])	d->G[idx] = a->G[idx];
185
+	else				d->G[idx] = b->G[idx];
186
+	if (a->B[idx] > b->B[idx])	d->B[idx] = a->B[idx];
187
+	else				d->B[idx] = b->B[idx];
185 188
 	}
186 189
 
187 190
 return 0;
@@ -201,13 +204,15 @@ if (FIMG_TYPE_RGB != a->type || FIMG_TYPE_RGB != b->type ||
201 204
 	return -8;
202 205
 	}
203 206
 
204
-nbiter = a->width * a->height * 3;
207
+nbiter = a->width * a->height ;
205 208
 
206 209
 for (idx=0; idx<nbiter; idx++) {
207
-	if (a->R[idx] < b->R[idx])
208
-			d->R[idx] = a->R[idx];
209
-	else
210
-			d->R[idx] = b->R[idx];
210
+	if (a->R[idx] < b->R[idx])	d->R[idx] = a->R[idx];
211
+	else				d->R[idx] = b->R[idx];
212
+	if (a->G[idx] < b->G[idx])	d->G[idx] = a->G[idx];
213
+	else				d->G[idx] = b->G[idx];
214
+	if (a->B[idx] < b->B[idx])	d->B[idx] = a->B[idx];
215
+	else				d->B[idx] = b->B[idx];
211 216
 	}
212 217
 
213 218
 return 0;

Loading…
Cancel
Save