[vlc-commits] audio format: use bswap*()
Rémi Denis-Courmont
git at videolan.org
Wed Aug 17 18:14:16 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Aug 17 19:08:54 2011 +0300| [0a2f90d4692d4754397f6c4b5d6162ab1880c08d] | committer: Rémi Denis-Courmont
audio format: use bswap*()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0a2f90d4692d4754397f6c4b5d6162ab1880c08d
---
modules/audio_filter/converter/format.c | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/modules/audio_filter/converter/format.c b/modules/audio_filter/converter/format.c
index bef50b2..0fc91c4 100644
--- a/modules/audio_filter/converter/format.c
+++ b/modules/audio_filter/converter/format.c
@@ -481,42 +481,38 @@ static void S24toFl32(block_t *bdst, const block_t *bsrc)
}
/* */
-#define XCHG(type, a, b) \
- do { type _tmp = a; a = b; b = _tmp; } while(0)
static void Swap64(block_t *b)
{
- uint8_t *data = (uint8_t *)b->p_buffer;
+ uint64_t *data = (uint64_t *)b->p_buffer;
for (size_t i = 0; i < b->i_buffer / 8; i++) {
- XCHG(uint8_t, data[0], data[7]);
- XCHG(uint8_t, data[1], data[6]);
- XCHG(uint8_t, data[2], data[5]);
- XCHG(uint8_t, data[3], data[4]);
- data += 8;
+ *data = bswap64 (*data);
+ data++;
}
}
static void Swap32(block_t *b)
{
- uint8_t *data = (uint8_t *)b->p_buffer;
+ uint32_t *data = (uint32_t *)b->p_buffer;
for (size_t i = 0; i < b->i_buffer / 4; i++) {
- XCHG(uint8_t, data[0], data[3]);
- XCHG(uint8_t, data[1], data[2]);
- data += 4;
+ *data = bswap32 (*data);
+ data++;
}
}
static void Swap24(block_t *b)
{
uint8_t *data = (uint8_t *)b->p_buffer;
for (size_t i = 0; i < b->i_buffer / 3; i++) {
- XCHG(uint8_t, data[0], data[2]);
+ uint8_t buf = data[0];
+ data[0] = data[2];
+ data[2] = buf;
data += 3;
}
}
static void Swap16(block_t *b)
{
- uint8_t *data = (uint8_t *)b->p_buffer;
+ uint16_t *data = (uint16_t *)b->p_buffer;
for (size_t i = 0; i < b->i_buffer / 2; i++) {
- XCHG(uint8_t, data[0], data[1]);
- data += 2;
+ *data = bswap16 (*data);
+ data++;
}
}
More information about the vlc-commits
mailing list