[Bf-blender-cvs] [3ff708a] bake-cycles: IMB buffer _mask functions shouldn't convert colorspaces (ammend to 68893054)

Dalai Felinto noreply at git.blender.org
Wed Apr 30 00:36:13 CEST 2014


Commit: 3ff708a3f235e2bbb1faec309d5d92ca0ba01913
Author: Dalai Felinto
Date:   Tue Apr 29 17:06:21 2014 -0300
https://developer.blender.org/rB3ff708a3f235e2bbb1faec309d5d92ca0ba01913

IMB buffer _mask functions shouldn't convert colorspaces (ammend to
68893054)

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

M	source/blender/imbuf/IMB_imbuf.h
M	source/blender/imbuf/intern/divers.c

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

diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index f446f25..f3d0863 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -389,7 +389,7 @@ void IMB_buffer_byte_from_float(unsigned char *rect_to, const float *rect_from,
 	int channels_from, float dither, int profile_to, int profile_from, bool predivide,
 	int width, int height, int stride_to, int stride_from);
 void IMB_buffer_byte_from_float_mask(unsigned char *rect_to, const float *rect_from,
-	int channels_from, float dither, int profile_to, int profile_from, bool predivide,
+	int channels_from, float dither, bool predivide,
 	int width, int height, int stride_to, int stride_from, char *mask);
 void IMB_buffer_float_from_byte(float *rect_to, const unsigned char *rect_from,
 	int profile_to, int profile_from, bool predivide,
@@ -398,8 +398,7 @@ void IMB_buffer_float_from_float(float *rect_to, const float *rect_from,
 	int channels_from, int profile_to, int profile_from, bool predivide,
 	int width, int height, int stride_to, int stride_from);
 void IMB_buffer_float_from_float_mask(float *rect_to, const float *rect_from,
-	int channels_from, int profile_to, int profile_from, bool predivide,
-	int width, int height, int stride_to, int stride_from, char *mask);
+	int channels_from, int width, int height, int stride_to, int stride_from, char *mask);
 void IMB_buffer_byte_from_byte(unsigned char *rect_to, const unsigned char *rect_from,
 	int profile_to, int profile_from, bool predivide,
 	int width, int height, int stride_to, int stride_from);
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 9a13f4e..bcbb786 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -330,19 +330,14 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
 
 /* float to byte pixels, output 4-channel RGBA */
 void IMB_buffer_byte_from_float_mask(uchar *rect_to, const float *rect_from,
-                                int channels_from, float dither, int profile_to, int profile_from, bool predivide,
+                                int channels_from, float dither, bool predivide,
                                 int width, int height, int stride_to, int stride_from, char *mask)
 {
-	float tmp[4];
 	int x, y;
 	DitherContext *di = NULL;
 	float inv_width = 1.0f / width,
 	inv_height = 1.0f / height;
 
-	/* we need valid profiles */
-	BLI_assert(profile_to != IB_PROFILE_NONE);
-	BLI_assert(profile_from != IB_PROFILE_NONE);
-
 	if (dither)
 		di = create_dither_context(dither);
 
@@ -363,33 +358,10 @@ void IMB_buffer_byte_from_float_mask(uchar *rect_to, const float *rect_from,
 			const float *from = rect_from + stride_from * y * 3;
 			uchar *to = rect_to + stride_to * y * 4;
 
-			if (profile_to == profile_from) {
-				/* no color space conversion */
-				for (x = 0; x < width; x++, from += 3, to += 4) {
-					if (*mask++ == FILTER_MASK_USED) {
-						rgb_float_to_uchar(to, from);
-						to[3] = 255;
-					}
-				}
-			}
-			else if (profile_to == IB_PROFILE_SRGB) {
-				/* convert from linear to sRGB */
-				for (x = 0; x < width; x++, from += 3, to += 4) {
-					if (*mask++ == FILTER_MASK_USED) {
-						linearrgb_to_srgb_v3_v3(tmp, from);
-						rgb_float_to_uchar(to, tmp);
-						to[3] = 255;
-					}
-				}
-			}
-			else if (profile_to == IB_PROFILE_LINEAR_RGB) {
-				/* convert from sRGB to linear */
-				for (x = 0; x < width; x++, from += 3, to += 4) {
-					if (*mask++ == FILTER_MASK_USED) {
-						srgb_to_linearrgb_v3_v3(tmp, from);
-						rgb_float_to_uchar(to, tmp);
-						to[3] = 255;
-					}
+			for (x = 0; x < width; x++, from += 3, to += 4) {
+				if (*mask++ == FILTER_MASK_USED) {
+					rgb_float_to_uchar(to, from);
+					to[3] = 255;
 				}
 			}
 		}
@@ -398,112 +370,34 @@ void IMB_buffer_byte_from_float_mask(uchar *rect_to, const float *rect_from,
 			const float *from = rect_from + stride_from * y * 4;
 			uchar *to = rect_to + stride_to * y * 4;
 
-			if (profile_to == profile_from) {
-				float straight[4];
+			float straight[4];
 
-				/* no color space conversion */
-				if (dither && predivide) {
-					for (x = 0; x < width; x++, from += 4, to += 4) {
-						if (*mask++ == FILTER_MASK_USED) {
-							premul_to_straight_v4_v4(straight, from);
-							float_to_byte_dither_v4(to, straight, di, (float) x * inv_width, t);
-						}
-					}
-				}
-				else if (dither) {
-					for (x = 0; x < width; x++, from += 4, to += 4)
-						if (*mask++ == FILTER_MASK_USED)
-							float_to_byte_dither_v4(to, from, di, (float) x * inv_width, t);
-				}
-				else if (predivide) {
-					for (x = 0; x < width; x++, from += 4, to += 4) {
-						if (*mask++ == FILTER_MASK_USED) {
-							premul_to_straight_v4_v4(straight, from);
-							rgba_float_to_uchar(to, straight);
-						}
+			if (dither && predivide) {
+				for (x = 0; x < width; x++, from += 4, to += 4) {
+					if (*mask++ == FILTER_MASK_USED) {
+						premul_to_straight_v4_v4(straight, from);
+						float_to_byte_dither_v4(to, straight, di, (float) x * inv_width, t);
 					}
 				}
-				else {
-					for (x = 0; x < width; x++, from += 4, to += 4)
-						if (*mask++ == FILTER_MASK_USED)
-							rgba_float_to_uchar(to, from);
-				}
 			}
-			else if (profile_to == IB_PROFILE_SRGB) {
-				/* convert from linear to sRGB */
-				unsigned short us[4];
-				float straight[4];
-
-				if (dither && predivide) {
-					for (x = 0; x < width; x++, from += 4, to += 4) {
-						if (*mask++ == FILTER_MASK_USED) {
-							premul_to_straight_v4_v4(straight, from);
-							linearrgb_to_srgb_ushort4(us, from);
-							ushort_to_byte_dither_v4(to, us, di, (float) x * inv_width, t);
-						}
-					}
-				}
-				else if (dither) {
-					for (x = 0; x < width; x++, from += 4, to += 4) {
-						if (*mask++ == FILTER_MASK_USED) {
-							linearrgb_to_srgb_ushort4(us, from);
-							ushort_to_byte_dither_v4(to, us, di, (float) x * inv_width, t);
-						}
-					}
-				}
-				else if (predivide) {
-					for (x = 0; x < width; x++, from += 4, to += 4) {
-						if (*mask++ == FILTER_MASK_USED) {
-							premul_to_straight_v4_v4(straight, from);
-							linearrgb_to_srgb_ushort4(us, from);
-							ushort_to_byte_v4(to, us);
-						}
-					}
-				}
-				else {
-					for (x = 0; x < width; x++, from += 4, to += 4) {
-						if (*mask++ == FILTER_MASK_USED) {
-							linearrgb_to_srgb_ushort4(us, from);
-							ushort_to_byte_v4(to, us);
-						}
-					}
-				}
+			else if (dither) {
+				for (x = 0; x < width; x++, from += 4, to += 4)
+					if (*mask++ == FILTER_MASK_USED)
+						float_to_byte_dither_v4(to, from, di, (float) x * inv_width, t);
 			}
-			else if (profile_to == IB_PROFILE_LINEAR_RGB) {
-				/* convert from sRGB to linear */
-				if (dither && predivide) {
-					for (x = 0; x < width; x++, from += 4, to += 4) {
-						if (*mask++ == FILTER_MASK_USED) {
-							srgb_to_linearrgb_predivide_v4(tmp, from);
-							float_to_byte_dither_v4(to, tmp, di, (float) x * inv_width, t);
-						}
-					}
-				}
-				else if (dither) {
-					for (x = 0; x < width; x++, from += 4, to += 4) {
-						if (*mask++ == FILTER_MASK_USED) {
-							srgb_to_linearrgb_v4(tmp, from);
-							float_to_byte_dither_v4(to, tmp, di, (float) x * inv_width, t);
-						}
-					}
-				}
-				else if (predivide) {
-					for (x = 0; x < width; x++, from += 4, to += 4) {
-						if (*mask++ == FILTER_MASK_USED) {
-							srgb_to_linearrgb_predivide_v4(tmp, from);
-							rgba_float_to_uchar(to, tmp);
-						}
-					}
-				}
-				else {
-					for (x = 0; x < width; x++, from += 4, to += 4) {
-						if (*mask++ == FILTER_MASK_USED) {
-							srgb_to_linearrgb_v4(tmp, from);
-							rgba_float_to_uchar(to, tmp);
-						}
+			else if (predivide) {
+				for (x = 0; x < width; x++, from += 4, to += 4) {
+					if (*mask++ == FILTER_MASK_USED) {
+						premul_to_straight_v4_v4(straight, from);
+						rgba_float_to_uchar(to, straight);
 					}
 				}
 			}
+			else {
+				for (x = 0; x < width; x++, from += 4, to += 4)
+					if (*mask++ == FILTER_MASK_USED)
+						rgba_float_to_uchar(to, from);
+			}
 		}
 	}
 
@@ -651,16 +545,11 @@ void IMB_buffer_float_from_float(float *rect_to, const float *rect_from,
 }
 
 /* float to float pixels, output 4-channel RGBA */
-void IMB_buffer_float_from_float_mask(float *rect_to, const float *rect_from,
-                                 int channels_from, int profile_to, int profile_from, bool predivide,
-                                 int width, int height, int stride_to, int stride_from, char *mask)
+void IMB_buffer_float_from_float_mask(float *rect_to, const float *rect_from, int channels_from,
+                                      int width, int height, int stride_to, int stride_from, char *mask)
 {
 	int x, y;
 
-	/* we need valid profiles */
-	BLI_assert(profile_to != IB_PROFILE_NONE);
-	BLI_assert(profile_from != IB_PROFILE_NONE);
-
 	if (channels_from == 1) {
 		/* single channel input */
 		for (y = 0; y < height; y++) {
@@ -678,31 +567,10 @@ void IMB_buffer_float_from_float_mask(float *rect_to, const float *rect_from,
 			const float *from = rect_from + stride_from * y * 3;
 			float *to = rect_to + stride_to * y * 4;
 
-			if (profile_to == profile_from) {
-				/* no color space conversion */
-				for (x = 0; x < width; x++, from += 3, to += 4) {
-					if (*mask++ == FILTER_MASK_USED) {
-						copy_v3_v3(to, from);
-						to[3] = 1.0f;
-					}
-				}
-			}
-			else if (profile_to == IB_PROFILE_LINEAR_RGB) {
-				/* convert from sRGB to linear */
-				for (x = 0; x < width; x++, from += 3, to += 4) {
-					if (*mask++ == FILTER_MASK_USED) {
-						srgb_to_linearrgb_v3_v3(to, from);
-						to[3] = 1.0f;
-					}
-				}
-			}
-			else if (profile_to == IB_PROFILE_SRGB) {
-				/* convert from linear to sRGB */
-				for (x = 0; x < width; x++, from += 3, to += 4) {
-					if (*mask++ == FILTER_MASK_USED) {
-						linearrgb_to_srgb_v3_v3(to, from);
-						to[3] = 1.0f;
-					}
+			for (x = 0; x < width; x++, from += 3, to += 4) {
+				if (*mask++ == FILTER_MASK_USED) {
+					copy_v3_v3(to, from);
+					to[3] = 1.0f;
 				}
 			}
 		}
@@ -713,38 +581,9 @@ void IMB_buffer_float_from_float_mask(float *rect_to, const fl

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list