Commit 0a2f90d4 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

audio format: use bswap*()

parent 9ff7bdc4
......@@ -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++;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment