Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-06-14 23:22:55 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-14 23:22:55 +0400
commit813348a4eeeb97536cc47a9eb30605cdb68ca781 (patch)
treea1006b6d371b876d3be7032c557ac115bfd56d50 /source/blender/nodes
parent8ae116fbbb505be7055046eb15ba82ced203ced2 (diff)
code cleanup: replace most fRGB functions with inline vector functions
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/composite/node_composite_util.c12
-rw-r--r--source/blender/nodes/composite/node_composite_util.h10
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_glare.c48
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_tonemap.c8
4 files changed, 34 insertions, 44 deletions
diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c
index ff223ac83cf..afd10d96e99 100644
--- a/source/blender/nodes/composite/node_composite_util.c
+++ b/source/blender/nodes/composite/node_composite_util.c
@@ -1022,7 +1022,7 @@ void convolve(CompBuf* dst, CompBuf* in1, CompBuf* in2)
for (y=0; y<in2->y; y++) {
colp = (fRGB*)&in2->rect[y*in2->x*in2->type];
for (x=0; x<in2->x; x++)
- fRGB_add(wt, colp[x]);
+ add_v3_v3(wt, colp[x]);
}
if (wt[0] != 0.f) wt[0] = 1.f/wt[0];
if (wt[1] != 0.f) wt[1] = 1.f/wt[1];
@@ -1030,7 +1030,7 @@ void convolve(CompBuf* dst, CompBuf* in1, CompBuf* in2)
for (y=0; y<in2->y; y++) {
colp = (fRGB*)&in2->rect[y*in2->x*in2->type];
for (x=0; x<in2->x; x++)
- fRGB_colormult(colp[x], wt);
+ mul_v3_v3(colp[x], wt);
}
// copy image data, unpacking interleaved RGBA into separate channels
@@ -1279,14 +1279,14 @@ CompBuf* qd_downScaledCopy(CompBuf* src, int scale)
xx = x*scale;
mx = xx + scale;
if (mx > src->x) mx = src->x;
- colsum[0] = colsum[1] = colsum[2] = 0.f;
+ zero_v3(colsum);
for (sy=yy; sy<my; sy++) {
fRGB* scolp = (fRGB*)&src->rect[sy*src->x*src->type];
for (sx=xx; sx<mx; sx++)
- fRGB_add(colsum, scolp[sx]);
+ add_v3_v3(colsum, scolp[sx]);
}
- fRGB_mult(colsum, fscale);
- fRGB_copy(fcolp[x], colsum);
+ mul_v3_fl(colsum, fscale);
+ copy_v3_v3(fcolp[x], colsum);
}
}
}
diff --git a/source/blender/nodes/composite/node_composite_util.h b/source/blender/nodes/composite/node_composite_util.h
index 42e6ea6bd20..8f772b19d5e 100644
--- a/source/blender/nodes/composite/node_composite_util.h
+++ b/source/blender/nodes/composite/node_composite_util.h
@@ -182,16 +182,6 @@ extern void node_ID_title_cb(void *node_v, void *unused_v);
/* utility functions used by glare, tonemap and lens distortion */
/* soms macros for color handling */
typedef float fRGB[4];
-/* copy c2 to c1 */
-#define fRGB_copy(c1, c2) { c1[0]=c2[0]; c1[1]=c2[1]; c1[2]=c2[2]; c1[3]=c2[3]; } (void)0
-/* add c2 to c1 */
-#define fRGB_add(c1, c2) { c1[0]+=c2[0]; c1[1]+=c2[1]; c1[2]+=c2[2]; } (void)0
-/* multiply c by float value s */
-#define fRGB_mult(c, s) { c[0]*=s; c[1]*=s; c[2]*=s; } (void)0
-/* multiply c2 by s and add to c1 */
-#define fRGB_madd(c1, c2, s) { c1[0]+=c2[0]*s; c1[1]+=c2[1]*s; c1[2]+=c2[2]*s; } (void)0
-/* multiply c2 by color c1 */
-#define fRGB_colormult(c, cs) { c[0]*=cs[0]; c[1]*=cs[1]; c[2]*=cs[2]; } (void)0
/* multiply c2 by color rgb, rgb as separate arguments */
#define fRGB_rgbmult(c, r, g, b) { c[0]*=(r); c[1]*=(g); c[2]*=(b); } (void)0
diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.c b/source/blender/nodes/composite/nodes/node_composite_glare.c
index 9b1505e9333..17a23d4295e 100644
--- a/source/blender/nodes/composite/nodes/node_composite_glare.c
+++ b/source/blender/nodes/composite/nodes/node_composite_glare.c
@@ -53,16 +53,16 @@ static void mixImages(CompBuf *dst, CompBuf *src, float mix)
dcolp = (fRGB*)&dst->rect[y*dst->x*dst->type];
scolp = (fRGB*)&src->rect[y*dst->x*dst->type];
for (x=0; x<dst->x; x++) {
- fRGB_copy(c1, dcolp[x]);
- fRGB_copy(c2, scolp[x]);
+ copy_v3_v3(c1, dcolp[x]);
+ copy_v3_v3(c2, scolp[x]);
c1[0] += mix*(c2[0] - c1[0]);
c1[1] += mix*(c2[1] - c1[1]);
c1[2] += mix*(c2[2] - c1[2]);
if (c1[0] < 0.f) c1[0] = 0.f;
if (c1[1] < 0.f) c1[1] = 0.f;
if (c1[2] < 0.f) c1[2] = 0.f;
- fRGB_mult(c1, mf);
- fRGB_copy(dcolp[x], c1);
+ mul_v3_fl(c1, mf);
+ copy_v3_v3(dcolp[x], c1);
}
}
}
@@ -72,7 +72,7 @@ static void mixImages(CompBuf *dst, CompBuf *src, float mix)
for (y=0; y<dst->y; y++) {
dcolp = (fRGB*)&dst->rect[y*dst->x*dst->type];
for (x=0; x<dst->x; x++) {
- fRGB_copy(c1, dcolp[x]);
+ copy_v3_v3(c1, dcolp[x]);
qd_getPixelLerp(src, (x + 0.5f)*xr - 0.5f, (y + 0.5f)*yr - 0.5f, c2);
c1[0] += mix*(c2[0] - c1[0]);
c1[1] += mix*(c2[1] - c1[1]);
@@ -80,8 +80,8 @@ static void mixImages(CompBuf *dst, CompBuf *src, float mix)
if (c1[0] < 0.f) c1[0] = 0.f;
if (c1[1] < 0.f) c1[1] = 0.f;
if (c1[2] < 0.f) c1[2] = 0.f;
- fRGB_mult(c1, mf);
- fRGB_copy(dcolp[x], c1);
+ mul_v3_fl(c1, mf);
+ copy_v3_v3(dcolp[x], c1);
}
}
}
@@ -146,11 +146,11 @@ static void star4(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
xm = x - i;
xp = x + i;
qd_getPixel(tbuf1, x, y, c);
- fRGB_mult(c, f1);
+ mul_v3_fl(c, f1);
qd_getPixel(tbuf1, (ndg->angle ? xm : x), ym, tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_getPixel(tbuf1, (ndg->angle ? xp : x), yp, tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_setPixel(tbuf1, x, y, c);
}
}
@@ -162,11 +162,11 @@ static void star4(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
xm = x - i;
xp = x + i;
qd_getPixel(tbuf1, x, y, c);
- fRGB_mult(c, f1);
+ mul_v3_fl(c, f1);
qd_getPixel(tbuf1, (ndg->angle ? xm : x), ym, tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_getPixel(tbuf1, (ndg->angle ? xp : x), yp, tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_setPixel(tbuf1, x, y, c);
}
}
@@ -179,11 +179,11 @@ static void star4(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
xm = x - i;
xp = x + i;
qd_getPixel(tbuf2, x, y, c);
- fRGB_mult(c, f1);
+ mul_v3_fl(c, f1);
qd_getPixel(tbuf2, xm, (ndg->angle ? yp : y), tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_getPixel(tbuf2, xp, (ndg->angle ? ym : y), tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_setPixel(tbuf2, x, y, c);
}
}
@@ -195,11 +195,11 @@ static void star4(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
xm = x - i;
xp = x + i;
qd_getPixel(tbuf2, x, y, c);
- fRGB_mult(c, f1);
+ mul_v3_fl(c, f1);
qd_getPixel(tbuf2, xm, (ndg->angle ? yp : y), tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_getPixel(tbuf2, xp, (ndg->angle ? ym : y), tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_setPixel(tbuf2, x, y, c);
}
}
@@ -342,11 +342,11 @@ static void ghosts(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
s = (u-0.5f)*sc + 0.5f, t = (v-0.5f)*sc + 0.5f;
qd_getPixelLerp(tbuf1, s*gbuf->x, t*gbuf->y, c);
sm = smoothMask(s, t);
- fRGB_mult(c, sm);
+ mul_v3_fl(c, sm);
s = (u-0.5f)*isc + 0.5f, t = (v-0.5f)*isc + 0.5f;
qd_getPixelLerp(tbuf2, s*gbuf->x - 0.5f, t*gbuf->y - 0.5f, tc);
sm = smoothMask(s, t);
- fRGB_madd(c, tc, sm);
+ madd_v3_v3fl(c, tc, sm);
qd_setPixel(gbuf, x, y, c);
}
}
@@ -363,9 +363,9 @@ static void ghosts(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
s = (u-0.5f)*scalef[np] + 0.5f;
t = (v-0.5f)*scalef[np] + 0.5f;
qd_getPixelLerp(gbuf, s*gbuf->x - 0.5f, t*gbuf->y - 0.5f, c);
- fRGB_colormult(c, cm[np]);
+ mul_v3_v3(c, cm[np]);
sm = smoothMask(s, t)*0.25f;
- fRGB_madd(tc, c, sm);
+ madd_v3_v3fl(tc, c, sm);
}
p = (x + y*tbuf1->x)*tbuf1->type;
tbuf1->rect[p] += tc[0];
@@ -413,7 +413,7 @@ static void fglow(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
//w = (1.f-fabs(u))*(1.f-fabs(v));
// actually, Hanning window is ok, cos^2 for some reason is slower
w = (0.5f + 0.5f*cos((double)u*M_PI))*(0.5f + 0.5f*cos((double)v*M_PI));
- fRGB_mult(fcol, w);
+ mul_v3_fl(fcol, w);
qd_setPixel(ckrn, x, y, fcol);
}
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.c b/source/blender/nodes/composite/nodes/node_composite_tonemap.c
index 6196825c9b3..50006e599e5 100644
--- a/source/blender/nodes/composite/nodes/node_composite_tonemap.c
+++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.c
@@ -53,14 +53,14 @@ static float avgLogLum(CompBuf *src, float* auto_key, float* Lav, float* Cav)
while (p--) {
float L = rgb_to_luma_y(bc[0]);
*Lav += L;
- fRGB_add(Cav, bc[0]);
+ add_v3_v3(Cav, bc[0]);
lsum += (float)log((double)MAX2(L, 0.0) + 1e-5);
maxl = (L > maxl) ? L : maxl;
minl = (L < minl) ? L : minl;
bc++;
}
*Lav *= sc;
- fRGB_mult(Cav, sc);
+ mul_v3_fl(Cav, sc);
maxl = log((double)maxl + 1e-5); minl = log((double)minl + 1e-5f); avl = lsum*sc;
*auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.f;
return exp((double)avl);
@@ -109,8 +109,8 @@ static void tonemap(NodeTonemap* ntm, CompBuf* dst, CompBuf* src)
fRGB* sp = (fRGB*)&src->rect[y*src->x*src->type];
fRGB* dp = (fRGB*)&dst->rect[y*src->x*src->type];
for (x=0; x<src->x; x++) {
- fRGB_copy(dp[x], sp[x]);
- fRGB_mult(dp[x], al);
+ copy_v4_v4(dp[x], sp[x]);
+ mul_v3_fl(dp[x], al);
dr = dp[x][0] + ntm->offset;
dg = dp[x][1] + ntm->offset;
db = dp[x][2] + ntm->offset;