Compare commits

..

No commits in common. "692735a57f1c5443f7e8dabd9f996664c33e10ae" and "4c5642881aceb704fc18519857f4aa89cbc4d5ad" have entirely different histories.

4 changed files with 13 additions and 41 deletions

View File

@ -62,7 +62,7 @@ for (foo=0; foo<NBP; foo++) {
printf("%5d / %5d\n", foo, NBP);
}
fait_un_dessin(&fimgB);
fimg_add_3(&fimgA, &fimgB, &fimgA);
fimg_add(&fimgA, &fimgB, &fimgA);
// fimg_mul(&fimgA, &fimgB, &fimgA);
}
tb = fimg_timer_get(0);

View File

@ -2,7 +2,7 @@
* floatimg.h
*/
#define FIMG_VERSION 87
#define FIMG_VERSION 86
/*
* in memory descriptor
@ -69,10 +69,9 @@ int fimg_images_compatible(FloatImg *a, FloatImg *b);
int fimg_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef);
/* 'operats' module */
int fimg_add_3(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_add_2(FloatImg *a, FloatImg *b); /* B+=A */
int fimg_sub_3(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_mul_3(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_add(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_sub(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_mul(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_minimum(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d);

View File

@ -19,7 +19,7 @@ extern int verbosity; /* must be declared around main() */
* A + B -> D
* why is this func so slow ?
*/
int fimg_add_3(FloatImg *a, FloatImg *b, FloatImg *d)
int fimg_add(FloatImg *a, FloatImg *b, FloatImg *d)
{
int idx, nbpixels;
@ -40,40 +40,13 @@ for (idx=0; idx<nbpixels; idx++) {
d->B[idx] = a->B[idx] + b->B[idx];
}
return 0;
}
/* ---------------------------------------------------------------- */
/*
* B += A may be faster than fimg_add_3 ?
*/
int fimg_add_2(FloatImg *a, FloatImg *b)
{
int idx, nbpixels;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, a, b);
#endif
if (3 != a->type || 3 != b->type) {
fprintf(stderr, "%s : got a bad type fimg\n", __func__);
return -8;
}
nbpixels = a->width * a->height;
for (idx=0; idx<nbpixels; idx++) {
b->R[idx] += a->R[idx];
b->G[idx] += a->G[idx];
b->B[idx] += a->B[idx];
}
return 0;
}
/* ---------------------------------------------------------------- */
/*
* A - B -> D
*/
int fimg_sub_3(FloatImg *a, FloatImg *b, FloatImg *d)
int fimg_sub(FloatImg *a, FloatImg *b, FloatImg *d)
{
int idx, nbpixels;
@ -103,7 +76,7 @@ return 0;
/*
* A * B -> D
*/
int fimg_mul_3(FloatImg *a, FloatImg *b, FloatImg *d)
int fimg_mul(FloatImg *a, FloatImg *b, FloatImg *d)
{
int idx, nbpixels;

View File

@ -80,16 +80,16 @@ int foo;
switch (action) {
case OP_ADD:
foo = fimg_add_3(A, B, D); break;
foo = fimg_add(A, B, D); break;
case OP_SUB:
foo = fimg_sub_3(A, B, D); break;
foo = fimg_sub(A, B, D); break;
case OP_MIX:
if (verbosity) fprintf(stderr, "fvalue is %f\n",
global_fvalue);
foo = fimg_interpolate(A, B, D, global_fvalue);
break;
case OP_MUL:
foo = fimg_mul_3(A, B, D); break;
foo = fimg_add(A, B, D); break;
case OP_MINI:
foo = fimg_maximum(A, B, D); break;
case OP_MAXI: