[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51504] trunk/blender/source/blender/imbuf /intern/cineon: Fix for inline functions of new cineon library

Sergey Sharybin sergey.vfx at gmail.com
Mon Oct 22 16:28:43 CEST 2012


Revision: 51504
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51504
Author:   nazgul
Date:     2012-10-22 14:28:43 +0000 (Mon, 22 Oct 2012)
Log Message:
-----------
Fix for inline functions of new cineon library

Modified Paths:
--------------
    trunk/blender/source/blender/imbuf/intern/cineon/logImageCore.c
    trunk/blender/source/blender/imbuf/intern/cineon/logImageCore.h

Modified: trunk/blender/source/blender/imbuf/intern/cineon/logImageCore.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/cineon/logImageCore.c	2012-10-22 14:22:05 UTC (rev 51503)
+++ trunk/blender/source/blender/imbuf/intern/cineon/logImageCore.c	2012-10-22 14:28:43 UTC (rev 51504)
@@ -1429,77 +1429,3 @@
 
 	return rvalue;
 }
-
-/*
- * Endianness swapping
- */
-
-inline unsigned short swap_ushort(unsigned short x, int swap)
-{
-	if (swap != 0)
-		return (x >> 8) | (x << 8);
-	else
-		return x;
-}
-
-inline unsigned int swap_uint(unsigned int x, int swap)
-{
-	if (swap != 0)
-		return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
-	else
-		return x;
-}
-
-inline float swap_float(float x, int swap)
-{
-	if (swap != 0) {
-		union {
-			float f;
-			unsigned char b[4];
-		} dat1, dat2;
-
-		dat1.f = x;
-		dat2.b[0] = dat1.b[3];
-		dat2.b[1] = dat1.b[2];
-		dat2.b[2] = dat1.b[1];
-		dat2.b[3] = dat1.b[0];
-		return dat2.f;
-	}
-	else
-		return x;
-}
-
-
-/*
- * Other
- */
-
-inline unsigned int clamp_uint(unsigned int x, unsigned int low, unsigned int high)
-{
-	if (x > high)
-		return high;
-	else if (x < low)
-		return low;
-	else
-		return x;
-}
-
-inline float clamp_float(float x, float low, float high)
-{
-	if (x > high)
-		return high;
-	else if (x < low)
-		return low;
-	else
-		return x;
-}
-
-inline unsigned int float_uint(float value, unsigned int max)
-{
-	if (value < 0.0f)
-		return 0;
-	else if (value > (1.0f - 0.5f / (float)max))
-		return max;
-	else
-		return (unsigned int)(((float)max * value) + 0.5f);
-}

Modified: trunk/blender/source/blender/imbuf/intern/cineon/logImageCore.h
===================================================================
--- trunk/blender/source/blender/imbuf/intern/cineon/logImageCore.h	2012-10-22 14:22:05 UTC (rev 51503)
+++ trunk/blender/source/blender/imbuf/intern/cineon/logImageCore.h	2012-10-22 14:28:43 UTC (rev 51504)
@@ -36,6 +36,7 @@
 #include <stdio.h>
 
 #include "BLO_sys_types.h"
+#include "BLI_utildefines.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -201,17 +202,80 @@
 int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB);
 int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB);
 
-/* Endianness conversion */
-inline unsigned short swap_ushort(unsigned short x, int swap);
-inline unsigned int swap_uint(unsigned int x, int swap);
-inline float swap_float(float x, int swap);
+/*
+ * Inline routines
+ */
 
+/* Endianness swapping */
+
+BLI_INLINE unsigned short swap_ushort(unsigned short x, int swap)
+{
+	if (swap != 0)
+		return (x >> 8) | (x << 8);
+	else
+		return x;
+}
+
+BLI_INLINE unsigned int swap_uint(unsigned int x, int swap)
+{
+	if (swap != 0)
+		return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
+	else
+		return x;
+}
+
+BLI_INLINE float swap_float(float x, int swap)
+{
+	if (swap != 0) {
+		union {
+			float f;
+			unsigned char b[4];
+		} dat1, dat2;
+
+		dat1.f = x;
+		dat2.b[0] = dat1.b[3];
+		dat2.b[1] = dat1.b[2];
+		dat2.b[2] = dat1.b[1];
+		dat2.b[3] = dat1.b[0];
+		return dat2.f;
+	}
+	else
+		return x;
+}
+
 /* Other */
-inline float clamp_float(float x, float low, float high);
-inline unsigned int clamp_uint(unsigned int x, unsigned int low, unsigned int high);
-inline unsigned int float_uint(float value, unsigned int max);
 
+BLI_INLINE unsigned int clamp_uint(unsigned int x, unsigned int low, unsigned int high)
+{
+	if (x > high)
+		return high;
+	else if (x < low)
+		return low;
+	else
+		return x;
+}
 
+BLI_INLINE float clamp_float(float x, float low, float high)
+{
+	if (x > high)
+		return high;
+	else if (x < low)
+		return low;
+	else
+		return x;
+}
+
+BLI_INLINE unsigned int float_uint(float value, unsigned int max)
+{
+	if (value < 0.0f)
+		return 0;
+	else if (value > (1.0f - 0.5f / (float)max))
+		return max;
+	else
+		return (unsigned int)(((float)max * value) + 0.5f);
+}
+
+
 #ifdef __cplusplus
 }
 #endif




More information about the Bf-blender-cvs mailing list