Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-10-22 18:28:43 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-10-22 18:28:43 +0400
commitfc5da14dad0256064a4778694af873fe48ab4fb2 (patch)
tree0894b2cce120c6f66eec99d696d769912794b116 /source/blender/imbuf/intern/cineon/logImageCore.h
parent40da6bb531ebb3b43a9e66f31390498620a9c082 (diff)
Fix for inline functions of new cineon library
Diffstat (limited to 'source/blender/imbuf/intern/cineon/logImageCore.h')
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.h78
1 files changed, 71 insertions, 7 deletions
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.h b/source/blender/imbuf/intern/cineon/logImageCore.h
index df8a5ed06a7..7c75f8b730b 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.h
+++ b/source/blender/imbuf/intern/cineon/logImageCore.h
@@ -36,6 +36,7 @@
#include <stdio.h>
#include "BLO_sys_types.h"
+#include "BLI_utildefines.h"
#ifdef __cplusplus
extern "C" {
@@ -201,15 +202,78 @@ unsigned int getRowLength(int width, LogImageElement logElement);
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