From ee65cd7685f3a2334bf47dbfeff5f0d576e082fd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Jun 2012 09:40:36 +0000 Subject: [PATCH] style cleanup --- .../operations/COM_GlareFogGlowOperation.cpp | 254 +++++++++--------- 1 file changed, 127 insertions(+), 127 deletions(-) diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp index aa847c2d10d..0c2ae96aa51 100644 --- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp @@ -30,13 +30,13 @@ typedef float fREAL; // returns next highest power of 2 of x, as well it's log2 in L2 -static unsigned int nextPow2(unsigned int x, unsigned int* L2) +static unsigned int nextPow2(unsigned int x, unsigned int *L2) { - unsigned int pw, x_notpow2 = x & (x-1); + unsigned int pw, x_notpow2 = x & (x - 1); *L2 = 0; - while (x>>=1) ++(*L2); + while (x >>= 1) ++(*L2); pw = 1 << (*L2); - if (x_notpow2) { (*L2)++; pw<<=1; } + if (x_notpow2) { (*L2)++; pw <<= 1; } return pw; } @@ -46,11 +46,11 @@ static unsigned int nextPow2(unsigned int x, unsigned int* L2) // use: r = revbin_upd(r, h) where h = N>>1 static unsigned int revbin_upd(unsigned int r, unsigned int h) { - while (!((r^=h)&h)) h >>= 1; + while (!((r ^= h) & h)) h >>= 1; return r; } //------------------------------------------------------------------------------ -static void FHT(fREAL* data, unsigned int M, unsigned int inverse) +static void FHT(fREAL *data, unsigned int M, unsigned int inverse) { double tt, fc, dc, fs, ds, a = M_PI; fREAL t1, t2; @@ -58,9 +58,9 @@ static void FHT(fREAL* data, unsigned int M, unsigned int inverse) int i, j = 0; unsigned int Nh = len >> 1; - for (i=1;i<(len-1);++i) { + for (i = 1; i < (len - 1); ++i) { j = revbin_upd(j, Nh); - if (j>i) { + if (j > i) { t1 = data[i]; data[i] = data[j]; data[j] = t1; @@ -68,40 +68,40 @@ static void FHT(fREAL* data, unsigned int M, unsigned int inverse) } do { - fREAL* data_n = &data[n]; + fREAL *data_n = &data[n]; istep = n << 1; - for (k=0; k> 1; - if (n>2) { + if (n > 2) { fc = dc = cos(a); - fs = ds = sqrt(1.0 - fc*fc); //sin(a); - bd = n-2; - for (bl=1; bl1) { - for (k=n2; k 1) { + for (k = n2; k < len; k += istep) { t1 = data_n[k]; data_n[k] = data[k] - t1; data[k] += t1; @@ -110,20 +110,20 @@ static void FHT(fREAL* data, unsigned int M, unsigned int inverse) n = istep; a *= 0.5; - } while (n log2 of width/height, - nzp -> the row where zero pad data starts, - inverse -> see above */ + nzp -> the row where zero pad data starts, + inverse -> see above */ static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My, - unsigned int nzp, unsigned int inverse) + unsigned int nzp, unsigned int inverse) { unsigned int i, j, Nx, Ny, maxy; fREAL t; @@ -133,25 +133,25 @@ static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My, // rows (forward transform skips 0 pad data) maxy = inverse ? Ny : nzp; - for (j=0; j0; i++) { + unsigned int k, Nym = Ny - 1, stm = 1 << (Mx + My); + for (i = 0; stm > 0; i++) { #define PRED(k) (((k & Nym) << Mx) + (k >> My)) - for (j=PRED(i); j>i; j=PRED(j)); + for (j = PRED(i); j > i; j = PRED(j)) ; if (j < i) continue; - for (k=i, j=PRED(i); j!=i; k=j, j=PRED(j), stm--) { - t=data[j], data[j]=data[k], data[k]=t; + for (k = i, j = PRED(i); j != i; k = j, j = PRED(j), stm--) { + t = data[j], data[j] = data[k], data[k] = t; } #undef PRED stm--; @@ -162,21 +162,21 @@ static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My, i = Mx, Mx = My, My = i; // now columns == transposed rows - for (j=0; j> 1); j++) { - unsigned int jm = (Ny - j) & (Ny-1); + for (j = 0; j <= (Ny >> 1); j++) { + unsigned int jm = (Ny - j) & (Ny - 1); unsigned int ji = j << Mx; unsigned int jmi = jm << Mx; - for (i=0; i<=(Nx >> 1); i++) { - unsigned int im = (Nx - i) & (Nx-1); + for (i = 0; i <= (Nx >> 1); i++) { + unsigned int im = (Nx - i) & (Nx - 1); fREAL A = data[ji + i]; fREAL B = data[jmi + i]; fREAL C = data[ji + im]; fREAL D = data[jmi + im]; - fREAL E = (fREAL)0.5*((A + D) - (B + C)); + fREAL E = (fREAL)0.5 * ((A + D) - (B + C)); data[ji + i] = A - E; data[jmi + i] = B + E; data[ji + im] = C + E; @@ -189,62 +189,62 @@ static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My, //------------------------------------------------------------------------------ /* 2D convolution calc, d1 *= d2, M/N - > log2 of width/height */ -static void fht_convolve(fREAL* d1, fREAL* d2, unsigned int M, unsigned int N) +static void fht_convolve(fREAL *d1, fREAL *d2, unsigned int M, unsigned int N) { fREAL a, b; unsigned int i, j, k, L, mj, mL; unsigned int m = 1 << M, n = 1 << N; - unsigned int m2 = 1 << (M-1), n2 = 1 << (N-1); - unsigned int mn2 = m << (N-1); + unsigned int m2 = 1 << (M - 1), n2 = 1 << (N - 1); + unsigned int mn2 = m << (N - 1); d1[0] *= d2[0]; d1[mn2] *= d2[mn2]; d1[m2] *= d2[m2]; d1[m2 + mn2] *= d2[m2 + mn2]; - for (i=1; igetHeight(); const unsigned int imageWidth = in1->getWidth(); const unsigned int imageHeight = in1->getHeight(); - float * kernelBuffer = in2->getBuffer(); - float * imageBuffer = in1->getBuffer(); + float *kernelBuffer = in2->getBuffer(); + float *imageBuffer = in1->getBuffer(); - MemoryBuffer* rdst = new MemoryBuffer(NULL, in1->getRect()); + MemoryBuffer *rdst = new MemoryBuffer(NULL, in1->getRect()); // convolution result width & height - w2 = 2*kernelWidth - 1; - h2 = 2*kernelHeight - 1; + w2 = 2 * kernelWidth - 1; + h2 = 2 * kernelHeight - 1; // FFT pow2 required size & log2 w2 = nextPow2(w2, &log2_w); h2 = nextPow2(h2, &log2_h); // alloc space - data1 = (fREAL*)MEM_callocN(3*w2*h2*sizeof(fREAL), "convolve_fast FHT data1"); - data2 = (fREAL*)MEM_callocN(w2*h2*sizeof(fREAL), "convolve_fast FHT data2"); + data1 = (fREAL *)MEM_callocN(3 * w2 * h2 * sizeof(fREAL), "convolve_fast FHT data1"); + data2 = (fREAL *)MEM_callocN(w2 * h2 * sizeof(fREAL), "convolve_fast FHT data2"); // normalize convolutor wt[0] = wt[1] = wt[2] = 0.f; - for (y=0; y data1 - for (y=0; y data2 - memset(data2, 0, w2*h2*sizeof(fREAL)); - for (y=0; y= imageHeight) continue; - fp = &data2[y*w2]; - colp = (fRGB*)&imageBuffer[yy*imageWidth*COM_NUMBER_OF_CHANNELS]; - for (x=0; x= imageWidth) continue; fp[x] = colp[xx][ch]; } @@ -334,8 +334,8 @@ void convolve(float* dst, MemoryBuffer* in1, MemoryBuffer* in2) // forward FHT // zero pad data start is different for each == height+1 - if (!in2done) FHT2D(data1ch, log2_w, log2_h, kernelHeight+1, 0); - FHT2D(data2, log2_w, log2_h, kernelHeight+1, 0); + if (!in2done) FHT2D(data1ch, log2_w, log2_h, kernelHeight + 1, 0); + FHT2D(data2, log2_w, log2_h, kernelHeight + 1, 0); // FHT2D transposed data, row/col now swapped // convolve & inverse FHT @@ -344,13 +344,13 @@ void convolve(float* dst, MemoryBuffer* in1, MemoryBuffer* in2) // data again transposed, so in order again // overlap-add result - for (y=0; y<(int)h2; y++) { - const int yy = ybl*ybsz + y - hh; + for (y = 0; y < (int)h2; y++) { + const int yy = ybl * ybsz + y - hh; if ((yy < 0) || (yy >= imageHeight)) continue; - fp = &data2[y*w2]; - colp = (fRGB*)&rdst->getBuffer()[yy*imageWidth*COM_NUMBER_OF_CHANNELS]; - for (x=0; x<(int)w2; x++) { - const int xx = xbl*xbsz + x - hw; + fp = &data2[y * w2]; + colp = (fRGB *)&rdst->getBuffer()[yy * imageWidth * COM_NUMBER_OF_CHANNELS]; + for (x = 0; x < (int)w2; x++) { + const int xx = xbl * xbsz + x - hw; if ((xx < 0) || (xx >= imageWidth)) continue; colp[xx][ch] += fp[x]; } @@ -363,7 +363,7 @@ void convolve(float* dst, MemoryBuffer* in1, MemoryBuffer* in2) MEM_freeN(data2); MEM_freeN(data1); - memcpy(dst, rdst->getBuffer(), sizeof(float)*imageWidth*imageHeight*COM_NUMBER_OF_CHANNELS); + memcpy(dst, rdst->getBuffer(), sizeof(float) * imageWidth * imageHeight * COM_NUMBER_OF_CHANNELS); delete(rdst); } @@ -382,19 +382,19 @@ void GlareFogGlowOperation::generateGlare(float *data, MemoryBuffer *inputTile, BLI_init_rcti(&kernelRect, 0, sz, 0, sz); ckrn = new MemoryBuffer(NULL, &kernelRect); - scale = 0.25f*sqrtf((float)sz*sz); + scale = 0.25f * sqrtf((float)sz * sz); - for (y=0; ywritePixel(x, y, fcol); }