summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2015-08-03 21:40:46 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2015-08-03 21:40:46 -0400
commite90adb001350e067437d64b1f9bf68a569fac6b5 (patch)
tree88243170ec68a5db93f65573b0b9c3c5058d8062
parentfc0276fad4ca6aa4b83230329f9fe5ad8b60a621 (diff)
downloadopus-e90adb001350e067437d64b1f9bf68a569fac6b5.tar.gz
More conservative alignment
Based on max size of void*, opus_int32 and opus_val32, rounded up to the nearest power of two
-rw-r--r--src/opus_private.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/opus_private.h b/src/opus_private.h
index 3177f524..44db28d7 100644
--- a/src/opus_private.h
+++ b/src/opus_private.h
@@ -107,10 +107,13 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, opus_int32 le
opus_val16 *pcm, int frame_size, int decode_fec, int self_delimited,
opus_int32 *packet_offset, int soft_clip);
-/* Make sure everything's aligned to sizeof(void *) bytes */
+/* Make sure everything is properly aligned. */
static OPUS_INLINE int align(int i)
{
- return (i+(int)sizeof(void *)-1)&-(int)sizeof(void *);
+ /* 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 opus_packet_parse_impl(const unsigned char *data, opus_int32 len,