[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47868] branches/soc-2012-bratwurst/source /blender/compositor: add missing files from merge

Antony Riakiotakis kalast at gmail.com
Thu Jun 14 09:54:01 CEST 2012


Revision: 47868
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47868
Author:   psy-fi
Date:     2012-06-14 07:53:52 +0000 (Thu, 14 Jun 2012)
Log Message:
-----------
add missing files from merge

Added Paths:
-----------
    branches/soc-2012-bratwurst/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp
    branches/soc-2012-bratwurst/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h
    branches/soc-2012-bratwurst/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
    branches/soc-2012-bratwurst/source/blender/compositor/operations/COM_GlareFogGlowOperation.h
    branches/soc-2012-bratwurst/source/blender/compositor/operations/COM_MixGlareOperation.cpp
    branches/soc-2012-bratwurst/source/blender/compositor/operations/COM_MixGlareOperation.h

Added: branches/soc-2012-bratwurst/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp	                        (rev 0)
+++ branches/soc-2012-bratwurst/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp	2012-06-14 07:53:52 UTC (rev 47868)
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor: 
+ *		Jeroen Bakker 
+ *		Monique Dewanchand
+ */
+
+#include "COM_SingleThreadedNodeOperation.h"
+
+SingleThreadedNodeOperation::SingleThreadedNodeOperation(): NodeOperation()
+{
+	this->cachedInstance = NULL;
+	setComplex(true);
+}
+
+void SingleThreadedNodeOperation::initExecution()
+{
+	initMutex();
+}
+
+void SingleThreadedNodeOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
+{
+	this->cachedInstance->read(color, x, y);
+}
+
+void SingleThreadedNodeOperation::deinitExecution()
+{
+	deinitMutex();
+	if (this->cachedInstance) {
+		delete cachedInstance;
+		this->cachedInstance = NULL;
+	}
+}
+void *SingleThreadedNodeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
+{
+	if (this->cachedInstance) return this->cachedInstance;
+	
+	lockMutex();
+	if (this->cachedInstance == NULL) {
+		//
+		this->cachedInstance = createMemoryBuffer(rect, memoryBuffers);
+	}
+	unlockMutex();
+	return this->cachedInstance;
+}

Added: branches/soc-2012-bratwurst/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h	                        (rev 0)
+++ branches/soc-2012-bratwurst/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h	2012-06-14 07:53:52 UTC (rev 47868)
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor: 
+ *		Jeroen Bakker 
+ *		Monique Dewanchand
+ */
+
+#ifndef _COM_SingleThreadedNodeOperation_h
+#define _COM_SingleThreadedNodeOperation_h
+#include "COM_NodeOperation.h"
+
+class SingleThreadedNodeOperation : public NodeOperation {
+private:
+	MemoryBuffer *cachedInstance;
+	
+protected:
+	inline bool isCached() {
+		return cachedInstance != NULL;
+	}
+
+public:
+	SingleThreadedNodeOperation();
+	
+	/**
+	 * the inner loop of this program
+	 */
+	void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
+	
+	/**
+	 * Initialize the execution
+	 */
+	void initExecution();
+	
+	/**
+	 * Deinitialize the execution
+	 */
+	void deinitExecution();
+
+	void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+
+	virtual MemoryBuffer *createMemoryBuffer(rcti *rect, MemoryBuffer **memoryBuffers) = 0;
+	
+	int isSingleThreaded() { return true; }
+};
+#endif

