diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2015-08-04 00:05:16 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2015-08-04 00:05:16 -0400 |
commit | 24539c4d7bd528bcb7fb55d44702f4a90fff05e7 (patch) | |
tree | 823098e97c2bcd0085a1926c1e397641e09f3369 | |
parent | e90adb001350e067437d64b1f9bf68a569fac6b5 (diff) | |
download | opus-24539c4d7bd528bcb7fb55d44702f4a90fff05e7.tar.gz |
Make align() work even on machines with 32-bit chars
-rw-r--r-- | src/opus_private.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/opus_private.h b/src/opus_private.h index 44db28d7..63338fee 100644 --- a/src/opus_private.h +++ b/src/opus_private.h @@ -110,10 +110,15 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, opus_int32 le /* Make sure everything is properly aligned. */ static OPUS_INLINE int align(int i) { + int size; /* Alignment is determined by the max size of void*, opus_int32 and opus_val32, rounded up to the nearest power of two. */ - int size = 1 << EC_ILOG(((sizeof(opus_int32)-1)|(sizeof(opus_val32)-1)|(sizeof(void*)-1))); - return (i+(int)size-1)&-(int)size; + int tmp = (sizeof(opus_int32)-1)|(sizeof(opus_val32)-1)|(sizeof(void*)-1); + if (tmp == 0) + size = 1; + else + size = 1 << EC_ILOG(tmp); + return (i+size-1)&-size; } int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, |