From e93dd374a46270d6cd873b7e2db557b346b1aac7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 10 Oct 2011 07:58:27 +0200 Subject: pcm_byteswap: use GLib byte swapping macros GLib's macros are implemented with inline assembly, and probably a lot faster than our naive bit shifting implementation. --- src/pcm_byteswap.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/pcm_byteswap.c b/src/pcm_byteswap.c index 63f116211..13ed85bfe 100644 --- a/src/pcm_byteswap.c +++ b/src/pcm_byteswap.c @@ -28,11 +28,6 @@ #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "pcm" -static inline uint16_t swab16(uint16_t x) -{ - return (x << 8) | (x >> 8); -} - const int16_t *pcm_byteswap_16(struct pcm_buffer *buffer, const int16_t *src, size_t len) { @@ -42,19 +37,11 @@ const int16_t *pcm_byteswap_16(struct pcm_buffer *buffer, assert(buf != NULL); for (i = 0; i < len / 2; i++) - buf[i] = swab16(src[i]); + buf[i] = GUINT16_SWAP_LE_BE(src[i]); return buf; } -static inline uint32_t swab32(uint32_t x) -{ - return (x << 24) | - ((x & 0xff00) << 8) | - ((x & 0xff0000) >> 8) | - (x >> 24); -} - const int32_t *pcm_byteswap_32(struct pcm_buffer *buffer, const int32_t *src, size_t len) { @@ -64,7 +51,7 @@ const int32_t *pcm_byteswap_32(struct pcm_buffer *buffer, assert(buf != NULL); for (i = 0; i < len / 4; i++) - buf[i] = swab32(src[i]); + buf[i] = GUINT32_SWAP_LE_BE(src[i]); return buf; } -- cgit v1.2.3