yse BLI_math for the compositor in more places.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 12 Jun 2012 20:04:55 +0000 (20:04 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 12 Jun 2012 20:04:55 +0000 (20:04 +0000)
26 files changed:
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenlib/BLI_math_vector.h
source/blender/blenlib/intern/math_vector_inline.c
source/blender/compositor/intern/COM_MemoryBuffer.cpp
source/blender/compositor/intern/COM_NodeOperation.h
source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
source/blender/compositor/operations/COM_BokehBlurOperation.cpp
source/blender/compositor/operations/COM_ColorCurveOperation.cpp
source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp
source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp
source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp
source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp
source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
source/blender/compositor/operations/COM_InvertOperation.cpp
source/blender/compositor/operations/COM_TonemapOperation.cpp
source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp

index ce62b9c10dcd42f86cd9c4c33490ab7d2fb77257..623d4b8a9315f401a4b38cc407c5a54fbce12104 100644 (file)
@@ -1002,9 +1002,7 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu,
                                                bp++;
 
                                        if (*fp != 0.0f) {
-                                               in[0] += (*fp) * bp->vec[0];
-                                               in[1] += (*fp) * bp->vec[1];
-                                               in[2] += (*fp) * bp->vec[2];
+                                               madd_v3_v3fl(in, bp->vec, *fp);
                                        }
                                }
                        }
@@ -1106,9 +1104,7 @@ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *
                                bp++;
 
                        if (*fp != 0.0f) {
-                               coord_fp[0] += (*fp) * bp->vec[0];
-                               coord_fp[1] += (*fp) * bp->vec[1];
-                               coord_fp[2] += (*fp) * bp->vec[2];
+                               madd_v3_v3fl(coord_fp, bp->vec, *fp);
 
                                if (tilt_fp)
                                        (*tilt_fp) += (*fp) * bp->alfa;
index 57983062e3f24abf3ecee894ed5239ead8234c2f..b61a39a2cd209bb4cf49d6e64159a2bf6dcae397 100644 (file)
@@ -1301,6 +1301,8 @@ ImBuf *BKE_tracking_sample_pattern_imbuf(int frame_width, int frame_height, ImBu
        (void) frame_height;
        (void) search_ibuf;
        (void) marker;
+       (void) track;
+       (void) use_mask;
 
        pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat);
 
index 7ff52a5824fee4cd484d555de2ad913e372fc0c1..be492fb6fdd8e74b420f08d5bc65afb476818674 100644 (file)
@@ -87,6 +87,8 @@ MINLINE void add_v2_v2(float r[2], const float a[2]);
 MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2]);
 MINLINE void add_v3_v3(float r[3], const float a[3]);
 MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3]);
+MINLINE void add_v4_v4(float r[4], const float a[4]);
+MINLINE void add_v4_v4v4(float r[4], const float a[4], const float b[4]);
 
 MINLINE void sub_v2_v2(float r[2], const float a[2]);
 MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2]);
@@ -103,6 +105,7 @@ MINLINE void mul_v2_v2(float r[2], const float a[2]);
 MINLINE void mul_v3_v3(float r[3], const float a[3]);
 MINLINE void mul_v3_v3v3(float r[3], const float a[3], const float b[3]);
 MINLINE void mul_v4_fl(float r[4], float f);
+MINLINE void mul_v4_v4fl(float r[3], const float a[3], float f);
 
 MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f);
 MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);
@@ -110,6 +113,7 @@ MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], floa
 MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f);
 MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3]);
 MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f);
+MINLINE void madd_v4_v4v4(float r[4], const float a[4], const float b[4]);
 
 MINLINE void negate_v2(float r[2]);
 MINLINE void negate_v2_v2(float r[2], const float a[2]);
index 56188048c0262de3ef876a47c5b3e938ac1aeb70..e89b2ece4673c4226301bcd1eb40142b365e133a 100644 (file)
@@ -272,6 +272,22 @@ MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
        r[2] = a[2] + b[2];
 }
 
+MINLINE void add_v4_v4(float r[4], const float a[4])
+{
+       r[0] += a[0];
+       r[1] += a[1];
+       r[2] += a[2];
+       r[3] += a[3];
+}
+
+MINLINE void add_v4_v4v4(float r[4], const float a[4], const float b[4])
+{
+       r[0] = a[0] + b[0];
+       r[1] = a[1] + b[1];
+       r[2] = a[2] + b[2];
+       r[3] = a[3] + b[3];
+}
+
 MINLINE void sub_v2_v2(float r[2], const float a[2])
 {
        r[0] -= a[0];
@@ -361,6 +377,14 @@ MINLINE void mul_v4_fl(float r[4], float f)
        r[3] *= f;
 }
 
+MINLINE void mul_v4_v4fl(float r[4], const float a[4], float f)
+{
+       r[0] = a[0] * f;
+       r[1] = a[1] * f;
+       r[2] = a[2] * f;
+       r[3] = a[3] * f;
+}
+
 MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
 {
        r[0] += a[0] * f;
@@ -409,6 +433,14 @@ MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
        r[3] += a[3] * f;
 }
 
