From c530661db21ce882d4b5ef16d64ed5fc8f469761 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 06:06:28 +0000 Subject: patch [#32556] Stupid endian conversion in avi format from Andreas Schwab (schwab) modified to use code from BLI_endian_switch. --- source/blender/avi/intern/endian.c | 31 ++++++++--------------- source/blender/blenlib/BLI_endian_switch_inline.h | 2 +- 2 files changed, 12 insertions(+), 21 deletions(-) (limited to 'source/blender') diff --git a/source/blender/avi/intern/endian.c b/source/blender/avi/intern/endian.c index c9b95d25810..8e5ed80f5a0 100644 --- a/source/blender/avi/intern/endian.c +++ b/source/blender/avi/intern/endian.c @@ -46,31 +46,22 @@ #endif #ifdef __BIG_ENDIAN__ + +/* copied from BLI_endian_switch_inline.h */ static void invert(int *num) { - int new = 0, i, j; - - for (j = 0; j < 4; j++) { - for (i = 0; i < 8; i++) { - new |= ((*num >> (j * 8 + i)) & 1) << ((3 - j) * 8 + i); - } - } - - *num = new; + int tval = *val; + *val = ((tval >> 24)) | + ((tval << 8) & 0x00ff0000) | + ((tval >> 8) & 0x0000ff00) | + ((tval << 24)); } -static void sinvert(short int *num) +static void sinvert(short int *val) { - short int new = 0; - int i, j; - - for (j = 0; j < 2; j++) { - for (i = 0; i < 8; i++) { - new |= ((*num >> (j * 8 + i)) & 1) << ((1 - j) * 8 + i); - } - } - - *num = new; + short tval = *val; + *val = (tval >> 8) | + (tval << 8); } static void Ichunk(AviChunk *chunk) diff --git a/source/blender/blenlib/BLI_endian_switch_inline.h b/source/blender/blenlib/BLI_endian_switch_inline.h index 6694276a995..948d462fde4 100644 --- a/source/blender/blenlib/BLI_endian_switch_inline.h +++ b/source/blender/blenlib/BLI_endian_switch_inline.h @@ -40,7 +40,7 @@ BLI_INLINE void BLI_endian_switch_int16(short *val) { short tval = *val; *val = (tval >> 8) | - (tval << 8); + (tval << 8); } BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val) -- cgit v1.2.3