From b8b5bf7dcde37d1be38f0dbbbbf268a4c292d4d8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 3 Sep 2012 09:03:25 +0000 Subject: array functions for endian switching. --- source/blender/blenlib/BLI_endian_switch.h | 9 +++ source/blender/blenlib/intern/endian_switch.c | 93 +++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_endian_switch.h b/source/blender/blenlib/BLI_endian_switch.h index 19da1ff35a3..7017e7ba789 100644 --- a/source/blender/blenlib/BLI_endian_switch.h +++ b/source/blender/blenlib/BLI_endian_switch.h @@ -29,5 +29,14 @@ #include "BLI_endian_switch_inline.h" +/* endian_switch.c */ +void BLI_endian_switch_int16_array(short *val, const int size); +void BLI_endian_switch_uint16_array(unsigned short *val, const int size); +void BLI_endian_switch_int32_array(int *val, const int size); +void BLI_endian_switch_uint32_array(unsigned int *val, const int size); +void BLI_endian_switch_float_array(float *val, const int size); +void BLI_endian_switch_int64_array(int64_t *val, const int size); +void BLI_endian_switch_uint64_array(uint64_t *val, const int size); +void BLI_endian_switch_double_array(double *val, const int size); #endif /* __BLI_ENDIAN_SWITCH_H__ */ diff --git a/source/blender/blenlib/intern/endian_switch.c b/source/blender/blenlib/intern/endian_switch.c index db4884d35b9..b9b18136863 100644 --- a/source/blender/blenlib/intern/endian_switch.c +++ b/source/blender/blenlib/intern/endian_switch.c @@ -23,3 +23,96 @@ /** \file blender/blenlib/intern/endian_switch.c * \ingroup bli */ + +#include "BLO_sys_types.h" +#include "BLI_utildefines.h" +#include "BLI_endian_switch.h" + +void BLI_endian_switch_int16_array(short *val, const int size) +{ + if (size > 0) { + int i = size; + val = val + (size - 1); + while (i--) { + BLI_endian_switch_int16(val--); + } + } +} + +void BLI_endian_switch_uint16_array(unsigned short *val, const int size) +{ + if (size > 0) { + int i = size; + val = val + (size - 1); + while (i--) { + BLI_endian_switch_uint16(val--); + } + } +} + +void BLI_endian_switch_int32_array(int *val, const int size) +{ + if (size > 0) { + int i = size; + val = val + (size - 1); + while (i--) { + BLI_endian_switch_int32(val--); + } + } +} + +void BLI_endian_switch_uint32_array(unsigned int *val, const int size) +{ + if (size > 0) { + int i = size; + val = val + (size - 1); + while (i--) { + BLI_endian_switch_uint32(val--); + } + } +} + +void BLI_endian_switch_float_array(float *val, const int size) +{ + if (size > 0) { + int i = size; + val = val + (size - 1); + while (i--) { + BLI_endian_switch_float(val--); + } + } +} + +void BLI_endian_switch_int64_array(int64_t *val, const int size) +{ + if (size > 0) { + int i = size; + val = val + (size - 1); + while (i--) { + BLI_endian_switch_int64(val--); + } + } +} + +void BLI_endian_switch_uint64_array(uint64_t *val, const int size) +{ + if (size > 0) { + int i = size; + val = val + (size - 1); + while (i--) { + BLI_endian_switch_uint64(val--); + } + } +} + + +void BLI_endian_switch_double_array(double *val, const int size) +{ + if (size > 0) { + int i = size; + val = val + (size - 1); + while (i--) { + BLI_endian_switch_double(val--); + } + } +} -- cgit v1.2.3