+MINLINE void madd_v4_v4v4(float r[4], const float a[4], const float b[4])
+{
+       r[0] += a[0] * b[0];
+       r[1] += a[1] * b[1];
+       r[2] += a[2] * b[2];
+       r[3] += a[3] * b[3];
+}
+
 MINLINE void mul_v3_v3v3(float r[3], const float v1[3], const float v2[3])
 {
        r[0] = v1[0] * v2[0];
index 3ebf8398c02844bb45410da7a1fad567e9607dc3..b88d42ea8d0aa600ed01d425821661bd76c41f1e 100644 (file)
@@ -329,9 +329,7 @@ void MemoryBuffer::readEWA(float result[4], float fx, float fy, float dx, float
                                float tc[4];
                                const float wt = EWA_WTS[(Q < 0.f) ? 0 : (unsigned int)Q];
                                read(tc, clipuv(u, width), clipuv(v, height));
-                               result[0] += tc[0]*wt;
-                               result[1] += tc[1]*wt;
-                               result[2] += tc[2]*wt;
+                               madd_v3_v3fl(result, tc, wt);
                                result[3] += result[3] ? tc[3]*wt : 0.f;
                                d += wt;
                        }
index db1fdda0bcfbb064360ef4e167c3bce5bff6b2c9..3f536fb3f2d5f934192dc6590876cfb2da4e078f 100644 (file)
@@ -35,6 +35,9 @@ class NodeOperation;
 #include "list"
 #include "BLI_threads.h"
 
+#include "BLI_math_color.h"
+#include "BLI_math_vector.h"
+
 class ReadBufferOperation;
 
 /**
index c891142b8086c49ec4b3b83c99d804af4a785f48..0c9f9b970312ccc4946f14deb473d821db1f0e61 100644 (file)
@@ -37,16 +37,10 @@ void AlphaOverKeyOperation::executePixel(float *outputValue, float x, float y, P
        inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers);
        
        if (inputOverColor[3] <= 0.0f) {
-               outputValue[0] = inputColor1[0];
-               outputValue[1] = inputColor1[1];
-               outputValue[2] = inputColor1[2];
-               outputValue[3] = inputColor1[3];
+               copy_v4_v4(outputValue, inputColor1);
        }
        else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
-               outputValue[0] = inputOverColor[0];
-               outputValue[1] = inputOverColor[1];
-               outputValue[2] = inputOverColor[2];
-               outputValue[3] = inputOverColor[3];
+               copy_v4_v4(outputValue, inputOverColor);
        }
        else {
                float premul = value[0]*inputOverColor[3];
index 7d489ce856e64cf9e2413d12a7a2a0926e0897cf..850bbd5cc00e1d1bf65784771b03e85c8fbc7990 100644 (file)
@@ -38,16 +38,10 @@ void AlphaOverMixedOperation::executePixel(float outputValue[4], float x, float
        inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers);
        
        if (inputOverColor[3] <= 0.0f) {
-               outputValue[0] = inputColor1[0];
-               outputValue[1] = inputColor1[1];
-               outputValue[2] = inputColor1[2];
-               outputValue[3] = inputColor1[3];
+               copy_v4_v4(outputValue, inputColor1);
        }
        else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
-               outputValue[0] = inputOverColor[0];
-               outputValue[1] = inputOverColor[1];
-               outputValue[2] = inputOverColor[2];
-               outputValue[3] = inputOverColor[3];
+               copy_v4_v4(outputValue, inputOverColor);
        }
        else {
                float addfac = 1.0f - this->x + inputOverColor[3]*this->x;
index 6cc333879173ff3805b36d584b65b3238872d27e..db67f2e040688e62a1707405f626ed92fbd0f454 100644 (file)
@@ -38,16 +38,10 @@ void AlphaOverPremultiplyOperation::executePixel(float *outputValue, float x, fl
        
        /* Zero alpha values should still permit an add of RGB data */
        if (inputOverColor[3]<0.0f) {
-               outputValue[0] = inputColor1[0];
-               outputValue[1] = inputColor1[1];
-               outputValue[2] = inputColor1[2];
-               outputValue[3] = inputColor1[3];
+               copy_v4_v4(outputValue, inputColor1);
        }
        else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
-               outputValue[0] = inputOverColor[0];
-               outputValue[1] = inputOverColor[1];
-               outputValue[2] = inputOverColor[2];
-               outputValue[3] = inputOverColor[3];
+               copy_v4_v4(outputValue, inputOverColor);
        }
        else {
                float mul = 1.0f - value[0]*inputOverColor[3];
index 88fe17f633e48f9f31275918ef4d13f8dd57dbbc..7129e7c140afbc44d01fbd60047a35eb3843a66e 100644 (file)
@@ -62,36 +62,27 @@ void BilateralBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
        int maxy = ceil(y + space);
        float deltaColor;
        this->inputDeterminatorProgram->read(determinatorReferenceColor, x, y, inputBuffers, data);
-       
-       blurColor[0] = 0.0f;
-       blurColor[1] = 0.0f;
-       blurColor[2] = 0.0f;
-       blurColor[3] = 0.0f;
+
+       zero_v4(blurColor);
        blurDivider = 0.0f;
        for (int yi = miny ; yi < maxy ; yi+=QualityStepHelper::getStep()) {
                for (int xi = minx ; xi < maxx ; xi+=QualityStepHelper::getStep()) {
                        // read determinator
                        this->inputDeterminatorProgram->read(determinator, xi, yi, inputBuffers, data);
-                       deltaColor = fabsf(determinatorReferenceColor[0] - determinator[0])+
-                               fabsf(determinatorReferenceColor[1] - determinator[1])+
-                               fabsf(determinatorReferenceColor[2] - determinator[2]); // do not take the alpha channel into account
+                       deltaColor = (fabsf(determinatorReferenceColor[0] - determinator[0]) +
+                                     fabsf(determinatorReferenceColor[1] - determinator[1]) +
+                                     fabsf(determinatorReferenceColor[2] - determinator[2])); // do not take the alpha channel into account
                        if (deltaColor< sigmacolor) {
                                // add this to the blur
                                this->inputColorProgram->read(tempColor, xi, yi, inputBuffers, data);
-                               blurColor[0]+=tempColor[0];
-                               blurColor[1]+=tempColor[1];
-                               blurColor[2]+=tempColor[2];
-                               blurColor[3]+=tempColor[3];
+                               add_v4_v4(blurColor, tempColor);
                                blurDivider += 1.0f;
                        }
                }
        }
        
        if (blurDivider > 0.0f) {
-               color[0] = blurColor[0]/blurDivider;
-               color[1] = blurColor[1]/blurDivider;
-               color[2] = blurColor[2]/blurDivider;
-               color[3] = blurColor[3]/blurDivider;
+               mul_v4_v4fl(color, blurColor, 1.0f / blurDivider);
        }
        else {
                color[0] = 0.0f;
index b4811c89dc59925f35f6436652fae5f6b549e701..67e24496cbe4b20a9e9e59fcf0606658abbabc2f 100644 (file)
@@ -79,14 +79,7 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
 
        inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST, inputBuffers);
        if (tempBoundingBox[0] >0.0f) {
-               tempColor[0] = 0;
-               tempColor[1] = 0;
-               tempColor[2] = 0;
-               tempColor[3] = 0;
-               float overallmultiplyerr = 0;
-               float overallmultiplyerg = 0;
-               float overallmultiplyerb = 0;
-               float overallmultiplyera = 0;
+               float overallmultiplyer[4] = {0.0f, 0.0f, 0.0f, 0.0f};
                MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
                float *buffer = inputBuffer->getBuffer();
                int bufferwidth = inputBuffer->getWidth();
@@ -103,6 +96,8 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
                maxy = min(maxy, inputBuffer->getRect()->ymax);
                maxx = min(maxx, inputBuffer->getRect()->xmax);
 
+               zero_v4(tempColor);
+
                int step = getStep();
                int offsetadd = getOffsetAdd();
 
@@ -113,21 +108,15 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
                                float u = this->bokehMidX - (nx-x) *m;
                                float v = this->bokehMidY - (ny-y) *m;
                                inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
-                               tempColor[0] += bokeh[0] * buffer[bufferindex];
-                               tempColor[1] += bokeh[1] * buffer[bufferindex+1];
-                               tempColor[2] += bokeh[2]* buffer[bufferindex+2];
-                               tempColor[3] += bokeh[3]* buffer[bufferindex+3];
-                               overallmultiplyerr += bokeh[0];
-                               overallmultiplyerg += bokeh[1];
-                               overallmultiplyerb += bokeh[2];
-                               overallmultiplyera += bokeh[3];
+                               madd_v4_v4v4(tempColor, bokeh, &buffer[bufferindex]);
+                               add_v4_v4(overallmultiplyer, bokeh);
                                bufferindex +=offsetadd;
                        }
                }
