forked from bartvdbraak/blender
Minor changes for more efficient endian switching
This commit is contained in:
parent
17ebbc06e2
commit
968351d916
@ -42,9 +42,13 @@ BLI_INLINE void BLI_endian_switch_int16(short *val)
|
||||
}
|
||||
BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
*val = __builtin_bswap16(*val);
|
||||
#else
|
||||
unsigned short tval = *val;
|
||||
*val = (tval >> 8) |
|
||||
(tval << 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -55,11 +59,15 @@ BLI_INLINE void BLI_endian_switch_int32(int *val)
|
||||
}
|
||||
BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
*val = __builtin_bswap32(*val);
|
||||
#else
|
||||
unsigned int tval = *val;
|
||||
*val = ((tval >> 24)) |
|
||||
((tval << 8) & 0x00ff0000) |
|
||||
((tval >> 8) & 0x0000ff00) |
|
||||
((tval << 24));
|
||||
#endif
|
||||
}
|
||||
BLI_INLINE void BLI_endian_switch_float(float *val)
|
||||
{
|
||||
@ -74,6 +82,9 @@ BLI_INLINE void BLI_endian_switch_int64(int64_t *val)
|
||||
}
|
||||
BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
*val = __builtin_bswap16(*val);
|
||||
#else
|
||||
uint64_t tval = *val;
|
||||
*val = ((tval >> 56)) |
|
||||
((tval << 40) & 0x00ff000000000000ll) |
|
||||
@ -83,6 +94,7 @@ BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val)
|
||||
((tval >> 24) & 0x0000000000ff0000ll) |
|
||||
((tval >> 40) & 0x000000000000ff00ll) |
|
||||
((tval << 56));
|
||||
#endif
|
||||
}
|
||||
BLI_INLINE void BLI_endian_switch_double(double *val)
|
||||
{
|
||||
|
@ -32,9 +32,8 @@ 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--);
|
||||
BLI_endian_switch_int16(val++);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -43,9 +42,8 @@ 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--);
|
||||
BLI_endian_switch_uint16(val++);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -54,9 +52,8 @@ 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--);
|
||||
BLI_endian_switch_int32(val++);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -65,9 +62,8 @@ 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--);
|
||||
BLI_endian_switch_uint32(val++);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,9 +72,8 @@ 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--);
|
||||
BLI_endian_switch_float(val++);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,9 +82,8 @@ 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--);
|
||||
BLI_endian_switch_int64(val++);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -98,9 +92,8 @@ 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--);
|
||||
BLI_endian_switch_uint64(val++);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,9 +103,8 @@ 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--);
|
||||
BLI_endian_switch_double(val++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user