[Bf-blender-cvs] [225f68c] master: Fix interpolation functions ignoring number of components when doing early output

Sergey Sharybin noreply at git.blender.org
Mon Feb 23 20:37:25 CET 2015


Commit: 225f68c324a3417fa3afb745c0e0f7e404737634
Author: Sergey Sharybin
Date:   Tue Feb 24 00:36:33 2015 +0500
Branches: master
https://developer.blender.org/rB225f68c324a3417fa3afb745c0e0f7e404737634

Fix interpolation functions ignoring number of components when doing early output

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

M	source/blender/blenlib/BLI_math_vector.h
M	source/blender/blenlib/intern/math_interp.c
M	source/blender/blenlib/intern/math_vector.c

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

diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 0f437b7..33319f3 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -321,6 +321,7 @@ void interp_vn_vn(float *array_tar, const float *array_src, const float t, const
 void fill_vn_i(int *array_tar, const int size, const int val);
 void fill_vn_short(short *array_tar, const int size, const short val);
 void fill_vn_ushort(unsigned short *array_tar, const int size, const unsigned short val);
+void fill_vn_uchar(unsigned char *array_tar, const int size, const unsigned char val);
 void fill_vn_fl(float *array_tar, const int size, const float val);
 
 /**************************** Inline Definitions ******************************/
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c
index a0c47be..6785046 100644
--- a/source/blender/blenlib/intern/math_interp.c
+++ b/source/blender/blenlib/intern/math_interp.c
@@ -111,10 +111,12 @@ BLI_INLINE void bicubic_interpolation(const unsigned char *byte_buffer, const fl
 
 	/* sample area entirely outside image? */
 	if (ceil(u) < 0 || floor(u) > width - 1 || ceil(v) < 0 || floor(v) > height - 1) {
-		if (float_output)
-			float_output[0] = float_output[1] = float_output[2] = float_output[3] = 0.0f;
-		if (byte_output)
-			byte_output[0] = byte_output[1] = byte_output[2] = byte_output[3] = 0;
+		if (float_output) {
+			fill_vn_fl(float_output, components, 0.0f);
+		}
+		if (byte_output) {
+			fill_vn_uchar(byte_output, components, 0);
+		}
 		return;
 	}
 
@@ -279,7 +281,7 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
 
 		/* sample area entirely outside image? */
 		if (x2 < 0 || x1 > width - 1 || y2 < 0 || y1 > height - 1) {
-			float_output[0] = float_output[1] = float_output[2] = float_output[3] = 0.0f;
+			fill_vn_fl(float_output, components, 0.0f);
 			return;
 		}
 
@@ -321,7 +323,7 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f
 
 		/* sample area entirely outside image? */
 		if (x2 < 0 || x1 > width - 1 || y2 < 0 || y1 > height - 1) {
-			byte_output[0] = byte_output[1] = byte_output[2] = byte_output[3] = 0;
+			fill_vn_uchar(byte_output, components, 0);
 			return;
 		}
 
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index d065fa7..1658c4f 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -1040,6 +1040,15 @@ void fill_vn_ushort(unsigned short *array_tar, const int size, const unsigned sh
 	}
 }
 
+void fill_vn_uchar(unsigned char *array_tar, const int size, const unsigned char val)
+{
+	unsigned char *tar = array_tar + (size - 1);
+	int i = size;
+	while (i--) {
+		*(tar--) = val;
+	}
+}
+
 void fill_vn_fl(float *array_tar, const int size, const float val)
 {
 	float *tar = array_tar + (size - 1);




More information about the Bf-blender-cvs mailing list