-               color[0] = tempColor[0] * (1.0f / overallmultiplyerr);
-               color[1] = tempColor[1] * (1.0f / overallmultiplyerg);
-               color[2] = tempColor[2] * (1.0f / overallmultiplyerb);
-               color[3] = tempColor[3] * (1.0f / overallmultiplyera);
+               color[0] = tempColor[0] * (1.0f / overallmultiplyer[0]);
+               color[1] = tempColor[1] * (1.0f / overallmultiplyer[1]);
+               color[2] = tempColor[2] * (1.0f / overallmultiplyer[2]);
+               color[3] = tempColor[3] * (1.0f / overallmultiplyer[3]);
        }
        else {
                inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers);
index a38012271f1af0b8ae96bf90e96bafa891e2e303..c4336ed5e06c764630d26bb95331667a20beeb60 100644 (file)
@@ -79,9 +79,7 @@ void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSamp
        if (*fac >= 1.0f)
                curvemapping_evaluate_premulRGBF(workingCopy, color, image);
        else if (*fac <= 0.0f) {
-               color[0] = image[0];
-               color[1] = image[1];
-               color[2] = image[2];
+               copy_v3_v3(color, image);
        }
        else {
                float col[4], mfac = 1.0f - *fac;
@@ -140,9 +138,7 @@ void ConstantLevelColorCurveOperation::executePixel(float *color, float x, float
        if (*fac >= 1.0f)
                curvemapping_evaluate_premulRGBF(this->curveMapping, color, image);
        else if (*fac <= 0.0f) {
-               color[0] = image[0];
-               color[1] = image[1];
-               color[2] = image[2];
+               copy_v3_v3(color, image);
        }
        else {
                float col[4], mfac = 1.0f - *fac;
index 547915f58c9060b89b4368269c7174da638c9090..db27e07d52f6e88a7e6251d2a08c80916500a3a3 100644 (file)
@@ -43,9 +43,7 @@ void ConvertKeyToPremulOperation::executePixel(float *outputValue, float x, floa
        this->inputColor->read(inputValue, x, y, sampler, inputBuffers);
        alpha = inputValue[3];
 
-       outputValue[0] = inputValue[0] * alpha;
-       outputValue[1] = inputValue[1] * alpha;
-       outputValue[2] = inputValue[2] * alpha;
+       mul_v3_v3fl(outputValue, inputValue, alpha);
 
        /* never touches the alpha */
        outputValue[3] = alpha;
index 16636ee2afcd66a148e6a9de0cbc18c49c281e39..920b5f8a775cf116375f39fb1953d1c2476967a0 100644 (file)
@@ -44,14 +44,10 @@ void ConvertPremulToKeyOperation::executePixel(float *outputValue, float x, floa
        alpha = inputValue[3];
 
        if (fabsf(alpha) < 1e-5f) {
-               outputValue[0] = 0.f;
-               outputValue[1] = 0.f;
-               outputValue[2] = 0.f;
+               zero_v3(outputValue);
        }
        else {
-               outputValue[0] = inputValue[0] / alpha;
-               outputValue[1] = inputValue[1] / alpha;
-               outputValue[2] = inputValue[2] / alpha;
+               mul_v3_v3fl(outputValue, inputValue, 1.0f / alpha);
        }
 
        /* never touches the alpha */
index c626dc030002234b8143f5c5558d34f4c1cabacf..ce62cf0ae493154f4b9969601e792edfe5cb1130 100644 (file)
@@ -60,9 +60,8 @@ void ConvertRGBToYCCOperation::executePixel(float *outputValue, float x, float y
        rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->mode);
 
        /* divided by 255 to normalize for viewing in */
-       outputValue[0] = color[0]/255.f; /* Y */
-       outputValue[1] = color[1]/255.f; /* Cb*/
-       outputValue[2] = color[2]/255.f; /* Cr*/
+       /* R,G,B --> Y,Cb,Cr */
+       mul_v3_v3fl(outputValue, color, 1.0f / 255.0f);
        outputValue[3] = inputColor[3];
 }
 
index d3048c131e41638940ae8a85ed35ee53bc8f29cf..dbfe4847c7880f34de8d8a66d1dbf29ecb157265 100644 (file)
@@ -57,9 +57,8 @@ void ConvertYCCToRGBOperation::executePixel(float *outputValue, float x, float y
        inputOperation->read(inputColor, x, y, sampler, inputBuffers);
 
        /* need to un-normalize the data */
-       inputColor[0] *= 255.f; /* Y */
-       inputColor[1] *= 255.f; /* Cb*/
-       inputColor[2] *= 255.f; /* Cr*/
+       /* R,G,B --> Y,Cb,Cr */
+       mul_v3_fl(inputColor, 255.0f);
 
        ycc_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2], this->mode);
        outputValue[3] = inputColor[3];
index db67412f3e737569f43493e0a67eed1068a756c4..6edb046a070f4c95b015b671215c38dff210eb4e 100644 (file)
 ConvolutionEdgeFilterOperation::ConvolutionEdgeFilterOperation() : ConvolutionFilterOperation()
 {
 }
-inline void addFilter(float *result, float*input, float value)
-{
-       result[0] += input[0] * value;
-       result[1] += input[1] * value;
-       result[2] += input[2] * value;
-}
 
 void ConvolutionEdgeFilterOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data)
 {
@@ -64,48 +58,48 @@ void ConvolutionEdgeFilterOperation::executePixel(float *color,int x, int y, Mem
        res2[3] = 0.0f;
        
        this->inputOperation->read(in1, x1, y1, inputBuffers, NULL);
-       addFilter(res1, in1, this->filter[0]);
-       addFilter(res2, in1, this->filter[0]);
+       madd_v3_v3fl(res1, in1, this->filter[0]);
+       madd_v3_v3fl(res2, in1, this->filter[0]);
        
        this->inputOperation->read(in1, x2, y1, inputBuffers, NULL);
-       addFilter(res1, in1, this->filter[1]);
-       addFilter(res2, in1, this->filter[3]);
+       madd_v3_v3fl(res1, in1, this->filter[1]);
+       madd_v3_v3fl(res2, in1, this->filter[3]);
        
        this->inputOperation->read(in1, x3, y1, inputBuffers, NULL);
-       addFilter(res1, in1, this->filter[2]);
-       addFilter(res2, in1, this->filter[6]);
+       madd_v3_v3fl(res1, in1, this->filter[2]);
+       madd_v3_v3fl(res2, in1, this->filter[6]);
        
        this->inputOperation->read(in1, x1, y2, inputBuffers, NULL);
-       addFilter(res1, in1, this->filter[3]);
-       addFilter(res2, in1, this->filter[1]);
+       madd_v3_v3fl(res1, in1, this->filter[3]);
+       madd_v3_v3fl(res2, in1, this->filter[1]);
        
        this->inputOperation->read(in2, x2, y2, inputBuffers, NULL);
-       addFilter(res1, in2, this->filter[4]);
-       addFilter(res2, in2, this->filter[4]);
+       madd_v3_v3fl(res1, in2, this->filter[4]);
+       madd_v3_v3fl(res2, in2, this->filter[4]);
        
        this->inputOperation->read(in1, x3, y2, inputBuffers, NULL);
-       addFilter(res1, in1, this->filter[5]);
-       addFilter(res2, in1, this->filter[7]);
+       madd_v3_v3fl(res1, in1, this->filter[5]);
+       madd_v3_v3fl(res2, in1, this->filter[7]);
        
        this->inputOperation->read(in1, x1, y3, inputBuffers, NULL);
-       addFilter(res1, in1, this->filter[6]);
-       addFilter(res2, in1, this->filter[2]);
+       madd_v3_v3fl(res1, in1, this->filter[6]);
+       madd_v3_v3fl(res2, in1, this->filter[2]);
        
        this->inputOperation->read(in1, x2, y3, inputBuffers, NULL);
-       addFilter(res1, in1, this->filter[7]);
-       addFilter(res2, in1, this->filter[5]);
+       madd_v3_v3fl(res1, in1, this->filter[7]);
+       madd_v3_v3fl(res2, in1, this->filter[5]);
        
        this->inputOperation->read(in1, x3, y3, inputBuffers, NULL);
-       addFilter(res1, in1, this->filter[8]);
-       addFilter(res2, in1, this->filter[8]);
+       madd_v3_v3fl(res1, in1, this->filter[8]);
+       madd_v3_v3fl(res2, in1, this->filter[8]);
        
-       color[0] = sqrt(res1[0]*res1[0]+res2[0]*res2[0]);
-       color[1] = sqrt(res1[1]*res1[1]+res2[1]*res2[1]);
-       color[2] = sqrt(res1[2]*res1[2]+res2[2]*res2[2]);
+       color[0] = sqrt(res1[0] * res1[0] + res2[0] * res2[0]);
+       color[1] = sqrt(res1[1] * res1[1] + res2[1] * res2[1]);
+       color[2] = sqrt(res1[2] * res1[2] + res2[2] * res2[2]);
        
-       color[0] = color[0]*value[0] + in2[0] * mval;
-       color[1] = color[1]*value[0] + in2[1] * mval;
-       color[2] = color[2]*value[0] + in2[2] * mval;
+       color[0] = color[0] * value[0] + in2[0] * mval;
+       color[1] = color[1] * value[0] + in2[1] * mval;
+       color[2] = color[2] * value[0] + in2[2] * mval;
        
        color[3] = in2[3];
 }
index 2720a0a414626ffe37793870bda61c10def31ac3..3c9cde92e2eab2298be554e554a7d89f5a6f9540 100644 (file)
@@ -69,10 +69,6 @@ void ConvolutionFilterOperation::deinitExecution()
 
 void ConvolutionFilterOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data)
 {
-       color[0] = 0.0;
-       color[1] = 0.0;
-       color[2] = 0.0;
-       color[3] = 0.0;
        float in1[4];
        float in2[4];
        int x1 = x - 1;
@@ -89,57 +85,32 @@ void ConvolutionFilterOperation::executePixel(float *color,int x, int y, MemoryB
        CLAMP(y3, 0, getHeight()-1);
        float value[4];
        this->inputValueOperation->read(value, x2, y2, inputBuffers, NULL);
-       float mval = 1.0f - value[0];
+       const float mval = 1.0f - value[0];
+
+       zero_v4(color);
        this->inputOperation->read(in1, x1, y1, inputBuffers, NULL);
-       color[0] += in1[0] * this->filter[0];
-       color[1] += in1[1] * this->filter[0];
-       color[2] += in1[2] * this->filter[0];
-       color[3] += in1[3] * this->filter[0];
+       madd_v4_v4fl(color, in1, this->filter[0]);
        this->inputOperation->read(in1, x2, y1, inputBuffers, NULL);
-       color[0] += in1[0] * this->filter[1];
-       color[1] += in1[1] * this->filter[1];
-       color[2] += in1[2] * this->filter[1];
-       color[3] += in1[3] * this->filter[1];
+       madd_v4_v4fl(color, in1, this->filter[1]);
        this->inputOperation->read(in1, x3, y1, inputBuffers, NULL);
-       color[0] += in1[0] * this->filter[2];
-       color[1] += in1[1] * this->filter[2];
-       color[2] += in1[2] * this->filter[2];
-       color[3] += in1[3] * this->filter[2];
+       madd_v4_v4fl(color, in1, this->filter[2]);
        this->inputOperation->read(in1, x1, y2, inputBuffers, NULL);
-       color[0] += in1[0] * this->filter[3];
-       color[1] += in1[1] * this->filter[3];
-       color[2] += in1[2] * this->filter[3];
-       color[3] += in1[3] * this->filter[3];
+       madd_v4_v4fl(color, in1, this->filter[3]);
        this->inputOperation->read(in2, x2, y2, inputBuffers, NULL);
-       color[0] += in2[0] * this->filter[4];
-       color[1] += in2[1] * this->filter[4];
-       color[2] += in2[2] * this->filter[4];
-       color[3] += in2[3] * this->filter[4];
+       madd_v4_v4fl(color, in2, this->filter[4]);
        this->inputOperation->read(in1, x3, y2, inputBuffers, NULL);
-       color[0] += in1[0] * this->filter[5];
-       color[1] += in1[1] * this->filter[5];
-       color[2] += in1[2] * this->filter[5];
-       color[3] += in1[3] * this->filter[5];
+       madd_v4_v4fl(color, in1, this->filter[5]);
        this->inputOperation->read(in1, x1, y3, inputBuffers, NULL);
-       color[0] += in1[0] * this->filter[6];
-       color[1] += in1[1] * this->filter[6];
-       color[2] += in1[2] * this->filter[6];
-       color[3] += in1[3] * this->filter[6];
+       madd_v4_v4fl(color, in1, this->filter[6]);
        this->inputOperation->read(in1, x2, y3, inputBuffers, NULL);
-       color[0] += in1[0] * this->filter[7];
-       color[1] += in1[1] * this->filter[7];
-       color[2] += in1[2] * this->filter[7];
-       color[3] += in1[3] * this->filter[7];
+       madd_v4_v4fl(color, in1, this->filter[7]);
        this->inputOperation->read(in1, x3, y3, inputBuffers, NULL);
-       color[0] += in1[0] * this->filter[8];
-       color[1] += in1[1] * this->filter[8];
-       color[2] += in1[2] * this->filter[8];
-       color[3] += in1[3] * this->filter[8];
+       madd_v4_v4fl(color, in1, this->filter[8]);
        
-       color[0] = color[0]*value[0] + in2[0] * mval;
-       color[1] = color[1]*value[0] + in2[1] * mval;
-       color[2] = color[2]*value[0] + in2[2] * mval;
-       color[3] = color[3]*value[0] + in2[3] * mval;
+       color[0] = color[0] * value[0] + in2[0] * mval;
+       color[1] = color[1] * value[0] + in2[1] * mval;
+       color[2] = color[2] * value[0] + in2[2] * mval;
+       color[3] = color[3] * value[0] + in2[3] * mval;
 }
 
 bool ConvolutionFilterOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
index 43cba09d16f9bc54e48ba5f6c508c9edc4446b63..60c31400eca3d4949b2140a45ef6bbe29fd5ae5c 100644 (file)
@@ -85,10 +85,7 @@ void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBu
 
                this->inputProgram->read(col, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, COM_PS_NEAREST, inputBuffers);
 
-               col2[0] += col[0];
-               col2[1] += col[1];
-               col2[2] += col[2];
-               col2[3] += col[3];
+               add_v4_v4(col2, col);
 
                /* double transformations */
                ltx += tx;
@@ -96,10 +93,8 @@ void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBu
                lrot += rot;
                lsc += sc;
        }
-       color[0] = col2[0]/iterations;
-       color[1] = col2[1]/iterations;
-       color[2] = col2[2]/iterations;
-       color[3] = col2[3]/iterations;
+
+       mul_v4_v4fl(color, col2, 1.0f / iterations);
 }
 
 void DirectionalBlurOperation::deinitExecution()
index 07cc07880e7e23f6d83dbd81a39252ab6fe283dd..80e35f63ac5117b25459851cdfbf39bdba7c0426 100644 (file)
@@ -138,21 +138,15 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory
                index = ((ny-y)+this->rady) * (this->radx*2+1) + (minx-x+this->radx);
                int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
                for (int nx = minx ; nx < maxx ; nx +=step) {
-                       float multiplyer = gausstab[index];
-                       tempColor[0] += multiplyer * buffer[bufferindex];
-                       tempColor[1] += multiplyer * buffer[bufferindex+1];
-                       tempColor[2] += multiplyer * buffer[bufferindex+2];
-                       tempColor[3] += multiplyer * buffer[bufferindex+3];
+                       const float multiplyer = gausstab[index];
+                       madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer);
                        overallmultiplyer += multiplyer;
                        index += step;
                        bufferindex +=offsetadd;
                }
        }