Added: branches/soc-2012-bratwurst/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp	                        (rev 0)
+++ branches/soc-2012-bratwurst/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp	2012-06-14 07:53:52 UTC (rev 47868)
@@ -0,0 +1,405 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ *		Jeroen Bakker
+ *		Monique Dewanchand
+ */
+
+#include "COM_GlareFogGlowOperation.h"
+#include "MEM_guardedalloc.h"
+
+/*
+ *  2D Fast Hartley Transform, used for convolution
+ */
+
+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)
+{
+	unsigned int pw, x_notpow2 = x & (x-1);
+	*L2 = 0;
+	while (x>>=1) ++(*L2);
+	pw = 1 << (*L2);
+	if (x_notpow2) { (*L2)++;  pw<<=1; }
+	return pw;
+}
+
+//------------------------------------------------------------------------------
+
+// from FXT library by Joerg Arndt, faster in order bitreversal
+// 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;
+	return r;
+}
+//------------------------------------------------------------------------------
+static void FHT(fREAL* data, unsigned int M, unsigned int inverse)
+{
+	double tt, fc, dc, fs, ds, a = M_PI;
+	fREAL t1, t2;
+	int n2, bd, bl, istep, k, len = 1 << M, n = 1;
+
+	int i, j = 0;
+	unsigned int Nh = len >> 1;
+	for (i=1;i<(len-1);++i) {
+		j = revbin_upd(j, Nh);
+		if (j>i) {
+			t1 = data[i];
+			data[i] = data[j];
+			data[j] = t1;
+		}
+	}
+
+	do {
+		fREAL* data_n = &data[n];
+
+		istep = n << 1;
+		for (k=0; k<len; k+=istep) {
+			t1 = data_n[k];
+			data_n[k] = data[k] - t1;
+			data[k] += t1;
+		}
+
+		n2 = n >> 1;
+		if (n>2) {
+			fc = dc = cos(a);
+			fs = ds = sqrt(1.0 - fc*fc); //sin(a);
+			bd = n-2;
+			for (bl=1; bl<n2; bl++) {
+				fREAL* data_nbd = &data_n[bd];
+				fREAL* data_bd = &data[bd];
+				for (k=bl; k<len; k+=istep) {
+					t1 = fc*data_n[k] + fs*data_nbd[k];
+					t2 = fs*data_n[k] - fc*data_nbd[k];
+					data_n[k] = data[k] - t1;
+					data_nbd[k] = data_bd[k] - t2;
+					data[k] += t1;
+					data_bd[k] += t2;
+				}
+				tt = fc*dc - fs*ds;
+				fs = fs*dc + fc*ds;
+				fc = tt;
+				bd -= 2;
+			}
+		}
+
+		if (n>1) {
+			for (k=n2; k<len; k+=istep) {
+				t1 = data_n[k];
+				data_n[k] = data[k] - t1;
+				data[k] += t1;
+			}
+		}
+
+		n = istep;
+		a *= 0.5;
+	} while (n<len);
+
+	if (inverse) {
+		fREAL sc = (fREAL)1 / (fREAL)len;
+		for (k=0; k<len; ++k)
+			data[k] *= sc;
+	}
+}
+//------------------------------------------------------------------------------
+/* 2D Fast Hartley Transform, Mx/My -> log2 of width/height,
+	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 i, j, Nx, Ny, maxy;
+	fREAL t;
+
+	Nx = 1 << Mx;
+	Ny = 1 << My;
+
+	// rows (forward transform skips 0 pad data)
+	maxy = inverse ? Ny : nzp;
+	for (j=0; j<maxy; ++j)
+		FHT(&data[Nx*j], Mx, inverse);
+
+	// transpose data
+	if (Nx==Ny) {  // square
+		for (j=0; j<Ny; ++j)
+			for (i=j+1; i<Nx; ++i) {
+				unsigned int op = i + (j << Mx), np = j + (i << My);
+				t=data[op], data[op]=data[np], data[np]=t;
+			}
+	}
+	else {  // rectangular
+		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));
+			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;
+			}
+			#undef PRED
+			stm--;
+		}
+	}
+	// swap Mx/My & Nx/Ny
+	i = Nx, Nx = Ny, Ny = i;
+	i = Mx, Mx = My, My = i;
+
+	// now columns == transposed rows
+	for (j=0; j<Ny; ++j)
+		FHT(&data[Nx*j], Mx, inverse);
+
+	// finalize
+	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);
+			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));
+			data[ji + i] = A - E;
+			data[jmi + i] = B + E;
+			data[ji + im] = C + E;
+			data[jmi + im] = D - E;
+		}
+	}
+
+}
+
+//------------------------------------------------------------------------------
+
+/* 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)
+{
+	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);
+
+	d1[0] *= d2[0];
+	d1[mn2] *= d2[mn2];
+	d1[m2] *= d2[m2];
+	d1[m2 + mn2] *= d2[m2 + mn2];
+	for (i=1; i<m2; i++) {
+		k = m - i;
+		a = d1[i]*d2[i] - d1[k]*d2[k];
+		b = d1[k]*d2[i] + d1[i]*d2[k];
+		d1[i] = (b + a)*(fREAL)0.5;
+		d1[k] = (b - a)*(fREAL)0.5;
+		a = d1[i + mn2]*d2[i + mn2] - d1[k + mn2]*d2[k + mn2];
+		b = d1[k + mn2]*d2[i + mn2] + d1[i + mn2]*d2[k + mn2];
+		d1[i + mn2] = (b + a)*(fREAL)0.5;
+		d1[k + mn2] = (b - a)*(fREAL)0.5;
+	}

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list