[Bf-blender-cvs] [43a4aaf] master: Compositor: Reduce number of divisions in EWA filtering

Sergey Sharybin noreply at git.blender.org
Thu Aug 27 19:46:09 CEST 2015


Commit: 43a4aaf8e6f0ccbd9ef63c44861206024f71590b
Author: Sergey Sharybin
Date:   Thu Aug 27 19:43:33 2015 +0200
Branches: master
https://developer.blender.org/rB43a4aaf8e6f0ccbd9ef63c44861206024f71590b

Compositor: Reduce number of divisions in EWA filtering

===================================================================

M	source/blender/compositor/intern/COM_MemoryBuffer.cpp

===================================================================

diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
index 162e08a..7ee5e2f 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@ -204,14 +204,15 @@ static void read_ewa_pixel_sampled(void *userdata, int x, int y, float result[4]
 void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivatives[2][2])
 {
 	BLI_assert(this->m_datatype == COM_DT_COLOR);
-	int width = this->getWidth(), height = this->getHeight();
+	float inv_width = 1.0f / (float)this->getWidth(),
+	      inv_height = 1.0f / (float)this->getHeight();
 	/* TODO(sergey): Render pipeline uses normalized coordinates and derivatives,
 	 * but compositor uses pixel space. For now let's just divide the values and
 	 * switch compositor to normalized space for EWA later.
 	 */
-	float uv_normal[2] = {uv[0] / width, uv[1] / height};
-	float du_normal[2] = {derivatives[0][0] / width, derivatives[0][1] / height};
-	float dv_normal[2] = {derivatives[1][0] / width, derivatives[1][1] / height};
+	float uv_normal[2] = {uv[0] * inv_width, uv[1] * inv_height};
+	float du_normal[2] = {derivatives[0][0] * inv_width, derivatives[0][1] * inv_height};
+	float dv_normal[2] = {derivatives[1][0] * inv_width, derivatives[1][1] * inv_height};
 
 	BLI_ewa_filter(this->getWidth(), this->getHeight(),
 	               false,




More information about the Bf-blender-cvs mailing list