-       float divider = 1.0f / overallmultiplyer;
-       color[0] = tempColor[0] * divider;
-       color[1] = tempColor[1] * divider;
-       color[2] = tempColor[2] * divider;
-       color[3] = tempColor[3] * divider;
+
+       mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer);
 }
 
 void GaussianBokehBlurOperation::deinitExecution()
index a7e443838a9cd15175b75e02a2134f2c6069fe26..e30cbfeff7e900b2e47358d4c47d3db7ed557a58 100644 (file)
@@ -99,19 +99,12 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
        int bufferindex = ((minx - bufferstartx)*4)+((miny-bufferstarty)*4*bufferwidth);
        for (int nx = minx ; nx < maxx ; nx +=step) {
                index = (nx-x)+this->rad;
-               float multiplyer = gausstab[index];
-               tempColor[0] += multiplyer * buffer[bufferindex];
-               tempColor[1] += multiplyer * buffer[bufferindex+1];
-               tempColor[2] += multiplyer * buffer[bufferindex+2];
-               tempColor[3] += multiplyer * buffer[bufferindex+3];
+               const float multiplyer = gausstab[index];
+               madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer);
                overallmultiplyer += multiplyer;
-               bufferindex +=offsetadd;
+               bufferindex += offsetadd;
        }
-       float divider = 1.0f / overallmultiplyer;
-       color[0] = tempColor[0] * divider;
-       color[1] = tempColor[1] * divider;
-       color[2] = tempColor[2] * divider;
-       color[3] = tempColor[3] * divider;
+       mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer);
 }
 
 void GaussianXBlurOperation::deinitExecution()
index c7da43fc20f45be81d9227e5554760116a4eccf4..c0561704596c038e72b037be476cc86ce8b7faf1 100644 (file)
@@ -95,18 +95,11 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
        for (int ny = miny ; ny < maxy ; ny +=step) {
                index = (ny-y)+this->rad;
                int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
-               float multiplyer = gausstab[index];
-               tempColor[0] += multiplyer * buffer[bufferindex];
-               tempColor[1] += multiplyer * buffer[bufferindex+1];
-               tempColor[2] += multiplyer * buffer[bufferindex+2];
-               tempColor[3] += multiplyer * buffer[bufferindex+3];
+               const float multiplyer = gausstab[index];
+               madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer);
                overallmultiplyer += multiplyer;
        }
-       float divider = 1.0f / overallmultiplyer;
-       color[0] = tempColor[0] * divider;
-       color[1] = tempColor[1] * divider;
-       color[2] = tempColor[2] * divider;
-       color[3] = tempColor[3] * divider;
+       mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer);
 }
 
 void GaussianYBlurOperation::deinitExecution()
index 602e18521eefcef9d8837ec50fa6577d86c4069c..fba3eca4af93ae373dc0e21bab353c29d43c4740 100644 (file)
@@ -42,28 +42,20 @@ void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTil
                                xm = x - i;
                                xp = x + i;
                                tbuf1->read(c, x, y);
-                               c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
+                               mul_v3_fl(c, f1);
                                tbuf1->read(tc, (settings->angle ? xm : x), ym);
-                               c[0]+=tc[0]*f2;
-                               c[1]+=tc[1]*f2;
-                               c[2]+=tc[2]*f2;
+                               madd_v3_v3fl(c, tc, f2);
                                tbuf1->read(tc, (settings->angle ? xp : x), yp);
-                               c[0]+=tc[0]*f2;
-                               c[1]+=tc[1]*f2;
-                               c[2]+=tc[2]*f2;
+                               madd_v3_v3fl(c, tc, f2);
                                c[3] = 1.0f;
                                tbuf1->writePixel(x, y, c);
 
                                tbuf2->read(c, x, y);
-                               c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
+                               mul_v3_fl(c, f1);
                                tbuf2->read(tc, xm, (settings->angle ? yp : y));
-                               c[0]+=tc[0]*f2;
-                               c[1]+=tc[1]*f2;
-                               c[2]+=tc[2]*f2;
+                               madd_v3_v3fl(c, tc, f2);
                                tbuf2->read(tc, xp, (settings->angle ? ym : y));
-                               c[0]+=tc[0]*f2;
-                               c[1]+=tc[1]*f2;
-                               c[2]+=tc[2]*f2;
+                               madd_v3_v3fl(c, tc, f2);
                                c[3] = 1.0f;
                                tbuf2->writePixel(x, y, c);
 
@@ -77,28 +69,20 @@ void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTil
                                xm = x - i;
                                xp = x + i;
                                tbuf1->read(c, x, y);
-                               c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
+                               mul_v3_fl(c, f1);
                                tbuf1->read(tc, (settings->angle ? xm : x), ym);
-                               c[0]+=tc[0]*f2;
-                               c[1]+=tc[1]*f2;
-                               c[2]+=tc[2]*f2;
+                               madd_v3_v3fl(c, tc, f2);
                                tbuf1->read(tc, (settings->angle ? xp : x), yp);
-                               c[0]+=tc[0]*f2;
-                               c[1]+=tc[1]*f2;
-                               c[2]+=tc[2]*f2;
+                               madd_v3_v3fl(c, tc, f2);
                                c[3] = 1.0f;
                                tbuf1->writePixel(x, y, c);
 
                                tbuf2->read(c, x, y);
-                               c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
+                               mul_v3_fl(c, f1);
                                tbuf2->read(tc, xm, (settings->angle ? yp : y));
-                               c[0]+=tc[0]*f2;
-                               c[1]+=tc[1]*f2;
-                               c[2]+=tc[2]*f2;
+                               madd_v3_v3fl(c, tc, f2);
                                tbuf2->read(tc, xp, (settings->angle ? ym : y));
-                               c[0]+=tc[0]*f2;
-                               c[1]+=tc[1]*f2;
-                               c[2]+=tc[2]*f2;
+                               madd_v3_v3fl(c, tc, f2);
                                c[3] = 1.0f;
                                tbuf2->writePixel(x, y, c);
                        }
index 982fe1a5450cda66f637c4eaa6e1d44f323a44c9..82158c4adad2245466bb9953761145007e0a4ed0 100644 (file)
@@ -55,9 +55,7 @@ void InvertOperation::executePixel(float *out, float x, float y, PixelSampler sa
                out[2] = (1.0f - inputColor[2])*value + inputColor[2]*invertedValue;
        }
        else {
-               out[0] = inputColor[0];
-               out[1] = inputColor[1];
-               out[2] = inputColor[2];
+               copy_v3_v3(out, inputColor);
        }
        
        if (alpha)
index d8089bdf3eae074d89b382a7090414d97a51a369..75adcf524c4f711f4dcbff2988b619632e45bf9f 100644 (file)
@@ -47,9 +47,7 @@ void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *in
 
        float output[4];
        this->imageReader->read(output, x, y, inputBuffers, NULL);
-       output[0] *= avg->al;
-       output[1] *= avg->al;
-       output[2] *= avg->al;
+       mul_v3_fl(output, avg->al);
        float dr = output[0] + this->data->offset;
        float dg = output[1] + this->data->offset;
        float db = output[2] + this->data->offset;
@@ -63,10 +61,7 @@ void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *in
                output[2] = powf(MAX2(output[2], 0.0f), igm);
        }
 
-       color[0] = output[0];
-       color[1] = output[1];
-       color[2] = output[2];
-       color[3] = output[3];
+       copy_v4_v4(color, output);
 }
 void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
 {
@@ -94,10 +89,7 @@ void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, Mem
        I_a = I_l + ia * (I_g - I_l);
        output[2] /= (output[2] + powf(f * I_a, m));
 
-       color[0] = output[0];
-       color[1] = output[1];
-       color[2] = output[2];
-       color[3] = output[3];
+       copy_v4_v4(color, output);
 }
 
 void TonemapOperation::deinitExecution()
@@ -143,18 +135,14 @@ void *TonemapOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuff
                while (p--) {
                        float L = 0.212671f * bc[0] + 0.71516f * bc[1] + 0.072169f * bc[2];
                        Lav += L;
-                       cav[0] += bc[0];
-                       cav[1] += bc[1];
-                       cav[2] += bc[2];
+                       add_v3_v3(cav, bc);
                        lsum += logf(MAX2(L, 0.0f) + 1e-5f);
                        maxl = (L > maxl) ? L : maxl;
                        minl = (L < minl) ? L : minl;
                        bc+=4;
                }
                data->lav = Lav * sc;
-               data->cav[0] = cav[0]*sc;
-               data->cav[1] = cav[1]*sc;
-               data->cav[2] = cav[2]*sc;
+               mul_v3_v3fl(data->cav, cav, sc);
                maxl = log((double)maxl + 1e-5); minl = log((double)minl + 1e-5); avl = lsum * sc;
                data->auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.f;
                float al = exp((double)avl);
index 562b0fc2bb5258447a55a3b1ac30f3e8d1902ca6..1544b1c8d0655e1d724d9f3a61ecb5a3056a3adf 100644 (file)
@@ -61,10 +61,7 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
        tempColor[2] = 0;
        tempColor[3] = 0;
        float tempSize[4];
-       float overallmultiplyerr = 0;
-       float overallmultiplyerg = 0;
-       float overallmultiplyerb = 0;
-       float overallmultiplyera = 0;
+       float overallmultiplyer[4] = {0.0f, 0.0f, 0.0f, 0.0f};
 
        int miny = y - maxBlur;
        int maxy = y + maxBlur;
@@ -76,10 +73,8 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
                tempColor[1] += readColor[1];
                tempColor[2] += readColor[2];
                tempColor[3] += readColor[3];
-               overallmultiplyerr += 1;
-               overallmultiplyerg += 1;
-               overallmultiplyerb += 1;
-               overallmultiplyera += 1;
+               add_v4_v4(tempColor, readColor);
+               add_v3_fl(overallmultiplyer, 1.0f);
                
                for (int ny = miny ; ny < maxy ; ny += QualityStepHelper::getStep()) {
                        for (int nx = minx ; nx < maxx ; nx += QualityStepHelper::getStep()) {
@@ -97,22 +92,17 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
                                                float v = 256 + dy*256/size;
                                                inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
                                                inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers);
-                                               tempColor[0] += bokeh[1]*readColor[0];
-                                               tempColor[1] += bokeh[2]*readColor[1];
-                                               tempColor[2] += bokeh[2]*readColor[2];
-                                               tempColor[3] += bokeh[3]*readColor[3];
-                                               overallmultiplyerr += bokeh[0];
-                                               overallmultiplyerg += bokeh[1];
-                                               overallmultiplyerb += bokeh[2];
-                                               overallmultiplyera += bokeh[3];
+                                               madd_v4_v4v4(tempColor, bokeh, readColor);
+                                               add_v4_v4(overallmultiplyer, bokeh);
                                        }
                                }
                        }
                }
-               color[0] = tempColor[0] / overallmultiplyerr;
-               color[1] = tempColor[1] / overallmultiplyerg;
-               color[2] = tempColor[2] / overallmultiplyerb;
-               color[3] = tempColor[3] / overallmultiplyera;
+
+               color[0] = tempColor[0] * (1.0f / overallmultiplyer[0]);
+               color[1] = tempColor[1] * (1.0f / overallmultiplyer[1]);
+               color[2] = tempColor[2] * (1.0f / overallmultiplyer[2]);
+               color[3] = tempColor[3] * (1.0f / overallmultiplyer[3]);
        }
 
 }